Re: [PATCH v2] fs/ufs: Replace kmap() with kmap_local_page()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On lunedì 16 maggio 2022 01:53:49 CEST Ira Weiny wrote:
> On Mon, May 09, 2022 at 09:12:07AM +0200, Fabio M. De Francesco wrote:
> > The use of kmap() is being deprecated in favor of kmap_local_page(). 
With
> > kmap_local_page(), the mapping is thread-local, CPU-local and not 
globally
> > visible.
> > 
> > The usage of kmap_local_page() in fs/ufs is thread-local, therefore 
replace
> > kmap() / kunmap() calls with kmap_local_page() / kunmap_local().
> > 
> > kunmap_local() requires the mapping address, so return that address 
from
> > ufs_get_page() to be used in ufs_put_page().
> > 
> > These changes are essentially ported from fs/ext2 and relie largely on
> > commit 782b76d7abdf ("fs/ext2: Replace kmap() with kmap_local_page()").
> > 
> > Suggested-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> > Signed-off-by: Fabio M. De Francesco <fmdefrancesco@xxxxxxxxx>
> > ---
> > 
> > v1 -> v2: Correct some style's issues reported by checkpatch.pl.
> > 	  Remove "inline" compiler directive from fs/ufs/ufs.h,
> > 	  Reported-by: kernel test robot <lkp@xxxxxxxxx>
> > 
> >  fs/ufs/dir.c   | 116 +++++++++++++++++++++++++++++++------------------
> >  fs/ufs/namei.c |  38 ++++++++--------
> >  fs/ufs/ufs.h   |  12 +++--
> >  3 files changed, 102 insertions(+), 64 deletions(-)
> > 
> >
> > [snip]
> >   
> > @@ -250,27 +251,31 @@ static int ufs_rename(struct user_namespace 
*mnt_userns, struct inode *old_dir,
> >  	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 ufs_dir_entry * dir_de = NULL;
> >  	struct page *old_page;
> > +	void *old_page_addr;
> >  	struct ufs_dir_entry *old_de;
> >  	int err = -ENOENT;
> >  
> >  	if (flags & ~RENAME_NOREPLACE)
> >  		return -EINVAL;
> >  
> > -	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page);
> > +	old_de = ufs_find_entry(old_dir, &old_dentry->d_name, &old_page,
> > +				&old_page_addr);
> >  	if (!old_de)
> >  		goto out;
> >  
> >  	if (S_ISDIR(old_inode->i_mode)) {
> >  		err = -EIO;
> > -		dir_de = ufs_dotdot(old_inode, &dir_page);
> > +		dir_de = ufs_dotdot(old_inode, &dir_page, 
&dir_page_addr);
> >  		if (!dir_de)
> >  			goto out_old;
> >  	}
> >  
> >  	if (new_inode) {
> >  		struct page *new_page;
> > +		void *page_addr;
> 
> Nit:
> 
> It might be good to make this new_page_addr to keep it straight with the 
other
> pages mapped in this function.
> 

Yes, it should be "new_page_addr" for consistency. I'm going to rename this 
variable and send v3.

>
> Regardless:
> 
> Reviewed-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> 

Thanks!

Fabio

> >  		struct ufs_dir_entry *new_de;
> >  
> >  		err = -ENOTEMPTY;
> > @@ -278,10 +283,11 @@ static int ufs_rename(struct user_namespace 
*mnt_userns, struct inode *old_dir,
> >  			goto out_dir;
> >  
> >  		err = -ENOENT;
> > -		new_de = ufs_find_entry(new_dir, &new_dentry->d_name, 
&new_page);
> > +		new_de = ufs_find_entry(new_dir, &new_dentry->d_name, 
&new_page,
> > +					&page_addr);
> >  		if (!new_de)
> >  			goto out_dir;
> > -		ufs_set_link(new_dir, new_de, new_page, old_inode, 1);
> > +		ufs_set_link(new_dir, new_de, new_page, page_addr, 
old_inode, 1);
> >  		new_inode->i_ctime = current_time(new_inode);
> >  		if (dir_de)
> >  			drop_nlink(new_inode);
> > @@ -300,29 +306,25 @@ static int ufs_rename(struct user_namespace 
*mnt_userns, struct inode *old_dir,
> >  	 */
> >  	old_inode->i_ctime = current_time(old_inode);
> >  
> > -	ufs_delete_entry(old_dir, old_de, old_page);
> > +	ufs_delete_entry(old_dir, old_de, old_page, old_page_addr);
> >  	mark_inode_dirty(old_inode);
> >  
> >  	if (dir_de) {
> >  		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_set_link(old_inode, dir_de, dir_page,
> > +				     dir_page_addr, new_dir, 0);
> > +		else
> > +			ufs_put_page(dir_page, dir_page_addr);
> >  		inode_dec_link_count(old_dir);
> >  	}
> >  	return 0;
> >  
> >  
> >  out_dir:
> > -	if (dir_de) {
> > -		kunmap(dir_page);
> > -		put_page(dir_page);
> > -	}
> > +	if (dir_de)
> > +		ufs_put_page(dir_page, dir_page_addr);
> >  out_old:
> > -	kunmap(old_page);
> > -	put_page(old_page);
> > +	ufs_put_page(old_page, old_page_addr);
> >  out:
> >  	return err;
> >  }
> >
> > [snip]
> >






[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux