diff options
author | Russ W. Knize <russ@knizefamily.net> | 2013-09-24 10:35:40 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-09-25 04:49:12 -0400 |
commit | 885166c03c1d0ea6d79d707229340e3161ed1316 (patch) | |
tree | cd7619af62a9b5420e84fbfe4077a6b1395dfbaf | |
parent | 691c6fd2a2d6b6db08b17beec5e42ab0687058c7 (diff) |
f2fs: don't let the orphan inode counter underflow
Accounting errors from buggy code calling the acquire/release/remove
orphan inode interfaces can cause n_orphans to underflow, which will
then cause acquire_orphan_inode() to return -ENOSPC on the next
operation. This commit guards against that condition.
Signed-off-by: Russ Knize <rknize@motorola.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/checkpoint.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index bb312201ca95..ca3944240db5 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -206,6 +206,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi) | |||
206 | void release_orphan_inode(struct f2fs_sb_info *sbi) | 206 | void release_orphan_inode(struct f2fs_sb_info *sbi) |
207 | { | 207 | { |
208 | mutex_lock(&sbi->orphan_inode_mutex); | 208 | mutex_lock(&sbi->orphan_inode_mutex); |
209 | BUG_ON(sbi->n_orphans == 0); | ||
209 | sbi->n_orphans--; | 210 | sbi->n_orphans--; |
210 | mutex_unlock(&sbi->orphan_inode_mutex); | 211 | mutex_unlock(&sbi->orphan_inode_mutex); |
211 | } | 212 | } |
@@ -253,6 +254,7 @@ void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino) | |||
253 | if (orphan->ino == ino) { | 254 | if (orphan->ino == ino) { |
254 | list_del(&orphan->list); | 255 | list_del(&orphan->list); |
255 | kmem_cache_free(orphan_entry_slab, orphan); | 256 | kmem_cache_free(orphan_entry_slab, orphan); |
257 | BUG_ON(sbi->n_orphans == 0); | ||
256 | sbi->n_orphans--; | 258 | sbi->n_orphans--; |
257 | break; | 259 | break; |
258 | } | 260 | } |