diff options
56 files changed, 319 insertions, 220 deletions
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 74acd9618819..8c91d1057d9a 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
@@ -297,7 +297,8 @@ in the beginning of ->setattr unconditionally. | |||
297 | be used instead. It gets called whenever the inode is evicted, whether it has | 297 | be used instead. It gets called whenever the inode is evicted, whether it has |
298 | remaining links or not. Caller does *not* evict the pagecache or inode-associated | 298 | remaining links or not. Caller does *not* evict the pagecache or inode-associated |
299 | metadata buffers; getting rid of those is responsibility of method, as it had | 299 | metadata buffers; getting rid of those is responsibility of method, as it had |
300 | been for ->delete_inode(). | 300 | been for ->delete_inode(). Caller makes sure async writeback cannot be running |
301 | for the inode while (or after) ->evict_inode() is called. | ||
301 | 302 | ||
302 | ->drop_inode() returns int now; it's called on final iput() with | 303 | ->drop_inode() returns int now; it's called on final iput() with |
303 | inode->i_lock held and it returns true if filesystems wants the inode to be | 304 | inode->i_lock held and it returns true if filesystems wants the inode to be |
@@ -306,14 +307,11 @@ updated appropriately. generic_delete_inode() is also alive and it consists | |||
306 | simply of return 1. Note that all actual eviction work is done by caller after | 307 | simply of return 1. Note that all actual eviction work is done by caller after |
307 | ->drop_inode() returns. | 308 | ->drop_inode() returns. |
308 | 309 | ||
309 | clear_inode() is gone; use end_writeback() instead. As before, it must | 310 | As before, clear_inode() must be called exactly once on each call of |
310 | be called exactly once on each call of ->evict_inode() (as it used to be for | 311 | ->evict_inode() (as it used to be for each call of ->delete_inode()). Unlike |
311 | each call of ->delete_inode()). Unlike before, if you are using inode-associated | 312 | before, if you are using inode-associated metadata buffers (i.e. |
312 | metadata buffers (i.e. mark_buffer_dirty_inode()), it's your responsibility to | 313 | mark_buffer_dirty_inode()), it's your responsibility to call |
313 | call invalidate_inode_buffers() before end_writeback(). | 314 | invalidate_inode_buffers() before clear_inode(). |
314 | No async writeback (and thus no calls of ->write_inode()) will happen | ||
315 | after end_writeback() returns, so actions that should not overlap with ->write_inode() | ||
316 | (e.g. freeing on-disk inode if i_nlink is 0) ought to be done after that call. | ||
317 | 315 | ||
318 | NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out | 316 | NOTE: checking i_nlink in the beginning of ->write_inode() and bailing out |
319 | if it's zero is not *and* *never* *had* *been* enough. Final unlink() and iput() | 317 | if it's zero is not *and* *never* *had* *been* enough. Final unlink() and iput() |
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c index 1d75c92ea8fb..66519d263da7 100644 --- a/arch/powerpc/platforms/cell/spufs/inode.c +++ b/arch/powerpc/platforms/cell/spufs/inode.c | |||
@@ -151,7 +151,7 @@ static void | |||
151 | spufs_evict_inode(struct inode *inode) | 151 | spufs_evict_inode(struct inode *inode) |
152 | { | 152 | { |
153 | struct spufs_inode_info *ei = SPUFS_I(inode); | 153 | struct spufs_inode_info *ei = SPUFS_I(inode); |
154 | end_writeback(inode); | 154 | clear_inode(inode); |
155 | if (ei->i_ctx) | 155 | if (ei->i_ctx) |
156 | put_spu_context(ei->i_ctx); | 156 | put_spu_context(ei->i_ctx); |
157 | if (ei->i_gang) | 157 | if (ei->i_gang) |
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 6a2cb560e968..73dae8b9b77a 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
@@ -115,7 +115,7 @@ static struct inode *hypfs_make_inode(struct super_block *sb, umode_t mode) | |||
115 | 115 | ||
116 | static void hypfs_evict_inode(struct inode *inode) | 116 | static void hypfs_evict_inode(struct inode *inode) |
117 | { | 117 | { |
118 | end_writeback(inode); | 118 | clear_inode(inode); |
119 | kfree(inode->i_private); | 119 | kfree(inode->i_private); |
120 | } | 120 | } |
121 | 121 | ||
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 014c8dd62962..57ccb7537dae 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -448,7 +448,7 @@ void v9fs_evict_inode(struct inode *inode) | |||
448 | struct v9fs_inode *v9inode = V9FS_I(inode); | 448 | struct v9fs_inode *v9inode = V9FS_I(inode); |
449 | 449 | ||
450 | truncate_inode_pages(inode->i_mapping, 0); | 450 | truncate_inode_pages(inode->i_mapping, 0); |
451 | end_writeback(inode); | 451 | clear_inode(inode); |
452 | filemap_fdatawrite(inode->i_mapping); | 452 | filemap_fdatawrite(inode->i_mapping); |
453 | 453 | ||
454 | #ifdef CONFIG_9P_FSCACHE | 454 | #ifdef CONFIG_9P_FSCACHE |
diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 88a4b0b50058..8bc4a59f4e7e 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c | |||
@@ -264,7 +264,7 @@ affs_evict_inode(struct inode *inode) | |||
264 | } | 264 | } |
265 | 265 | ||
266 | invalidate_inode_buffers(inode); | 266 | invalidate_inode_buffers(inode); |
267 | end_writeback(inode); | 267 | clear_inode(inode); |
268 | affs_free_prealloc(inode); | 268 | affs_free_prealloc(inode); |
269 | cache_page = (unsigned long)AFFS_I(inode)->i_lc; | 269 | cache_page = (unsigned long)AFFS_I(inode)->i_lc; |
270 | if (cache_page) { | 270 | if (cache_page) { |
diff --git a/fs/afs/inode.c b/fs/afs/inode.c index d890ae3b2ce6..95cffd38239f 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c | |||
@@ -423,7 +423,7 @@ void afs_evict_inode(struct inode *inode) | |||
423 | ASSERTCMP(inode->i_ino, ==, vnode->fid.vnode); | 423 | ASSERTCMP(inode->i_ino, ==, vnode->fid.vnode); |
424 | 424 | ||
425 | truncate_inode_pages(&inode->i_data, 0); | 425 | truncate_inode_pages(&inode->i_data, 0); |
426 | end_writeback(inode); | 426 | clear_inode(inode); |
427 | 427 | ||
428 | afs_give_up_callback(vnode); | 428 | afs_give_up_callback(vnode); |
429 | 429 | ||
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c index 6e488ebe7784..8a4fed8ead30 100644 --- a/fs/autofs4/inode.c +++ b/fs/autofs4/inode.c | |||
@@ -100,7 +100,7 @@ static int autofs4_show_options(struct seq_file *m, struct dentry *root) | |||
100 | 100 | ||
101 | static void autofs4_evict_inode(struct inode *inode) | 101 | static void autofs4_evict_inode(struct inode *inode) |
102 | { | 102 | { |
103 | end_writeback(inode); | 103 | clear_inode(inode); |
104 | kfree(inode->i_private); | 104 | kfree(inode->i_private); |
105 | } | 105 | } |
106 | 106 | ||
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index e23dc7c8b884..9870417c26e7 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c | |||
@@ -174,7 +174,7 @@ static void bfs_evict_inode(struct inode *inode) | |||
174 | 174 | ||
175 | truncate_inode_pages(&inode->i_data, 0); | 175 | truncate_inode_pages(&inode->i_data, 0); |
176 | invalidate_inode_buffers(inode); | 176 | invalidate_inode_buffers(inode); |
177 | end_writeback(inode); | 177 | clear_inode(inode); |
178 | 178 | ||
179 | if (inode->i_nlink) | 179 | if (inode->i_nlink) |
180 | return; | 180 | return; |
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 613aa0618235..790b3cddca67 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -505,7 +505,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode) | |||
505 | 505 | ||
506 | static void bm_evict_inode(struct inode *inode) | 506 | static void bm_evict_inode(struct inode *inode) |
507 | { | 507 | { |
508 | end_writeback(inode); | 508 | clear_inode(inode); |
509 | kfree(inode->i_private); | 509 | kfree(inode->i_private); |
510 | } | 510 | } |
511 | 511 | ||
diff --git a/fs/block_dev.c b/fs/block_dev.c index ba11c30f302d..c2bbe1fb1326 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -487,7 +487,7 @@ static void bdev_evict_inode(struct inode *inode) | |||
487 | struct list_head *p; | 487 | struct list_head *p; |
488 | truncate_inode_pages(&inode->i_data, 0); | 488 | truncate_inode_pages(&inode->i_data, 0); |
489 | invalidate_inode_buffers(inode); /* is it needed here? */ | 489 | invalidate_inode_buffers(inode); /* is it needed here? */ |
490 | end_writeback(inode); | 490 | clear_inode(inode); |
491 | spin_lock(&bdev_lock); | 491 | spin_lock(&bdev_lock); |
492 | while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) { | 492 | while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) { |
493 | __bd_forget(list_entry(p, struct inode, i_devices)); | 493 | __bd_forget(list_entry(p, struct inode, i_devices)); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 61b16c641ce0..ceb7b9c9edcc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3756,7 +3756,7 @@ void btrfs_evict_inode(struct inode *inode) | |||
3756 | btrfs_end_transaction(trans, root); | 3756 | btrfs_end_transaction(trans, root); |
3757 | btrfs_btree_balance_dirty(root, nr); | 3757 | btrfs_btree_balance_dirty(root, nr); |
3758 | no_delete: | 3758 | no_delete: |
3759 | end_writeback(inode); | 3759 | clear_inode(inode); |
3760 | return; | 3760 | return; |
3761 | } | 3761 | } |
3762 | 3762 | ||
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 541ef81f6ae8..0a0fa0250e99 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -272,7 +272,7 @@ static void | |||
272 | cifs_evict_inode(struct inode *inode) | 272 | cifs_evict_inode(struct inode *inode) |
273 | { | 273 | { |
274 | truncate_inode_pages(&inode->i_data, 0); | 274 | truncate_inode_pages(&inode->i_data, 0); |
275 | end_writeback(inode); | 275 | clear_inode(inode); |
276 | cifs_fscache_release_inode_cookie(inode); | 276 | cifs_fscache_release_inode_cookie(inode); |
277 | } | 277 | } |
278 | 278 | ||
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 2870597b5c9d..f1813120d753 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -244,7 +244,7 @@ static void coda_put_super(struct super_block *sb) | |||
244 | static void coda_evict_inode(struct inode *inode) | 244 | static void coda_evict_inode(struct inode *inode) |
245 | { | 245 | { |
246 | truncate_inode_pages(&inode->i_data, 0); | 246 | truncate_inode_pages(&inode->i_data, 0); |
247 | end_writeback(inode); | 247 | clear_inode(inode); |
248 | coda_cache_clear_inode(inode); | 248 | coda_cache_clear_inode(inode); |
249 | } | 249 | } |
250 | 250 | ||
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index 2dd946b636d2..e879cf8ff0b1 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c | |||
@@ -133,7 +133,7 @@ static int ecryptfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
133 | static void ecryptfs_evict_inode(struct inode *inode) | 133 | static void ecryptfs_evict_inode(struct inode *inode) |
134 | { | 134 | { |
135 | truncate_inode_pages(&inode->i_data, 0); | 135 | truncate_inode_pages(&inode->i_data, 0); |
136 | end_writeback(inode); | 136 | clear_inode(inode); |
137 | iput(ecryptfs_inode_to_lower(inode)); | 137 | iput(ecryptfs_inode_to_lower(inode)); |
138 | } | 138 | } |
139 | 139 | ||
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index ea5e1f97806a..5badb0c039de 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
@@ -1473,7 +1473,7 @@ void exofs_evict_inode(struct inode *inode) | |||
1473 | goto no_delete; | 1473 | goto no_delete; |
1474 | 1474 | ||
1475 | inode->i_size = 0; | 1475 | inode->i_size = 0; |
1476 | end_writeback(inode); | 1476 | clear_inode(inode); |
1477 | 1477 | ||
1478 | /* if we are deleting an obj that hasn't been created yet, wait. | 1478 | /* if we are deleting an obj that hasn't been created yet, wait. |
1479 | * This also makes sure that create_done cannot be called with an | 1479 | * This also makes sure that create_done cannot be called with an |
@@ -1503,5 +1503,5 @@ void exofs_evict_inode(struct inode *inode) | |||
1503 | return; | 1503 | return; |
1504 | 1504 | ||
1505 | no_delete: | 1505 | no_delete: |
1506 | end_writeback(inode); | 1506 | clear_inode(inode); |
1507 | } | 1507 | } |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index f9fa95f8443d..264d315f6c47 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -90,7 +90,7 @@ void ext2_evict_inode(struct inode * inode) | |||
90 | } | 90 | } |
91 | 91 | ||
92 | invalidate_inode_buffers(inode); | 92 | invalidate_inode_buffers(inode); |
93 | end_writeback(inode); | 93 | clear_inode(inode); |
94 | 94 | ||
95 | ext2_discard_reservation(inode); | 95 | ext2_discard_reservation(inode); |
96 | rsv = EXT2_I(inode)->i_block_alloc_info; | 96 | rsv = EXT2_I(inode)->i_block_alloc_info; |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index a09790a412b1..9a4a5c48b1c9 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -272,18 +272,18 @@ void ext3_evict_inode (struct inode *inode) | |||
272 | if (ext3_mark_inode_dirty(handle, inode)) { | 272 | if (ext3_mark_inode_dirty(handle, inode)) { |
273 | /* If that failed, just dquot_drop() and be done with that */ | 273 | /* If that failed, just dquot_drop() and be done with that */ |
274 | dquot_drop(inode); | 274 | dquot_drop(inode); |
275 | end_writeback(inode); | 275 | clear_inode(inode); |
276 | } else { | 276 | } else { |
277 | ext3_xattr_delete_inode(handle, inode); | 277 | ext3_xattr_delete_inode(handle, inode); |
278 | dquot_free_inode(inode); | 278 | dquot_free_inode(inode); |
279 | dquot_drop(inode); | 279 | dquot_drop(inode); |
280 | end_writeback(inode); | 280 | clear_inode(inode); |
281 | ext3_free_inode(handle, inode); | 281 | ext3_free_inode(handle, inode); |
282 | } | 282 | } |
283 | ext3_journal_stop(handle); | 283 | ext3_journal_stop(handle); |
284 | return; | 284 | return; |
285 | no_delete: | 285 | no_delete: |
286 | end_writeback(inode); | 286 | clear_inode(inode); |
287 | dquot_drop(inode); | 287 | dquot_drop(inode); |
288 | } | 288 | } |
289 | 289 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 1867a98e0c49..35b5954489ee 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1007,7 +1007,7 @@ static void destroy_inodecache(void) | |||
1007 | void ext4_clear_inode(struct inode *inode) | 1007 | void ext4_clear_inode(struct inode *inode) |
1008 | { | 1008 | { |
1009 | invalidate_inode_buffers(inode); | 1009 | invalidate_inode_buffers(inode); |
1010 | end_writeback(inode); | 1010 | clear_inode(inode); |
1011 | dquot_drop(inode); | 1011 | dquot_drop(inode); |
1012 | ext4_discard_preallocations(inode); | 1012 | ext4_discard_preallocations(inode); |
1013 | if (EXT4_I(inode)->jinode) { | 1013 | if (EXT4_I(inode)->jinode) { |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 21687e31acc0..b3d290c1b513 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -454,7 +454,7 @@ static void fat_evict_inode(struct inode *inode) | |||
454 | fat_truncate_blocks(inode, 0); | 454 | fat_truncate_blocks(inode, 0); |
455 | } | 455 | } |
456 | invalidate_inode_buffers(inode); | 456 | invalidate_inode_buffers(inode); |
457 | end_writeback(inode); | 457 | clear_inode(inode); |
458 | fat_cache_inval_inode(inode); | 458 | fat_cache_inval_inode(inode); |
459 | fat_detach(inode); | 459 | fat_detach(inode); |
460 | } | 460 | } |
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c index cf9ef918a2a9..ef67c95f12d4 100644 --- a/fs/freevxfs/vxfs_inode.c +++ b/fs/freevxfs/vxfs_inode.c | |||
@@ -355,6 +355,6 @@ void | |||
355 | vxfs_evict_inode(struct inode *ip) | 355 | vxfs_evict_inode(struct inode *ip) |
356 | { | 356 | { |
357 | truncate_inode_pages(&ip->i_data, 0); | 357 | truncate_inode_pages(&ip->i_data, 0); |
358 | end_writeback(ip); | 358 | clear_inode(ip); |
359 | call_rcu(&ip->i_rcu, vxfs_i_callback); | 359 | call_rcu(&ip->i_rcu, vxfs_i_callback); |
360 | } | 360 | } |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 539f36cf3e4a..8d2fb8c88cf3 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -231,11 +231,8 @@ static void requeue_io(struct inode *inode, struct bdi_writeback *wb) | |||
231 | 231 | ||
232 | static void inode_sync_complete(struct inode *inode) | 232 | static void inode_sync_complete(struct inode *inode) |
233 | { | 233 | { |
234 | /* | 234 | inode->i_state &= ~I_SYNC; |
235 | * Prevent speculative execution through | 235 | /* Waiters must see I_SYNC cleared before being woken up */ |
236 | * spin_unlock(&wb->list_lock); | ||
237 | */ | ||
238 | |||
239 | smp_mb(); | 236 | smp_mb(); |
240 | wake_up_bit(&inode->i_state, __I_SYNC); | 237 | wake_up_bit(&inode->i_state, __I_SYNC); |
241 | } | 238 | } |
@@ -329,10 +326,12 @@ static int write_inode(struct inode *inode, struct writeback_control *wbc) | |||
329 | } | 326 | } |
330 | 327 | ||
331 | /* | 328 | /* |
332 | * Wait for writeback on an inode to complete. | 329 | * Wait for writeback on an inode to complete. Called with i_lock held. |
330 | * Caller must make sure inode cannot go away when we drop i_lock. | ||
333 | */ | 331 | */ |
334 | static void inode_wait_for_writeback(struct inode *inode, | 332 | static void __inode_wait_for_writeback(struct inode *inode) |
335 | struct bdi_writeback *wb) | 333 | __releases(inode->i_lock) |
334 | __acquires(inode->i_lock) | ||
336 | { | 335 | { |
337 | DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); | 336 | DEFINE_WAIT_BIT(wq, &inode->i_state, __I_SYNC); |
338 | wait_queue_head_t *wqh; | 337 | wait_queue_head_t *wqh; |
@@ -340,70 +339,119 @@ static void inode_wait_for_writeback(struct inode *inode, | |||
340 | wqh = bit_waitqueue(&inode->i_state, __I_SYNC); | 339 | wqh = bit_waitqueue(&inode->i_state, __I_SYNC); |
341 | while (inode->i_state & I_SYNC) { | 340 | while (inode->i_state & I_SYNC) { |
342 | spin_unlock(&inode->i_lock); | 341 | spin_unlock(&inode->i_lock); |
343 | spin_unlock(&wb->list_lock); | ||
344 | __wait_on_bit(wqh, &wq, inode_wait, TASK_UNINTERRUPTIBLE); | 342 | __wait_on_bit(wqh, &wq, inode_wait, TASK_UNINTERRUPTIBLE); |
345 | spin_lock(&wb->list_lock); | ||
346 | spin_lock(&inode->i_lock); | 343 | spin_lock(&inode->i_lock); |
347 | } | 344 | } |
348 | } | 345 | } |
349 | 346 | ||
350 | /* | 347 | /* |
351 | * Write out an inode's dirty pages. Called under wb->list_lock and | 348 | * Wait for writeback on an inode to complete. Caller must have inode pinned. |
352 | * inode->i_lock. Either the caller has an active reference on the inode or | ||
353 | * the inode has I_WILL_FREE set. | ||
354 | * | ||
355 | * If `wait' is set, wait on the writeout. | ||
356 | * | ||
357 | * The whole writeout design is quite complex and fragile. We want to avoid | ||
358 | * starvation of particular inodes when others are being redirtied, prevent | ||
359 | * livelocks, etc. | ||
360 | */ | 349 | */ |
361 | static int | 350 | void inode_wait_for_writeback(struct inode *inode) |
362 | writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | ||
363 | struct writeback_control *wbc) | ||
364 | { | 351 | { |
365 | struct address_space *mapping = inode->i_mapping; | 352 | spin_lock(&inode->i_lock); |
366 | long nr_to_write = wbc->nr_to_write; | 353 | __inode_wait_for_writeback(inode); |
367 | unsigned dirty; | 354 | spin_unlock(&inode->i_lock); |
368 | int ret; | 355 | } |
369 | 356 | ||
370 | assert_spin_locked(&wb->list_lock); | 357 | /* |
371 | assert_spin_locked(&inode->i_lock); | 358 | * Sleep until I_SYNC is cleared. This function must be called with i_lock |
359 | * held and drops it. It is aimed for callers not holding any inode reference | ||
360 | * so once i_lock is dropped, inode can go away. | ||
361 | */ | ||
362 | static void inode_sleep_on_writeback(struct inode *inode) | ||
363 | __releases(inode->i_lock) | ||
364 | { | ||
365 | DEFINE_WAIT(wait); | ||
366 | wait_queue_head_t *wqh = bit_waitqueue(&inode->i_state, __I_SYNC); | ||
367 | int sleep; | ||
372 | 368 | ||
373 | if (!atomic_read(&inode->i_count)) | 369 | prepare_to_wait(wqh, &wait, TASK_UNINTERRUPTIBLE); |
374 | WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); | 370 | sleep = inode->i_state & I_SYNC; |
375 | else | 371 | spin_unlock(&inode->i_lock); |
376 | WARN_ON(inode->i_state & I_WILL_FREE); | 372 | if (sleep) |
373 | schedule(); | ||
374 | finish_wait(wqh, &wait); | ||
375 | } | ||
377 | 376 | ||
378 | if (inode->i_state & I_SYNC) { | 377 | /* |
378 | * Find proper writeback list for the inode depending on its current state and | ||
379 | * possibly also change of its state while we were doing writeback. Here we | ||
380 | * handle things such as livelock prevention or fairness of writeback among | ||
381 | * inodes. This function can be called only by flusher thread - noone else | ||
382 | * processes all inodes in writeback lists and requeueing inodes behind flusher | ||
383 | * thread's back can have unexpected consequences. | ||
384 | */ | ||
385 | static void requeue_inode(struct inode *inode, struct bdi_writeback *wb, | ||
386 | struct writeback_control *wbc) | ||
387 | { | ||
388 | if (inode->i_state & I_FREEING) | ||
389 | return; | ||
390 | |||
391 | /* | ||
392 | * Sync livelock prevention. Each inode is tagged and synced in one | ||
393 | * shot. If still dirty, it will be redirty_tail()'ed below. Update | ||
394 | * the dirty time to prevent enqueue and sync it again. | ||
395 | */ | ||
396 | if ((inode->i_state & I_DIRTY) && | ||
397 | (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)) | ||
398 | inode->dirtied_when = jiffies; | ||
399 | |||
400 | if (wbc->pages_skipped) { | ||
379 | /* | 401 | /* |
380 | * If this inode is locked for writeback and we are not doing | 402 | * writeback is not making progress due to locked |
381 | * writeback-for-data-integrity, move it to b_more_io so that | 403 | * buffers. Skip this inode for now. |
382 | * writeback can proceed with the other inodes on s_io. | ||
383 | * | ||
384 | * We'll have another go at writing back this inode when we | ||
385 | * completed a full scan of b_io. | ||
386 | */ | 404 | */ |
387 | if (wbc->sync_mode != WB_SYNC_ALL) { | 405 | redirty_tail(inode, wb); |
406 | return; | ||
407 | } | ||
408 | |||
409 | if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)) { | ||
410 | /* | ||
411 | * We didn't write back all the pages. nfs_writepages() | ||
412 | * sometimes bales out without doing anything. | ||
413 | */ | ||
414 | if (wbc->nr_to_write <= 0) { | ||
415 | /* Slice used up. Queue for next turn. */ | ||
388 | requeue_io(inode, wb); | 416 | requeue_io(inode, wb); |
389 | trace_writeback_single_inode_requeue(inode, wbc, | 417 | } else { |
390 | nr_to_write); | 418 | /* |
391 | return 0; | 419 | * Writeback blocked by something other than |
420 | * congestion. Delay the inode for some time to | ||
421 | * avoid spinning on the CPU (100% iowait) | ||
422 | * retrying writeback of the dirty page/inode | ||
423 | * that cannot be performed immediately. | ||
424 | */ | ||
425 | redirty_tail(inode, wb); | ||
392 | } | 426 | } |
393 | 427 | } else if (inode->i_state & I_DIRTY) { | |
394 | /* | 428 | /* |
395 | * It's a data-integrity sync. We must wait. | 429 | * Filesystems can dirty the inode during writeback operations, |
430 | * such as delayed allocation during submission or metadata | ||
431 | * updates after data IO completion. | ||
396 | */ | 432 | */ |
397 | inode_wait_for_writeback(inode, wb); | 433 | redirty_tail(inode, wb); |
434 | } else { | ||
435 | /* The inode is clean. Remove from writeback lists. */ | ||
436 | list_del_init(&inode->i_wb_list); | ||
398 | } | 437 | } |
438 | } | ||
399 | 439 | ||
400 | BUG_ON(inode->i_state & I_SYNC); | 440 | /* |
441 | * Write out an inode and its dirty pages. Do not update the writeback list | ||
442 | * linkage. That is left to the caller. The caller is also responsible for | ||
443 | * setting I_SYNC flag and calling inode_sync_complete() to clear it. | ||
444 | */ | ||
445 | static int | ||
446 | __writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | ||
447 | struct writeback_control *wbc) | ||
448 | { | ||
449 | struct address_space *mapping = inode->i_mapping; | ||
450 | long nr_to_write = wbc->nr_to_write; | ||
451 | unsigned dirty; | ||
452 | int ret; | ||
401 | 453 | ||
402 | /* Set I_SYNC, reset I_DIRTY_PAGES */ | 454 | WARN_ON(!(inode->i_state & I_SYNC)); |
403 | inode->i_state |= I_SYNC; | ||
404 | inode->i_state &= ~I_DIRTY_PAGES; | ||
405 | spin_unlock(&inode->i_lock); | ||
406 | spin_unlock(&wb->list_lock); | ||
407 | 455 | ||
408 | ret = do_writepages(mapping, wbc); | 456 | ret = do_writepages(mapping, wbc); |
409 | 457 | ||
@@ -424,6 +472,9 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | |||
424 | * write_inode() | 472 | * write_inode() |
425 | */ | 473 | */ |
426 | spin_lock(&inode->i_lock); | 474 | spin_lock(&inode->i_lock); |
475 | /* Clear I_DIRTY_PAGES if we've written out all dirty pages */ | ||
476 | if (!mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) | ||
477 | inode->i_state &= ~I_DIRTY_PAGES; | ||
427 | dirty = inode->i_state & I_DIRTY; | 478 | dirty = inode->i_state & I_DIRTY; |
428 | inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC); | 479 | inode->i_state &= ~(I_DIRTY_SYNC | I_DIRTY_DATASYNC); |
429 | spin_unlock(&inode->i_lock); | 480 | spin_unlock(&inode->i_lock); |
@@ -433,60 +484,67 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | |||
433 | if (ret == 0) | 484 | if (ret == 0) |
434 | ret = err; | 485 | ret = err; |
435 | } | 486 | } |
487 | trace_writeback_single_inode(inode, wbc, nr_to_write); | ||
488 | return ret; | ||
489 | } | ||
490 | |||
491 | /* | ||
492 | * Write out an inode's dirty pages. Either the caller has an active reference | ||
493 | * on the inode or the inode has I_WILL_FREE set. | ||
494 | * | ||
495 | * This function is designed to be called for writing back one inode which | ||
496 | * we go e.g. from filesystem. Flusher thread uses __writeback_single_inode() | ||
497 | * and does more profound writeback list handling in writeback_sb_inodes(). | ||
498 | */ | ||
499 | static int | ||
500 | writeback_single_inode(struct inode *inode, struct bdi_writeback *wb, | ||
501 | struct writeback_control *wbc) | ||
502 | { | ||
503 | int ret = 0; | ||
436 | 504 | ||
437 | spin_lock(&wb->list_lock); | ||
438 | spin_lock(&inode->i_lock); | 505 | spin_lock(&inode->i_lock); |
439 | inode->i_state &= ~I_SYNC; | 506 | if (!atomic_read(&inode->i_count)) |
440 | if (!(inode->i_state & I_FREEING)) { | 507 | WARN_ON(!(inode->i_state & (I_WILL_FREE|I_FREEING))); |
508 | else | ||
509 | WARN_ON(inode->i_state & I_WILL_FREE); | ||
510 | |||
511 | if (inode->i_state & I_SYNC) { | ||
512 | if (wbc->sync_mode != WB_SYNC_ALL) | ||
513 | goto out; | ||
441 | /* | 514 | /* |
442 | * Sync livelock prevention. Each inode is tagged and synced in | 515 | * It's a data-integrity sync. We must wait. Since callers hold |
443 | * one shot. If still dirty, it will be redirty_tail()'ed below. | 516 | * inode reference or inode has I_WILL_FREE set, it cannot go |
444 | * Update the dirty time to prevent enqueue and sync it again. | 517 | * away under us. |
445 | */ | 518 | */ |
446 | if ((inode->i_state & I_DIRTY) && | 519 | __inode_wait_for_writeback(inode); |
447 | (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)) | ||
448 | inode->dirtied_when = jiffies; | ||
449 | |||
450 | if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { | ||
451 | /* | ||
452 | * We didn't write back all the pages. nfs_writepages() | ||
453 | * sometimes bales out without doing anything. | ||
454 | */ | ||
455 | inode->i_state |= I_DIRTY_PAGES; | ||
456 | if (wbc->nr_to_write <= 0) { | ||
457 | /* | ||
458 | * slice used up: queue for next turn | ||
459 | */ | ||
460 | requeue_io(inode, wb); | ||
461 | } else { | ||
462 | /* | ||
463 | * Writeback blocked by something other than | ||
464 | * congestion. Delay the inode for some time to | ||
465 | * avoid spinning on the CPU (100% iowait) | ||
466 | * retrying writeback of the dirty page/inode | ||
467 | * that cannot be performed immediately. | ||
468 | */ | ||
469 | redirty_tail(inode, wb); | ||
470 | } | ||
471 | } else if (inode->i_state & I_DIRTY) { | ||
472 | /* | ||
473 | * Filesystems can dirty the inode during writeback | ||
474 | * operations, such as delayed allocation during | ||
475 | * submission or metadata updates after data IO | ||
476 | * completion. | ||
477 | */ | ||
478 | redirty_tail(inode, wb); | ||
479 | } else { | ||
480 | /* | ||
481 | * The inode is clean. At this point we either have | ||
482 | * a reference to the inode or it's on it's way out. | ||
483 | * No need to add it back to the LRU. | ||
484 | */ | ||
485 | list_del_init(&inode->i_wb_list); | ||
486 | } | ||
487 | } | 520 | } |
521 | WARN_ON(inode->i_state & I_SYNC); | ||
522 | /* | ||
523 | * Skip inode if it is clean. We don't want to mess with writeback | ||
524 | * lists in this function since flusher thread may be doing for example | ||
525 | * sync in parallel and if we move the inode, it could get skipped. So | ||
526 | * here we make sure inode is on some writeback list and leave it there | ||
527 | * unless we have completely cleaned the inode. | ||
528 | */ | ||
529 | if (!(inode->i_state & I_DIRTY)) | ||
530 | goto out; | ||
531 | inode->i_state |= I_SYNC; | ||
532 | spin_unlock(&inode->i_lock); | ||
533 | |||
534 | ret = __writeback_single_inode(inode, wb, wbc); | ||
535 | |||
536 | spin_lock(&wb->list_lock); | ||
537 | spin_lock(&inode->i_lock); | ||
538 | /* | ||
539 | * If inode is clean, remove it from writeback lists. Otherwise don't | ||
540 | * touch it. See comment above for explanation. | ||
541 | */ | ||
542 | if (!(inode->i_state & I_DIRTY)) | ||
543 | list_del_init(&inode->i_wb_list); | ||
544 | spin_unlock(&wb->list_lock); | ||
488 | inode_sync_complete(inode); | 545 | inode_sync_complete(inode); |
489 | trace_writeback_single_inode(inode, wbc, nr_to_write); | 546 | out: |
547 | spin_unlock(&inode->i_lock); | ||
490 | return ret; | 548 | return ret; |
491 | } | 549 | } |
492 | 550 | ||
@@ -580,29 +638,57 @@ static long writeback_sb_inodes(struct super_block *sb, | |||
580 | redirty_tail(inode, wb); | 638 | redirty_tail(inode, wb); |
581 | continue; | 639 | continue; |
582 | } | 640 | } |
583 | __iget(inode); | 641 | if ((inode->i_state & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) { |
642 | /* | ||
643 | * If this inode is locked for writeback and we are not | ||
644 | * doing writeback-for-data-integrity, move it to | ||
645 | * b_more_io so that writeback can proceed with the | ||
646 | * other inodes on s_io. | ||
647 | * | ||
648 | * We'll have another go at writing back this inode | ||
649 | * when we completed a full scan of b_io. | ||
650 | */ | ||
651 | spin_unlock(&inode->i_lock); | ||
652 | requeue_io(inode, wb); | ||
653 | trace_writeback_sb_inodes_requeue(inode); | ||
654 | continue; | ||
655 | } | ||
656 | spin_unlock(&wb->list_lock); | ||
657 | |||
658 | /* | ||
659 | * We already requeued the inode if it had I_SYNC set and we | ||
660 | * are doing WB_SYNC_NONE writeback. So this catches only the | ||
661 | * WB_SYNC_ALL case. | ||
662 | */ | ||
663 | if (inode->i_state & I_SYNC) { | ||
664 | /* Wait for I_SYNC. This function drops i_lock... */ | ||
665 | inode_sleep_on_writeback(inode); | ||
666 | /* Inode may be gone, start again */ | ||
667 | continue; | ||
668 | } | ||
669 | inode->i_state |= I_SYNC; | ||
670 | spin_unlock(&inode->i_lock); | ||
671 | |||
584 | write_chunk = writeback_chunk_size(wb->bdi, work); | 672 | write_chunk = writeback_chunk_size(wb->bdi, work); |
585 | wbc.nr_to_write = write_chunk; | 673 | wbc.nr_to_write = write_chunk; |
586 | wbc.pages_skipped = 0; | 674 | wbc.pages_skipped = 0; |
587 | 675 | ||
588 | writeback_single_inode(inode, wb, &wbc); | 676 | /* |
677 | * We use I_SYNC to pin the inode in memory. While it is set | ||
678 | * evict_inode() will wait so the inode cannot be freed. | ||
679 | */ | ||
680 | __writeback_single_inode(inode, wb, &wbc); | ||
589 | 681 | ||
590 | work->nr_pages -= write_chunk - wbc.nr_to_write; | 682 | work->nr_pages -= write_chunk - wbc.nr_to_write; |
591 | wrote += write_chunk - wbc.nr_to_write; | 683 | wrote += write_chunk - wbc.nr_to_write; |
684 | spin_lock(&wb->list_lock); | ||
685 | spin_lock(&inode->i_lock); | ||
592 | if (!(inode->i_state & I_DIRTY)) | 686 | if (!(inode->i_state & I_DIRTY)) |
593 | wrote++; | 687 | wrote++; |
594 | if (wbc.pages_skipped) { | 688 | requeue_inode(inode, wb, &wbc); |
595 | /* | 689 | inode_sync_complete(inode); |
596 | * writeback is not making progress due to locked | ||
597 | * buffers. Skip this inode for now. | ||
598 | */ | ||
599 | redirty_tail(inode, wb); | ||
600 | } | ||
601 | spin_unlock(&inode->i_lock); | 690 | spin_unlock(&inode->i_lock); |
602 | spin_unlock(&wb->list_lock); | 691 | cond_resched_lock(&wb->list_lock); |
603 | iput(inode); | ||
604 | cond_resched(); | ||
605 | spin_lock(&wb->list_lock); | ||
606 | /* | 692 | /* |
607 | * bail out to wb_writeback() often enough to check | 693 | * bail out to wb_writeback() often enough to check |
608 | * background threshold and other termination conditions. | 694 | * background threshold and other termination conditions. |
@@ -796,8 +882,10 @@ static long wb_writeback(struct bdi_writeback *wb, | |||
796 | trace_writeback_wait(wb->bdi, work); | 882 | trace_writeback_wait(wb->bdi, work); |
797 | inode = wb_inode(wb->b_more_io.prev); | 883 | inode = wb_inode(wb->b_more_io.prev); |
798 | spin_lock(&inode->i_lock); | 884 | spin_lock(&inode->i_lock); |
799 | inode_wait_for_writeback(inode, wb); | 885 | spin_unlock(&wb->list_lock); |
800 | spin_unlock(&inode->i_lock); | 886 | /* This function drops i_lock... */ |
887 | inode_sleep_on_writeback(inode); | ||
888 | spin_lock(&wb->list_lock); | ||
801 | } | 889 | } |
802 | } | 890 | } |
803 | spin_unlock(&wb->list_lock); | 891 | spin_unlock(&wb->list_lock); |
@@ -1331,7 +1419,6 @@ EXPORT_SYMBOL(sync_inodes_sb); | |||
1331 | int write_inode_now(struct inode *inode, int sync) | 1419 | int write_inode_now(struct inode *inode, int sync) |
1332 | { | 1420 | { |
1333 | struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; | 1421 | struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; |
1334 | int ret; | ||
1335 | struct writeback_control wbc = { | 1422 | struct writeback_control wbc = { |
1336 | .nr_to_write = LONG_MAX, | 1423 | .nr_to_write = LONG_MAX, |
1337 | .sync_mode = sync ? WB_SYNC_ALL : WB_SYNC_NONE, | 1424 | .sync_mode = sync ? WB_SYNC_ALL : WB_SYNC_NONE, |
@@ -1343,12 +1430,7 @@ int write_inode_now(struct inode *inode, int sync) | |||
1343 | wbc.nr_to_write = 0; | 1430 | wbc.nr_to_write = 0; |
1344 | 1431 | ||
1345 | might_sleep(); | 1432 | might_sleep(); |
1346 | spin_lock(&wb->list_lock); | 1433 | return writeback_single_inode(inode, wb, &wbc); |
1347 | spin_lock(&inode->i_lock); | ||
1348 | ret = writeback_single_inode(inode, wb, &wbc); | ||
1349 | spin_unlock(&inode->i_lock); | ||
1350 | spin_unlock(&wb->list_lock); | ||
1351 | return ret; | ||
1352 | } | 1434 | } |
1353 | EXPORT_SYMBOL(write_inode_now); | 1435 | EXPORT_SYMBOL(write_inode_now); |
1354 | 1436 | ||
@@ -1365,15 +1447,7 @@ EXPORT_SYMBOL(write_inode_now); | |||
1365 | */ | 1447 | */ |
1366 | int sync_inode(struct inode *inode, struct writeback_control *wbc) | 1448 | int sync_inode(struct inode *inode, struct writeback_control *wbc) |
1367 | { | 1449 | { |
1368 | struct bdi_writeback *wb = &inode_to_bdi(inode)->wb; | 1450 | return writeback_single_inode(inode, &inode_to_bdi(inode)->wb, wbc); |
1369 | int ret; | ||
1370 | |||
1371 | spin_lock(&wb->list_lock); | ||
1372 | spin_lock(&inode->i_lock); | ||
1373 | ret = writeback_single_inode(inode, wb, wbc); | ||
1374 | spin_unlock(&inode->i_lock); | ||
1375 | spin_unlock(&wb->list_lock); | ||
1376 | return ret; | ||
1377 | } | 1451 | } |
1378 | EXPORT_SYMBOL(sync_inode); | 1452 | EXPORT_SYMBOL(sync_inode); |
1379 | 1453 | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 26783eb2b1fc..56f6dcf30768 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -122,7 +122,7 @@ static void fuse_destroy_inode(struct inode *inode) | |||
122 | static void fuse_evict_inode(struct inode *inode) | 122 | static void fuse_evict_inode(struct inode *inode) |
123 | { | 123 | { |
124 | truncate_inode_pages(&inode->i_data, 0); | 124 | truncate_inode_pages(&inode->i_data, 0); |
125 | end_writeback(inode); | 125 | clear_inode(inode); |
126 | if (inode->i_sb->s_flags & MS_ACTIVE) { | 126 | if (inode->i_sb->s_flags & MS_ACTIVE) { |
127 | struct fuse_conn *fc = get_fuse_conn(inode); | 127 | struct fuse_conn *fc = get_fuse_conn(inode); |
128 | struct fuse_inode *fi = get_fuse_inode(inode); | 128 | struct fuse_inode *fi = get_fuse_inode(inode); |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 6172fa77ad59..713e621c240b 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -1554,7 +1554,7 @@ out_unlock: | |||
1554 | out: | 1554 | out: |
1555 | /* Case 3 starts here */ | 1555 | /* Case 3 starts here */ |
1556 | truncate_inode_pages(&inode->i_data, 0); | 1556 | truncate_inode_pages(&inode->i_data, 0); |
1557 | end_writeback(inode); | 1557 | clear_inode(inode); |
1558 | gfs2_dir_hash_inval(ip); | 1558 | gfs2_dir_hash_inval(ip); |
1559 | ip->i_gl->gl_object = NULL; | 1559 | ip->i_gl->gl_object = NULL; |
1560 | flush_delayed_work_sync(&ip->i_gl->gl_work); | 1560 | flush_delayed_work_sync(&ip->i_gl->gl_work); |
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c index 737dbeb64320..761ec06354b4 100644 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c | |||
@@ -532,7 +532,7 @@ out: | |||
532 | void hfs_evict_inode(struct inode *inode) | 532 | void hfs_evict_inode(struct inode *inode) |
533 | { | 533 | { |
534 | truncate_inode_pages(&inode->i_data, 0); | 534 | truncate_inode_pages(&inode->i_data, 0); |
535 | end_writeback(inode); | 535 | clear_inode(inode); |
536 | if (HFS_IS_RSRC(inode) && HFS_I(inode)->rsrc_inode) { | 536 | if (HFS_IS_RSRC(inode) && HFS_I(inode)->rsrc_inode) { |
537 | HFS_I(HFS_I(inode)->rsrc_inode)->rsrc_inode = NULL; | 537 | HFS_I(HFS_I(inode)->rsrc_inode)->rsrc_inode = NULL; |
538 | iput(HFS_I(inode)->rsrc_inode); | 538 | iput(HFS_I(inode)->rsrc_inode); |
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index ceb1c281eefb..a9bca4b8768b 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
@@ -154,7 +154,7 @@ static void hfsplus_evict_inode(struct inode *inode) | |||
154 | { | 154 | { |
155 | dprint(DBG_INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino); | 155 | dprint(DBG_INODE, "hfsplus_evict_inode: %lu\n", inode->i_ino); |
156 | truncate_inode_pages(&inode->i_data, 0); | 156 | truncate_inode_pages(&inode->i_data, 0); |
157 | end_writeback(inode); | 157 | clear_inode(inode); |
158 | if (HFSPLUS_IS_RSRC(inode)) { | 158 | if (HFSPLUS_IS_RSRC(inode)) { |
159 | HFSPLUS_I(HFSPLUS_I(inode)->rsrc_inode)->rsrc_inode = NULL; | 159 | HFSPLUS_I(HFSPLUS_I(inode)->rsrc_inode)->rsrc_inode = NULL; |
160 | iput(HFSPLUS_I(inode)->rsrc_inode); | 160 | iput(HFSPLUS_I(inode)->rsrc_inode); |
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index 07c516bfea76..2afa5bbccf9b 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c | |||
@@ -240,7 +240,7 @@ static struct inode *hostfs_alloc_inode(struct super_block *sb) | |||
240 | static void hostfs_evict_inode(struct inode *inode) | 240 | static void hostfs_evict_inode(struct inode *inode) |
241 | { | 241 | { |
242 | truncate_inode_pages(&inode->i_data, 0); | 242 | truncate_inode_pages(&inode->i_data, 0); |
243 | end_writeback(inode); | 243 | clear_inode(inode); |
244 | if (HOSTFS_I(inode)->fd != -1) { | 244 | if (HOSTFS_I(inode)->fd != -1) { |
245 | close_file(&HOSTFS_I(inode)->fd); | 245 | close_file(&HOSTFS_I(inode)->fd); |
246 | HOSTFS_I(inode)->fd = -1; | 246 | HOSTFS_I(inode)->fd = -1; |
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 3b2cec29972b..b43066cbdc6a 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c | |||
@@ -299,7 +299,7 @@ void hpfs_write_if_changed(struct inode *inode) | |||
299 | void hpfs_evict_inode(struct inode *inode) | 299 | void hpfs_evict_inode(struct inode *inode) |
300 | { | 300 | { |
301 | truncate_inode_pages(&inode->i_data, 0); | 301 | truncate_inode_pages(&inode->i_data, 0); |
302 | end_writeback(inode); | 302 | clear_inode(inode); |
303 | if (!inode->i_nlink) { | 303 | if (!inode->i_nlink) { |
304 | hpfs_lock(inode->i_sb); | 304 | hpfs_lock(inode->i_sb); |
305 | hpfs_remove_fnode(inode->i_sb, inode->i_ino); | 305 | hpfs_remove_fnode(inode->i_sb, inode->i_ino); |
diff --git a/fs/hppfs/hppfs.c b/fs/hppfs/hppfs.c index a80e45a690ac..d4f93b52cec5 100644 --- a/fs/hppfs/hppfs.c +++ b/fs/hppfs/hppfs.c | |||
@@ -614,7 +614,7 @@ static struct inode *hppfs_alloc_inode(struct super_block *sb) | |||
614 | 614 | ||
615 | void hppfs_evict_inode(struct inode *ino) | 615 | void hppfs_evict_inode(struct inode *ino) |
616 | { | 616 | { |
617 | end_writeback(ino); | 617 | clear_inode(ino); |
618 | dput(HPPFS_I(ino)->proc_dentry); | 618 | dput(HPPFS_I(ino)->proc_dentry); |
619 | mntput(ino->i_sb->s_fs_info); | 619 | mntput(ino->i_sb->s_fs_info); |
620 | } | 620 | } |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 001ef01d2fe2..cc9281b6c628 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -393,7 +393,7 @@ static void truncate_hugepages(struct inode *inode, loff_t lstart) | |||
393 | static void hugetlbfs_evict_inode(struct inode *inode) | 393 | static void hugetlbfs_evict_inode(struct inode *inode) |
394 | { | 394 | { |
395 | truncate_hugepages(inode, 0); | 395 | truncate_hugepages(inode, 0); |
396 | end_writeback(inode); | 396 | clear_inode(inode); |
397 | } | 397 | } |
398 | 398 | ||
399 | static inline void | 399 | static inline void |
diff --git a/fs/inode.c b/fs/inode.c index da93f7d160d4..6bc8761cc333 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -486,7 +486,7 @@ void __remove_inode_hash(struct inode *inode) | |||
486 | } | 486 | } |
487 | EXPORT_SYMBOL(__remove_inode_hash); | 487 | EXPORT_SYMBOL(__remove_inode_hash); |
488 | 488 | ||
489 | void end_writeback(struct inode *inode) | 489 | void clear_inode(struct inode *inode) |
490 | { | 490 | { |
491 | might_sleep(); | 491 | might_sleep(); |
492 | /* | 492 | /* |
@@ -500,11 +500,10 @@ void end_writeback(struct inode *inode) | |||
500 | BUG_ON(!list_empty(&inode->i_data.private_list)); | 500 | BUG_ON(!list_empty(&inode->i_data.private_list)); |
501 | BUG_ON(!(inode->i_state & I_FREEING)); | 501 | BUG_ON(!(inode->i_state & I_FREEING)); |
502 | BUG_ON(inode->i_state & I_CLEAR); | 502 | BUG_ON(inode->i_state & I_CLEAR); |
503 | inode_sync_wait(inode); | ||
504 | /* don't need i_lock here, no concurrent mods to i_state */ | 503 | /* don't need i_lock here, no concurrent mods to i_state */ |
505 | inode->i_state = I_FREEING | I_CLEAR; | 504 | inode->i_state = I_FREEING | I_CLEAR; |
506 | } | 505 | } |
507 | EXPORT_SYMBOL(end_writeback); | 506 | EXPORT_SYMBOL(clear_inode); |
508 | 507 | ||
509 | /* | 508 | /* |
510 | * Free the inode passed in, removing it from the lists it is still connected | 509 | * Free the inode passed in, removing it from the lists it is still connected |
@@ -531,12 +530,20 @@ static void evict(struct inode *inode) | |||
531 | 530 | ||
532 | inode_sb_list_del(inode); | 531 | inode_sb_list_del(inode); |
533 | 532 | ||
533 | /* | ||
534 | * Wait for flusher thread to be done with the inode so that filesystem | ||
535 | * does not start destroying it while writeback is still running. Since | ||
536 | * the inode has I_FREEING set, flusher thread won't start new work on | ||
537 | * the inode. We just have to wait for running writeback to finish. | ||
538 | */ | ||
539 | inode_wait_for_writeback(inode); | ||
540 | |||
534 | if (op->evict_inode) { | 541 | if (op->evict_inode) { |
535 | op->evict_inode(inode); | 542 | op->evict_inode(inode); |
536 | } else { | 543 | } else { |
537 | if (inode->i_data.nrpages) | 544 | if (inode->i_data.nrpages) |
538 | truncate_inode_pages(&inode->i_data, 0); | 545 | truncate_inode_pages(&inode->i_data, 0); |
539 | end_writeback(inode); | 546 | clear_inode(inode); |
540 | } | 547 | } |
541 | if (S_ISBLK(inode->i_mode) && inode->i_bdev) | 548 | if (S_ISBLK(inode->i_mode) && inode->i_bdev) |
542 | bd_forget(inode); | 549 | bd_forget(inode); |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index bb6f993ebca9..3d3092eda811 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -240,7 +240,7 @@ void jffs2_evict_inode (struct inode *inode) | |||
240 | jffs2_dbg(1, "%s(): ino #%lu mode %o\n", | 240 | jffs2_dbg(1, "%s(): ino #%lu mode %o\n", |
241 | __func__, inode->i_ino, inode->i_mode); | 241 | __func__, inode->i_ino, inode->i_mode); |
242 | truncate_inode_pages(&inode->i_data, 0); | 242 | truncate_inode_pages(&inode->i_data, 0); |
243 | end_writeback(inode); | 243 | clear_inode(inode); |
244 | jffs2_do_clear_inode(c, f); | 244 | jffs2_do_clear_inode(c, f); |
245 | } | 245 | } |
246 | 246 | ||
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 77b69b27f825..4692bf3ca8cb 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c | |||
@@ -169,7 +169,7 @@ void jfs_evict_inode(struct inode *inode) | |||
169 | } else { | 169 | } else { |
170 | truncate_inode_pages(&inode->i_data, 0); | 170 | truncate_inode_pages(&inode->i_data, 0); |
171 | } | 171 | } |
172 | end_writeback(inode); | 172 | clear_inode(inode); |
173 | dquot_drop(inode); | 173 | dquot_drop(inode); |
174 | } | 174 | } |
175 | 175 | ||
diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c index e3ab5e5a904c..f1cb512c5019 100644 --- a/fs/logfs/readwrite.c +++ b/fs/logfs/readwrite.c | |||
@@ -2175,7 +2175,7 @@ void logfs_evict_inode(struct inode *inode) | |||
2175 | } | 2175 | } |
2176 | } | 2176 | } |
2177 | truncate_inode_pages(&inode->i_data, 0); | 2177 | truncate_inode_pages(&inode->i_data, 0); |
2178 | end_writeback(inode); | 2178 | clear_inode(inode); |
2179 | 2179 | ||
2180 | /* Cheaper version of write_inode. All changes are concealed in | 2180 | /* Cheaper version of write_inode. All changes are concealed in |
2181 | * aliases, which are moved back. No write to the medium happens. | 2181 | * aliases, which are moved back. No write to the medium happens. |
diff --git a/fs/minix/inode.c b/fs/minix/inode.c index fcb05d2c6b5f..2a503ad020d5 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c | |||
@@ -32,7 +32,7 @@ static void minix_evict_inode(struct inode *inode) | |||
32 | minix_truncate(inode); | 32 | minix_truncate(inode); |
33 | } | 33 | } |
34 | invalidate_inode_buffers(inode); | 34 | invalidate_inode_buffers(inode); |
35 | end_writeback(inode); | 35 | clear_inode(inode); |
36 | if (!inode->i_nlink) | 36 | if (!inode->i_nlink) |
37 | minix_free_inode(inode); | 37 | minix_free_inode(inode); |
38 | } | 38 | } |
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c index 87484fb8d177..333df07ae3bd 100644 --- a/fs/ncpfs/inode.c +++ b/fs/ncpfs/inode.c | |||
@@ -292,7 +292,7 @@ static void | |||
292 | ncp_evict_inode(struct inode *inode) | 292 | ncp_evict_inode(struct inode *inode) |
293 | { | 293 | { |
294 | truncate_inode_pages(&inode->i_data, 0); | 294 | truncate_inode_pages(&inode->i_data, 0); |
295 | end_writeback(inode); | 295 | clear_inode(inode); |
296 | 296 | ||
297 | if (S_ISDIR(inode->i_mode)) { | 297 | if (S_ISDIR(inode->i_mode)) { |
298 | DDPRINTK("ncp_evict_inode: put directory %ld\n", inode->i_ino); | 298 | DDPRINTK("ncp_evict_inode: put directory %ld\n", inode->i_ino); |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index e8bbfa5b3500..c6073139b402 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -121,7 +121,7 @@ static void nfs_clear_inode(struct inode *inode) | |||
121 | void nfs_evict_inode(struct inode *inode) | 121 | void nfs_evict_inode(struct inode *inode) |
122 | { | 122 | { |
123 | truncate_inode_pages(&inode->i_data, 0); | 123 | truncate_inode_pages(&inode->i_data, 0); |
124 | end_writeback(inode); | 124 | clear_inode(inode); |
125 | nfs_clear_inode(inode); | 125 | nfs_clear_inode(inode); |
126 | } | 126 | } |
127 | 127 | ||
@@ -1500,7 +1500,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1500 | void nfs4_evict_inode(struct inode *inode) | 1500 | void nfs4_evict_inode(struct inode *inode) |
1501 | { | 1501 | { |
1502 | truncate_inode_pages(&inode->i_data, 0); | 1502 | truncate_inode_pages(&inode->i_data, 0); |
1503 | end_writeback(inode); | 1503 | clear_inode(inode); |
1504 | pnfs_return_layout(inode); | 1504 | pnfs_return_layout(inode); |
1505 | pnfs_destroy_layout(NFS_I(inode)); | 1505 | pnfs_destroy_layout(NFS_I(inode)); |
1506 | /* If we are holding a delegation, return it! */ | 1506 | /* If we are holding a delegation, return it! */ |
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 8f7b95ac1f7e..7cc64465ec26 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c | |||
@@ -734,7 +734,7 @@ void nilfs_evict_inode(struct inode *inode) | |||
734 | if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) { | 734 | if (inode->i_nlink || !ii->i_root || unlikely(is_bad_inode(inode))) { |
735 | if (inode->i_data.nrpages) | 735 | if (inode->i_data.nrpages) |
736 | truncate_inode_pages(&inode->i_data, 0); | 736 | truncate_inode_pages(&inode->i_data, 0); |
737 | end_writeback(inode); | 737 | clear_inode(inode); |
738 | nilfs_clear_inode(inode); | 738 | nilfs_clear_inode(inode); |
739 | return; | 739 | return; |
740 | } | 740 | } |
@@ -746,7 +746,7 @@ void nilfs_evict_inode(struct inode *inode) | |||
746 | /* TODO: some of the following operations may fail. */ | 746 | /* TODO: some of the following operations may fail. */ |
747 | nilfs_truncate_bmap(ii, 0); | 747 | nilfs_truncate_bmap(ii, 0); |
748 | nilfs_mark_inode_dirty(inode); | 748 | nilfs_mark_inode_dirty(inode); |
749 | end_writeback(inode); | 749 | clear_inode(inode); |
750 | 750 | ||
751 | ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino); | 751 | ret = nilfs_ifile_delete_inode(ii->i_root->ifile, inode->i_ino); |
752 | if (!ret) | 752 | if (!ret) |
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 2eaa66652944..c6dbd3db6ca8 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c | |||
@@ -2258,7 +2258,7 @@ void ntfs_evict_big_inode(struct inode *vi) | |||
2258 | ntfs_inode *ni = NTFS_I(vi); | 2258 | ntfs_inode *ni = NTFS_I(vi); |
2259 | 2259 | ||
2260 | truncate_inode_pages(&vi->i_data, 0); | 2260 | truncate_inode_pages(&vi->i_data, 0); |
2261 | end_writeback(vi); | 2261 | clear_inode(vi); |
2262 | 2262 | ||
2263 | #ifdef NTFS_RW | 2263 | #ifdef NTFS_RW |
2264 | if (NInoDirty(ni)) { | 2264 | if (NInoDirty(ni)) { |
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c index 3b5825ef3193..e31d6ae013ab 100644 --- a/fs/ocfs2/dlmfs/dlmfs.c +++ b/fs/ocfs2/dlmfs/dlmfs.c | |||
@@ -367,7 +367,7 @@ static void dlmfs_evict_inode(struct inode *inode) | |||
367 | int status; | 367 | int status; |
368 | struct dlmfs_inode_private *ip; | 368 | struct dlmfs_inode_private *ip; |
369 | 369 | ||
370 | end_writeback(inode); | 370 | clear_inode(inode); |
371 | 371 | ||
372 | mlog(0, "inode %lu\n", inode->i_ino); | 372 | mlog(0, "inode %lu\n", inode->i_ino); |
373 | 373 | ||
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 17454a904d7b..735514ca400f 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -1069,7 +1069,7 @@ static void ocfs2_clear_inode(struct inode *inode) | |||
1069 | int status; | 1069 | int status; |
1070 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1070 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
1071 | 1071 | ||
1072 | end_writeback(inode); | 1072 | clear_inode(inode); |
1073 | trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno, | 1073 | trace_ocfs2_clear_inode((unsigned long long)oi->ip_blkno, |
1074 | inode->i_nlink); | 1074 | inode->i_nlink); |
1075 | 1075 | ||
diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index dbc842222589..e6213b3725d1 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c | |||
@@ -184,7 +184,7 @@ int omfs_sync_inode(struct inode *inode) | |||
184 | static void omfs_evict_inode(struct inode *inode) | 184 | static void omfs_evict_inode(struct inode *inode) |
185 | { | 185 | { |
186 | truncate_inode_pages(&inode->i_data, 0); | 186 | truncate_inode_pages(&inode->i_data, 0); |
187 | end_writeback(inode); | 187 | clear_inode(inode); |
188 | 188 | ||
189 | if (inode->i_nlink) | 189 | if (inode->i_nlink) |
190 | return; | 190 | return; |
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 554ecc54799f..7ac817b64a71 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
@@ -33,7 +33,7 @@ static void proc_evict_inode(struct inode *inode) | |||
33 | const struct proc_ns_operations *ns_ops; | 33 | const struct proc_ns_operations *ns_ops; |
34 | 34 | ||
35 | truncate_inode_pages(&inode->i_data, 0); | 35 | truncate_inode_pages(&inode->i_data, 0); |
36 | end_writeback(inode); | 36 | clear_inode(inode); |
37 | 37 | ||
38 | /* Stop tracking associated processes */ | 38 | /* Stop tracking associated processes */ |
39 | put_pid(PROC_I(inode)->pid); | 39 | put_pid(PROC_I(inode)->pid); |
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 19507889bb7f..aeb19e68e086 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c | |||
@@ -85,7 +85,7 @@ static void pstore_evict_inode(struct inode *inode) | |||
85 | struct pstore_private *p = inode->i_private; | 85 | struct pstore_private *p = inode->i_private; |
86 | unsigned long flags; | 86 | unsigned long flags; |
87 | 87 | ||
88 | end_writeback(inode); | 88 | clear_inode(inode); |
89 | if (p) { | 89 | if (p) { |
90 | spin_lock_irqsave(&allpstore_lock, flags); | 90 | spin_lock_irqsave(&allpstore_lock, flags); |
91 | list_del(&p->list); | 91 | list_del(&p->list); |
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 494c315c7417..59d06871a850 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -76,14 +76,14 @@ void reiserfs_evict_inode(struct inode *inode) | |||
76 | ; | 76 | ; |
77 | } | 77 | } |
78 | out: | 78 | out: |
79 | end_writeback(inode); /* note this must go after the journal_end to prevent deadlock */ | 79 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ |
80 | dquot_drop(inode); | 80 | dquot_drop(inode); |
81 | inode->i_blocks = 0; | 81 | inode->i_blocks = 0; |
82 | reiserfs_write_unlock_once(inode->i_sb, depth); | 82 | reiserfs_write_unlock_once(inode->i_sb, depth); |
83 | return; | 83 | return; |
84 | 84 | ||
85 | no_delete: | 85 | no_delete: |
86 | end_writeback(inode); | 86 | clear_inode(inode); |
87 | dquot_drop(inode); | 87 | dquot_drop(inode); |
88 | } | 88 | } |
89 | 89 | ||
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index 907c2b3af758..0ce3ccf7f401 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -310,7 +310,7 @@ void sysfs_evict_inode(struct inode *inode) | |||
310 | struct sysfs_dirent *sd = inode->i_private; | 310 | struct sysfs_dirent *sd = inode->i_private; |
311 | 311 | ||
312 | truncate_inode_pages(&inode->i_data, 0); | 312 | truncate_inode_pages(&inode->i_data, 0); |
313 | end_writeback(inode); | 313 | clear_inode(inode); |
314 | sysfs_put(sd); | 314 | sysfs_put(sd); |
315 | } | 315 | } |
316 | 316 | ||
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index 3da5ce25faf0..08d0b2568cd3 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c | |||
@@ -316,7 +316,7 @@ static void sysv_evict_inode(struct inode *inode) | |||
316 | sysv_truncate(inode); | 316 | sysv_truncate(inode); |
317 | } | 317 | } |
318 | invalidate_inode_buffers(inode); | 318 | invalidate_inode_buffers(inode); |
319 | end_writeback(inode); | 319 | clear_inode(inode); |
320 | if (!inode->i_nlink) | 320 | if (!inode->i_nlink) |
321 | sysv_free_inode(inode); | 321 | sysv_free_inode(inode); |
322 | } | 322 | } |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 001acccac0d6..5862dd9d2784 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -378,7 +378,7 @@ out: | |||
378 | smp_wmb(); | 378 | smp_wmb(); |
379 | } | 379 | } |
380 | done: | 380 | done: |
381 | end_writeback(inode); | 381 | clear_inode(inode); |
382 | } | 382 | } |
383 | 383 | ||
384 | static void ubifs_dirty_inode(struct inode *inode, int flags) | 384 | static void ubifs_dirty_inode(struct inode *inode, int flags) |
diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 7d7528008359..873e1bab9c4c 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c | |||
@@ -80,7 +80,7 @@ void udf_evict_inode(struct inode *inode) | |||
80 | } else | 80 | } else |
81 | truncate_inode_pages(&inode->i_data, 0); | 81 | truncate_inode_pages(&inode->i_data, 0); |
82 | invalidate_inode_buffers(inode); | 82 | invalidate_inode_buffers(inode); |
83 | end_writeback(inode); | 83 | clear_inode(inode); |
84 | if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && | 84 | if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && |
85 | inode->i_size != iinfo->i_lenExtents) { | 85 | inode->i_size != iinfo->i_lenExtents) { |
86 | udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n", | 86 | udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n", |
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 7cdd3953d67e..dd7c89d8a1c1 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -895,7 +895,7 @@ void ufs_evict_inode(struct inode * inode) | |||
895 | } | 895 | } |
896 | 896 | ||
897 | invalidate_inode_buffers(inode); | 897 | invalidate_inode_buffers(inode); |
898 | end_writeback(inode); | 898 | clear_inode(inode); |
899 | 899 | ||
900 | if (want_delete) { | 900 | if (want_delete) { |
901 | lock_ufs(inode->i_sb); | 901 | lock_ufs(inode->i_sb); |
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 2fcfd5b0b046..0d9de41a7151 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -932,7 +932,7 @@ xfs_fs_evict_inode( | |||
932 | trace_xfs_evict_inode(ip); | 932 | trace_xfs_evict_inode(ip); |
933 | 933 | ||
934 | truncate_inode_pages(&inode->i_data, 0); | 934 | truncate_inode_pages(&inode->i_data, 0); |
935 | end_writeback(inode); | 935 | clear_inode(inode); |
936 | XFS_STATS_INC(vn_rele); | 936 | XFS_STATS_INC(vn_rele); |
937 | XFS_STATS_INC(vn_remove); | 937 | XFS_STATS_INC(vn_remove); |
938 | XFS_STATS_DEC(vn_active); | 938 | XFS_STATS_DEC(vn_active); |
diff --git a/include/linux/fs.h b/include/linux/fs.h index c0e53372b082..cdc1a9630948 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1764,8 +1764,8 @@ struct super_operations { | |||
1764 | * I_FREEING Set when inode is about to be freed but still has dirty | 1764 | * I_FREEING Set when inode is about to be freed but still has dirty |
1765 | * pages or buffers attached or the inode itself is still | 1765 | * pages or buffers attached or the inode itself is still |
1766 | * dirty. | 1766 | * dirty. |
1767 | * I_CLEAR Added by end_writeback(). In this state the inode is clean | 1767 | * I_CLEAR Added by clear_inode(). In this state the inode is |
1768 | * and can be destroyed. Inode keeps I_FREEING. | 1768 | * clean and can be destroyed. Inode keeps I_FREEING. |
1769 | * | 1769 | * |
1770 | * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are | 1770 | * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are |
1771 | * prohibited for many purposes. iget() must wait for | 1771 | * prohibited for many purposes. iget() must wait for |
@@ -1773,9 +1773,10 @@ struct super_operations { | |||
1773 | * anew. Other functions will just ignore such inodes, | 1773 | * anew. Other functions will just ignore such inodes, |
1774 | * if appropriate. I_NEW is used for waiting. | 1774 | * if appropriate. I_NEW is used for waiting. |
1775 | * | 1775 | * |
1776 | * I_SYNC Synchonized write of dirty inode data. The bits is | 1776 | * I_SYNC Writeback of inode is running. The bit is set during |
1777 | * set during data writeback, and cleared with a wakeup | 1777 | * data writeback, and cleared with a wakeup on the bit |
1778 | * on the bit address once it is done. | 1778 | * address once it is done. The bit is also used to pin |
1779 | * the inode in memory for flusher thread. | ||
1779 | * | 1780 | * |
1780 | * I_REFERENCED Marks the inode as recently references on the LRU list. | 1781 | * I_REFERENCED Marks the inode as recently references on the LRU list. |
1781 | * | 1782 | * |
@@ -2349,7 +2350,7 @@ extern unsigned int get_next_ino(void); | |||
2349 | 2350 | ||
2350 | extern void __iget(struct inode * inode); | 2351 | extern void __iget(struct inode * inode); |
2351 | extern void iget_failed(struct inode *); | 2352 | extern void iget_failed(struct inode *); |
2352 | extern void end_writeback(struct inode *); | 2353 | extern void clear_inode(struct inode *); |
2353 | extern void __destroy_inode(struct inode *); | 2354 | extern void __destroy_inode(struct inode *); |
2354 | extern struct inode *new_inode_pseudo(struct super_block *sb); | 2355 | extern struct inode *new_inode_pseudo(struct super_block *sb); |
2355 | extern struct inode *new_inode(struct super_block *sb); | 2356 | extern struct inode *new_inode(struct super_block *sb); |
diff --git a/include/linux/writeback.h b/include/linux/writeback.h index a2b84f598e2b..6d0a0fcd80e7 100644 --- a/include/linux/writeback.h +++ b/include/linux/writeback.h | |||
@@ -58,7 +58,6 @@ extern const char *wb_reason_name[]; | |||
58 | * in a manner such that unspecified fields are set to zero. | 58 | * in a manner such that unspecified fields are set to zero. |
59 | */ | 59 | */ |
60 | struct writeback_control { | 60 | struct writeback_control { |
61 | enum writeback_sync_modes sync_mode; | ||
62 | long nr_to_write; /* Write this many pages, and decrement | 61 | long nr_to_write; /* Write this many pages, and decrement |
63 | this for each page written */ | 62 | this for each page written */ |
64 | long pages_skipped; /* Pages which were not written */ | 63 | long pages_skipped; /* Pages which were not written */ |
@@ -71,6 +70,8 @@ struct writeback_control { | |||
71 | loff_t range_start; | 70 | loff_t range_start; |
72 | loff_t range_end; | 71 | loff_t range_end; |
73 | 72 | ||
73 | enum writeback_sync_modes sync_mode; | ||
74 | |||
74 | unsigned for_kupdate:1; /* A kupdate writeback */ | 75 | unsigned for_kupdate:1; /* A kupdate writeback */ |
75 | unsigned for_background:1; /* A background writeback */ | 76 | unsigned for_background:1; /* A background writeback */ |
76 | unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ | 77 | unsigned tagged_writepages:1; /* tag-and-write to avoid livelock */ |
@@ -94,6 +95,7 @@ long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages, | |||
94 | enum wb_reason reason); | 95 | enum wb_reason reason); |
95 | long wb_do_writeback(struct bdi_writeback *wb, int force_wait); | 96 | long wb_do_writeback(struct bdi_writeback *wb, int force_wait); |
96 | void wakeup_flusher_threads(long nr_pages, enum wb_reason reason); | 97 | void wakeup_flusher_threads(long nr_pages, enum wb_reason reason); |
98 | void inode_wait_for_writeback(struct inode *inode); | ||
97 | 99 | ||
98 | /* writeback.h requires fs.h; it, too, is not included from here. */ | 100 | /* writeback.h requires fs.h; it, too, is not included from here. */ |
99 | static inline void wait_on_inode(struct inode *inode) | 101 | static inline void wait_on_inode(struct inode *inode) |
@@ -101,12 +103,6 @@ static inline void wait_on_inode(struct inode *inode) | |||
101 | might_sleep(); | 103 | might_sleep(); |
102 | wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE); | 104 | wait_on_bit(&inode->i_state, __I_NEW, inode_wait, TASK_UNINTERRUPTIBLE); |
103 | } | 105 | } |
104 | static inline void inode_sync_wait(struct inode *inode) | ||
105 | { | ||
106 | might_sleep(); | ||
107 | wait_on_bit(&inode->i_state, __I_SYNC, inode_wait, | ||
108 | TASK_UNINTERRUPTIBLE); | ||
109 | } | ||
110 | 106 | ||
111 | 107 | ||
112 | /* | 108 | /* |
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h index 7b81887b023f..b453d92c2253 100644 --- a/include/trace/events/writeback.h +++ b/include/trace/events/writeback.h | |||
@@ -372,6 +372,35 @@ TRACE_EVENT(balance_dirty_pages, | |||
372 | ) | 372 | ) |
373 | ); | 373 | ); |
374 | 374 | ||
375 | TRACE_EVENT(writeback_sb_inodes_requeue, | ||
376 | |||
377 | TP_PROTO(struct inode *inode), | ||
378 | TP_ARGS(inode), | ||
379 | |||
380 | TP_STRUCT__entry( | ||
381 | __array(char, name, 32) | ||
382 | __field(unsigned long, ino) | ||
383 | __field(unsigned long, state) | ||
384 | __field(unsigned long, dirtied_when) | ||
385 | ), | ||
386 | |||
387 | TP_fast_assign( | ||
388 | strncpy(__entry->name, | ||
389 | dev_name(inode_to_bdi(inode)->dev), 32); | ||
390 | __entry->ino = inode->i_ino; | ||
391 | __entry->state = inode->i_state; | ||
392 | __entry->dirtied_when = inode->dirtied_when; | ||
393 | ), | ||
394 | |||
395 | TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu", | ||
396 | __entry->name, | ||
397 | __entry->ino, | ||
398 | show_inode_state(__entry->state), | ||
399 | __entry->dirtied_when, | ||
400 | (jiffies - __entry->dirtied_when) / HZ | ||
401 | ) | ||
402 | ); | ||
403 | |||
375 | DECLARE_EVENT_CLASS(writeback_congest_waited_template, | 404 | DECLARE_EVENT_CLASS(writeback_congest_waited_template, |
376 | 405 | ||
377 | TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), | 406 | TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed), |
@@ -450,13 +479,6 @@ DECLARE_EVENT_CLASS(writeback_single_inode_template, | |||
450 | ) | 479 | ) |
451 | ); | 480 | ); |
452 | 481 | ||
453 | DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue, | ||
454 | TP_PROTO(struct inode *inode, | ||
455 | struct writeback_control *wbc, | ||
456 | unsigned long nr_to_write), | ||
457 | TP_ARGS(inode, wbc, nr_to_write) | ||
458 | ); | ||
459 | |||
460 | DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode, | 482 | DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode, |
461 | TP_PROTO(struct inode *inode, | 483 | TP_PROTO(struct inode *inode, |
462 | struct writeback_control *wbc, | 484 | struct writeback_control *wbc, |
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index b6a0d46fbad7..a2757d4ab773 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -251,7 +251,7 @@ static void mqueue_evict_inode(struct inode *inode) | |||
251 | int i; | 251 | int i; |
252 | struct ipc_namespace *ipc_ns; | 252 | struct ipc_namespace *ipc_ns; |
253 | 253 | ||
254 | end_writeback(inode); | 254 | clear_inode(inode); |
255 | 255 | ||
256 | if (S_ISDIR(inode->i_mode)) | 256 | if (S_ISDIR(inode->i_mode)) |
257 | return; | 257 | return; |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 26adea8ca2e7..93d8d2f7108c 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -204,7 +204,7 @@ static unsigned long highmem_dirtyable_memory(unsigned long total) | |||
204 | * Returns the global number of pages potentially available for dirty | 204 | * Returns the global number of pages potentially available for dirty |
205 | * page cache. This is the base value for the global dirty limits. | 205 | * page cache. This is the base value for the global dirty limits. |
206 | */ | 206 | */ |
207 | unsigned long global_dirtyable_memory(void) | 207 | static unsigned long global_dirtyable_memory(void) |
208 | { | 208 | { |
209 | unsigned long x; | 209 | unsigned long x; |
210 | 210 | ||
@@ -1568,6 +1568,7 @@ void writeback_set_ratelimit(void) | |||
1568 | unsigned long background_thresh; | 1568 | unsigned long background_thresh; |
1569 | unsigned long dirty_thresh; | 1569 | unsigned long dirty_thresh; |
1570 | global_dirty_limits(&background_thresh, &dirty_thresh); | 1570 | global_dirty_limits(&background_thresh, &dirty_thresh); |
1571 | global_dirty_limit = dirty_thresh; | ||
1571 | ratelimit_pages = dirty_thresh / (num_online_cpus() * 32); | 1572 | ratelimit_pages = dirty_thresh / (num_online_cpus() * 32); |
1572 | if (ratelimit_pages < 16) | 1573 | if (ratelimit_pages < 16) |
1573 | ratelimit_pages = 16; | 1574 | ratelimit_pages = 16; |
diff --git a/mm/shmem.c b/mm/shmem.c index d7b433a1ef5e..be5af34a070d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -597,7 +597,7 @@ static void shmem_evict_inode(struct inode *inode) | |||
597 | } | 597 | } |
598 | BUG_ON(inode->i_blocks); | 598 | BUG_ON(inode->i_blocks); |
599 | shmem_free_inode(inode->i_sb); | 599 | shmem_free_inode(inode->i_sb); |
600 | end_writeback(inode); | 600 | clear_inode(inode); |
601 | } | 601 | } |
602 | 602 | ||
603 | /* | 603 | /* |