From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E6E8C433DF for ; Tue, 25 Aug 2020 00:27:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 676AD2074D for ; Tue, 25 Aug 2020 00:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726356AbgHYA1m (ORCPT ); Mon, 24 Aug 2020 20:27:42 -0400 Received: from mail110.syd.optusnet.com.au ([211.29.132.97]:47262 "EHLO mail110.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbgHYA1k (ORCPT ); Mon, 24 Aug 2020 20:27:40 -0400 Received: from dread.disaster.area (pa49-181-146-199.pa.nsw.optusnet.com.au [49.181.146.199]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id A92681092F9; Tue, 25 Aug 2020 10:27:37 +1000 (AEST) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1kAMoJ-0005mv-WC; Tue, 25 Aug 2020 10:27:36 +1000 Date: Tue, 25 Aug 2020 10:27:35 +1000 From: Dave Chinner To: "Matthew Wilcox (Oracle)" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Darrick J . Wong" , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 9/9] iomap: Change calling convention for zeroing Message-ID: <20200825002735.GI12131@dread.disaster.area> References: <20200824145511.10500-1-willy@infradead.org> <20200824145511.10500-10-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200824145511.10500-10-willy@infradead.org> X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.3 cv=QIgWuTDL c=1 sm=1 tr=0 cx=a_idp_d a=GorAHYkI+xOargNMzM6qxQ==:117 a=GorAHYkI+xOargNMzM6qxQ==:17 a=kj9zAlcOel0A:10 a=y4yBn9ojGxQA:10 a=JfrnYn6hAAAA:8 a=7-415B0cAAAA:8 a=Yagp9b6qcfzQHBwh10oA:9 a=afcYxvJ0ROV6oatP:21 a=wHxIqCD_xUrfLMnn:21 a=CjuIK1q_8ugA:10 a=1CNFftbPRP8L7MoqJWF3:22 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On Mon, Aug 24, 2020 at 03:55:10PM +0100, Matthew Wilcox (Oracle) wrote: > Pass the full length to iomap_zero() and dax_iomap_zero(), and have > them return how many bytes they actually handled. This is preparatory > work for handling THP, although it looks like DAX could actually take > advantage of it if there's a larger contiguous area. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > fs/dax.c | 13 ++++++------- > fs/iomap/buffered-io.c | 33 +++++++++++++++------------------ > include/linux/dax.h | 3 +-- > 3 files changed, 22 insertions(+), 27 deletions(-) > > diff --git a/fs/dax.c b/fs/dax.c > index 95341af1a966..f2b912cb034e 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1037,18 +1037,18 @@ static vm_fault_t dax_load_hole(struct xa_state *xas, > return ret; > } > > -int dax_iomap_zero(loff_t pos, unsigned offset, unsigned size, > - struct iomap *iomap) > +loff_t dax_iomap_zero(loff_t pos, u64 length, struct iomap *iomap) > { > sector_t sector = iomap_sector(iomap, pos & PAGE_MASK); > pgoff_t pgoff; > long rc, id; > void *kaddr; > bool page_aligned = false; > - > + unsigned offset = offset_in_page(pos); > + unsigned size = min_t(u64, PAGE_SIZE - offset, length); > > if (IS_ALIGNED(sector << SECTOR_SHIFT, PAGE_SIZE) && > - IS_ALIGNED(size, PAGE_SIZE)) > + (size == PAGE_SIZE)) > page_aligned = true; > > rc = bdev_dax_pgoff(iomap->bdev, sector, PAGE_SIZE, &pgoff); > @@ -1058,8 +1058,7 @@ int dax_iomap_zero(loff_t pos, unsigned offset, unsigned size, > id = dax_read_lock(); > > if (page_aligned) > - rc = dax_zero_page_range(iomap->dax_dev, pgoff, > - size >> PAGE_SHIFT); > + rc = dax_zero_page_range(iomap->dax_dev, pgoff, 1); > else > rc = dax_direct_access(iomap->dax_dev, pgoff, 1, &kaddr, NULL); > if (rc < 0) { > @@ -1072,7 +1071,7 @@ int dax_iomap_zero(loff_t pos, unsigned offset, unsigned size, > dax_flush(iomap->dax_dev, kaddr + offset, size); > } > dax_read_unlock(id); > - return 0; > + return size; > } > > static loff_t > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index 7f618ab4b11e..2dba054095e8 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -901,11 +901,13 @@ iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len, > } > EXPORT_SYMBOL_GPL(iomap_file_unshare); > > -static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset, > - unsigned bytes, struct iomap *iomap, struct iomap *srcmap) > +static loff_t iomap_zero(struct inode *inode, loff_t pos, u64 length, > + struct iomap *iomap, struct iomap *srcmap) While you are touching this, please convert it back to: static loff_t iomap_zero(struct inode *inode, loff_t pos, u64 length, struct iomap *iomap, struct iomap *srcmap) > { > struct page *page; > int status; > + unsigned offset = offset_in_page(pos); > + unsigned bytes = min_t(u64, PAGE_SIZE - offset, length); > > status = iomap_write_begin(inode, pos, bytes, 0, &page, iomap, srcmap); > if (status) > @@ -917,38 +919,33 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset, > return iomap_write_end(inode, pos, bytes, bytes, page, iomap, srcmap); > } > > -static loff_t > -iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, > - void *data, struct iomap *iomap, struct iomap *srcmap) > +static loff_t iomap_zero_range_actor(struct inode *inode, loff_t pos, > + loff_t length, void *data, struct iomap *iomap, > + struct iomap *srcmap) And leave this as it was formatted. /me missed this when iomap_readahead() was introduced, too. > { > bool *did_zero = data; > loff_t written = 0; > - int status; > > /* already zeroed? we're done. */ > if (srcmap->type == IOMAP_HOLE || srcmap->type == IOMAP_UNWRITTEN) > - return count; > + return length; > > do { > - unsigned offset, bytes; > - > - offset = offset_in_page(pos); > - bytes = min_t(loff_t, PAGE_SIZE - offset, count); > + loff_t bytes; > > if (IS_DAX(inode)) > - status = dax_iomap_zero(pos, offset, bytes, iomap); > + bytes = dax_iomap_zero(pos, length, iomap); Hmmm. everything is loff_t here, but the callers are defining length as u64, not loff_t. Is there a potential sign conversion problem here? (sure 64 bit is way beyond anything we'll pass here, but...) Cheers, Dave. -- Dave Chinner david@fromorbit.com