diff options
author | Sage Weil <sage@newdream.net> | 2009-10-14 17:24:19 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-10-14 17:43:56 -0400 |
commit | cdc35f96277314bbfeefd0505410cabd69aebd8d (patch) | |
tree | 296cdc331f4a8902f284a7cf72ba29529121a94f /fs/ceph/caps.c | |
parent | f2cf418cec8d61df0651a0140a92a8c75246e14f (diff) |
ceph: move generic flushing code into helper
Both callers of __mark_caps_flushing() do the same work; move it
into the helper.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r-- | fs/ceph/caps.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 5c7d0e9bbb7b..111439d883d2 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -1272,16 +1272,30 @@ static void ceph_flush_snaps(struct ceph_inode_info *ci) | |||
1272 | /* | 1272 | /* |
1273 | * Add dirty inode to the flushing list. Assigned a seq number so we | 1273 | * Add dirty inode to the flushing list. Assigned a seq number so we |
1274 | * can wait for caps to flush without starving. | 1274 | * can wait for caps to flush without starving. |
1275 | * | ||
1276 | * Called under i_lock. | ||
1275 | */ | 1277 | */ |
1276 | static void __mark_caps_flushing(struct inode *inode, | 1278 | static int __mark_caps_flushing(struct inode *inode, |
1277 | struct ceph_mds_session *session) | 1279 | struct ceph_mds_session *session) |
1278 | { | 1280 | { |
1279 | struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc; | 1281 | struct ceph_mds_client *mdsc = &ceph_client(inode->i_sb)->mdsc; |
1280 | struct ceph_inode_info *ci = ceph_inode(inode); | 1282 | struct ceph_inode_info *ci = ceph_inode(inode); |
1281 | 1283 | int flushing; | |
1284 | |||
1285 | BUG_ON(ci->i_dirty_caps == 0); | ||
1282 | BUG_ON(list_empty(&ci->i_dirty_item)); | 1286 | BUG_ON(list_empty(&ci->i_dirty_item)); |
1287 | |||
1288 | flushing = ci->i_dirty_caps; | ||
1289 | dout("__mark_caps_flushing flushing %s, flushing_caps %s -> %s\n", | ||
1290 | ceph_cap_string(flushing), | ||
1291 | ceph_cap_string(ci->i_flushing_caps), | ||
1292 | ceph_cap_string(ci->i_flushing_caps | flushing)); | ||
1293 | ci->i_flushing_caps |= flushing; | ||
1294 | ci->i_dirty_caps = 0; | ||
1295 | |||
1283 | spin_lock(&mdsc->cap_dirty_lock); | 1296 | spin_lock(&mdsc->cap_dirty_lock); |
1284 | if (list_empty(&ci->i_flushing_item)) { | 1297 | if (list_empty(&ci->i_flushing_item)) { |
1298 | list_del_init(&ci->i_dirty_item); | ||
1285 | list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); | 1299 | list_add_tail(&ci->i_flushing_item, &session->s_cap_flushing); |
1286 | mdsc->num_cap_flushing++; | 1300 | mdsc->num_cap_flushing++; |
1287 | ci->i_cap_flush_seq = ++mdsc->cap_flush_seq; | 1301 | ci->i_cap_flush_seq = ++mdsc->cap_flush_seq; |
@@ -1289,6 +1303,8 @@ static void __mark_caps_flushing(struct inode *inode, | |||
1289 | ci->i_cap_flush_seq); | 1303 | ci->i_cap_flush_seq); |
1290 | } | 1304 | } |
1291 | spin_unlock(&mdsc->cap_dirty_lock); | 1305 | spin_unlock(&mdsc->cap_dirty_lock); |
1306 | |||
1307 | return flushing; | ||
1292 | } | 1308 | } |
1293 | 1309 | ||
1294 | /* | 1310 | /* |
@@ -1504,17 +1520,8 @@ ack: | |||
1504 | took_snap_rwsem = 1; | 1520 | took_snap_rwsem = 1; |
1505 | } | 1521 | } |
1506 | 1522 | ||
1507 | if (cap == ci->i_auth_cap && ci->i_dirty_caps) { | 1523 | if (cap == ci->i_auth_cap && ci->i_dirty_caps) |
1508 | /* update dirty, flushing bits */ | 1524 | flushing = __mark_caps_flushing(inode, session); |
1509 | flushing = ci->i_dirty_caps; | ||
1510 | dout(" flushing %s, flushing_caps %s -> %s\n", | ||
1511 | ceph_cap_string(flushing), | ||
1512 | ceph_cap_string(ci->i_flushing_caps), | ||
1513 | ceph_cap_string(ci->i_flushing_caps | flushing)); | ||
1514 | ci->i_flushing_caps |= flushing; | ||
1515 | ci->i_dirty_caps = 0; | ||
1516 | __mark_caps_flushing(inode, session); | ||
1517 | } | ||
1518 | 1525 | ||
1519 | mds = cap->mds; /* remember mds, so we don't repeat */ | 1526 | mds = cap->mds; /* remember mds, so we don't repeat */ |
1520 | sent++; | 1527 | sent++; |
@@ -1605,15 +1612,7 @@ retry: | |||
1605 | if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) | 1612 | if (cap->session->s_state < CEPH_MDS_SESSION_OPEN) |
1606 | goto out; | 1613 | goto out; |
1607 | 1614 | ||
1608 | __mark_caps_flushing(inode, session); | 1615 | flushing = __mark_caps_flushing(inode, session); |
1609 | |||
1610 | flushing = ci->i_dirty_caps; | ||
1611 | dout(" flushing %s, flushing_caps %s -> %s\n", | ||
1612 | ceph_cap_string(flushing), | ||
1613 | ceph_cap_string(ci->i_flushing_caps), | ||
1614 | ceph_cap_string(ci->i_flushing_caps | flushing)); | ||
1615 | ci->i_flushing_caps |= flushing; | ||
1616 | ci->i_dirty_caps = 0; | ||
1617 | 1616 | ||
1618 | /* __send_cap drops i_lock */ | 1617 | /* __send_cap drops i_lock */ |
1619 | delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, used, want, | 1618 | delayed = __send_cap(mdsc, cap, CEPH_CAP_OP_FLUSH, used, want, |