From 750fc5bc98606df0d3d25e8ddda8288ec186a258 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 10 Jul 2019 10:15:31 -0400 Subject: [PATCH] LU-12137 osd-ldiskfs: migrate osd_ios_lookup_one_len() to osd_compat.c 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 Reviewed-on: https://review.whamcloud.com/35453 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger --- lustre/osd-ldiskfs/osd_compat.c | 36 ++++++++++++++++++++++++++++++++++++ lustre/osd-ldiskfs/osd_internal.h | 3 +++ lustre/osd-ldiskfs/osd_scrub.c | 26 -------------------------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c index 8f231cb..ae42d2c 100644 --- a/lustre/osd-ldiskfs/osd_compat.c +++ b/lustre/osd-ldiskfs/osd_compat.c @@ -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, diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index a28ba4c..323bc32 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -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); diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index c1fb942..22ee164 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -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) -- 1.8.3.1