lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240412143749.3tryph4khox3euef@quack3>
Date: Fri, 12 Apr 2024 16:37:49 +0200
From: Jan Kara <jack@...e.cz>
To: Alistair Popple <apopple@...dia.com>
Cc: linux-mm@...ck.org, david@...morbit.com, dan.j.williams@...el.com,
	jhubbard@...dia.com, rcampbell@...dia.com, willy@...radead.org,
	jgg@...dia.com, linux-fsdevel@...r.kernel.org, jack@...e.cz,
	djwong@...nel.org, hch@....de, david@...hat.com,
	ruansy.fnst@...itsu.com, nvdimm@...ts.linux.dev,
	linux-xfs@...r.kernel.org, linux-ext4@...r.kernel.org,
	jglisse@...hat.com
Subject: Re: [RFC 05/10] fs/dax: Refactor wait for dax idle page

On Thu 11-04-24 10:57:26, Alistair Popple wrote:
> A FS DAX page is considered idle when its refcount drops to one. This
> is currently open-coded in all file systems supporting FS DAX. Move
> the idle detection to a common function to make future changes easier.
> 
> Signed-off-by: Alistair Popple <apopple@...dia.com>

Good cleanup. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  fs/ext4/inode.c     |  5 +----
>  fs/fuse/dax.c       |  4 +---
>  fs/xfs/xfs_file.c   |  4 +---
>  include/linux/dax.h | 11 +++++++++++
>  4 files changed, 14 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 4ce35f1..e9cef7d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3868,10 +3868,7 @@ int ext4_break_layouts(struct inode *inode)
>  		if (!page)
>  			return 0;
>  
> -		error = ___wait_var_event(&page->_refcount,
> -				atomic_read(&page->_refcount) == 1,
> -				TASK_INTERRUPTIBLE, 0, 0,
> -				ext4_wait_dax_page(inode));
> +		error = dax_wait_page_idle(page, ext4_wait_dax_page, inode);
>  	} while (error == 0);
>  
>  	return error;
> diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
> index 23904a6..8a62483 100644
> --- a/fs/fuse/dax.c
> +++ b/fs/fuse/dax.c
> @@ -676,9 +676,7 @@ static int __fuse_dax_break_layouts(struct inode *inode, bool *retry,
>  		return 0;
>  
>  	*retry = true;
> -	return ___wait_var_event(&page->_refcount,
> -			atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE,
> -			0, 0, fuse_wait_dax_page(inode));
> +	return dax_wait_page_idle(page, fuse_wait_dax_page, inode);
>  }
>  
>  /* dmap_end == 0 leads to unmapping of whole file */
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 2037002..099cd70 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -849,9 +849,7 @@ xfs_break_dax_layouts(
>  		return 0;
>  
>  	*retry = true;
> -	return ___wait_var_event(&page->_refcount,
> -			atomic_read(&page->_refcount) == 1, TASK_INTERRUPTIBLE,
> -			0, 0, xfs_wait_dax_page(inode));
> +	return dax_wait_page_idle(page, xfs_wait_dax_page, inode);
>  }
>  
>  int
> diff --git a/include/linux/dax.h b/include/linux/dax.h
> index 22cd990..bced4d4 100644
> --- a/include/linux/dax.h
> +++ b/include/linux/dax.h
> @@ -212,6 +212,17 @@ int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero,
>  int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
>  		const struct iomap_ops *ops);
>  
> +static inline int dax_wait_page_idle(struct page *page,
> +				void (cb)(struct inode *),
> +				struct inode *inode)
> +{
> +	int ret;
> +
> +	ret = ___wait_var_event(page, page_ref_count(page) == 1,
> +				TASK_INTERRUPTIBLE, 0, 0, cb(inode));
> +	return ret;
> +}
> +
>  #if IS_ENABLED(CONFIG_DAX)
>  int dax_read_lock(void);
>  void dax_read_unlock(int id);
> -- 
> git-series 0.9.1
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ