1

ext2_find_entry()/ext2_dotdot(): callers don't need page_addr anymore

... and that's how it should've been done in the first place

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Tested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Al Viro 2022-12-13 20:53:47 -05:00 committed by Jan Kara
parent dae42837ba
commit b8b9e8b35d
3 changed files with 21 additions and 39 deletions

View File

@ -339,8 +339,7 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
* should be treated as a call to ext2_get_page() for nesting purposes.
*/
struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
const struct qstr *child, struct page **res_page,
void **res_page_addr)
const struct qstr *child, struct page **res_page)
{
const char *name = child->name;
int namelen = child->len;
@ -350,27 +349,22 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
struct page *page = NULL;
struct ext2_inode_info *ei = EXT2_I(dir);
ext2_dirent * de;
void *page_addr;
if (npages == 0)
goto out;
/* OFFSET_CACHE */
*res_page = NULL;
*res_page_addr = NULL;
start = ei->i_dir_start_lookup;
if (start >= npages)
start = 0;
n = start;
do {
char *kaddr;
char *kaddr = ext2_get_page(dir, n, 0, &page);
if (IS_ERR(kaddr))
return ERR_CAST(kaddr);
page_addr = ext2_get_page(dir, n, 0, &page);
if (IS_ERR(page_addr))
return ERR_CAST(page_addr);
kaddr = page_addr;
de = (ext2_dirent *) kaddr;
kaddr += ext2_last_byte(dir, n) - reclen;
while ((char *) de <= kaddr) {
@ -402,7 +396,6 @@ out:
found:
*res_page = page;
*res_page_addr = page_addr;
ei->i_dir_start_lookup = n;
return de;
}
@ -419,26 +412,21 @@ found:
* ext2_find_entry() and ext2_dotdot() act as a call to ext2_get_page() and
* should be treated as a call to ext2_get_page() for nesting purposes.
*/
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p,
void **pa)
struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p)
{
void *page_addr = ext2_get_page(dir, 0, 0, p);
ext2_dirent *de = NULL;
ext2_dirent *de = ext2_get_page(dir, 0, 0, p);
if (!IS_ERR(page_addr)) {
de = ext2_next_entry((ext2_dirent *) page_addr);
*pa = page_addr;
}
return de;
if (!IS_ERR(de))
return ext2_next_entry(de);
return NULL;
}
int ext2_inode_by_name(struct inode *dir, const struct qstr *child, ino_t *ino)
{
struct ext2_dir_entry_2 *de;
struct page *page;
void *page_addr;
de = ext2_find_entry(dir, child, &page, &page_addr);
de = ext2_find_entry(dir, child, &page);
if (IS_ERR(de))
return PTR_ERR(de);
@ -510,10 +498,9 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
* to protect that region.
*/
for (n = 0; n <= npages; n++) {
char *kaddr;
char *kaddr = ext2_get_page(dir, n, 0, &page);
char *dir_end;
kaddr = ext2_get_page(dir, n, 0, &page);
if (IS_ERR(kaddr))
return PTR_ERR(kaddr);
lock_page(page);

View File

@ -730,10 +730,10 @@ extern int ext2_inode_by_name(struct inode *dir,
const struct qstr *child, ino_t *ino);
extern int ext2_make_empty(struct inode *, struct inode *);
extern struct ext2_dir_entry_2 *ext2_find_entry(struct inode *, const struct qstr *,
struct page **, void **res_page_addr);
struct page **);
extern int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page);
extern int ext2_empty_dir (struct inode *);
extern struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p, void **pa);
extern struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p);
int ext2_set_link(struct inode *dir, struct ext2_dir_entry_2 *de,
struct page *page, struct inode *inode, bool update_times);
static inline void ext2_put_page(struct page *page, void *page_addr)

View File

@ -269,19 +269,18 @@ out_dir:
goto out;
}
static int ext2_unlink(struct inode * dir, struct dentry *dentry)
static int ext2_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode * inode = d_inode(dentry);
struct ext2_dir_entry_2 * de;
struct page * page;
void *page_addr;
struct inode *inode = d_inode(dentry);
struct ext2_dir_entry_2 *de;
struct page *page;
int err;
err = dquot_initialize(dir);
if (err)
goto out;
de = ext2_find_entry(dir, &dentry->d_name, &page, &page_addr);
de = ext2_find_entry(dir, &dentry->d_name, &page);
if (IS_ERR(de)) {
err = PTR_ERR(de);
goto out;
@ -323,10 +322,8 @@ static int ext2_rename (struct mnt_idmap * idmap,
struct inode * old_inode = d_inode(old_dentry);
struct inode * new_inode = d_inode(new_dentry);
struct page * dir_page = NULL;
void *dir_page_addr;
struct ext2_dir_entry_2 * dir_de = NULL;
struct page * old_page;
void *old_page_addr;
struct ext2_dir_entry_2 * old_de;
int err;
@ -341,20 +338,18 @@ static int ext2_rename (struct mnt_idmap * idmap,
if (err)
return err;
old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page,
&old_page_addr);
old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page);
if (IS_ERR(old_de))
return PTR_ERR(old_de);
if (S_ISDIR(old_inode->i_mode)) {
err = -EIO;
dir_de = ext2_dotdot(old_inode, &dir_page, &dir_page_addr);
dir_de = ext2_dotdot(old_inode, &dir_page);
if (!dir_de)
goto out_old;
}
if (new_inode) {
void *page_addr;
struct page *new_page;
struct ext2_dir_entry_2 *new_de;
@ -363,7 +358,7 @@ static int ext2_rename (struct mnt_idmap * idmap,
goto out_dir;
new_de = ext2_find_entry(new_dir, &new_dentry->d_name,
&new_page, &page_addr);
&new_page);
if (IS_ERR(new_de)) {
err = PTR_ERR(new_de);
goto out_dir;