Whamcloud - gitweb
LU-12137 osd-ldiskfs: migrate osd_ios_lookup_one_len() to osd_compat.c
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_compat.c
index 1374f90..ae42d2c 100644 (file)
@@ -59,13 +59,49 @@ static void osd_push_ctxt(const struct osd_device *dev,
        OBD_SET_CTXT_MAGIC(newctxt);
        newctxt->pwdmnt = dev->od_mnt;
        newctxt->pwd = dev->od_mnt->mnt_root;
-       newctxt->fs = get_ds();
+       newctxt->fs = KERNEL_DS;
        newctxt->umask = current_umask();
        newctxt->dt = NULL;
 
        push_ctxt(save, newctxt);
 }
 
+/**
+ * osd_ios_lookup_one_len - lookup single pathname component
+ *
+ * @name:      pathname component to lookup
+ * @base:      base directory to lookup from
+ * @len:       maximum length @len should be interpreted to
+ *
+ * Treat found dentry with NULL d_inode as an -ENOENT error so LFSCK
+ * can repair the file.
+ */
+struct dentry *osd_ios_lookup_one_len(const char *name, struct dentry *base,
+                                     int len)
+{
+       struct dentry *dentry;
+
+       dentry = ll_lookup_one_len(name, base, len);
+       if (IS_ERR(dentry)) {
+               int rc = PTR_ERR(dentry);
+
+               if (rc != -ENOENT)
+                       CERROR("Fail to find %.*s in %.*s (%lu/%u): rc = %d\n",
+                              len, name, base->d_name.len,
+                              base->d_name.name, base->d_inode->i_ino,
+                              base->d_inode->i_generation, rc);
+
+               return dentry;
+       }
+
+       if (dentry->d_inode == NULL) {
+               dput(dentry);
+               return ERR_PTR(-ENOENT);
+       }
+
+       return dentry;
+}
+
 /* utility to make a directory */
 static struct dentry *
 simple_mkdir(const struct lu_env *env, struct osd_device *osd,
@@ -1260,7 +1296,8 @@ int osd_obj_map_recover(struct osd_thread_info *info,
                        if (unlikely(rc == -ENOENT))
                                rc = 0;
                }
-               RETURN(rc);
+               if (rc)
+                       RETURN(rc);
        }
 
        bh = osd_ldiskfs_find_entry(src_parent, &src_child->d_name, &de,
@@ -1407,11 +1444,7 @@ int osd_obj_spec_lookup(struct osd_thread_info *info, struct osd_device *osd,
 #ifndef HAVE_BIO_INTEGRITY_ENABLED
 bool bio_integrity_enabled(struct bio *bio)
 {
-# ifdef HAVE_BI_BDEV
-       struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
-# else
-       struct blk_integrity *bi = blk_get_integrity(bio->bi_disk);
-# endif
+       struct blk_integrity *bi = blk_get_integrity(bio_get_disk(bio));
 
        if (bio_op(bio) != REQ_OP_READ && bio_op(bio) != REQ_OP_WRITE)
                return false;