diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-09-02 18:52:58 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2014-09-09 16:15:02 -0400 |
commit | 9850cf4a8908886370b1f15aacf83d291f098c72 (patch) | |
tree | 2ee332a189922cefd47e26ce335cab7ad21e96b2 /fs | |
parent | 2ae4c673e3cbd69bc2decf6d7f5961f3c7b9b38b (diff) |
f2fs: need fsck.f2fs when f2fs_bug_on is triggered
If any f2fs_bug_on is triggered, fsck.f2fs is needed.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/f2fs/checkpoint.c | 6 | ||||
-rw-r--r-- | fs/f2fs/data.c | 4 | ||||
-rw-r--r-- | fs/f2fs/dir.c | 4 | ||||
-rw-r--r-- | fs/f2fs/f2fs.h | 26 | ||||
-rw-r--r-- | fs/f2fs/file.c | 2 | ||||
-rw-r--r-- | fs/f2fs/inline.c | 4 | ||||
-rw-r--r-- | fs/f2fs/inode.c | 2 | ||||
-rw-r--r-- | fs/f2fs/node.c | 58 | ||||
-rw-r--r-- | fs/f2fs/recovery.c | 8 | ||||
-rw-r--r-- | fs/f2fs/segment.c | 17 | ||||
-rw-r--r-- | fs/f2fs/xattr.c | 2 |
11 files changed, 70 insertions, 63 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 5af97d99106e..935a56e03bf6 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -374,7 +374,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi) | |||
374 | void release_orphan_inode(struct f2fs_sb_info *sbi) | 374 | void release_orphan_inode(struct f2fs_sb_info *sbi) |
375 | { | 375 | { |
376 | spin_lock(&sbi->ino_lock[ORPHAN_INO]); | 376 | spin_lock(&sbi->ino_lock[ORPHAN_INO]); |
377 | f2fs_bug_on(sbi->n_orphans == 0); | 377 | f2fs_bug_on(sbi, sbi->n_orphans == 0); |
378 | sbi->n_orphans--; | 378 | sbi->n_orphans--; |
379 | spin_unlock(&sbi->ino_lock[ORPHAN_INO]); | 379 | spin_unlock(&sbi->ino_lock[ORPHAN_INO]); |
380 | } | 380 | } |
@@ -394,7 +394,7 @@ void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) | |||
394 | static void recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) | 394 | static void recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) |
395 | { | 395 | { |
396 | struct inode *inode = f2fs_iget(sbi->sb, ino); | 396 | struct inode *inode = f2fs_iget(sbi->sb, ino); |
397 | f2fs_bug_on(IS_ERR(inode)); | 397 | f2fs_bug_on(sbi, IS_ERR(inode)); |
398 | clear_nlink(inode); | 398 | clear_nlink(inode); |
399 | 399 | ||
400 | /* truncate all the data during iput */ | 400 | /* truncate all the data during iput */ |
@@ -455,7 +455,7 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk) | |||
455 | list_for_each_entry(orphan, head, list) { | 455 | list_for_each_entry(orphan, head, list) { |
456 | if (!page) { | 456 | if (!page) { |
457 | page = find_get_page(META_MAPPING(sbi), start_blk++); | 457 | page = find_get_page(META_MAPPING(sbi), start_blk++); |
458 | f2fs_bug_on(!page); | 458 | f2fs_bug_on(sbi, !page); |
459 | orphan_blk = | 459 | orphan_blk = |
460 | (struct f2fs_orphan_block *)page_address(page); | 460 | (struct f2fs_orphan_block *)page_address(page); |
461 | memset(orphan_blk, 0, sizeof(*orphan_blk)); | 461 | memset(orphan_blk, 0, sizeof(*orphan_blk)); |
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8eb6fcaa0a6b..64d855085edf 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
@@ -258,7 +258,7 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index) | |||
258 | int err; | 258 | int err; |
259 | 259 | ||
260 | /* if inode_page exists, index should be zero */ | 260 | /* if inode_page exists, index should be zero */ |
261 | f2fs_bug_on(!need_put && index); | 261 | f2fs_bug_on(F2FS_I_SB(dn->inode), !need_put && index); |
262 | 262 | ||
263 | err = get_dnode_of_data(dn, index, ALLOC_NODE); | 263 | err = get_dnode_of_data(dn, index, ALLOC_NODE); |
264 | if (err) | 264 | if (err) |
@@ -321,7 +321,7 @@ void update_extent_cache(block_t blk_addr, struct dnode_of_data *dn) | |||
321 | block_t start_blkaddr, end_blkaddr; | 321 | block_t start_blkaddr, end_blkaddr; |
322 | int need_update = true; | 322 | int need_update = true; |
323 | 323 | ||
324 | f2fs_bug_on(blk_addr == NEW_ADDR); | 324 | f2fs_bug_on(F2FS_I_SB(dn->inode), blk_addr == NEW_ADDR); |
325 | fofs = start_bidx_of_node(ofs_of_node(dn->node_page), fi) + | 325 | fofs = start_bidx_of_node(ofs_of_node(dn->node_page), fi) + |
326 | dn->ofs_in_node; | 326 | dn->ofs_in_node; |
327 | 327 | ||
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index c242904d9724..f1ceeb2f898e 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
@@ -126,7 +126,7 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, | |||
126 | * For the most part, it should be a bug when name_len is zero. | 126 | * For the most part, it should be a bug when name_len is zero. |
127 | * We stop here for figuring out where the bugs has occurred. | 127 | * We stop here for figuring out where the bugs has occurred. |
128 | */ | 128 | */ |
129 | f2fs_bug_on(!de->name_len); | 129 | f2fs_bug_on(F2FS_P_SB(dentry_page), !de->name_len); |
130 | 130 | ||
131 | bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); | 131 | bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); |
132 | } | 132 | } |
@@ -151,7 +151,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir, | |||
151 | bool room = false; | 151 | bool room = false; |
152 | int max_slots = 0; | 152 | int max_slots = 0; |
153 | 153 | ||
154 | f2fs_bug_on(level > MAX_DIR_HASH_DEPTH); | 154 | f2fs_bug_on(F2FS_I_SB(dir), level > MAX_DIR_HASH_DEPTH); |
155 | 155 | ||
156 | nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level); | 156 | nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level); |
157 | nblock = bucket_blocks(level); | 157 | nblock = bucket_blocks(level); |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 210c62df08c3..b389ced9090b 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
@@ -21,10 +21,16 @@ | |||
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | 22 | ||
23 | #ifdef CONFIG_F2FS_CHECK_FS | 23 | #ifdef CONFIG_F2FS_CHECK_FS |
24 | #define f2fs_bug_on(condition) BUG_ON(condition) | 24 | #define f2fs_bug_on(sbi, condition) BUG_ON(condition) |
25 | #define f2fs_down_write(x, y) down_write_nest_lock(x, y) | 25 | #define f2fs_down_write(x, y) down_write_nest_lock(x, y) |
26 | #else | 26 | #else |
27 | #define f2fs_bug_on(condition) WARN_ON(condition) | 27 | #define f2fs_bug_on(sbi, condition) \ |
28 | do { \ | ||
29 | if (unlikely(condition)) { \ | ||
30 | WARN_ON(1); \ | ||
31 | sbi->need_fsck = true; \ | ||
32 | } \ | ||
33 | } while (0) | ||
28 | #define f2fs_down_write(x, y) down_write(x) | 34 | #define f2fs_down_write(x, y) down_write(x) |
29 | #endif | 35 | #endif |
30 | 36 | ||
@@ -719,8 +725,8 @@ static inline void dec_valid_block_count(struct f2fs_sb_info *sbi, | |||
719 | blkcnt_t count) | 725 | blkcnt_t count) |
720 | { | 726 | { |
721 | spin_lock(&sbi->stat_lock); | 727 | spin_lock(&sbi->stat_lock); |
722 | f2fs_bug_on(sbi->total_valid_block_count < (block_t) count); | 728 | f2fs_bug_on(sbi, sbi->total_valid_block_count < (block_t) count); |
723 | f2fs_bug_on(inode->i_blocks < count); | 729 | f2fs_bug_on(sbi, inode->i_blocks < count); |
724 | inode->i_blocks -= count; | 730 | inode->i_blocks -= count; |
725 | sbi->total_valid_block_count -= (block_t)count; | 731 | sbi->total_valid_block_count -= (block_t)count; |
726 | spin_unlock(&sbi->stat_lock); | 732 | spin_unlock(&sbi->stat_lock); |
@@ -864,9 +870,9 @@ static inline void dec_valid_node_count(struct f2fs_sb_info *sbi, | |||
864 | { | 870 | { |
865 | spin_lock(&sbi->stat_lock); | 871 | spin_lock(&sbi->stat_lock); |
866 | 872 | ||
867 | f2fs_bug_on(!sbi->total_valid_block_count); | 873 | f2fs_bug_on(sbi, !sbi->total_valid_block_count); |
868 | f2fs_bug_on(!sbi->total_valid_node_count); | 874 | f2fs_bug_on(sbi, !sbi->total_valid_node_count); |
869 | f2fs_bug_on(!inode->i_blocks); | 875 | f2fs_bug_on(sbi, !inode->i_blocks); |
870 | 876 | ||
871 | inode->i_blocks--; | 877 | inode->i_blocks--; |
872 | sbi->total_valid_node_count--; | 878 | sbi->total_valid_node_count--; |
@@ -883,7 +889,7 @@ static inline unsigned int valid_node_count(struct f2fs_sb_info *sbi) | |||
883 | static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) | 889 | static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) |
884 | { | 890 | { |
885 | spin_lock(&sbi->stat_lock); | 891 | spin_lock(&sbi->stat_lock); |
886 | f2fs_bug_on(sbi->total_valid_inode_count == sbi->total_node_count); | 892 | f2fs_bug_on(sbi, sbi->total_valid_inode_count == sbi->total_node_count); |
887 | sbi->total_valid_inode_count++; | 893 | sbi->total_valid_inode_count++; |
888 | spin_unlock(&sbi->stat_lock); | 894 | spin_unlock(&sbi->stat_lock); |
889 | } | 895 | } |
@@ -891,7 +897,7 @@ static inline void inc_valid_inode_count(struct f2fs_sb_info *sbi) | |||
891 | static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi) | 897 | static inline void dec_valid_inode_count(struct f2fs_sb_info *sbi) |
892 | { | 898 | { |
893 | spin_lock(&sbi->stat_lock); | 899 | spin_lock(&sbi->stat_lock); |
894 | f2fs_bug_on(!sbi->total_valid_inode_count); | 900 | f2fs_bug_on(sbi, !sbi->total_valid_inode_count); |
895 | sbi->total_valid_inode_count--; | 901 | sbi->total_valid_inode_count--; |
896 | spin_unlock(&sbi->stat_lock); | 902 | spin_unlock(&sbi->stat_lock); |
897 | } | 903 | } |
@@ -907,7 +913,7 @@ static inline void f2fs_put_page(struct page *page, int unlock) | |||
907 | return; | 913 | return; |
908 | 914 | ||
909 | if (unlock) { | 915 | if (unlock) { |
910 | f2fs_bug_on(!PageLocked(page)); | 916 | f2fs_bug_on(F2FS_P_SB(page), !PageLocked(page)); |
911 | unlock_page(page); | 917 | unlock_page(page); |
912 | } | 918 | } |
913 | page_cache_release(page); | 919 | page_cache_release(page); |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 411f053720c2..9f0ea3d3251b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -463,7 +463,7 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock) | |||
463 | count = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode)); | 463 | count = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode)); |
464 | 464 | ||
465 | count -= dn.ofs_in_node; | 465 | count -= dn.ofs_in_node; |
466 | f2fs_bug_on(count < 0); | 466 | f2fs_bug_on(sbi, count < 0); |
467 | 467 | ||
468 | if (dn.ofs_in_node || IS_INODE(dn.node_page)) { | 468 | if (dn.ofs_in_node || IS_INODE(dn.node_page)) { |
469 | truncate_data_blocks_range(&dn, count); | 469 | truncate_data_blocks_range(&dn, count); |
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 289f99e9a339..6aef11d69e33 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c | |||
@@ -226,7 +226,7 @@ bool recover_inline_data(struct inode *inode, struct page *npage) | |||
226 | ri && (ri->i_inline & F2FS_INLINE_DATA)) { | 226 | ri && (ri->i_inline & F2FS_INLINE_DATA)) { |
227 | process_inline: | 227 | process_inline: |
228 | ipage = get_node_page(sbi, inode->i_ino); | 228 | ipage = get_node_page(sbi, inode->i_ino); |
229 | f2fs_bug_on(IS_ERR(ipage)); | 229 | f2fs_bug_on(sbi, IS_ERR(ipage)); |
230 | 230 | ||
231 | f2fs_wait_on_page_writeback(ipage, NODE); | 231 | f2fs_wait_on_page_writeback(ipage, NODE); |
232 | 232 | ||
@@ -240,7 +240,7 @@ process_inline: | |||
240 | 240 | ||
241 | if (f2fs_has_inline_data(inode)) { | 241 | if (f2fs_has_inline_data(inode)) { |
242 | ipage = get_node_page(sbi, inode->i_ino); | 242 | ipage = get_node_page(sbi, inode->i_ino); |
243 | f2fs_bug_on(IS_ERR(ipage)); | 243 | f2fs_bug_on(sbi, IS_ERR(ipage)); |
244 | f2fs_wait_on_page_writeback(ipage, NODE); | 244 | f2fs_wait_on_page_writeback(ipage, NODE); |
245 | zero_user_segment(ipage, INLINE_DATA_OFFSET, | 245 | zero_user_segment(ipage, INLINE_DATA_OFFSET, |
246 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); | 246 | INLINE_DATA_OFFSET + MAX_INLINE_DATA); |
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index bf99e1fe82a0..95c0bc2a666c 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c | |||
@@ -276,7 +276,7 @@ void f2fs_evict_inode(struct inode *inode) | |||
276 | inode->i_ino == F2FS_META_INO(sbi)) | 276 | inode->i_ino == F2FS_META_INO(sbi)) |
277 | goto out_clear; | 277 | goto out_clear; |
278 | 278 | ||
279 | f2fs_bug_on(get_dirty_dents(inode)); | 279 | f2fs_bug_on(sbi, get_dirty_dents(inode)); |
280 | remove_dirty_dir_inode(inode); | 280 | remove_dirty_dir_inode(inode); |
281 | 281 | ||
282 | if (inode->i_nlink || is_bad_inode(inode)) | 282 | if (inode->i_nlink || is_bad_inode(inode)) |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 725a47130b82..1af7879bfb75 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -91,7 +91,7 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid) | |||
91 | /* get current nat block page with lock */ | 91 | /* get current nat block page with lock */ |
92 | src_page = get_meta_page(sbi, src_off); | 92 | src_page = get_meta_page(sbi, src_off); |
93 | dst_page = grab_meta_page(sbi, dst_off); | 93 | dst_page = grab_meta_page(sbi, dst_off); |
94 | f2fs_bug_on(PageDirty(src_page)); | 94 | f2fs_bug_on(sbi, PageDirty(src_page)); |
95 | 95 | ||
96 | src_addr = page_address(src_page); | 96 | src_addr = page_address(src_page); |
97 | dst_addr = page_address(dst_page); | 97 | dst_addr = page_address(dst_page); |
@@ -215,7 +215,7 @@ retry: | |||
215 | goto retry; | 215 | goto retry; |
216 | } | 216 | } |
217 | e->ni = *ni; | 217 | e->ni = *ni; |
218 | f2fs_bug_on(ni->blk_addr == NEW_ADDR); | 218 | f2fs_bug_on(sbi, ni->blk_addr == NEW_ADDR); |
219 | } else if (new_blkaddr == NEW_ADDR) { | 219 | } else if (new_blkaddr == NEW_ADDR) { |
220 | /* | 220 | /* |
221 | * when nid is reallocated, | 221 | * when nid is reallocated, |
@@ -223,16 +223,16 @@ retry: | |||
223 | * So, reinitialize it with new information. | 223 | * So, reinitialize it with new information. |
224 | */ | 224 | */ |
225 | e->ni = *ni; | 225 | e->ni = *ni; |
226 | f2fs_bug_on(ni->blk_addr != NULL_ADDR); | 226 | f2fs_bug_on(sbi, ni->blk_addr != NULL_ADDR); |
227 | } | 227 | } |
228 | 228 | ||
229 | /* sanity check */ | 229 | /* sanity check */ |
230 | f2fs_bug_on(nat_get_blkaddr(e) != ni->blk_addr); | 230 | f2fs_bug_on(sbi, nat_get_blkaddr(e) != ni->blk_addr); |
231 | f2fs_bug_on(nat_get_blkaddr(e) == NULL_ADDR && | 231 | f2fs_bug_on(sbi, nat_get_blkaddr(e) == NULL_ADDR && |
232 | new_blkaddr == NULL_ADDR); | 232 | new_blkaddr == NULL_ADDR); |
233 | f2fs_bug_on(nat_get_blkaddr(e) == NEW_ADDR && | 233 | f2fs_bug_on(sbi, nat_get_blkaddr(e) == NEW_ADDR && |
234 | new_blkaddr == NEW_ADDR); | 234 | new_blkaddr == NEW_ADDR); |
235 | f2fs_bug_on(nat_get_blkaddr(e) != NEW_ADDR && | 235 | f2fs_bug_on(sbi, nat_get_blkaddr(e) != NEW_ADDR && |
236 | nat_get_blkaddr(e) != NULL_ADDR && | 236 | nat_get_blkaddr(e) != NULL_ADDR && |
237 | new_blkaddr == NEW_ADDR); | 237 | new_blkaddr == NEW_ADDR); |
238 | 238 | ||
@@ -508,10 +508,10 @@ static void truncate_node(struct dnode_of_data *dn) | |||
508 | 508 | ||
509 | get_node_info(sbi, dn->nid, &ni); | 509 | get_node_info(sbi, dn->nid, &ni); |
510 | if (dn->inode->i_blocks == 0) { | 510 | if (dn->inode->i_blocks == 0) { |
511 | f2fs_bug_on(ni.blk_addr != NULL_ADDR); | 511 | f2fs_bug_on(sbi, ni.blk_addr != NULL_ADDR); |
512 | goto invalidate; | 512 | goto invalidate; |
513 | } | 513 | } |
514 | f2fs_bug_on(ni.blk_addr == NULL_ADDR); | 514 | f2fs_bug_on(sbi, ni.blk_addr == NULL_ADDR); |
515 | 515 | ||
516 | /* Deallocate node address */ | 516 | /* Deallocate node address */ |
517 | invalidate_blocks(sbi, ni.blk_addr); | 517 | invalidate_blocks(sbi, ni.blk_addr); |
@@ -836,7 +836,8 @@ void remove_inode_page(struct inode *inode) | |||
836 | truncate_data_blocks_range(&dn, 1); | 836 | truncate_data_blocks_range(&dn, 1); |
837 | 837 | ||
838 | /* 0 is possible, after f2fs_new_inode() has failed */ | 838 | /* 0 is possible, after f2fs_new_inode() has failed */ |
839 | f2fs_bug_on(inode->i_blocks != 0 && inode->i_blocks != 1); | 839 | f2fs_bug_on(F2FS_I_SB(inode), |
840 | inode->i_blocks != 0 && inode->i_blocks != 1); | ||
840 | 841 | ||
841 | /* will put inode & node pages */ | 842 | /* will put inode & node pages */ |
842 | truncate_node(&dn); | 843 | truncate_node(&dn); |
@@ -876,7 +877,7 @@ struct page *new_node_page(struct dnode_of_data *dn, | |||
876 | get_node_info(sbi, dn->nid, &old_ni); | 877 | get_node_info(sbi, dn->nid, &old_ni); |
877 | 878 | ||
878 | /* Reinitialize old_ni with new node page */ | 879 | /* Reinitialize old_ni with new node page */ |
879 | f2fs_bug_on(old_ni.blk_addr != NULL_ADDR); | 880 | f2fs_bug_on(sbi, old_ni.blk_addr != NULL_ADDR); |
880 | new_ni = old_ni; | 881 | new_ni = old_ni; |
881 | new_ni.ino = dn->inode->i_ino; | 882 | new_ni.ino = dn->inode->i_ino; |
882 | set_node_addr(sbi, &new_ni, NEW_ADDR, false); | 883 | set_node_addr(sbi, &new_ni, NEW_ADDR, false); |
@@ -1222,7 +1223,7 @@ static int f2fs_write_node_page(struct page *page, | |||
1222 | 1223 | ||
1223 | /* get old block addr of this node page */ | 1224 | /* get old block addr of this node page */ |
1224 | nid = nid_of_node(page); | 1225 | nid = nid_of_node(page); |
1225 | f2fs_bug_on(page->index != nid); | 1226 | f2fs_bug_on(sbi, page->index != nid); |
1226 | 1227 | ||
1227 | get_node_info(sbi, nid, &ni); | 1228 | get_node_info(sbi, nid, &ni); |
1228 | 1229 | ||
@@ -1405,7 +1406,7 @@ static void scan_nat_page(struct f2fs_sb_info *sbi, | |||
1405 | break; | 1406 | break; |
1406 | 1407 | ||
1407 | blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr); | 1408 | blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr); |
1408 | f2fs_bug_on(blk_addr == NEW_ADDR); | 1409 | f2fs_bug_on(sbi, blk_addr == NEW_ADDR); |
1409 | if (blk_addr == NULL_ADDR) { | 1410 | if (blk_addr == NULL_ADDR) { |
1410 | if (add_free_nid(sbi, start_nid, true) < 0) | 1411 | if (add_free_nid(sbi, start_nid, true) < 0) |
1411 | break; | 1412 | break; |
@@ -1475,12 +1476,12 @@ retry: | |||
1475 | 1476 | ||
1476 | /* We should not use stale free nids created by build_free_nids */ | 1477 | /* We should not use stale free nids created by build_free_nids */ |
1477 | if (nm_i->fcnt && !on_build_free_nids(nm_i)) { | 1478 | if (nm_i->fcnt && !on_build_free_nids(nm_i)) { |
1478 | f2fs_bug_on(list_empty(&nm_i->free_nid_list)); | 1479 | f2fs_bug_on(sbi, list_empty(&nm_i->free_nid_list)); |
1479 | list_for_each_entry(i, &nm_i->free_nid_list, list) | 1480 | list_for_each_entry(i, &nm_i->free_nid_list, list) |
1480 | if (i->state == NID_NEW) | 1481 | if (i->state == NID_NEW) |
1481 | break; | 1482 | break; |
1482 | 1483 | ||
1483 | f2fs_bug_on(i->state != NID_NEW); | 1484 | f2fs_bug_on(sbi, i->state != NID_NEW); |
1484 | *nid = i->nid; | 1485 | *nid = i->nid; |
1485 | i->state = NID_ALLOC; | 1486 | i->state = NID_ALLOC; |
1486 | nm_i->fcnt--; | 1487 | nm_i->fcnt--; |
@@ -1506,7 +1507,7 @@ void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid) | |||
1506 | 1507 | ||
1507 | spin_lock(&nm_i->free_nid_list_lock); | 1508 | spin_lock(&nm_i->free_nid_list_lock); |
1508 | i = __lookup_free_nid_list(nm_i, nid); | 1509 | i = __lookup_free_nid_list(nm_i, nid); |
1509 | f2fs_bug_on(!i || i->state != NID_ALLOC); | 1510 | f2fs_bug_on(sbi, !i || i->state != NID_ALLOC); |
1510 | __del_from_free_nid_list(nm_i, i); | 1511 | __del_from_free_nid_list(nm_i, i); |
1511 | spin_unlock(&nm_i->free_nid_list_lock); | 1512 | spin_unlock(&nm_i->free_nid_list_lock); |
1512 | 1513 | ||
@@ -1527,7 +1528,7 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid) | |||
1527 | 1528 | ||
1528 | spin_lock(&nm_i->free_nid_list_lock); | 1529 | spin_lock(&nm_i->free_nid_list_lock); |
1529 | i = __lookup_free_nid_list(nm_i, nid); | 1530 | i = __lookup_free_nid_list(nm_i, nid); |
1530 | f2fs_bug_on(!i || i->state != NID_ALLOC); | 1531 | f2fs_bug_on(sbi, !i || i->state != NID_ALLOC); |
1531 | if (!available_free_memory(sbi, FREE_NIDS)) { | 1532 | if (!available_free_memory(sbi, FREE_NIDS)) { |
1532 | __del_from_free_nid_list(nm_i, i); | 1533 | __del_from_free_nid_list(nm_i, i); |
1533 | need_free = true; | 1534 | need_free = true; |
@@ -1549,7 +1550,7 @@ void recover_inline_xattr(struct inode *inode, struct page *page) | |||
1549 | struct f2fs_inode *ri; | 1550 | struct f2fs_inode *ri; |
1550 | 1551 | ||
1551 | ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino); | 1552 | ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino); |
1552 | f2fs_bug_on(IS_ERR(ipage)); | 1553 | f2fs_bug_on(F2FS_I_SB(inode), IS_ERR(ipage)); |
1553 | 1554 | ||
1554 | ri = F2FS_INODE(page); | 1555 | ri = F2FS_INODE(page); |
1555 | if (!(ri->i_inline & F2FS_INLINE_XATTR)) { | 1556 | if (!(ri->i_inline & F2FS_INLINE_XATTR)) { |
@@ -1581,7 +1582,7 @@ void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) | |||
1581 | 1582 | ||
1582 | /* Deallocate node address */ | 1583 | /* Deallocate node address */ |
1583 | get_node_info(sbi, prev_xnid, &ni); | 1584 | get_node_info(sbi, prev_xnid, &ni); |
1584 | f2fs_bug_on(ni.blk_addr == NULL_ADDR); | 1585 | f2fs_bug_on(sbi, ni.blk_addr == NULL_ADDR); |
1585 | invalidate_blocks(sbi, ni.blk_addr); | 1586 | invalidate_blocks(sbi, ni.blk_addr); |
1586 | dec_valid_node_count(sbi, inode); | 1587 | dec_valid_node_count(sbi, inode); |
1587 | set_node_addr(sbi, &ni, NULL_ADDR, false); | 1588 | set_node_addr(sbi, &ni, NULL_ADDR, false); |
@@ -1589,7 +1590,7 @@ void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) | |||
1589 | recover_xnid: | 1590 | recover_xnid: |
1590 | /* 2: allocate new xattr nid */ | 1591 | /* 2: allocate new xattr nid */ |
1591 | if (unlikely(!inc_valid_node_count(sbi, inode))) | 1592 | if (unlikely(!inc_valid_node_count(sbi, inode))) |
1592 | f2fs_bug_on(1); | 1593 | f2fs_bug_on(sbi, 1); |
1593 | 1594 | ||
1594 | remove_free_nid(NM_I(sbi), new_xnid); | 1595 | remove_free_nid(NM_I(sbi), new_xnid); |
1595 | get_node_info(sbi, new_xnid, &ni); | 1596 | get_node_info(sbi, new_xnid, &ni); |
@@ -1738,8 +1739,6 @@ static struct nat_entry_set *grab_nat_entry_set(void) | |||
1738 | static void release_nat_entry_set(struct nat_entry_set *nes, | 1739 | static void release_nat_entry_set(struct nat_entry_set *nes, |
1739 | struct f2fs_nm_info *nm_i) | 1740 | struct f2fs_nm_info *nm_i) |
1740 | { | 1741 | { |
1741 | f2fs_bug_on(!list_empty(&nes->entry_list)); | ||
1742 | |||
1743 | nm_i->dirty_nat_cnt -= nes->entry_cnt; | 1742 | nm_i->dirty_nat_cnt -= nes->entry_cnt; |
1744 | list_del(&nes->set_list); | 1743 | list_del(&nes->set_list); |
1745 | kmem_cache_free(nat_entry_set_slab, nes); | 1744 | kmem_cache_free(nat_entry_set_slab, nes); |
@@ -1892,7 +1891,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) | |||
1892 | } else { | 1891 | } else { |
1893 | page = get_next_nat_page(sbi, start_nid); | 1892 | page = get_next_nat_page(sbi, start_nid); |
1894 | nat_blk = page_address(page); | 1893 | nat_blk = page_address(page); |
1895 | f2fs_bug_on(!nat_blk); | 1894 | f2fs_bug_on(sbi, !nat_blk); |
1896 | } | 1895 | } |
1897 | 1896 | ||
1898 | /* flush dirty nats in nat entry set */ | 1897 | /* flush dirty nats in nat entry set */ |
@@ -1904,7 +1903,7 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) | |||
1904 | if (to_journal) { | 1903 | if (to_journal) { |
1905 | offset = lookup_journal_in_cursum(sum, | 1904 | offset = lookup_journal_in_cursum(sum, |
1906 | NAT_JOURNAL, nid, 1); | 1905 | NAT_JOURNAL, nid, 1); |
1907 | f2fs_bug_on(offset < 0); | 1906 | f2fs_bug_on(sbi, offset < 0); |
1908 | raw_ne = &nat_in_journal(sum, offset); | 1907 | raw_ne = &nat_in_journal(sum, offset); |
1909 | nid_in_journal(sum, offset) = cpu_to_le32(nid); | 1908 | nid_in_journal(sum, offset) = cpu_to_le32(nid); |
1910 | } else { | 1909 | } else { |
@@ -1929,11 +1928,12 @@ void flush_nat_entries(struct f2fs_sb_info *sbi) | |||
1929 | else | 1928 | else |
1930 | f2fs_put_page(page, 1); | 1929 | f2fs_put_page(page, 1); |
1931 | 1930 | ||
1931 | f2fs_bug_on(sbi, !list_empty(&nes->entry_list)); | ||
1932 | release_nat_entry_set(nes, nm_i); | 1932 | release_nat_entry_set(nes, nm_i); |
1933 | } | 1933 | } |
1934 | 1934 | ||
1935 | f2fs_bug_on(!list_empty(head)); | 1935 | f2fs_bug_on(sbi, !list_empty(head)); |
1936 | f2fs_bug_on(nm_i->dirty_nat_cnt); | 1936 | f2fs_bug_on(sbi, nm_i->dirty_nat_cnt); |
1937 | } | 1937 | } |
1938 | 1938 | ||
1939 | static int init_node_manager(struct f2fs_sb_info *sbi) | 1939 | static int init_node_manager(struct f2fs_sb_info *sbi) |
@@ -2011,14 +2011,14 @@ void destroy_node_manager(struct f2fs_sb_info *sbi) | |||
2011 | /* destroy free nid list */ | 2011 | /* destroy free nid list */ |
2012 | spin_lock(&nm_i->free_nid_list_lock); | 2012 | spin_lock(&nm_i->free_nid_list_lock); |
2013 | list_for_each_entry_safe(i, next_i, &nm_i->free_nid_list, list) { | 2013 | list_for_each_entry_safe(i, next_i, &nm_i->free_nid_list, list) { |
2014 | f2fs_bug_on(i->state == NID_ALLOC); | 2014 | f2fs_bug_on(sbi, i->state == NID_ALLOC); |
2015 | __del_from_free_nid_list(nm_i, i); | 2015 | __del_from_free_nid_list(nm_i, i); |
2016 | nm_i->fcnt--; | 2016 | nm_i->fcnt--; |
2017 | spin_unlock(&nm_i->free_nid_list_lock); | 2017 | spin_unlock(&nm_i->free_nid_list_lock); |
2018 | kmem_cache_free(free_nid_slab, i); | 2018 | kmem_cache_free(free_nid_slab, i); |
2019 | spin_lock(&nm_i->free_nid_list_lock); | 2019 | spin_lock(&nm_i->free_nid_list_lock); |
2020 | } | 2020 | } |
2021 | f2fs_bug_on(nm_i->fcnt); | 2021 | f2fs_bug_on(sbi, nm_i->fcnt); |
2022 | spin_unlock(&nm_i->free_nid_list_lock); | 2022 | spin_unlock(&nm_i->free_nid_list_lock); |
2023 | 2023 | ||
2024 | /* destroy nat cache */ | 2024 | /* destroy nat cache */ |
@@ -2030,7 +2030,7 @@ void destroy_node_manager(struct f2fs_sb_info *sbi) | |||
2030 | for (idx = 0; idx < found; idx++) | 2030 | for (idx = 0; idx < found; idx++) |
2031 | __del_from_nat_cache(nm_i, natvec[idx]); | 2031 | __del_from_nat_cache(nm_i, natvec[idx]); |
2032 | } | 2032 | } |
2033 | f2fs_bug_on(nm_i->nat_cnt); | 2033 | f2fs_bug_on(sbi, nm_i->nat_cnt); |
2034 | write_unlock(&nm_i->nat_tree_lock); | 2034 | write_unlock(&nm_i->nat_tree_lock); |
2035 | 2035 | ||
2036 | kfree(nm_i->nat_bitmap); | 2036 | kfree(nm_i->nat_bitmap); |
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index 5c095f7ac21c..6c5a74a45f33 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c | |||
@@ -331,8 +331,8 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, | |||
331 | f2fs_wait_on_page_writeback(dn.node_page, NODE); | 331 | f2fs_wait_on_page_writeback(dn.node_page, NODE); |
332 | 332 | ||
333 | get_node_info(sbi, dn.nid, &ni); | 333 | get_node_info(sbi, dn.nid, &ni); |
334 | f2fs_bug_on(ni.ino != ino_of_node(page)); | 334 | f2fs_bug_on(sbi, ni.ino != ino_of_node(page)); |
335 | f2fs_bug_on(ofs_of_node(dn.node_page) != ofs_of_node(page)); | 335 | f2fs_bug_on(sbi, ofs_of_node(dn.node_page) != ofs_of_node(page)); |
336 | 336 | ||
337 | for (; start < end; start++) { | 337 | for (; start < end; start++) { |
338 | block_t src, dest; | 338 | block_t src, dest; |
@@ -344,7 +344,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, | |||
344 | if (src == NULL_ADDR) { | 344 | if (src == NULL_ADDR) { |
345 | err = reserve_new_block(&dn); | 345 | err = reserve_new_block(&dn); |
346 | /* We should not get -ENOSPC */ | 346 | /* We should not get -ENOSPC */ |
347 | f2fs_bug_on(err); | 347 | f2fs_bug_on(sbi, err); |
348 | } | 348 | } |
349 | 349 | ||
350 | /* Check the previous node page having this index */ | 350 | /* Check the previous node page having this index */ |
@@ -474,7 +474,7 @@ int recover_fsync_data(struct f2fs_sb_info *sbi) | |||
474 | /* step #2: recover data */ | 474 | /* step #2: recover data */ |
475 | err = recover_data(sbi, &inode_list, CURSEG_WARM_NODE); | 475 | err = recover_data(sbi, &inode_list, CURSEG_WARM_NODE); |
476 | if (!err) | 476 | if (!err) |
477 | f2fs_bug_on(!list_empty(&inode_list)); | 477 | f2fs_bug_on(sbi, !list_empty(&inode_list)); |
478 | out: | 478 | out: |
479 | destroy_fsync_dnodes(&inode_list); | 479 | destroy_fsync_dnodes(&inode_list); |
480 | kmem_cache_destroy(fsync_entry_slab); | 480 | kmem_cache_destroy(fsync_entry_slab); |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a270726e3367..abfbbca63271 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -516,7 +516,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del) | |||
516 | new_vblocks = se->valid_blocks + del; | 516 | new_vblocks = se->valid_blocks + del; |
517 | offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr); | 517 | offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr); |
518 | 518 | ||
519 | f2fs_bug_on((new_vblocks >> (sizeof(unsigned short) << 3) || | 519 | f2fs_bug_on(sbi, (new_vblocks >> (sizeof(unsigned short) << 3) || |
520 | (new_vblocks > sbi->blocks_per_seg))); | 520 | (new_vblocks > sbi->blocks_per_seg))); |
521 | 521 | ||
522 | se->valid_blocks = new_vblocks; | 522 | se->valid_blocks = new_vblocks; |
@@ -558,7 +558,7 @@ void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr) | |||
558 | unsigned int segno = GET_SEGNO(sbi, addr); | 558 | unsigned int segno = GET_SEGNO(sbi, addr); |
559 | struct sit_info *sit_i = SIT_I(sbi); | 559 | struct sit_info *sit_i = SIT_I(sbi); |
560 | 560 | ||
561 | f2fs_bug_on(addr == NULL_ADDR); | 561 | f2fs_bug_on(sbi, addr == NULL_ADDR); |
562 | if (addr == NEW_ADDR) | 562 | if (addr == NEW_ADDR) |
563 | return; | 563 | return; |
564 | 564 | ||
@@ -671,7 +671,7 @@ find_other_zone: | |||
671 | if (dir == ALLOC_RIGHT) { | 671 | if (dir == ALLOC_RIGHT) { |
672 | secno = find_next_zero_bit(free_i->free_secmap, | 672 | secno = find_next_zero_bit(free_i->free_secmap, |
673 | TOTAL_SECS(sbi), 0); | 673 | TOTAL_SECS(sbi), 0); |
674 | f2fs_bug_on(secno >= TOTAL_SECS(sbi)); | 674 | f2fs_bug_on(sbi, secno >= TOTAL_SECS(sbi)); |
675 | } else { | 675 | } else { |
676 | go_left = 1; | 676 | go_left = 1; |
677 | left_start = hint - 1; | 677 | left_start = hint - 1; |
@@ -687,7 +687,7 @@ find_other_zone: | |||
687 | } | 687 | } |
688 | left_start = find_next_zero_bit(free_i->free_secmap, | 688 | left_start = find_next_zero_bit(free_i->free_secmap, |
689 | TOTAL_SECS(sbi), 0); | 689 | TOTAL_SECS(sbi), 0); |
690 | f2fs_bug_on(left_start >= TOTAL_SECS(sbi)); | 690 | f2fs_bug_on(sbi, left_start >= TOTAL_SECS(sbi)); |
691 | break; | 691 | break; |
692 | } | 692 | } |
693 | secno = left_start; | 693 | secno = left_start; |
@@ -726,7 +726,7 @@ skip_left: | |||
726 | } | 726 | } |
727 | got_it: | 727 | got_it: |
728 | /* set it as dirty segment in free segmap */ | 728 | /* set it as dirty segment in free segmap */ |
729 | f2fs_bug_on(test_bit(segno, free_i->free_segmap)); | 729 | f2fs_bug_on(sbi, test_bit(segno, free_i->free_segmap)); |
730 | __set_inuse(sbi, segno); | 730 | __set_inuse(sbi, segno); |
731 | *newseg = segno; | 731 | *newseg = segno; |
732 | write_unlock(&free_i->segmap_lock); | 732 | write_unlock(&free_i->segmap_lock); |
@@ -960,7 +960,8 @@ static int __get_segment_type(struct page *page, enum page_type p_type) | |||
960 | return __get_segment_type_4(page, p_type); | 960 | return __get_segment_type_4(page, p_type); |
961 | } | 961 | } |
962 | /* NR_CURSEG_TYPE(6) logs by default */ | 962 | /* NR_CURSEG_TYPE(6) logs by default */ |
963 | f2fs_bug_on(F2FS_P_SB(page)->active_logs != NR_CURSEG_TYPE); | 963 | f2fs_bug_on(F2FS_P_SB(page), |
964 | F2FS_P_SB(page)->active_logs != NR_CURSEG_TYPE); | ||
964 | return __get_segment_type_6(page, p_type); | 965 | return __get_segment_type_6(page, p_type); |
965 | } | 966 | } |
966 | 967 | ||
@@ -1044,7 +1045,7 @@ void write_data_page(struct page *page, struct dnode_of_data *dn, | |||
1044 | struct f2fs_summary sum; | 1045 | struct f2fs_summary sum; |
1045 | struct node_info ni; | 1046 | struct node_info ni; |
1046 | 1047 | ||
1047 | f2fs_bug_on(dn->data_blkaddr == NULL_ADDR); | 1048 | f2fs_bug_on(sbi, dn->data_blkaddr == NULL_ADDR); |
1048 | get_node_info(sbi, dn->nid, &ni); | 1049 | get_node_info(sbi, dn->nid, &ni); |
1049 | set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version); | 1050 | set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version); |
1050 | 1051 | ||
@@ -1424,7 +1425,7 @@ static struct page *get_next_sit_page(struct f2fs_sb_info *sbi, | |||
1424 | /* get current sit block page without lock */ | 1425 | /* get current sit block page without lock */ |
1425 | src_page = get_meta_page(sbi, src_off); | 1426 | src_page = get_meta_page(sbi, src_off); |
1426 | dst_page = grab_meta_page(sbi, dst_off); | 1427 | dst_page = grab_meta_page(sbi, dst_off); |
1427 | f2fs_bug_on(PageDirty(src_page)); | 1428 | f2fs_bug_on(sbi, PageDirty(src_page)); |
1428 | 1429 | ||
1429 | src_addr = page_address(src_page); | 1430 | src_addr = page_address(src_page); |
1430 | dst_addr = page_address(dst_page); | 1431 | dst_addr = page_address(dst_page); |
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index d92a47da62b8..deca8728117b 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -373,7 +373,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, | |||
373 | alloc_nid_failed(sbi, new_nid); | 373 | alloc_nid_failed(sbi, new_nid); |
374 | return PTR_ERR(xpage); | 374 | return PTR_ERR(xpage); |
375 | } | 375 | } |
376 | f2fs_bug_on(new_nid); | 376 | f2fs_bug_on(sbi, new_nid); |
377 | f2fs_wait_on_page_writeback(xpage, NODE); | 377 | f2fs_wait_on_page_writeback(xpage, NODE); |
378 | } else { | 378 | } else { |
379 | struct dnode_of_data dn; | 379 | struct dnode_of_data dn; |