diff options
author | Sage Weil <sage@newdream.net> | 2010-02-09 18:24:44 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2010-02-11 14:48:54 -0500 |
commit | 3c6f6b79a64db7f1c7abf09d693db3b0066784fb (patch) | |
tree | e17b4cd848212b0556180331280044dd1526b742 /fs/ceph/inode.c | |
parent | 6a026589ba333185c466c906376fe022a27a53f9 (diff) |
ceph: cleanup async writeback, truncation, invalidate helpers
Grab inode ref in helper. Make work functions static, with consistent
naming.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/inode.c')
-rw-r--r-- | fs/ceph/inode.c | 61 |
1 files changed, 52 insertions, 9 deletions
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index af85f2de2f7c..58bdff09c2c1 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -28,7 +28,9 @@ | |||
28 | 28 | ||
29 | static const struct inode_operations ceph_symlink_iops; | 29 | static const struct inode_operations ceph_symlink_iops; |
30 | 30 | ||
31 | static void ceph_inode_invalidate_pages(struct work_struct *work); | 31 | static void ceph_invalidate_work(struct work_struct *work); |
32 | static void ceph_writeback_work(struct work_struct *work); | ||
33 | static void ceph_vmtruncate_work(struct work_struct *work); | ||
32 | 34 | ||
33 | /* | 35 | /* |
34 | * find or create an inode, given the ceph ino number | 36 | * find or create an inode, given the ceph ino number |
@@ -357,8 +359,8 @@ struct inode *ceph_alloc_inode(struct super_block *sb) | |||
357 | INIT_LIST_HEAD(&ci->i_snap_realm_item); | 359 | INIT_LIST_HEAD(&ci->i_snap_realm_item); |
358 | INIT_LIST_HEAD(&ci->i_snap_flush_item); | 360 | INIT_LIST_HEAD(&ci->i_snap_flush_item); |
359 | 361 | ||
360 | INIT_WORK(&ci->i_wb_work, ceph_inode_writeback); | 362 | INIT_WORK(&ci->i_wb_work, ceph_writeback_work); |
361 | INIT_WORK(&ci->i_pg_inv_work, ceph_inode_invalidate_pages); | 363 | INIT_WORK(&ci->i_pg_inv_work, ceph_invalidate_work); |
362 | 364 | ||
363 | INIT_WORK(&ci->i_vmtruncate_work, ceph_vmtruncate_work); | 365 | INIT_WORK(&ci->i_vmtruncate_work, ceph_vmtruncate_work); |
364 | 366 | ||
@@ -675,9 +677,7 @@ no_change: | |||
675 | 677 | ||
676 | /* queue truncate if we saw i_size decrease */ | 678 | /* queue truncate if we saw i_size decrease */ |
677 | if (queue_trunc) | 679 | if (queue_trunc) |
678 | if (queue_work(ceph_client(inode->i_sb)->trunc_wq, | 680 | ceph_queue_vmtruncate(inode); |
679 | &ci->i_vmtruncate_work)) | ||
680 | igrab(inode); | ||
681 | 681 | ||
682 | /* populate frag tree */ | 682 | /* populate frag tree */ |
683 | /* FIXME: move me up, if/when version reflects fragtree changes */ | 683 | /* FIXME: move me up, if/when version reflects fragtree changes */ |
@@ -1243,7 +1243,18 @@ int ceph_inode_set_size(struct inode *inode, loff_t size) | |||
1243 | * Write back inode data in a worker thread. (This can't be done | 1243 | * Write back inode data in a worker thread. (This can't be done |
1244 | * in the message handler context.) | 1244 | * in the message handler context.) |
1245 | */ | 1245 | */ |
1246 | void ceph_inode_writeback(struct work_struct *work) | 1246 | void ceph_queue_writeback(struct inode *inode) |
1247 | { | ||
1248 | if (queue_work(ceph_inode_to_client(inode)->wb_wq, | ||
1249 | &ceph_inode(inode)->i_wb_work)) { | ||
1250 | dout("ceph_queue_invalidate %p\n", inode); | ||
1251 | igrab(inode); | ||
1252 | } else { | ||
1253 | dout("ceph_queue_invalidate %p failed\n", inode); | ||
1254 | } | ||
1255 | } | ||
1256 | |||
1257 | static void ceph_writeback_work(struct work_struct *work) | ||
1247 | { | 1258 | { |
1248 | struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, | 1259 | struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, |
1249 | i_wb_work); | 1260 | i_wb_work); |
@@ -1255,10 +1266,24 @@ void ceph_inode_writeback(struct work_struct *work) | |||
1255 | } | 1266 | } |
1256 | 1267 | ||
1257 | /* | 1268 | /* |
1269 | * queue an async invalidation | ||
1270 | */ | ||
1271 | void ceph_queue_invalidate(struct inode *inode) | ||
1272 | { | ||
1273 | if (queue_work(ceph_inode_to_client(inode)->pg_inv_wq, | ||
1274 | &ceph_inode(inode)->i_pg_inv_work)) { | ||
1275 | dout("ceph_queue_invalidate %p\n", inode); | ||
1276 | igrab(inode); | ||
1277 | } else { | ||
1278 | dout("ceph_queue_invalidate %p failed\n", inode); | ||
1279 | } | ||
1280 | } | ||
1281 | |||
1282 | /* | ||
1258 | * Invalidate inode pages in a worker thread. (This can't be done | 1283 | * Invalidate inode pages in a worker thread. (This can't be done |
1259 | * in the message handler context.) | 1284 | * in the message handler context.) |
1260 | */ | 1285 | */ |
1261 | static void ceph_inode_invalidate_pages(struct work_struct *work) | 1286 | static void ceph_invalidate_work(struct work_struct *work) |
1262 | { | 1287 | { |
1263 | struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, | 1288 | struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, |
1264 | i_pg_inv_work); | 1289 | i_pg_inv_work); |
@@ -1307,7 +1332,7 @@ out: | |||
1307 | * | 1332 | * |
1308 | * We also truncate in a separate thread as well. | 1333 | * We also truncate in a separate thread as well. |
1309 | */ | 1334 | */ |
1310 | void ceph_vmtruncate_work(struct work_struct *work) | 1335 | static void ceph_vmtruncate_work(struct work_struct *work) |
1311 | { | 1336 | { |
1312 | struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, | 1337 | struct ceph_inode_info *ci = container_of(work, struct ceph_inode_info, |
1313 | i_vmtruncate_work); | 1338 | i_vmtruncate_work); |
@@ -1321,6 +1346,24 @@ void ceph_vmtruncate_work(struct work_struct *work) | |||
1321 | } | 1346 | } |
1322 | 1347 | ||
1323 | /* | 1348 | /* |
1349 | * Queue an async vmtruncate. If we fail to queue work, we will handle | ||
1350 | * the truncation the next time we call __ceph_do_pending_vmtruncate. | ||
1351 | */ | ||
1352 | void ceph_queue_vmtruncate(struct inode *inode) | ||
1353 | { | ||
1354 | struct ceph_inode_info *ci = ceph_inode(inode); | ||
1355 | |||
1356 | if (queue_work(ceph_client(inode->i_sb)->trunc_wq, | ||
1357 | &ci->i_vmtruncate_work)) { | ||
1358 | dout("ceph_queue_vmtruncate %p\n", inode); | ||
1359 | igrab(inode); | ||
1360 | } else { | ||
1361 | dout("ceph_queue_vmtruncate %p failed, pending=%d\n", | ||
1362 | inode, ci->i_truncate_pending); | ||
1363 | } | ||
1364 | } | ||
1365 | |||
1366 | /* | ||
1324 | * called with i_mutex held. | 1367 | * called with i_mutex held. |
1325 | * | 1368 | * |
1326 | * Make sure any pending truncation is applied before doing anything | 1369 | * Make sure any pending truncation is applied before doing anything |