new helper: lookup_positive_unlocked()
Most of the callers of lookup_one_len_unlocked() treat negatives are ERR_PTR(-ENOENT). Provide a helper that would do just that. Note that a pinned positive dentry remains positive - it's ->d_inode is stable, etc.; a pinned _negative_ dentry can become positive at any point as long as you are not holding its parent at least shared. So using lookup_one_len_unlocked() needs to be careful; lookup_positive_unlocked() is safer and that's what the callers end up open-coding anyway. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Цей коміт міститься в:
@@ -200,7 +200,7 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
|
||||
int err;
|
||||
bool last_element = !post[0];
|
||||
|
||||
this = lookup_one_len_unlocked(name, base, namelen);
|
||||
this = lookup_positive_unlocked(name, base, namelen);
|
||||
if (IS_ERR(this)) {
|
||||
err = PTR_ERR(this);
|
||||
this = NULL;
|
||||
@@ -208,8 +208,6 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d,
|
||||
goto out;
|
||||
goto out_err;
|
||||
}
|
||||
if (!this->d_inode)
|
||||
goto put_and_out;
|
||||
|
||||
if (ovl_dentry_weird(this)) {
|
||||
/* Don't support traversing automounts and other weirdness */
|
||||
@@ -651,7 +649,7 @@ struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh)
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
index = lookup_one_len_unlocked(name.name, ofs->indexdir, name.len);
|
||||
index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len);
|
||||
kfree(name.name);
|
||||
if (IS_ERR(index)) {
|
||||
if (PTR_ERR(index) == -ENOENT)
|
||||
@@ -659,9 +657,7 @@ struct dentry *ovl_get_index_fh(struct ovl_fs *ofs, struct ovl_fh *fh)
|
||||
return index;
|
||||
}
|
||||
|
||||
if (d_is_negative(index))
|
||||
err = 0;
|
||||
else if (ovl_is_whiteout(index))
|
||||
if (ovl_is_whiteout(index))
|
||||
err = -ESTALE;
|
||||
else if (ovl_dentry_weird(index))
|
||||
err = -EIO;
|
||||
@@ -685,7 +681,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper,
|
||||
if (err)
|
||||
return ERR_PTR(err);
|
||||
|
||||
index = lookup_one_len_unlocked(name.name, ofs->indexdir, name.len);
|
||||
index = lookup_positive_unlocked(name.name, ofs->indexdir, name.len);
|
||||
if (IS_ERR(index)) {
|
||||
err = PTR_ERR(index);
|
||||
if (err == -ENOENT) {
|
||||
@@ -700,9 +696,7 @@ struct dentry *ovl_lookup_index(struct ovl_fs *ofs, struct dentry *upper,
|
||||
}
|
||||
|
||||
inode = d_inode(index);
|
||||
if (d_is_negative(index)) {
|
||||
goto out_dput;
|
||||
} else if (ovl_is_whiteout(index) && !verify) {
|
||||
if (ovl_is_whiteout(index) && !verify) {
|
||||
/*
|
||||
* When index lookup is called with !verify for decoding an
|
||||
* overlay file handle, a whiteout index implies that decode
|
||||
@@ -1131,7 +1125,7 @@ bool ovl_lower_positive(struct dentry *dentry)
|
||||
struct dentry *this;
|
||||
struct dentry *lowerdir = poe->lowerstack[i].dentry;
|
||||
|
||||
this = lookup_one_len_unlocked(name->name, lowerdir,
|
||||
this = lookup_positive_unlocked(name->name, lowerdir,
|
||||
name->len);
|
||||
if (IS_ERR(this)) {
|
||||
switch (PTR_ERR(this)) {
|
||||
@@ -1148,10 +1142,8 @@ bool ovl_lower_positive(struct dentry *dentry)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (this->d_inode) {
|
||||
positive = !ovl_is_whiteout(this);
|
||||
done = true;
|
||||
}
|
||||
positive = !ovl_is_whiteout(this);
|
||||
done = true;
|
||||
dput(this);
|
||||
}
|
||||
}
|
||||
|
Посилання в новій задачі
Заблокувати користувача