diff mbox series

[v5,3/4] fs/ufs: Use ufs_put_page() in ufs_rename()

Message ID 20221229225100.22141-4-fmdefrancesco@gmail.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series fs/ufs: Replace kmap() with kmap_local_page | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Fabio M. De Francesco Dec. 29, 2022, 10:50 p.m. UTC
Use the ufs_put_page() helper in ufs_rename() instead of open-coding three
kunmap() + put_page().

Cc: Al Viro <viro@zeniv.linux.org.uk>
Suggested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
---
 fs/ufs/dir.c   | 2 +-
 fs/ufs/namei.c | 9 +++------
 fs/ufs/ufs.h   | 1 +
 3 files changed, 5 insertions(+), 7 deletions(-)

Comments

Ira Weiny Dec. 30, 2022, 12:50 a.m. UTC | #1
On Thu, Dec 29, 2022 at 11:50:59PM +0100, Fabio M. De Francesco wrote:
> Use the ufs_put_page() helper in ufs_rename() instead of open-coding three
> kunmap() + put_page().
> 
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Suggested-by: Ira Weiny <ira.weiny@intel.com>

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
>  fs/ufs/dir.c   | 2 +-
>  fs/ufs/namei.c | 9 +++------
>  fs/ufs/ufs.h   | 1 +
>  3 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
> index ae3b20354a28..0bfd563ab0c2 100644
> --- a/fs/ufs/dir.c
> +++ b/fs/ufs/dir.c
> @@ -61,7 +61,7 @@ static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len)
>  	return err;
>  }
>  
> -static inline void ufs_put_page(struct page *page)
> +inline void ufs_put_page(struct page *page)
>  {
>  	kunmap(page);
>  	put_page(page);
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index 29d5a0e0c8f0..486b0f2e8b7a 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -307,8 +307,7 @@ static int ufs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
>  		if (old_dir != new_dir)
>  			ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0);
>  		else {
> -			kunmap(dir_page);
> -			put_page(dir_page);
> +			ufs_put_page(dir_page);
>  		}
>  		inode_dec_link_count(old_dir);
>  	}
> @@ -317,12 +316,10 @@ static int ufs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
>  
>  out_dir:
>  	if (dir_de) {
> -		kunmap(dir_page);
> -		put_page(dir_page);
> +		ufs_put_page(dir_page);
>  	}
>  out_old:
> -	kunmap(old_page);
> -	put_page(old_page);
> +	ufs_put_page(old_page);
>  out:
>  	return err;
>  }
> diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
> index 550f7c5a3636..f7ba8df25d03 100644
> --- a/fs/ufs/ufs.h
> +++ b/fs/ufs/ufs.h
> @@ -98,6 +98,7 @@ extern struct ufs_cg_private_info * ufs_load_cylinder (struct super_block *, uns
>  extern void ufs_put_cylinder (struct super_block *, unsigned);
>  
>  /* dir.c */
> +extern void ufs_put_page(struct page *page);
>  extern const struct inode_operations ufs_dir_inode_operations;
>  extern int ufs_add_link (struct dentry *, struct inode *);
>  extern ino_t ufs_inode_by_name(struct inode *, const struct qstr *);
> -- 
> 2.39.0
>
diff mbox series

Patch

diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
index ae3b20354a28..0bfd563ab0c2 100644
--- a/fs/ufs/dir.c
+++ b/fs/ufs/dir.c
@@ -61,7 +61,7 @@  static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len)
 	return err;
 }
 
-static inline void ufs_put_page(struct page *page)
+inline void ufs_put_page(struct page *page)
 {
 	kunmap(page);
 	put_page(page);
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 29d5a0e0c8f0..486b0f2e8b7a 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -307,8 +307,7 @@  static int ufs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
 		if (old_dir != new_dir)
 			ufs_set_link(old_inode, dir_de, dir_page, new_dir, 0);
 		else {
-			kunmap(dir_page);
-			put_page(dir_page);
+			ufs_put_page(dir_page);
 		}
 		inode_dec_link_count(old_dir);
 	}
@@ -317,12 +316,10 @@  static int ufs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
 
 out_dir:
 	if (dir_de) {
-		kunmap(dir_page);
-		put_page(dir_page);
+		ufs_put_page(dir_page);
 	}
 out_old:
-	kunmap(old_page);
-	put_page(old_page);
+	ufs_put_page(old_page);
 out:
 	return err;
 }
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 550f7c5a3636..f7ba8df25d03 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -98,6 +98,7 @@  extern struct ufs_cg_private_info * ufs_load_cylinder (struct super_block *, uns
 extern void ufs_put_cylinder (struct super_block *, unsigned);
 
 /* dir.c */
+extern void ufs_put_page(struct page *page);
 extern const struct inode_operations ufs_dir_inode_operations;
 extern int ufs_add_link (struct dentry *, struct inode *);
 extern ino_t ufs_inode_by_name(struct inode *, const struct qstr *);