From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:60656 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729187AbfB0Blx (ORCPT ); Tue, 26 Feb 2019 20:41:53 -0500 Date: Wed, 27 Feb 2019 09:41:34 +0800 From: Ming Lei Subject: Re: [PATCH] xfs: allocate sector sized IO buffer via page_frag_alloc Message-ID: <20190227014133.GB16802@ming.t460p> References: <20190226093302.GA24879@ming.t460p> <20190226121209.GC11592@bombadil.infradead.org> <20190226123545.GA6163@ming.t460p> <20190226130230.GD11592@bombadil.infradead.org> <20190226134247.GA30942@ming.t460p> <20190226140440.GF11592@bombadil.infradead.org> <20190226161433.GH21626@magnolia> <20190226161912.GG11592@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190226161912.GG11592@bombadil.infradead.org> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: Matthew Wilcox Cc: "Darrick J. Wong" , Ming Lei , Vlastimil Babka , Dave Chinner , "open list:XFS FILESYSTEM" , Jens Axboe , Vitaly Kuznetsov , Dave Chinner , Christoph Hellwig , Alexander Duyck , Aaron Lu , Christopher Lameter , Linux FS Devel , linux-mm , linux-block , Pekka Enberg , David Rientjes , Joonsoo Kim On Tue, Feb 26, 2019 at 08:19:12AM -0800, Matthew Wilcox wrote: > On Tue, Feb 26, 2019 at 08:14:33AM -0800, Darrick J. Wong wrote: > > On Tue, Feb 26, 2019 at 06:04:40AM -0800, Matthew Wilcox wrote: > > > On Tue, Feb 26, 2019 at 09:42:48PM +0800, Ming Lei wrote: > > > > On Tue, Feb 26, 2019 at 05:02:30AM -0800, Matthew Wilcox wrote: > > > > > Wait, we're imposing a ridiculous amount of complexity on XFS for no > > > > > reason at all? We should just change this to 512-byte alignment. Tying > > > > > it to the blocksize of the device never made any sense. > > > > > > > > OK, that is fine since we can fallback to buffered IO for loop in case of > > > > unaligned dio. > > > > > > > > Then something like the following patch should work for all fs, could > > > > anyone comment on this approach? > > > > > > That's not even close to what I meant. > > > > > > diff --git a/fs/direct-io.c b/fs/direct-io.c > > > index ec2fb6fe6d37..dee1fc47a7fc 100644 > > > --- a/fs/direct-io.c > > > +++ b/fs/direct-io.c > > > @@ -1185,18 +1185,20 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, > > > > Wait a minute, are you all saying that /directio/ is broken on XFS too?? > > XFS doesn't use blockdev_direct_IO anymore. > > > > I thought we were talking about alignment of XFS metadata buffers > > (xfs_buf.c), which is a very different topic. > > > > As I understand the problem, in non-debug mode the slab caches give > > xfs_buf chunks of memory that are aligned well enough to work, but in > > debug mode the slabs allocate slightly more bytes to carry debug > > information which pushes the returned address up slightly, thus breaking > > the alignment requirements. > > > > So why can't we just move the debug info to the end of the object? If > > our 512 byte allocation turns into a (512 + a few more) bytes we'll end > > up using 1024 bytes on the allocation regardless, so it shouldn't matter > > to put the debug info at offset 512. If the reason is fear that kernel > > code will scribble off the end of the object, then return (*obj + 512). > > Maybe you all have already covered this, though? > > I don't know _what_ Ming Lei is saying. I thought the problem was > with slab redzones, which need to be before and after each object, > but apparently the problem is with KASAN as well. I have mentioned several times that it is triggered on xfs over loop/dio, however it may be addressed by falling back to buffered IO in case unaligned buffer. Please see lo_rw_aio(). Thanks, Ming