From 782b76d7abdf02b12c46ed6f1e9bf715569027f7 Mon Sep 17 00:00:00 2001 From: Ira Weiny Date: Sun, 28 Mar 2021 23:54:02 -0700 Subject: fs/ext2: Replace kmap() with kmap_local_page() The k[un]map() calls in ext2_[get|put]_page() are localized to a single thread. kmap_local_page() is more efficient. Replace the kmap/kunmap calls with kmap_local_page()/kunmap_local(). kunmap_local() requires the mapping address so return that address from ext2_get_page() to be used in ext2_put_page(). This works well because many of the callers need the address anyway so it is not bad to return it along with the page. In addition, kmap_local_page()/kunmap_local() require strict nesting rules to be followed. Document the new nesting requirements of ext2_get_page() and ext2_put_page() as well as the relationship between ext2_get_page(), ext2_find_entry(), and ext2_dotdot(). Adjust one ext2_put_page() call site in ext2_rename() to ensure the new nesting requirements are met. Finally, adjust code style for checkpatch. To: Jan Kara Link: https://lore.kernel.org/r/20210329065402.3297092-3-ira.weiny@intel.com Signed-off-by: Ira Weiny Signed-off-by: Jan Kara --- fs/ext2/ext2.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'fs/ext2/ext2.h') diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 3309fb2d327a..ad01ef997926 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -742,14 +742,16 @@ extern int ext2_add_link (struct dentry *, struct inode *); 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 **); +extern struct ext2_dir_entry_2 *ext2_find_entry(struct inode *, const struct qstr *, + struct page **, void **res_page_addr); extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *); extern int ext2_empty_dir (struct inode *); -extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **); -extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); -static inline void ext2_put_page(struct page *page) +extern struct ext2_dir_entry_2 *ext2_dotdot(struct inode *dir, struct page **p, void **pa); +extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, void *, + struct inode *, int); +static inline void ext2_put_page(struct page *page, void *page_addr) { - kunmap(page); + kunmap_local(page_addr); put_page(page); } -- cgit v1.2.3