]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/nilfs2/direct.c
nilfs2: unify bmap operations starting use of indirect block address
[karo-tx-linux.git] / fs / nilfs2 / direct.c
index e3ec24850089d8cb16c6a82184bda1cfabd68b11..5cbba8284bea95a4e0f716c35b74b20e1590a54e 100644 (file)
@@ -210,7 +210,6 @@ static int nilfs_direct_last_key(const struct nilfs_bmap *bmap, __u64 *keyp)
        if (lastkey == NILFS_DIRECT_KEY_MAX + 1)
                return -ENOENT;
 
-       BUG_ON(keyp == NULL);
        *keyp = lastkey;
 
        return 0;
@@ -328,12 +327,9 @@ static int nilfs_direct_assign_v(struct nilfs_direct *direct,
        int ret;
 
        req.bpr_ptr = ptr;
-       ret = direct->d_bmap.b_pops->bpop_prepare_start_ptr(
-               &direct->d_bmap, &req);
-       if (ret < 0)
+       ret = nilfs_bmap_start_v(&direct->d_bmap, &req, blocknr);
+       if (unlikely(ret < 0))
                return ret;
-       direct->d_bmap.b_pops->bpop_commit_start_ptr(&direct->d_bmap,
-                                                    &req, blocknr);
 
        binfo->bi_v.bi_vblocknr = nilfs_bmap_ptr_to_dptr(ptr);
        binfo->bi_v.bi_blkoff = nilfs_bmap_key_to_dkey(key);
@@ -366,9 +362,17 @@ static int nilfs_direct_assign(struct nilfs_bmap *bmap,
 
        direct = (struct nilfs_direct *)bmap;
        key = nilfs_bmap_data_get_key(bmap, *bh);
-       BUG_ON(key > NILFS_DIRECT_KEY_MAX);
+       if (unlikely(key > NILFS_DIRECT_KEY_MAX)) {
+               printk(KERN_CRIT "%s: invalid key: %llu\n", __func__,
+                      (unsigned long long)key);
+               return -EINVAL;
+       }
        ptr = nilfs_direct_get_ptr(direct, key);
-       BUG_ON(ptr == NILFS_BMAP_INVALID_PTR);
+       if (unlikely(ptr == NILFS_BMAP_INVALID_PTR)) {
+               printk(KERN_CRIT "%s: invalid pointer: %llu\n", __func__,
+                      (unsigned long long)ptr);
+               return -EINVAL;
+       }
 
        return direct->d_ops->dop_assign(direct, key, ptr, bh,
                                         blocknr, binfo);