diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-04-06 22:01:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-07 11:31:19 -0400 |
commit | 1f5abe7e7dbcd83e73212c6cb135a6106cea6a0b (patch) | |
tree | f80e97297d5badebd31bbb17003d76a4ea30453a /fs/nilfs2/sufile.c | |
parent | 2c2e52fc4fca251e68f90821c9ff5cb18be4df58 (diff) |
nilfs2: replace BUG_ON and BUG calls triggerable from ioctl
Pekka Enberg advised me:
> It would be nice if BUG(), BUG_ON(), and panic() calls would be
> converted to proper error handling using WARN_ON() calls. The BUG()
> call in nilfs_cpfile_delete_checkpoints(), for example, looks to be
> triggerable from user-space via the ioctl() system call.
This will follow the comment and keep them to a minimum.
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nilfs2/sufile.c')
-rw-r--r-- | fs/nilfs2/sufile.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c index cc714c72b138..4cf47e03a3ab 100644 --- a/fs/nilfs2/sufile.c +++ b/fs/nilfs2/sufile.c | |||
@@ -231,10 +231,11 @@ int nilfs_sufile_cancel_free(struct inode *sufile, __u64 segnum) | |||
231 | kaddr = kmap_atomic(su_bh->b_page, KM_USER0); | 231 | kaddr = kmap_atomic(su_bh->b_page, KM_USER0); |
232 | su = nilfs_sufile_block_get_segment_usage( | 232 | su = nilfs_sufile_block_get_segment_usage( |
233 | sufile, segnum, su_bh, kaddr); | 233 | sufile, segnum, su_bh, kaddr); |
234 | if (!nilfs_segment_usage_clean(su)) { | 234 | if (unlikely(!nilfs_segment_usage_clean(su))) { |
235 | printk(KERN_CRIT "%s: segment %llu must be clean\n", | 235 | printk(KERN_WARNING "%s: segment %llu must be clean\n", |
236 | __func__, (unsigned long long)segnum); | 236 | __func__, (unsigned long long)segnum); |
237 | BUG(); | 237 | kunmap_atomic(kaddr, KM_USER0); |
238 | goto out_su_bh; | ||
238 | } | 239 | } |
239 | nilfs_segment_usage_set_dirty(su); | 240 | nilfs_segment_usage_set_dirty(su); |
240 | kunmap_atomic(kaddr, KM_USER0); | 241 | kunmap_atomic(kaddr, KM_USER0); |
@@ -249,11 +250,10 @@ int nilfs_sufile_cancel_free(struct inode *sufile, __u64 segnum) | |||
249 | nilfs_mdt_mark_buffer_dirty(su_bh); | 250 | nilfs_mdt_mark_buffer_dirty(su_bh); |
250 | nilfs_mdt_mark_dirty(sufile); | 251 | nilfs_mdt_mark_dirty(sufile); |
251 | 252 | ||
253 | out_su_bh: | ||
252 | brelse(su_bh); | 254 | brelse(su_bh); |
253 | |||
254 | out_header: | 255 | out_header: |
255 | brelse(header_bh); | 256 | brelse(header_bh); |
256 | |||
257 | out_sem: | 257 | out_sem: |
258 | up_write(&NILFS_MDT(sufile)->mi_sem); | 258 | up_write(&NILFS_MDT(sufile)->mi_sem); |
259 | return ret; | 259 | return ret; |
@@ -317,7 +317,7 @@ int nilfs_sufile_freev(struct inode *sufile, __u64 *segnum, size_t nsegs) | |||
317 | kaddr = kmap_atomic(su_bh[i]->b_page, KM_USER0); | 317 | kaddr = kmap_atomic(su_bh[i]->b_page, KM_USER0); |
318 | su = nilfs_sufile_block_get_segment_usage( | 318 | su = nilfs_sufile_block_get_segment_usage( |
319 | sufile, segnum[i], su_bh[i], kaddr); | 319 | sufile, segnum[i], su_bh[i], kaddr); |
320 | BUG_ON(nilfs_segment_usage_error(su)); | 320 | WARN_ON(nilfs_segment_usage_error(su)); |
321 | nilfs_segment_usage_set_clean(su); | 321 | nilfs_segment_usage_set_clean(su); |
322 | kunmap_atomic(kaddr, KM_USER0); | 322 | kunmap_atomic(kaddr, KM_USER0); |
323 | nilfs_mdt_mark_buffer_dirty(su_bh[i]); | 323 | nilfs_mdt_mark_buffer_dirty(su_bh[i]); |
@@ -385,8 +385,8 @@ int nilfs_sufile_get_segment_usage(struct inode *sufile, __u64 segnum, | |||
385 | int ret; | 385 | int ret; |
386 | 386 | ||
387 | /* segnum is 0 origin */ | 387 | /* segnum is 0 origin */ |
388 | BUG_ON(segnum >= nilfs_sufile_get_nsegments(sufile)); | 388 | if (segnum >= nilfs_sufile_get_nsegments(sufile)) |
389 | 389 | return -EINVAL; | |
390 | down_write(&NILFS_MDT(sufile)->mi_sem); | 390 | down_write(&NILFS_MDT(sufile)->mi_sem); |
391 | ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 1, &bh); | 391 | ret = nilfs_sufile_get_segment_usage_block(sufile, segnum, 1, &bh); |
392 | if (ret < 0) | 392 | if (ret < 0) |
@@ -515,6 +515,8 @@ int nilfs_sufile_get_ncleansegs(struct inode *sufile, unsigned long *nsegsp) | |||
515 | * %-EIO - I/O error. | 515 | * %-EIO - I/O error. |
516 | * | 516 | * |
517 | * %-ENOMEM - Insufficient amount of memory available. | 517 | * %-ENOMEM - Insufficient amount of memory available. |
518 | * | ||
519 | * %-EINVAL - Invalid segment usage number. | ||
518 | */ | 520 | */ |
519 | int nilfs_sufile_set_error(struct inode *sufile, __u64 segnum) | 521 | int nilfs_sufile_set_error(struct inode *sufile, __u64 segnum) |
520 | { | 522 | { |
@@ -524,8 +526,11 @@ int nilfs_sufile_set_error(struct inode *sufile, __u64 segnum) | |||
524 | void *kaddr; | 526 | void *kaddr; |
525 | int ret; | 527 | int ret; |
526 | 528 | ||
527 | BUG_ON(segnum >= nilfs_sufile_get_nsegments(sufile)); | 529 | if (unlikely(segnum >= nilfs_sufile_get_nsegments(sufile))) { |
528 | 530 | printk(KERN_WARNING "%s: invalid segment number: %llu\n", | |
531 | __func__, (unsigned long long)segnum); | ||
532 | return -EINVAL; | ||
533 | } | ||
529 | down_write(&NILFS_MDT(sufile)->mi_sem); | 534 | down_write(&NILFS_MDT(sufile)->mi_sem); |
530 | 535 | ||
531 | ret = nilfs_sufile_get_header_block(sufile, &header_bh); | 536 | ret = nilfs_sufile_get_header_block(sufile, &header_bh); |