Whamcloud - gitweb
LU-12137 osd-ldiskfs: migrate osd_ios_lookup_one_len() to osd_compat.c 53/35453/2
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 10 Jul 2019 14:15:31 +0000 (10:15 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 17 Jul 2019 06:22:09 +0000 (06:22 +0000)
The function osd_ios_lookup_one_len() was created for the LFSCK code
to look for a dentry by name and if the inode of that dentry was
NULL treat it as an -ENOENT so LFSCK would repair the file. This
function will be used for more the scrub infrastructure in future
patches so move it to osd_compat.c.

Test-Parameters: trivial

Change-Id: Ic34c1110f8ced7a4a2f7c0fa3b8a9403be9940ca
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/35453
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_scrub.c

index 8f231cb..ae42d2c 100644 (file)
@@ -66,6 +66,42 @@ static void osd_push_ctxt(const struct osd_device *dev,
        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,
index a28ba4c..323bc32 100644 (file)
@@ -793,6 +793,9 @@ int osd_oii_lookup(struct osd_device *dev, const struct lu_fid *fid,
                   struct osd_inode_id *id);
 void osd_scrub_dump(struct seq_file *m, struct osd_device *dev);
 
+struct dentry *osd_ios_lookup_one_len(const char *name, struct dentry *base,
+                                     int len);
+
 int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
                   u64 seq, struct lu_seq_range *range);
 
index c1fb942..22ee164 100644 (file)
@@ -1741,32 +1741,6 @@ struct osd_ios_filldir_buf {
        int                      oifb_items;
 };
 
-static inline struct dentry *
-osd_ios_lookup_one_len(const char *name, struct dentry *parent, int namelen)
-{
-       struct dentry *dentry;
-
-       dentry = ll_lookup_one_len(name, parent, namelen);
-       if (IS_ERR(dentry)) {
-               int rc = PTR_ERR(dentry);
-
-               if (rc != -ENOENT)
-                       CERROR("Fail to find %.*s in %.*s (%lu/%u): rc = %d\n",
-                              namelen, name, parent->d_name.len,
-                              parent->d_name.name, parent->d_inode->i_ino,
-                              parent->d_inode->i_generation, rc);
-
-               return dentry;
-       }
-
-       if (dentry->d_inode == NULL) {
-               dput(dentry);
-               return ERR_PTR(-ENOENT);
-       }
-
-       return dentry;
-}
-
 static int
 osd_ios_new_item(struct osd_device *dev, struct dentry *dentry,
                 scandir_t scandir, filldir_t filldir)