From patchwork Sat Jun 23 13:06:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 10483623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8BE31604D3 for ; Sat, 23 Jun 2018 13:06:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B03D28DD0 for ; Sat, 23 Jun 2018 13:06:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F62628DE8; Sat, 23 Jun 2018 13:06:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA3528DD0 for ; Sat, 23 Jun 2018 13:06:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbeFWNG2 (ORCPT ); Sat, 23 Jun 2018 09:06:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55502 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751787AbeFWNG1 (ORCPT ); Sat, 23 Jun 2018 09:06:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AE504022905; Sat, 23 Jun 2018 13:06:26 +0000 (UTC) Received: from bfoster (dhcp-41-2.bos.redhat.com [10.18.41.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DA782166BB2; Sat, 23 Jun 2018 13:06:26 +0000 (UTC) Date: Sat, 23 Jun 2018 09:06:24 -0400 From: Brian Foster To: Christoph Hellwig Cc: "Darrick J. Wong" , 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 Message-ID: <20180623130624.GA16691@bfoster> References: <20180615130209.1970-1-hch@lst.de> <20180615130209.1970-24-hch@lst.de> <20180619165211.GD2806@bfoster> <20180620075655.GA2668@lst.de> <20180620143252.GE3241@bfoster> <20180620160803.GA4838@magnolia> <20180620181259.GD4493@bfoster> <20180620190230.GB4838@magnolia> <20180621084646.GA5764@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180621084646.GA5764@lst.de> User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Sat, 23 Jun 2018 13:06:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Sat, 23 Jun 2018 13:06:26 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bfoster@redhat.com' RCPT:'' Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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" /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