linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 23/24] iomap: add support for sub-pagesize buffered I/O without buffer heads
Date: Sat, 23 Jun 2018 09:06:24 -0400	[thread overview]
Message-ID: <20180623130624.GA16691@bfoster> (raw)
In-Reply-To: <20180621084646.GA5764@lst.de>

On Thu, Jun 21, 2018 at 10:46:46AM +0200, Christoph Hellwig wrote:
> On Wed, Jun 20, 2018 at 12:02:30PM -0700, Darrick J. Wong wrote:
> > I managed to cut the testcase down to a nine-line fsx script and so
> > turned it into a fstests regression case.  It seems to reproduce 100% on
> > scsi disks and doesn't at all on pmem.
> > 
> > Note that changing the second to last line of the fsxops script to call
> > punch_hole instead of zero_range triggers it too.
> > 
> > I've also narrowed it down to something going wrong w.r.t. handling the
> > page cache somewhere under xfs_free_file_space.
> 
> So far this doesn't reproduce for me with or without the iomap code.
> But I've only run it a few times in a VM on my laptop.

After playing around a bit more, I observed that this became much harder
to reproduce after creating a new fs or using a largish fs. I think it's
hit or miss based on the content of free space in the filesystem. The
appended diff applied on top of Darrick's recent xfstests test[1] makes
this reproduce reliably for me (with -bsize=1k).

The problem, I think, is essentially that readpage doesn't zero out
real/allocated post-eof blocks on the current page. For example, once
this test runs at least once, the following command is all that is
required to observe the difference in behavior between the buffer head
path and the new iomap path:

  xfs_io -c "mmap 0x21000 0x1000" -c "mread -v 0x21c00 0x100" <scratch_mnt>/a

The former returns zeroes for the post-eof (i_size == 0x21a20) portion
of the page due to the (iblock < lblock) check in
block_read_full_page(). If the block is post eof, get_block() isn't
called, the bh is left unmapped and the portion of the page is
explicitly zeroed in the same loop. The iomap code appears to read and
expose whatever is on disk if the block is allocated. I'm guessing we at
least need to consider doing something similar in iomap_readpage_actor()
(or perhaps somewhere in that path that also covers the write path)..?
I'm not sure it's sufficient to rely on writeback to zero the page and
otherwise let it expose garbage until that point.

Brian

[1] https://marc.info/?l=linux-xfs&m=152960597620340&w=2

--- 8< ---

diff --git a/tests/generic/708 b/tests/generic/708
index d380053f..355cc6b1 100755
--- a/tests/generic/708
+++ b/tests/generic/708
@@ -30,19 +30,17 @@ _require_scratch
 
 rm -f $seqres.full
 
-_scratch_mkfs >>$seqres.full 2>&1
+_scratch_mkfs_sized $((1024 * 1024 * 100)) >>$seqres.full 2>&1
 _scratch_mount
 
+$XFS_IO_PROG -fc "pwrite 0 100m" -c fsync $SCRATCH_MNT/file >>$seqres.full 2>&1
+rm -f $SCRATCH_MNT/file
+
 cat >> $tmp.fsxops << ENDL
-fallocate 0x77e2 0x5f06 0x269a2 keep_size
-mapwrite 0x2e7fc 0x42ba 0x3f989
-write 0x67a9 0x714e 0x3f989
-write 0x39f96 0x185a 0x3f989
-collapse_range 0x36000 0x8000 0x3f989
-mapread 0x74c0 0x1bb3 0x3e2d0
-truncate 0x0 0x8aa2 0x3e2d0
-zero_range 0x1265 0x783d 0x8aa2
-mapread 0x7bd8 0xeca 0x8aa2
+truncate 0x0 0x1f0d6 0x380e1
+write 0x1ad87 0x6c99 0x180d6
+zero_range 0x14426 0xd3aa 0x21a20 keep_size
+mapread 0x1f69a 0x2386 0x21a20
 ENDL
 
 victim=$SCRATCH_MNT/a

  reply	other threads:[~2018-06-23 13:06 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15 13:01 stop using buffer heads in xfs v6 Christoph Hellwig
2018-06-15 13:01 ` [PATCH 01/24] iomap: add an iomap-based readpage and readpages implementation Christoph Hellwig
2018-06-29 14:44   ` [PATCH] iomap: Add inline data support to iomap_readpage_actor Andreas Gruenbacher
2018-07-01  6:21     ` Christoph Hellwig
2018-07-01 21:43       ` Andreas Gruenbacher
2018-07-02 12:52         ` Christoph Hellwig
2018-07-02 15:05           ` Andreas Gruenbacher
2018-06-15 13:01 ` [PATCH 02/24] xfs: use iomap for blocksize == PAGE_SIZE readpage and readpages Christoph Hellwig
2018-06-15 13:01 ` [PATCH 03/24] iomap: add initial support for writes without buffer heads Christoph Hellwig
2018-06-15 13:01 ` [PATCH 04/24] xfs: simplify xfs_bmap_punch_delalloc_range Christoph Hellwig
2018-06-15 13:01 ` [PATCH 05/24] xfs: simplify xfs_aops_discard_page Christoph Hellwig
2018-06-15 13:01 ` [PATCH 06/24] xfs: move locking into xfs_bmap_punch_delalloc_range Christoph Hellwig
2018-06-19  5:26   ` Darrick J. Wong
2018-06-15 13:01 ` [PATCH 07/24] xfs: do not set the page uptodate in xfs_writepage_map Christoph Hellwig
2018-06-15 13:01 ` [PATCH 08/24] xfs: don't clear imap_valid for a non-uptodate buffers Christoph Hellwig
2018-06-15 13:01 ` [PATCH 09/24] xfs: don't use XFS_BMAPI_IGSTATE in xfs_map_blocks Christoph Hellwig
2018-06-19  5:27   ` Darrick J. Wong
2018-06-15 13:01 ` [PATCH 10/24] xfs: remove xfs_reflink_trim_irec_to_next_cow Christoph Hellwig
2018-06-19  5:30   ` Darrick J. Wong
2018-06-15 13:01 ` [PATCH 11/24] xfs: remove xfs_map_cow Christoph Hellwig
2018-06-18 17:38   ` Brian Foster
2018-06-19  5:35     ` Darrick J. Wong
2018-06-19 16:53       ` Christoph Hellwig
2018-06-20  0:37         ` Darrick J. Wong
2018-06-15 13:01 ` [PATCH 12/24] xfs: rename the offset variable in xfs_writepage_map Christoph Hellwig
2018-06-19  5:37   ` Darrick J. Wong
2018-06-15 13:01 ` [PATCH 13/24] xfs: make xfs_writepage_map extent map centric Christoph Hellwig
2018-06-18 17:38   ` Brian Foster
2018-06-19  5:43   ` Darrick J. Wong
2018-06-19 16:52     ` Christoph Hellwig
2018-06-15 13:01 ` [PATCH 14/24] xfs: remove the now unused XFS_BMAPI_IGSTATE flag Christoph Hellwig
2018-06-15 13:02 ` [PATCH 15/24] xfs: remove xfs_reflink_find_cow_mapping Christoph Hellwig
2018-06-15 13:02 ` [PATCH 16/24] xfs: simplify xfs_map_blocks by using xfs_iext_lookup_extent directly Christoph Hellwig
2018-06-15 13:02 ` [PATCH 17/24] xfs: remove the imap_valid flag Christoph Hellwig
2018-06-15 13:02 ` [PATCH 18/24] xfs: don't look at buffer heads in xfs_add_to_ioend Christoph Hellwig
2018-06-15 13:02 ` [PATCH 19/24] xfs: move all writeback buffer_head manipulation into xfs_map_at_offset Christoph Hellwig
2018-06-15 13:02 ` [PATCH 20/24] xfs: remove xfs_start_page_writeback Christoph Hellwig
2018-06-15 13:02 ` [PATCH 21/24] xfs: refactor the tail of xfs_writepage_map Christoph Hellwig
2018-06-15 13:02 ` [PATCH 22/24] xfs: allow writeback on pages without buffer heads Christoph Hellwig
2018-06-15 13:02 ` [PATCH 23/24] iomap: add support for sub-pagesize buffered I/O " Christoph Hellwig
2018-06-19 16:52   ` Brian Foster
2018-06-20  7:56     ` Christoph Hellwig
2018-06-20 14:32       ` Brian Foster
2018-06-20 16:08         ` Darrick J. Wong
2018-06-20 18:12           ` Brian Foster
2018-06-20 19:02             ` Darrick J. Wong
2018-06-21  8:46               ` Christoph Hellwig
2018-06-23 13:06                 ` Brian Foster [this message]
2018-06-29 15:59                   ` Christoph Hellwig
2018-07-02 12:50                   ` Christoph Hellwig
2018-07-02 18:16                     ` Brian Foster
2018-06-21  7:53         ` Christoph Hellwig
2018-06-15 13:02 ` [PATCH 24/24] xfs: add support for sub-pagesize writeback without buffer_heads Christoph Hellwig
2018-06-19  6:15   ` Darrick J. Wong

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=20180623130624.GA16691@bfoster \
    --to=bfoster@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).