Merge tag 'v6.6-p5' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[platform/kernel/linux-starfive.git] / fs / nilfs2 / bmap.c
index 798a2c1..7a8f166 100644 (file)
@@ -67,20 +67,28 @@ int nilfs_bmap_lookup_at_level(struct nilfs_bmap *bmap, __u64 key, int level,
 
        down_read(&bmap->b_sem);
        ret = bmap->b_ops->bop_lookup(bmap, key, level, ptrp);
-       if (ret < 0) {
-               ret = nilfs_bmap_convert_error(bmap, __func__, ret);
+       if (ret < 0)
                goto out;
-       }
+
        if (NILFS_BMAP_USE_VBN(bmap)) {
                ret = nilfs_dat_translate(nilfs_bmap_get_dat(bmap), *ptrp,
                                          &blocknr);
                if (!ret)
                        *ptrp = blocknr;
+               else if (ret == -ENOENT) {
+                       /*
+                        * If there was no valid entry in DAT for the block
+                        * address obtained by b_ops->bop_lookup, then pass
+                        * internal code -EINVAL to nilfs_bmap_convert_error
+                        * to treat it as metadata corruption.
+                        */
+                       ret = -EINVAL;
+               }
        }
 
  out:
        up_read(&bmap->b_sem);
-       return ret;
+       return nilfs_bmap_convert_error(bmap, __func__, ret);
 }
 
 int nilfs_bmap_lookup_contig(struct nilfs_bmap *bmap, __u64 key, __u64 *ptrp,