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: <264614fc4fa08df2b0899da1cd38bb07150cd7f3.camel@hammerspace.com>
Date:   Sun, 24 May 2020 14:05:31 +0000
From:   Trond Myklebust <trondmy@...merspace.com>
To:     "axboe@...nel.dk" <axboe@...nel.dk>,
        "io-uring@...r.kernel.org" <io-uring@...r.kernel.org>
CC:     "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 05/12] mm: support async buffered reads in
 generic_file_buffered_read()

On Sat, 2020-05-23 at 12:57 -0600, Jens Axboe wrote:
> Use the async page locking infrastructure, if IOCB_WAITQ is set in
> the
> passed in iocb. The caller must expect an -EIOCBQUEUED return value,
> which means that IO is started but not done yet. This is similar to
> how
> O_DIRECT signals the same operation. Once the callback is received by
> the caller for IO completion, the caller must retry the operation.
> 
> Signed-off-by: Jens Axboe <axboe@...nel.dk>
> ---
>  mm/filemap.c | 33 ++++++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index c746541b1d49..a3b86c9acdc8 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -1219,6 +1219,14 @@ static int __wait_on_page_locked_async(struct
> page *page,
>  	return ret;
>  }
>  
> +static int wait_on_page_locked_async(struct page *page,
> +				     struct wait_page_queue *wait)
> +{
> +	if (!PageLocked(page))
> +		return 0;
> +	return __wait_on_page_locked_async(compound_head(page), wait,
> false);
> +}
> +
>  /**
>   * put_and_wait_on_page_locked - Drop a reference and wait for it to
> be unlocked
>   * @page: The page to wait for.
> @@ -2058,17 +2066,25 @@ static ssize_t
> generic_file_buffered_read(struct kiocb *iocb,
>  					index, last_index - index);
>  		}
>  		if (!PageUptodate(page)) {
> -			if (iocb->ki_flags & IOCB_NOWAIT) {
> -				put_page(page);
> -				goto would_block;
> -			}
> -
>  			/*
>  			 * See comment in do_read_cache_page on why
>  			 * wait_on_page_locked is used to avoid
> unnecessarily
>  			 * serialisations and why it's safe.
>  			 */
> -			error = wait_on_page_locked_killable(page);
> +			if (iocb->ki_flags & IOCB_WAITQ) {
> +				if (written) {
> +					put_page(page);
> +					goto out;
> +				}
> +				error = wait_on_page_locked_async(page,
> +								iocb-
> >private);

If it is being used in 'generic_file_buffered_read()' as storage for a
wait queue, then it is hard to consider this a 'private' field.

Perhaps either rename and add type checking, or else add a separate
field altogether to struct kiocb?

> +			} else {
> +				if (iocb->ki_flags & IOCB_NOWAIT) {
> +					put_page(page);
> +					goto would_block;
> +				}
> +				error =
> wait_on_page_locked_killable(page);
> +			}
>  			if (unlikely(error))
>  				goto readpage_error;
>  			if (PageUptodate(page))
> @@ -2156,7 +2172,10 @@ static ssize_t
> generic_file_buffered_read(struct kiocb *iocb,
>  
>  page_not_up_to_date:
>  		/* Get exclusive access to the page ... */
> -		error = lock_page_killable(page);
> +		if (iocb->ki_flags & IOCB_WAITQ)
> +			error = lock_page_async(page, iocb->private);
> +		else
> +			error = lock_page_killable(page);
>  		if (unlikely(error))
>  			goto readpage_error;
>  
-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@...merspace.com


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ