diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2010-06-02 17:38:30 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-08-09 16:47:44 -0400 |
commit | a4ffdde6e56fdf8c34ddadc2674d6eb978083369 (patch) | |
tree | 0fa07df92d804cb7d0482135195e4835cb16403a | |
parent | b5fc510c48f631882ccec3c0f02a25d5b67de09f (diff) |
simplify checks for I_CLEAR/I_FREEING
add I_CLEAR instead of replacing I_FREEING with it. I_CLEAR is
equivalent to I_FREEING for almost all code looking at either;
it's there to keep track of having called clear_inode() exactly
once per inode lifetime, at some point after having set I_FREEING.
I_CLEAR and I_FREEING never get set at the same time with the
current code, so we can switch to setting i_flags to I_FREEING | I_CLEAR
instead of I_CLEAR without loss of information. As the result of
such change, checks become simpler and the amount of code that needs
to know about I_CLEAR shrinks a lot.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/btrfs/inode.c | 2 | ||||
-rw-r--r-- | fs/drop_caches.c | 2 | ||||
-rw-r--r-- | fs/fs-writeback.c | 8 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 2 | ||||
-rw-r--r-- | fs/inode.c | 16 | ||||
-rw-r--r-- | fs/nilfs2/gcdat.c | 2 | ||||
-rw-r--r-- | fs/notify/inode_mark.c | 6 | ||||
-rw-r--r-- | fs/notify/inotify/inotify.c | 7 | ||||
-rw-r--r-- | fs/quota/dquot.c | 2 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 4 | ||||
-rw-r--r-- | include/linux/fs.h | 4 |
11 files changed, 27 insertions, 28 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7f9e0536db1a..95eac0116963 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3860,7 +3860,7 @@ again: | |||
3860 | p = &parent->rb_right; | 3860 | p = &parent->rb_right; |
3861 | else { | 3861 | else { |
3862 | WARN_ON(!(entry->vfs_inode.i_state & | 3862 | WARN_ON(!(entry->vfs_inode.i_state & |
3863 | (I_WILL_FREE | I_FREEING | I_CLEAR))); | 3863 | (I_WILL_FREE | I_FREEING))); |
3864 | rb_erase(parent, &root->inode_tree); | 3864 | rb_erase(parent, &root->inode_tree); |
3865 | RB_CLEAR_NODE(parent); | 3865 | RB_CLEAR_NODE(parent); |
3866 | spin_unlock(&root->inode_lock); | 3866 | spin_unlock(&root->inode_lock); |
diff --git a/fs/drop_caches.c b/fs/drop_caches.c index 83c4f600786a..2195c213ab2f 100644 --- a/fs/drop_caches.c +++ b/fs/drop_caches.c | |||
@@ -18,7 +18,7 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused) | |||
18 | 18 | ||
19 | spin_lock(&inode_lock); | 19 | spin_lock(&inode_lock); |
20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 20 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
21 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW)) | 21 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) |
22 | continue; | 22 | continue; |
23 | if (inode->i_mapping->nrpages == 0) | 23 | if (inode->i_mapping->nrpages == 0) |
24 | continue; | 24 | continue; |
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d5be1693ac93..7608880b5c58 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -352,7 +352,7 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
352 | 352 | ||
353 | spin_lock(&inode_lock); | 353 | spin_lock(&inode_lock); |
354 | inode->i_state &= ~I_SYNC; | 354 | inode->i_state &= ~I_SYNC; |
355 | if (!(inode->i_state & (I_FREEING | I_CLEAR))) { | 355 | if (!(inode->i_state & I_FREEING)) { |
356 | if ((inode->i_state & I_DIRTY_PAGES) && wbc->for_kupdate) { | 356 | if ((inode->i_state & I_DIRTY_PAGES) && wbc->for_kupdate) { |
357 | /* | 357 | /* |
358 | * More pages get dirtied by a fast dirtier. | 358 | * More pages get dirtied by a fast dirtier. |
@@ -499,7 +499,7 @@ static int writeback_sb_inodes(struct super_block *sb, struct bdi_writeback *wb, | |||
499 | if (inode_dirtied_after(inode, wbc->wb_start)) | 499 | if (inode_dirtied_after(inode, wbc->wb_start)) |
500 | return 1; | 500 | return 1; |
501 | 501 | ||
502 | BUG_ON(inode->i_state & (I_FREEING | I_CLEAR)); | 502 | BUG_ON(inode->i_state & I_FREEING); |
503 | __iget(inode); | 503 | __iget(inode); |
504 | pages_skipped = wbc->pages_skipped; | 504 | pages_skipped = wbc->pages_skipped; |
505 | writeback_single_inode(inode, wbc); | 505 | writeback_single_inode(inode, wbc); |
@@ -935,7 +935,7 @@ void __mark_inode_dirty(struct inode *inode, int flags) | |||
935 | if (hlist_unhashed(&inode->i_hash)) | 935 | if (hlist_unhashed(&inode->i_hash)) |
936 | goto out; | 936 | goto out; |
937 | } | 937 | } |
938 | if (inode->i_state & (I_FREEING|I_CLEAR)) | 938 | if (inode->i_state & I_FREEING) |
939 | goto out; | 939 | goto out; |
940 | 940 | ||
941 | /* | 941 | /* |
@@ -1001,7 +1001,7 @@ static void wait_sb_inodes(struct super_block *sb) | |||
1001 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 1001 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
1002 | struct address_space *mapping; | 1002 | struct address_space *mapping; |
1003 | 1003 | ||
1004 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW)) | 1004 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) |
1005 | continue; | 1005 | continue; |
1006 | mapping = inode->i_mapping; | 1006 | mapping = inode->i_mapping; |
1007 | if (mapping->nrpages == 0) | 1007 | if (mapping->nrpages == 0) |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 6c023a3b5d25..08140f185a37 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -84,7 +84,7 @@ static int iget_skip_test(struct inode *inode, void *opaque) | |||
84 | struct gfs2_skip_data *data = opaque; | 84 | struct gfs2_skip_data *data = opaque; |
85 | 85 | ||
86 | if (ip->i_no_addr == data->no_addr) { | 86 | if (ip->i_no_addr == data->no_addr) { |
87 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)){ | 87 | if (inode->i_state & (I_FREEING|I_WILL_FREE)){ |
88 | data->skipped = 1; | 88 | data->skipped = 1; |
89 | return 0; | 89 | return 0; |
90 | } | 90 | } |
diff --git a/fs/inode.c b/fs/inode.c index 722860b323a9..71fe079ca32a 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
@@ -317,7 +317,7 @@ void clear_inode(struct inode *inode) | |||
317 | bd_forget(inode); | 317 | bd_forget(inode); |
318 | if (S_ISCHR(inode->i_mode) && inode->i_cdev) | 318 | if (S_ISCHR(inode->i_mode) && inode->i_cdev) |
319 | cd_forget(inode); | 319 | cd_forget(inode); |
320 | inode->i_state = I_CLEAR; | 320 | inode->i_state = I_FREEING | I_CLEAR; |
321 | } | 321 | } |
322 | EXPORT_SYMBOL(clear_inode); | 322 | EXPORT_SYMBOL(clear_inode); |
323 | 323 | ||
@@ -553,7 +553,7 @@ repeat: | |||
553 | continue; | 553 | continue; |
554 | if (!test(inode, data)) | 554 | if (!test(inode, data)) |
555 | continue; | 555 | continue; |
556 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { | 556 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) { |
557 | __wait_on_freeing_inode(inode); | 557 | __wait_on_freeing_inode(inode); |
558 | goto repeat; | 558 | goto repeat; |
559 | } | 559 | } |
@@ -578,7 +578,7 @@ repeat: | |||
578 | continue; | 578 | continue; |
579 | if (inode->i_sb != sb) | 579 | if (inode->i_sb != sb) |
580 | continue; | 580 | continue; |
581 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) { | 581 | if (inode->i_state & (I_FREEING|I_WILL_FREE)) { |
582 | __wait_on_freeing_inode(inode); | 582 | __wait_on_freeing_inode(inode); |
583 | goto repeat; | 583 | goto repeat; |
584 | } | 584 | } |
@@ -840,7 +840,7 @@ EXPORT_SYMBOL(iunique); | |||
840 | struct inode *igrab(struct inode *inode) | 840 | struct inode *igrab(struct inode *inode) |
841 | { | 841 | { |
842 | spin_lock(&inode_lock); | 842 | spin_lock(&inode_lock); |
843 | if (!(inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE))) | 843 | if (!(inode->i_state & (I_FREEING|I_WILL_FREE))) |
844 | __iget(inode); | 844 | __iget(inode); |
845 | else | 845 | else |
846 | /* | 846 | /* |
@@ -1089,7 +1089,7 @@ int insert_inode_locked(struct inode *inode) | |||
1089 | continue; | 1089 | continue; |
1090 | if (old->i_sb != sb) | 1090 | if (old->i_sb != sb) |
1091 | continue; | 1091 | continue; |
1092 | if (old->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) | 1092 | if (old->i_state & (I_FREEING|I_WILL_FREE)) |
1093 | continue; | 1093 | continue; |
1094 | break; | 1094 | break; |
1095 | } | 1095 | } |
@@ -1128,7 +1128,7 @@ int insert_inode_locked4(struct inode *inode, unsigned long hashval, | |||
1128 | continue; | 1128 | continue; |
1129 | if (!test(old, data)) | 1129 | if (!test(old, data)) |
1130 | continue; | 1130 | continue; |
1131 | if (old->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE)) | 1131 | if (old->i_state & (I_FREEING|I_WILL_FREE)) |
1132 | continue; | 1132 | continue; |
1133 | break; | 1133 | break; |
1134 | } | 1134 | } |
@@ -1218,7 +1218,7 @@ void generic_delete_inode(struct inode *inode) | |||
1218 | hlist_del_init(&inode->i_hash); | 1218 | hlist_del_init(&inode->i_hash); |
1219 | spin_unlock(&inode_lock); | 1219 | spin_unlock(&inode_lock); |
1220 | wake_up_inode(inode); | 1220 | wake_up_inode(inode); |
1221 | BUG_ON(inode->i_state != I_CLEAR); | 1221 | BUG_ON(inode->i_state != (I_FREEING | I_CLEAR)); |
1222 | destroy_inode(inode); | 1222 | destroy_inode(inode); |
1223 | } | 1223 | } |
1224 | EXPORT_SYMBOL(generic_delete_inode); | 1224 | EXPORT_SYMBOL(generic_delete_inode); |
@@ -1322,7 +1322,7 @@ static inline void iput_final(struct inode *inode) | |||
1322 | void iput(struct inode *inode) | 1322 | void iput(struct inode *inode) |
1323 | { | 1323 | { |
1324 | if (inode) { | 1324 | if (inode) { |
1325 | BUG_ON(inode->i_state == I_CLEAR); | 1325 | BUG_ON(inode->i_state & I_CLEAR); |
1326 | 1326 | ||
1327 | if (atomic_dec_and_lock(&inode->i_count, &inode_lock)) | 1327 | if (atomic_dec_and_lock(&inode->i_count, &inode_lock)) |
1328 | iput_final(inode); | 1328 | iput_final(inode); |
diff --git a/fs/nilfs2/gcdat.c b/fs/nilfs2/gcdat.c index dd5f7e0a95f6..84a45d1d5464 100644 --- a/fs/nilfs2/gcdat.c +++ b/fs/nilfs2/gcdat.c | |||
@@ -78,7 +78,7 @@ void nilfs_clear_gcdat_inode(struct the_nilfs *nilfs) | |||
78 | struct inode *gcdat = nilfs->ns_gc_dat; | 78 | struct inode *gcdat = nilfs->ns_gc_dat; |
79 | struct nilfs_inode_info *gii = NILFS_I(gcdat); | 79 | struct nilfs_inode_info *gii = NILFS_I(gcdat); |
80 | 80 | ||
81 | gcdat->i_state = I_CLEAR; | 81 | gcdat->i_state = I_FREEING | I_CLEAR; |
82 | gii->i_flags = 0; | 82 | gii->i_flags = 0; |
83 | 83 | ||
84 | nilfs_palloc_clear_cache(gcdat); | 84 | nilfs_palloc_clear_cache(gcdat); |
diff --git a/fs/notify/inode_mark.c b/fs/notify/inode_mark.c index 0399bcbe09c8..152b83ec005d 100644 --- a/fs/notify/inode_mark.c +++ b/fs/notify/inode_mark.c | |||
@@ -369,11 +369,11 @@ void fsnotify_unmount_inodes(struct list_head *list) | |||
369 | struct inode *need_iput_tmp; | 369 | struct inode *need_iput_tmp; |
370 | 370 | ||
371 | /* | 371 | /* |
372 | * We cannot __iget() an inode in state I_CLEAR, I_FREEING, | 372 | * We cannot __iget() an inode in state I_FREEING, |
373 | * I_WILL_FREE, or I_NEW which is fine because by that point | 373 | * I_WILL_FREE, or I_NEW which is fine because by that point |
374 | * the inode cannot have any associated watches. | 374 | * the inode cannot have any associated watches. |
375 | */ | 375 | */ |
376 | if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) | 376 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) |
377 | continue; | 377 | continue; |
378 | 378 | ||
379 | /* | 379 | /* |
@@ -397,7 +397,7 @@ void fsnotify_unmount_inodes(struct list_head *list) | |||
397 | /* In case the dropping of a reference would nuke next_i. */ | 397 | /* In case the dropping of a reference would nuke next_i. */ |
398 | if ((&next_i->i_sb_list != list) && | 398 | if ((&next_i->i_sb_list != list) && |
399 | atomic_read(&next_i->i_count) && | 399 | atomic_read(&next_i->i_count) && |
400 | !(next_i->i_state & (I_CLEAR | I_FREEING | I_WILL_FREE))) { | 400 | !(next_i->i_state & (I_FREEING | I_WILL_FREE))) { |
401 | __iget(next_i); | 401 | __iget(next_i); |
402 | need_iput = next_i; | 402 | need_iput = next_i; |
403 | } | 403 | } |
diff --git a/fs/notify/inotify/inotify.c b/fs/notify/inotify/inotify.c index 27b75ebc7460..cf6b0429a257 100644 --- a/fs/notify/inotify/inotify.c +++ b/fs/notify/inotify/inotify.c | |||
@@ -377,11 +377,11 @@ void inotify_unmount_inodes(struct list_head *list) | |||
377 | struct list_head *watches; | 377 | struct list_head *watches; |
378 | 378 | ||
379 | /* | 379 | /* |
380 | * We cannot __iget() an inode in state I_CLEAR, I_FREEING, | 380 | * We cannot __iget() an inode in state I_FREEING, |
381 | * I_WILL_FREE, or I_NEW which is fine because by that point | 381 | * I_WILL_FREE, or I_NEW which is fine because by that point |
382 | * the inode cannot have any associated watches. | 382 | * the inode cannot have any associated watches. |
383 | */ | 383 | */ |
384 | if (inode->i_state & (I_CLEAR|I_FREEING|I_WILL_FREE|I_NEW)) | 384 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) |
385 | continue; | 385 | continue; |
386 | 386 | ||
387 | /* | 387 | /* |
@@ -403,8 +403,7 @@ void inotify_unmount_inodes(struct list_head *list) | |||
403 | /* In case the dropping of a reference would nuke next_i. */ | 403 | /* In case the dropping of a reference would nuke next_i. */ |
404 | if ((&next_i->i_sb_list != list) && | 404 | if ((&next_i->i_sb_list != list) && |
405 | atomic_read(&next_i->i_count) && | 405 | atomic_read(&next_i->i_count) && |
406 | !(next_i->i_state & (I_CLEAR | I_FREEING | | 406 | !(next_i->i_state & (I_FREEING|I_WILL_FREE))) { |
407 | I_WILL_FREE))) { | ||
408 | __iget(next_i); | 407 | __iget(next_i); |
409 | need_iput = next_i; | 408 | need_iput = next_i; |
410 | } | 409 | } |
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 437d2ca2de97..5cec3e2348f1 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
@@ -885,7 +885,7 @@ static void add_dquot_ref(struct super_block *sb, int type) | |||
885 | 885 | ||
886 | spin_lock(&inode_lock); | 886 | spin_lock(&inode_lock); |
887 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { | 887 | list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { |
888 | if (inode->i_state & (I_FREEING|I_CLEAR|I_WILL_FREE|I_NEW)) | 888 | if (inode->i_state & (I_FREEING|I_WILL_FREE|I_NEW)) |
889 | continue; | 889 | continue; |
890 | #ifdef CONFIG_QUOTA_DEBUG | 890 | #ifdef CONFIG_QUOTA_DEBUG |
891 | if (unlikely(inode_get_rsv_space(inode) > 0)) | 891 | if (unlikely(inode_get_rsv_space(inode) > 0)) |
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index 62dd349facee..68be25dcd301 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -80,7 +80,7 @@ xfs_mark_inode_dirty_sync( | |||
80 | { | 80 | { |
81 | struct inode *inode = VFS_I(ip); | 81 | struct inode *inode = VFS_I(ip); |
82 | 82 | ||
83 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING|I_CLEAR))) | 83 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) |
84 | mark_inode_dirty_sync(inode); | 84 | mark_inode_dirty_sync(inode); |
85 | } | 85 | } |
86 | 86 | ||
@@ -90,7 +90,7 @@ xfs_mark_inode_dirty( | |||
90 | { | 90 | { |
91 | struct inode *inode = VFS_I(ip); | 91 | struct inode *inode = VFS_I(ip); |
92 | 92 | ||
93 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING|I_CLEAR))) | 93 | if (!(inode->i_state & (I_WILL_FREE|I_FREEING))) |
94 | mark_inode_dirty(inode); | 94 | mark_inode_dirty(inode); |
95 | } | 95 | } |
96 | 96 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index 5547b1b027db..218693d8d446 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1616,8 +1616,8 @@ struct super_operations { | |||
1616 | * I_FREEING Set when inode is about to be freed but still has dirty | 1616 | * I_FREEING Set when inode is about to be freed but still has dirty |
1617 | * pages or buffers attached or the inode itself is still | 1617 | * pages or buffers attached or the inode itself is still |
1618 | * dirty. | 1618 | * dirty. |
1619 | * I_CLEAR Set by clear_inode(). In this state the inode is clean | 1619 | * I_CLEAR Added by clear_inode(). In this state the inode is clean |
1620 | * and can be destroyed. | 1620 | * and can be destroyed. Inode keeps I_FREEING. |
1621 | * | 1621 | * |
1622 | * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are | 1622 | * Inodes that are I_WILL_FREE, I_FREEING or I_CLEAR are |
1623 | * prohibited for many purposes. iget() must wait for | 1623 | * prohibited for many purposes. iget() must wait for |