Skip to content

Commit

Permalink
LU-12137 osd-ldiskfs: migrate osd_ios_lookup_one_len() to osd_compat.c
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-on: https://review.whamcloud.com/35453
Tested-by: jenkins <[email protected]>
Tested-by: Maloo <[email protected]>
Reviewed-by: Neil Brown <[email protected]>
Reviewed-by: Alex Zhuravlev <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
  • Loading branch information
James Simmons authored and Oleg Drokin committed Jul 17, 2019
1 parent 076a596 commit 750fc5b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 26 deletions.
36 changes: 36 additions & 0 deletions lustre/osd-ldiskfs/osd_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions lustre/osd-ldiskfs/osd_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
26 changes: 0 additions & 26 deletions lustre/osd-ldiskfs/osd_scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 750fc5b

Please sign in to comment.