All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Andreas Gruenbacher <agruenba@redhat.com>,
	Christoph Hellwig <hch@infradead.org>,
	"Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, cluster-devel@redhat.com,
	linux-ext4@vger.kernel.org
Subject: Re: [PATCH] iomap: Fix direct I/O write consistency check
Date: Thu, 3 Sep 2020 16:12:33 -0500	[thread overview]
Message-ID: <695a418c-ba6d-d3e9-f521-7dfa059764db@sandeen.net> (raw)
In-Reply-To: <20200903165632.1338996-1-agruenba@redhat.com>

On 9/3/20 11:56 AM, Andreas Gruenbacher wrote:
> When a direct I/O write falls back to buffered I/O entirely, dio->size
> will be 0 in iomap_dio_complete.  Function invalidate_inode_pages2_range
> will try to invalidate the rest of the address space.

(Because if ->size == 0 and offset == 0, then invalidating up to (0+0-1) will
invalidate the entire range.)


                err = invalidate_inode_pages2_range(inode->i_mapping,
                                offset >> PAGE_SHIFT,
                                (offset + dio->size - 1) >> PAGE_SHIFT);

so I guess this behavior is unique to writing to a hole at offset 0?

FWIW, this same test yields the same results on ext3 when it falls back to
buffered.

-Eric

> If there are any
> dirty pages in that range, the write will fail and a "Page cache
> invalidation failure on direct I/O" error will be logged.
> 
> On gfs2, this can be reproduced as follows:
> 
>   xfs_io \
>     -c "open -ft foo" -c "pwrite 4k 4k" -c "close" \
>     -c "open -d foo" -c "pwrite 0 4k"
> 
> Fix this by recognizing 0-length writes.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/iomap/direct-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index c1aafb2ab990..c9d6b4eecdb7 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -108,7 +108,7 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio)
>  	 * ->end_io() when necessary, otherwise a racing buffer read would cache
>  	 * zeros from unwritten extents.
>  	 */
> -	if (!dio->error &&
> +	if (!dio->error && dio->size &&
>  	    (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {
>  		int err;
>  		err = invalidate_inode_pages2_range(inode->i_mapping,
> 

WARNING: multiple messages have this Message-ID (diff)
From: Eric Sandeen <sandeen@sandeen.net>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] iomap: Fix direct I/O write consistency check
Date: Thu, 3 Sep 2020 16:12:33 -0500	[thread overview]
Message-ID: <695a418c-ba6d-d3e9-f521-7dfa059764db@sandeen.net> (raw)
In-Reply-To: <20200903165632.1338996-1-agruenba@redhat.com>

On 9/3/20 11:56 AM, Andreas Gruenbacher wrote:
> When a direct I/O write falls back to buffered I/O entirely, dio->size
> will be 0 in iomap_dio_complete.  Function invalidate_inode_pages2_range
> will try to invalidate the rest of the address space.

(Because if ->size == 0 and offset == 0, then invalidating up to (0+0-1) will
invalidate the entire range.)


                err = invalidate_inode_pages2_range(inode->i_mapping,
                                offset >> PAGE_SHIFT,
                                (offset + dio->size - 1) >> PAGE_SHIFT);

so I guess this behavior is unique to writing to a hole at offset 0?

FWIW, this same test yields the same results on ext3 when it falls back to
buffered.

-Eric

> If there are any
> dirty pages in that range, the write will fail and a "Page cache
> invalidation failure on direct I/O" error will be logged.
> 
> On gfs2, this can be reproduced as follows:
> 
>   xfs_io \
>     -c "open -ft foo" -c "pwrite 4k 4k" -c "close" \
>     -c "open -d foo" -c "pwrite 0 4k"
> 
> Fix this by recognizing 0-length writes.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  fs/iomap/direct-io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index c1aafb2ab990..c9d6b4eecdb7 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -108,7 +108,7 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio)
>  	 * ->end_io() when necessary, otherwise a racing buffer read would cache
>  	 * zeros from unwritten extents.
>  	 */
> -	if (!dio->error &&
> +	if (!dio->error && dio->size &&
>  	    (dio->flags & IOMAP_DIO_WRITE) && inode->i_mapping->nrpages) {
>  		int err;
>  		err = invalidate_inode_pages2_range(inode->i_mapping,
> 




  reply	other threads:[~2020-09-03 21:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-03 16:56 [PATCH] iomap: Fix direct I/O write consistency check Andreas Gruenbacher
2020-09-03 16:56 ` [Cluster-devel] " Andreas Gruenbacher
2020-09-03 21:12 ` Eric Sandeen [this message]
2020-09-03 21:12   ` Eric Sandeen
2020-09-03 21:47   ` Andreas Gruenbacher
2020-09-03 21:47     ` [Cluster-devel] " Andreas Gruenbacher
2020-09-07  7:07 ` Christoph Hellwig
2020-09-07  7:07   ` [Cluster-devel] " Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=695a418c-ba6d-d3e9-f521-7dfa059764db@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=agruenba@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@infradead.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.