Skip to content

Commit 750fc5b

Browse files
James SimmonsOleg Drokin
authored andcommitted
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 <[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]>
1 parent 076a596 commit 750fc5b

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

lustre/osd-ldiskfs/osd_compat.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,42 @@ static void osd_push_ctxt(const struct osd_device *dev,
6666
push_ctxt(save, newctxt);
6767
}
6868

69+
/**
70+
* osd_ios_lookup_one_len - lookup single pathname component
71+
*
72+
* @name: pathname component to lookup
73+
* @base: base directory to lookup from
74+
* @len: maximum length @len should be interpreted to
75+
*
76+
* Treat found dentry with NULL d_inode as an -ENOENT error so LFSCK
77+
* can repair the file.
78+
*/
79+
struct dentry *osd_ios_lookup_one_len(const char *name, struct dentry *base,
80+
int len)
81+
{
82+
struct dentry *dentry;
83+
84+
dentry = ll_lookup_one_len(name, base, len);
85+
if (IS_ERR(dentry)) {
86+
int rc = PTR_ERR(dentry);
87+
88+
if (rc != -ENOENT)
89+
CERROR("Fail to find %.*s in %.*s (%lu/%u): rc = %d\n",
90+
len, name, base->d_name.len,
91+
base->d_name.name, base->d_inode->i_ino,
92+
base->d_inode->i_generation, rc);
93+
94+
return dentry;
95+
}
96+
97+
if (dentry->d_inode == NULL) {
98+
dput(dentry);
99+
return ERR_PTR(-ENOENT);
100+
}
101+
102+
return dentry;
103+
}
104+
69105
/* utility to make a directory */
70106
static struct dentry *
71107
simple_mkdir(const struct lu_env *env, struct osd_device *osd,

lustre/osd-ldiskfs/osd_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,9 @@ int osd_oii_lookup(struct osd_device *dev, const struct lu_fid *fid,
793793
struct osd_inode_id *id);
794794
void osd_scrub_dump(struct seq_file *m, struct osd_device *dev);
795795

796+
struct dentry *osd_ios_lookup_one_len(const char *name, struct dentry *base,
797+
int len);
798+
796799
int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
797800
u64 seq, struct lu_seq_range *range);
798801

lustre/osd-ldiskfs/osd_scrub.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,32 +1741,6 @@ struct osd_ios_filldir_buf {
17411741
int oifb_items;
17421742
};
17431743

1744-
static inline struct dentry *
1745-
osd_ios_lookup_one_len(const char *name, struct dentry *parent, int namelen)
1746-
{
1747-
struct dentry *dentry;
1748-
1749-
dentry = ll_lookup_one_len(name, parent, namelen);
1750-
if (IS_ERR(dentry)) {
1751-
int rc = PTR_ERR(dentry);
1752-
1753-
if (rc != -ENOENT)
1754-
CERROR("Fail to find %.*s in %.*s (%lu/%u): rc = %d\n",
1755-
namelen, name, parent->d_name.len,
1756-
parent->d_name.name, parent->d_inode->i_ino,
1757-
parent->d_inode->i_generation, rc);
1758-
1759-
return dentry;
1760-
}
1761-
1762-
if (dentry->d_inode == NULL) {
1763-
dput(dentry);
1764-
return ERR_PTR(-ENOENT);
1765-
}
1766-
1767-
return dentry;
1768-
}
1769-
17701744
static int
17711745
osd_ios_new_item(struct osd_device *dev, struct dentry *dentry,
17721746
scandir_t scandir, filldir_t filldir)

0 commit comments

Comments
 (0)