ufs: Convert directory handling to kmap_local

Remove kmap use and use folio_release_kmap() instead of ufs_put_page().

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2024-07-08 18:01:47 -04:00 committed by Christian Brauner
parent 0f3e63f30b
commit 516b97cf03
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
2 changed files with 17 additions and 28 deletions

View File

@ -66,12 +66,6 @@ static int ufs_handle_dirsync(struct inode *dir)
return err;
}
static inline void ufs_put_page(struct page *page)
{
kunmap(page);
put_page(page);
}
ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
{
ino_t res = 0;
@ -81,7 +75,7 @@ ino_t ufs_inode_by_name(struct inode *dir, const struct qstr *qstr)
de = ufs_find_entry(dir, qstr, &folio);
if (de) {
res = fs32_to_cpu(dir->i_sb, de->d_ino);
ufs_put_page(&folio->page);
folio_release_kmap(folio, de);
}
return res;
}
@ -104,7 +98,7 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de,
ufs_set_de_type(dir->i_sb, de, inode->i_mode);
ufs_commit_chunk(folio, pos, len);
ufs_put_page(&folio->page);
folio_release_kmap(folio, de);
if (update_times)
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
mark_inode_dirty(dir);
@ -197,7 +191,7 @@ static void *ufs_get_folio(struct inode *dir, unsigned long n,
if (IS_ERR(folio))
return ERR_CAST(folio);
kaddr = kmap(&folio->page);
kaddr = kmap_local_folio(folio, 0);
if (unlikely(!folio_test_checked(folio))) {
if (!ufs_check_folio(folio, kaddr))
goto fail;
@ -206,7 +200,7 @@ static void *ufs_get_folio(struct inode *dir, unsigned long n,
return kaddr;
fail:
ufs_put_page(&folio->page);
folio_release_kmap(folio, kaddr);
return ERR_PTR(-EIO);
}
@ -283,7 +277,7 @@ struct ufs_dir_entry *ufs_find_entry(struct inode *dir, const struct qstr *qstr,
goto found;
de = ufs_next_entry(sb, de);
}
ufs_put_page(&(*foliop)->page);
folio_release_kmap(*foliop, kaddr);
}
if (++n >= npages)
n = 0;
@ -359,7 +353,7 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode)
de = (struct ufs_dir_entry *) ((char *) de + rec_len);
}
folio_unlock(folio);
ufs_put_page(&folio->page);
folio_release_kmap(folio, kaddr);
}
BUG();
return -EINVAL;
@ -390,7 +384,7 @@ got_it:
err = ufs_handle_dirsync(dir);
/* OFFSET_CACHE */
out_put:
ufs_put_page(&folio->page);
folio_release_kmap(folio, de);
return err;
out_unlock:
folio_unlock(folio);
@ -468,13 +462,13 @@ ufs_readdir(struct file *file, struct dir_context *ctx)
ufs_get_de_namlen(sb, de),
fs32_to_cpu(sb, de->d_ino),
d_type)) {
ufs_put_page(&folio->page);
folio_release_kmap(folio, de);
return 0;
}
}
ctx->pos += fs16_to_cpu(sb, de->d_reclen);
}
ufs_put_page(&folio->page);
folio_release_kmap(folio, kaddr);
}
return 0;
}
@ -531,7 +525,7 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir,
mark_inode_dirty(inode);
err = ufs_handle_dirsync(inode);
out:
ufs_put_page(&folio->page);
folio_release_kmap(folio, kaddr);
UFSD("EXIT\n");
return err;
}
@ -624,12 +618,12 @@ int ufs_empty_dir(struct inode * inode)
}
de = ufs_next_entry(sb, de);
}
ufs_put_page(&folio->page);
folio_release_kmap(folio, kaddr);
}
return 1;
not_empty:
ufs_put_page(&folio->page);
folio_release_kmap(folio, kaddr);
return 0;
}

View File

@ -306,23 +306,18 @@ static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
if (dir_de) {
if (old_dir != new_dir)
ufs_set_link(old_inode, dir_de, dir_folio, new_dir, 0);
else {
kunmap(&dir_folio->page);
folio_put(dir_folio);
}
else
folio_release_kmap(dir_folio, new_dir);
inode_dec_link_count(old_dir);
}
return 0;
out_dir:
if (dir_de) {
kunmap(&dir_folio->page);
folio_put(dir_folio);
}
if (dir_de)
folio_release_kmap(dir_folio, dir_de);
out_old:
kunmap(&old_folio->page);
folio_put(old_folio);
folio_release_kmap(old_folio, old_de);
out:
return err;
}