Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3041775pxk; Tue, 15 Sep 2020 08:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC1vI0tSLqTGo9kb4BYYjQ7mXmUF4jIt4RYG1ObWFyxcOuC3oNjw5cdtc3l7d4wY3q1R2j X-Received: by 2002:a17:906:e113:: with SMTP id gj19mr21044527ejb.263.1600184408882; Tue, 15 Sep 2020 08:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600184408; cv=none; d=google.com; s=arc-20160816; b=qWgLWitB7Uk/WNM8ATPAKG2/1nEX/7CBsUOTbcq5PUCMyD13rnxnG7bsnO08+iuI3O l5WAjpip9CXT4joIMJHudOpKTRowuMciRt9pvAZ0GHVGpNLQChr82K7btHThvx1IXskJ loCA39HFSm6aLJ98pD2sRxNHoFCZLc3yWU1IQrJOE/uHKASpkG2gzPhwmPFeczrcwC4t 6VBV6+a16h1ETOoHuII7odRtaOLzw4d+g0Tb7VWkGAcQCZ/Euzv8vzqfRhQcTaQJLRUu cH5uPQJCZdbjFWlMeQxQf5Yj2L8YCrfd0b0Vu+GlHHV1EWsiO2rMStEdG17pC6eJ6PKU fCzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=mlThoEMSQhnrF2B05hNa3u+h6x1vqKwVnvXnWiW5QVk=; b=h1i65zGvMWOONYFWFZfIAioi7Va98VwT89ZyVINKNK7xZ+0Ye7dzIBwG6GI4Btklj4 zRJHdfyf4ADICfsrf2fxxopTlb3On6NpJ4Lzhlnxd5K4RoYJvl9WGz+blAkXKa/M/Dt8 btUl1VU4B76A78IS8twJUd98Ms4sgOKlMBl0sXZy6dcXJ/Cor/zjuIULjrurXrH8bDdE o43UPnxgbrDBLGJV3ukFVeuHPmF866OIuMDmJWQm6op5Mk4cku+EmHUS672cgekvyMGe ST7ZffeU8ry9wsCG1Gczr+/c8tGUuDBdpydIgvVOXab3T7WHz2G++li0nuE0Cy4un0x1 fcXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=HbERskiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd28si9686915ejb.302.2020.09.15.08.39.44; Tue, 15 Sep 2020 08:40:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=HbERskiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727206AbgIOPhi (ORCPT + 99 others); Tue, 15 Sep 2020 11:37:38 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:53022 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbgIOO7K (ORCPT ); Tue, 15 Sep 2020 10:59:10 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08FEsvh3085178; Tue, 15 Sep 2020 14:58:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=mlThoEMSQhnrF2B05hNa3u+h6x1vqKwVnvXnWiW5QVk=; b=HbERskiOrilJ40tG6czBgl8d7tVhMbTQp7EaVuB2v8HAZl6RpHwpNhx/5Xr8c/o3vWir 7I36DDb+c5Ar/cFDkhArjuGwcnNuHYNzp/L0Twyvnc3gYibHtclDfheLsDFLHnRV4jME vBDLlEcNGZ0pxEO0m+LCspGO117c4qm/LJ/mCkURL6T163HoDuijSiFZ21JQi3zZWrWW IJtqrFJLLNnmhY2c4RmvCeGlnhR3tBFUhfaNNk91yXFZjok4Y/rf10bgsyJpjFiee6Ai DrhniYtjFHJx5QZQ94INkT/1meXmKfombfMZhSVnA7KwTAnNsMJrNFZstdT/n3jXZleB uw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 33gp9m5k2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 15 Sep 2020 14:58:13 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08FEtqM4072492; Tue, 15 Sep 2020 14:58:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 33hm30p1am-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Sep 2020 14:58:12 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 08FEw5qW018021; Tue, 15 Sep 2020 14:58:05 GMT Received: from [192.168.0.190] (/68.201.65.98) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Sep 2020 14:58:05 +0000 Subject: Re: [PATCH v2 2/9] fs: Introduce i_blocks_per_page To: "Matthew Wilcox (Oracle)" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: "Darrick J . Wong" , Christoph Hellwig , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Dave Kleikamp , jfs-discussion@lists.sourceforge.net, Christoph Hellwig , Dave Chinner References: <20200910234707.5504-1-willy@infradead.org> <20200910234707.5504-3-willy@infradead.org> From: Dave Kleikamp Autocrypt: addr=dave.kleikamp@oracle.com; prefer-encrypt=mutual; keydata= mQINBE7VCEMBEAC3kywrdIxxL/I9maTCxaWTBiHZFNhT5K8QZGLUfW3uFrW89PdAtloSEc1W ScC9O+D2Ygqwx46ZVA7qMXHxpNQ6IZp8he88gQ9lilWD8OJ/T3OKyT6ITdkmsgv6G08QdGCP 0+mCpETv79kcj+Z4pzKLN5QyKW40R3LGcJ6a+0AG5As5/ZkmhceSffdSyDS6zKff3c6cgfQH zl+ugygdKItr3UGIfxuzF3b9uYicsVStwIxyuyzY8i1yYYnnXZtWkI9ZwxT+00PqjCvfVioy xswoscukLQntlkfd4gwM8t56RIxqEo4iNmFwmBYHlSd7C+8SrvPAOgvOtr1vjzJhEsJ2uJNW O2pgZc8xMxe8vhyZK1Nih67hbtzSIpFij06zHwAt4AY3sCbWslOExb8JboINWhI89QcgNmMK uwLHag3D/zZQXQIBvC5H27T49NA6scA92j2qFO6Beks3n/HW6TJni/S9sUXRghRiGDdc/pFr 20R3ivRzKyYBoSWl/3Syo0JcWdEpqq6ti/5MTRFZ+HQjwgUGZ5w+Xu2ttq/q9MyjD4odfKuF WoXk3bF+9LozDNkRi+JxCNT9+D4lsm3kdFTUXHf/qU/iHTPjwYZd6UQeCHJPN6fpjiXolF+u qIwOed8g8nXEXKGafIl3zsAzXBeXKZwECi9VPOxT4vrGHnlTHwARAQABtDZEYXZpZCBLbGVp a2FtcCAoQUtBIFNoYWdneSkgPGRhdmUua2xlaWthbXBAb3JhY2xlLmNvbT6JAjgEEwECACIF Ak7VCEMCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEDaohF61QIxkpSsP/3DtjVT0 4vPPB7WWGWapnIb8IN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68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200910234707.5504-3-willy@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9745 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009150125 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9745 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 clxscore=1011 lowpriorityscore=0 phishscore=0 spamscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009150125 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/10/20 6:47 PM, Matthew Wilcox (Oracle) wrote: > This helper is useful for both THPs and for supporting block size larger > than page size. Convert all users that I could find (we have a few > different ways of writing this idiom, and I may have missed some). > > Signed-off-by: Matthew Wilcox (Oracle) > Reviewed-by: Christoph Hellwig > Reviewed-by: Dave Chinner > Reviewed-by: Darrick J. Wong For jfs: Acked-by: Dave Kleikamp > --- > fs/iomap/buffered-io.c | 8 ++++---- > fs/jfs/jfs_metapage.c | 2 +- > fs/xfs/xfs_aops.c | 2 +- > include/linux/pagemap.h | 16 ++++++++++++++++ > 4 files changed, 22 insertions(+), 6 deletions(-) > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index d81a9a86c5aa..330f86b825d7 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -46,7 +46,7 @@ iomap_page_create(struct inode *inode, struct page *page) > { > struct iomap_page *iop = to_iomap_page(page); > > - if (iop || i_blocksize(inode) == PAGE_SIZE) > + if (iop || i_blocks_per_page(inode, page) <= 1) > return iop; > > iop = kmalloc(sizeof(*iop), GFP_NOFS | __GFP_NOFAIL); > @@ -147,7 +147,7 @@ iomap_iop_set_range_uptodate(struct page *page, unsigned off, unsigned len) > unsigned int i; > > spin_lock_irqsave(&iop->uptodate_lock, flags); > - for (i = 0; i < PAGE_SIZE / i_blocksize(inode); i++) { > + for (i = 0; i < i_blocks_per_page(inode, page); i++) { > if (i >= first && i <= last) > set_bit(i, iop->uptodate); > else if (!test_bit(i, iop->uptodate)) > @@ -1077,7 +1077,7 @@ iomap_finish_page_writeback(struct inode *inode, struct page *page, > mapping_set_error(inode->i_mapping, -EIO); > } > > - WARN_ON_ONCE(i_blocksize(inode) < PAGE_SIZE && !iop); > + WARN_ON_ONCE(i_blocks_per_page(inode, page) > 1 && !iop); > WARN_ON_ONCE(iop && atomic_read(&iop->write_count) <= 0); > > if (!iop || atomic_dec_and_test(&iop->write_count)) > @@ -1373,7 +1373,7 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc, > int error = 0, count = 0, i; > LIST_HEAD(submit_list); > > - WARN_ON_ONCE(i_blocksize(inode) < PAGE_SIZE && !iop); > + WARN_ON_ONCE(i_blocks_per_page(inode, page) > 1 && !iop); > WARN_ON_ONCE(iop && atomic_read(&iop->write_count) != 0); > > /* > diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c > index a2f5338a5ea1..176580f54af9 100644 > --- a/fs/jfs/jfs_metapage.c > +++ b/fs/jfs/jfs_metapage.c > @@ -473,7 +473,7 @@ static int metapage_readpage(struct file *fp, struct page *page) > struct inode *inode = page->mapping->host; > struct bio *bio = NULL; > int block_offset; > - int blocks_per_page = PAGE_SIZE >> inode->i_blkbits; > + int blocks_per_page = i_blocks_per_page(inode, page); > sector_t page_start; /* address of page in fs blocks */ > sector_t pblock; > int xlen; > diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c > index b35611882ff9..55d126d4e096 100644 > --- a/fs/xfs/xfs_aops.c > +++ b/fs/xfs/xfs_aops.c > @@ -544,7 +544,7 @@ xfs_discard_page( > page, ip->i_ino, offset); > > error = xfs_bmap_punch_delalloc_range(ip, start_fsb, > - PAGE_SIZE / i_blocksize(inode)); > + i_blocks_per_page(inode, page)); > if (error && !XFS_FORCED_SHUTDOWN(mp)) > xfs_alert(mp, "page discard unable to remove delalloc mapping."); > out_invalidate: > diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h > index 50d2c39b47ab..f7f602040913 100644 > --- a/include/linux/pagemap.h > +++ b/include/linux/pagemap.h > @@ -975,4 +975,20 @@ static inline int page_mkwrite_check_truncate(struct page *page, > return offset; > } > > +/** > + * i_blocks_per_page - How many blocks fit in this page. > + * @inode: The inode which contains the blocks. > + * @page: The page (head page if the page is a THP). > + * > + * If the block size is larger than the size of this page, return zero. > + * > + * Context: The caller should hold a refcount on the page to prevent it > + * from being split. > + * Return: The number of filesystem blocks covered by this page. > + */ > +static inline > +unsigned int i_blocks_per_page(struct inode *inode, struct page *page) > +{ > + return thp_size(page) >> inode->i_blkbits; > +} > #endif /* _LINUX_PAGEMAP_H */ >