aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/btree.c
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2009-04-06 22:01:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-07 11:31:19 -0400
commit1f5abe7e7dbcd83e73212c6cb135a6106cea6a0b (patch)
treef80e97297d5badebd31bbb17003d76a4ea30453a /fs/nilfs2/btree.c
parent2c2e52fc4fca251e68f90821c9ff5cb18be4df58 (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/btree.c')
-rw-r--r--fs/nilfs2/btree.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index 53f0d4c31cb0..6b37a2767293 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -425,7 +425,6 @@ static int nilfs_btree_node_lookup(const struct nilfs_btree *btree,
425 index++; 425 index++;
426 426
427 out: 427 out:
428 BUG_ON(indexp == NULL);
429 *indexp = index; 428 *indexp = index;
430 429
431 return s == 0; 430 return s == 0;
@@ -477,8 +476,6 @@ static int nilfs_btree_do_lookup(const struct nilfs_btree *btree,
477 __u64 ptr; 476 __u64 ptr;
478 int level, index, found, ret; 477 int level, index, found, ret;
479 478
480 BUG_ON(minlevel <= NILFS_BTREE_LEVEL_DATA);
481
482 node = nilfs_btree_get_root(btree); 479 node = nilfs_btree_get_root(btree);
483 level = nilfs_btree_node_get_level(btree, node); 480 level = nilfs_btree_node_get_level(btree, node);
484 if ((level < minlevel) || 481 if ((level < minlevel) ||
@@ -505,7 +502,7 @@ static int nilfs_btree_do_lookup(const struct nilfs_btree *btree,
505 if (index < nilfs_btree_node_nchildren_max(btree, node)) 502 if (index < nilfs_btree_node_nchildren_max(btree, node))
506 ptr = nilfs_btree_node_get_ptr(btree, node, index); 503 ptr = nilfs_btree_node_get_ptr(btree, node, index);
507 else { 504 else {
508 BUG_ON(found || level != NILFS_BTREE_LEVEL_NODE_MIN); 505 WARN_ON(found || level != NILFS_BTREE_LEVEL_NODE_MIN);
509 /* insert */ 506 /* insert */
510 ptr = NILFS_BMAP_INVALID_PTR; 507 ptr = NILFS_BMAP_INVALID_PTR;
511 } 508 }
@@ -1366,7 +1363,7 @@ static int nilfs_btree_prepare_delete(struct nilfs_btree *btree,
1366 } else { 1363 } else {
1367 /* no siblings */ 1364 /* no siblings */
1368 /* the only child of the root node */ 1365 /* the only child of the root node */
1369 BUG_ON(level != nilfs_btree_height(btree) - 2); 1366 WARN_ON(level != nilfs_btree_height(btree) - 2);
1370 if (nilfs_btree_node_get_nchildren(btree, node) - 1 <= 1367 if (nilfs_btree_node_get_nchildren(btree, node) - 1 <=
1371 NILFS_BTREE_ROOT_NCHILDREN_MAX) { 1368 NILFS_BTREE_ROOT_NCHILDREN_MAX) {
1372 path[level].bp_op = nilfs_btree_shrink; 1369 path[level].bp_op = nilfs_btree_shrink;
@@ -1543,7 +1540,7 @@ static int nilfs_btree_gather_data(struct nilfs_bmap *bmap,
1543 break; 1540 break;
1544 case 3: 1541 case 3:
1545 nchildren = nilfs_btree_node_get_nchildren(btree, root); 1542 nchildren = nilfs_btree_node_get_nchildren(btree, root);
1546 BUG_ON(nchildren > 1); 1543 WARN_ON(nchildren > 1);
1547 ptr = nilfs_btree_node_get_ptr(btree, root, nchildren - 1); 1544 ptr = nilfs_btree_node_get_ptr(btree, root, nchildren - 1);
1548 ret = nilfs_bmap_get_block(bmap, ptr, &bh); 1545 ret = nilfs_bmap_get_block(bmap, ptr, &bh);
1549 if (ret < 0) 1546 if (ret < 0)
@@ -1552,7 +1549,7 @@ static int nilfs_btree_gather_data(struct nilfs_bmap *bmap,
1552 break; 1549 break;
1553 default: 1550 default:
1554 node = NULL; 1551 node = NULL;
1555 BUG(); 1552 return -EINVAL;
1556 } 1553 }
1557 1554
1558 nchildren = nilfs_btree_node_get_nchildren(btree, node); 1555 nchildren = nilfs_btree_node_get_nchildren(btree, node);
@@ -1833,14 +1830,13 @@ static int nilfs_btree_prepare_propagate_v(struct nilfs_btree *btree,
1833 while ((++level < nilfs_btree_height(btree) - 1) && 1830 while ((++level < nilfs_btree_height(btree) - 1) &&
1834 !buffer_dirty(path[level].bp_bh)) { 1831 !buffer_dirty(path[level].bp_bh)) {
1835 1832
1836 BUG_ON(buffer_nilfs_volatile(path[level].bp_bh)); 1833 WARN_ON(buffer_nilfs_volatile(path[level].bp_bh));
1837 ret = nilfs_btree_prepare_update_v(btree, path, level); 1834 ret = nilfs_btree_prepare_update_v(btree, path, level);
1838 if (ret < 0) 1835 if (ret < 0)
1839 goto out; 1836 goto out;
1840 } 1837 }
1841 1838
1842 /* success */ 1839 /* success */
1843 BUG_ON(maxlevelp == NULL);
1844 *maxlevelp = level - 1; 1840 *maxlevelp = level - 1;
1845 return 0; 1841 return 0;
1846 1842
@@ -1909,7 +1905,7 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
1909 __u64 key; 1905 __u64 key;
1910 int level, ret; 1906 int level, ret;
1911 1907
1912 BUG_ON(!buffer_dirty(bh)); 1908 WARN_ON(!buffer_dirty(bh));
1913 1909
1914 btree = (struct nilfs_btree *)bmap; 1910 btree = (struct nilfs_btree *)bmap;
1915 path = nilfs_btree_alloc_path(btree); 1911 path = nilfs_btree_alloc_path(btree);
@@ -1928,12 +1924,9 @@ static int nilfs_btree_propagate(const struct nilfs_bmap *bmap,
1928 1924
1929 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1); 1925 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1);
1930 if (ret < 0) { 1926 if (ret < 0) {
1931 /* BUG_ON(ret == -ENOENT); */ 1927 if (unlikely(ret == -ENOENT))
1932 if (ret == -ENOENT) {
1933 printk(KERN_CRIT "%s: key = %llu, level == %d\n", 1928 printk(KERN_CRIT "%s: key = %llu, level == %d\n",
1934 __func__, (unsigned long long)key, level); 1929 __func__, (unsigned long long)key, level);
1935 BUG();
1936 }
1937 goto out; 1930 goto out;
1938 } 1931 }
1939 1932
@@ -2117,7 +2110,7 @@ static int nilfs_btree_assign(struct nilfs_bmap *bmap,
2117 2110
2118 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1); 2111 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1);
2119 if (ret < 0) { 2112 if (ret < 0) {
2120 BUG_ON(ret == -ENOENT); 2113 WARN_ON(ret == -ENOENT);
2121 goto out; 2114 goto out;
2122 } 2115 }
2123 2116
@@ -2175,12 +2168,12 @@ static int nilfs_btree_mark(struct nilfs_bmap *bmap, __u64 key, int level)
2175 2168
2176 ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1); 2169 ret = nilfs_btree_do_lookup(btree, path, key, &ptr, level + 1);
2177 if (ret < 0) { 2170 if (ret < 0) {
2178 BUG_ON(ret == -ENOENT); 2171 WARN_ON(ret == -ENOENT);
2179 goto out; 2172 goto out;
2180 } 2173 }
2181 ret = nilfs_bmap_get_block(&btree->bt_bmap, ptr, &bh); 2174 ret = nilfs_bmap_get_block(&btree->bt_bmap, ptr, &bh);
2182 if (ret < 0) { 2175 if (ret < 0) {
2183 BUG_ON(ret == -ENOENT); 2176 WARN_ON(ret == -ENOENT);
2184 goto out; 2177 goto out;
2185 } 2178 }
2186 2179