diff options
author | Ira Weiny <ira.weiny@intel.com> | 2021-03-29 08:54:02 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2021-03-31 13:10:20 +0200 |
commit | 782b76d7abdf02b12c46ed6f1e9bf715569027f7 (patch) | |
tree | ff01e154cd08335de0da0f1cf8fae5262202f61c /fs/ext2/namei.c | |
parent | ext2: Match up ext2_put_page() with ext2_dotdot() and ext2_find_entry() (diff) | |
download | linux-782b76d7abdf02b12c46ed6f1e9bf715569027f7.tar.xz linux-782b76d7abdf02b12c46ed6f1e9bf715569027f7.zip |
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 <jack@suse.com>
Link: https://lore.kernel.org/r/20210329065402.3297092-3-ira.weiny@intel.com
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext2/namei.c')
-rw-r--r-- | fs/ext2/namei.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 7af9ab3f975e..c45e175bea9c 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c @@ -281,20 +281,21 @@ 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; int err; err = dquot_initialize(dir); if (err) goto out; - de = ext2_find_entry(dir, &dentry->d_name, &page); + de = ext2_find_entry(dir, &dentry->d_name, &page, &page_addr); if (IS_ERR(de)) { err = PTR_ERR(de); goto out; } err = ext2_delete_entry (de, page); - ext2_put_page(page); + ext2_put_page(page, page_addr); if (err) goto out; @@ -329,8 +330,10 @@ static int ext2_rename (struct user_namespace * mnt_userns, 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; @@ -345,7 +348,8 @@ static int ext2_rename (struct user_namespace * mnt_userns, if (err) goto out; - old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page); + old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page, + &old_page_addr); if (IS_ERR(old_de)) { err = PTR_ERR(old_de); goto out; @@ -353,12 +357,13 @@ static int ext2_rename (struct user_namespace * mnt_userns, if (S_ISDIR(old_inode->i_mode)) { err = -EIO; - dir_de = ext2_dotdot(old_inode, &dir_page); + dir_de = ext2_dotdot(old_inode, &dir_page, &dir_page_addr); if (!dir_de) goto out_old; } if (new_inode) { + void *page_addr; struct page *new_page; struct ext2_dir_entry_2 *new_de; @@ -366,13 +371,14 @@ static int ext2_rename (struct user_namespace * mnt_userns, if (dir_de && !ext2_empty_dir (new_inode)) goto out_dir; - new_de = ext2_find_entry(new_dir, &new_dentry->d_name, &new_page); + new_de = ext2_find_entry(new_dir, &new_dentry->d_name, + &new_page, &page_addr); if (IS_ERR(new_de)) { err = PTR_ERR(new_de); goto out_dir; } - ext2_set_link(new_dir, new_de, new_page, old_inode, 1); - ext2_put_page(new_page); + ext2_set_link(new_dir, new_de, new_page, page_addr, old_inode, 1); + ext2_put_page(new_page, page_addr); new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); @@ -392,24 +398,25 @@ static int ext2_rename (struct user_namespace * mnt_userns, old_inode->i_ctime = current_time(old_inode); mark_inode_dirty(old_inode); - ext2_delete_entry (old_de, old_page); - ext2_put_page(old_page); + ext2_delete_entry(old_de, old_page); if (dir_de) { if (old_dir != new_dir) - ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0); + ext2_set_link(old_inode, dir_de, dir_page, + dir_page_addr, new_dir, 0); - ext2_put_page(dir_page); + ext2_put_page(dir_page, dir_page_addr); inode_dec_link_count(old_dir); } - return 0; + ext2_put_page(old_page, old_page_addr); + return 0; out_dir: if (dir_de) - ext2_put_page(dir_page); + ext2_put_page(dir_page, dir_page_addr); out_old: - ext2_put_page(old_page); + ext2_put_page(old_page, old_page_addr); out: return err; } |