diff options
author | Sage Weil <sage@newdream.net> | 2009-10-15 21:13:53 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-10-15 21:14:44 -0400 |
commit | 76e3b390d41db9d69e254a09dd1aedd3e6aac25f (patch) | |
tree | 2a2b6586fd36dcef430d1c13e07aa42ceaa51c84 /fs/ceph/caps.c | |
parent | 8f3bc053c610826a657714649ea596f07875db2e (diff) |
ceph: move dirty caps code around
Cleanup only.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r-- | fs/ceph/caps.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 40b8d3471244..7d166182e98d 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -1270,6 +1270,41 @@ static void ceph_flush_snaps(struct ceph_inode_info *ci) | |||
1270 | } | 1270 | } |
1271 | 1271 | ||
1272 | /* | 1272 | /* |
1273 | * Mark caps dirty. If inode is newly dirty, add to the global dirty | ||
1274 | * list. | ||
1275 | */ | ||
1276 | void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) | ||
1277 | { | ||
1278 | struct ceph_mds_client *mdsc = &ceph_client(ci->vfs_inode.i_sb)->mdsc; | ||
1279 | struct inode *inode = &ci->vfs_inode; | ||
1280 | int was = ci->i_dirty_caps; | ||
1281 | int dirty = 0; | ||
1282 | |||
1283 | dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode, | ||
1284 | ceph_cap_string(mask), ceph_cap_string(was), | ||
1285 | ceph_cap_string(was | mask)); | ||
1286 | ci->i_dirty_caps |= mask; | ||
1287 | if (was == 0) { | ||
1288 | dout(" inode %p now dirty\n", &ci->vfs_inode); | ||
1289 | BUG_ON(!list_empty(&ci->i_dirty_item)); | ||
1290 | spin_lock(&mdsc->cap_dirty_lock); | ||
1291 | list_add(&ci->i_dirty_item, &mdsc->cap_dirty); | ||
1292 | spin_unlock(&mdsc->cap_dirty_lock); | ||
1293 | if (ci->i_flushing_caps == 0) { | ||
1294 | igrab(inode); | ||
1295 | dirty |= I_DIRTY_SYNC; | ||
1296 | } | ||
1297 | } | ||
1298 | BUG_ON(list_empty(&ci->i_dirty_item)); | ||
1299 | if (((was | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && | ||
1300 | (mask & CEPH_CAP_FILE_BUFFER)) | ||
1301 | dirty |= I_DIRTY_DATASYNC; | ||
1302 | if (dirty) | ||
1303 | __mark_inode_dirty(inode, dirty); | ||
1304 | __cap_delay_requeue(mdsc, ci); | ||
1305 | } | ||
1306 | |||
1307 | /* | ||
1273 | * Add dirty inode to the flushing list. Assigned a seq number so we | 1308 | * Add dirty inode to the flushing list. Assigned a seq number so we |
1274 | * can wait for caps to flush without starving. | 1309 | * can wait for caps to flush without starving. |
1275 | * | 1310 | * |
@@ -1558,39 +1593,6 @@ ack: | |||
1558 | } | 1593 | } |
1559 | 1594 | ||
1560 | /* | 1595 | /* |
1561 | * Mark caps dirty. If inode is newly dirty, add to the global dirty | ||
1562 | * list. | ||
1563 | */ | ||
1564 | void __ceph_mark_dirty_caps(struct ceph_inode_info *ci, int mask) | ||
1565 | { | ||
1566 | struct ceph_mds_client *mdsc = &ceph_client(ci->vfs_inode.i_sb)->mdsc; | ||
1567 | struct inode *inode = &ci->vfs_inode; | ||
1568 | int was_dirty = ci->i_dirty_caps; | ||
1569 | int dirty = 0; | ||
1570 | |||
1571 | dout("__mark_dirty_caps %p %s dirty %s -> %s\n", &ci->vfs_inode, | ||
1572 | ceph_cap_string(mask), ceph_cap_string(ci->i_dirty_caps), | ||
1573 | ceph_cap_string(ci->i_dirty_caps | mask)); | ||
1574 | ci->i_dirty_caps |= mask; | ||
1575 | if (!was_dirty) { | ||
1576 | dout(" inode %p now dirty\n", &ci->vfs_inode); | ||
1577 | spin_lock(&mdsc->cap_dirty_lock); | ||
1578 | list_add(&ci->i_dirty_item, &mdsc->cap_dirty); | ||
1579 | spin_unlock(&mdsc->cap_dirty_lock); | ||
1580 | if (ci->i_flushing_caps == 0) { | ||
1581 | igrab(inode); | ||
1582 | dirty |= I_DIRTY_SYNC; | ||
1583 | } | ||
1584 | } | ||
1585 | if (((was_dirty | ci->i_flushing_caps) & CEPH_CAP_FILE_BUFFER) && | ||
1586 | (mask & CEPH_CAP_FILE_BUFFER)) | ||
1587 | dirty |= I_DIRTY_DATASYNC; | ||
1588 | if (dirty) | ||
1589 | __mark_inode_dirty(inode, dirty); | ||
1590 | __cap_delay_requeue(mdsc, ci); | ||
1591 | } | ||
1592 | |||
1593 | /* | ||
1594 | * Try to flush dirty caps back to the auth mds. | 1596 | * Try to flush dirty caps back to the auth mds. |
1595 | */ | 1597 | */ |
1596 | static int try_flush_caps(struct inode *inode, struct ceph_mds_session *session, | 1598 | static int try_flush_caps(struct inode *inode, struct ceph_mds_session *session, |
@@ -2370,6 +2372,8 @@ static void handle_cap_flush_ack(struct inode *inode, | |||
2370 | dout(" inode %p now clean\n", inode); | 2372 | dout(" inode %p now clean\n", inode); |
2371 | BUG_ON(!list_empty(&ci->i_dirty_item)); | 2373 | BUG_ON(!list_empty(&ci->i_dirty_item)); |
2372 | drop = 1; | 2374 | drop = 1; |
2375 | } else { | ||
2376 | BUG_ON(list_empty(&ci->i_dirty_item)); | ||
2373 | } | 2377 | } |
2374 | } | 2378 | } |
2375 | spin_unlock(&mdsc->cap_dirty_lock); | 2379 | spin_unlock(&mdsc->cap_dirty_lock); |