Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp601923lqs; Thu, 13 Jun 2024 22:57:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8mmy/XBECIu1T1ZDGuKAPHO4nT5Qer6polHYigzbSm66IxHw78p41GAu8BfMU0JRnx4TxI/dRSLekGndelBkteOabEa4D7qN7UN6m8Q== X-Google-Smtp-Source: AGHT+IGPQ4yxLWro6UqmT3MAT4MptqPtZcrfOd4I2D8PphFcH7UVFk7Khfg1dl9YbDFu4NqGdZX/ X-Received: by 2002:a05:6808:11c3:b0:3d2:2b9e:b6d0 with SMTP id 5614622812f47-3d24e8fb5bbmr2277554b6e.26.1718344630878; Thu, 13 Jun 2024 22:57:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718344630; cv=pass; d=google.com; s=arc-20160816; b=xr/O1s6VAqfVE6/4J92iVj7JR218mZM50a2SarEPd50b8dWZTO1zv9mKxq0llxsQWg a4lk1Yh+AK8YXO7SOscxwVhlCXm9Sn1c7EXz0chtimj/eCExp957nreHsWB4ly4SrwzV gPKBJaZq3Yd2IOjiQZsY8k0Gkg8UDDNTZ1JxCD64UfgkV16Uo0cmF+ADNn6P8SqFiDcl 8yUkiUV+ugfeS6dcKKrpk3UVonOhRPoXJevzB6YxBjEnT2EX7bWRzdDFaF+kAvs6O7H0 qmcZyd5XoE60+EZzas/Ssdozpp8aXCERSLhzmA70km/9ILulK1M7NW92vuUnzPvuLInC QGPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BdOBQlv2UEIzA+JbBGsNcVjy+aAn9V5BzVl0meTkVSA=; fh=Fd4PFnA3krwNIPOvLxQhGscKlAzzE71m6dr/VE1uxA8=; b=OO9guMc18qETRfwsVkDa7rqtOJbjgvHD8arin9GoTdPxnGwVg2wDHbkH5W2z7unPw3 SR/tBvFfdIE/z/+WZLHaDYris9AnOeF0HEcJJ6OWnal9QS0oub/mVU9r7O+y1IEWO9pY 6h/P/zKu9mISQMXR8vkXGIqSLRPrSNhPsKFDUijzN6QzS1PshypfoezmLSmpcPkAEwD2 PaEhNAS+w9mcmZgbBgnJUbLyAS/BE5TVrM0Kk4KofsqvWSE+/AFk/PW6x3EsSv5H5KE6 3/Oztv/Zjn28mR18cav5j6NS5bjRKHyskaWkklHourUqWHmGy6+Efdl2FKT43+S9k2iV NUVw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=QwxU+VsQ; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-214381-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214381-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-705cc8f5211si2951583b3a.27.2024.06.13.22.57.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 22:57:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214381-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=QwxU+VsQ; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-214381-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214381-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7D81B283D4F for ; Fri, 14 Jun 2024 05:57:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47DE91482E8; Fri, 14 Jun 2024 05:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QwxU+VsQ" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43A81145B34; Fri, 14 Jun 2024 05:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718344619; cv=none; b=poavpz4qubKfDCxc8YKZFIB18M2xEpGBgqrAOv8BQ/fU164KnA+4mlu46THuyMTEnu/CI/0zy/h70Ayj+kAHeTZPAXP/b5y/95PJ2q7RBfD6IHd6VJ4AVBTBvgduYm9y5JI/UeQU4HJTOhCD8pgf9ojMeOgIMwYQQ05ixTHeDM4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718344619; c=relaxed/simple; bh=9e63V/aitR05S10xPdwh2WzKG5CZqxBgdcljUnT4fEk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QAbb3CUWuJsSBEyGDpUzXkdfEuvOFVJ6HXwTn48mBWcE84IMo6E6PRiXmPBawS1Tm6rfxoOCuE3XQ6vh7JS3ql5mqhYsfM2YGE81zK9RDlTLUE6LXfPFNN73ai+dkbN9sdm8n6uBSdHqcQIbIOVUOE+I5rSTBJOk0Y4b3+P3mWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=QwxU+VsQ; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=BdOBQlv2UEIzA+JbBGsNcVjy+aAn9V5BzVl0meTkVSA=; b=QwxU+VsQXgVdPLL57Z0m45O0sg LkN8a04tcbHxhOlGe2TpZE9QE2WdGtFmJJ0mGzIUgjCb3+2LRw1MR0dik3CwdEkjg9PS0bJU9nuyp Ul766Xa9OOmq/h49xysJLA7aMX1qI5WXrOsjFwKqFShyzQLsAsheGs2e3uWrEt51cUnPV7pZ1gD/q AyRbDac0g//Z0Lfh8Joaw4cxBu2lVSRDSDLiOOCo0X+RnAubuU0bRt8UrWNpWMk/tMqcWwq2g4q0l EumSgTp2jndVrqke0/6mN5CVtIkp9RFriQg94qpw+NPlJLTRONIH08Rw6RA6cUH77iITnXW1YKyZw Mi8jU9Jg==; Received: from hch by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHzvg-00000001Yqi-20XX; Fri, 14 Jun 2024 05:56:52 +0000 Date: Thu, 13 Jun 2024 22:56:52 -0700 From: Christoph Hellwig To: Zhang Yi Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, djwong@kernel.org, hch@infradead.org, brauner@kernel.org, david@fromorbit.com, chandanbabu@kernel.org, jack@suse.cz, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: Re: [PATCH -next v5 2/8] iomap: pass blocksize to iomap_truncate_page() Message-ID: References: <20240613090033.2246907-1-yi.zhang@huaweicloud.com> <20240613090033.2246907-3-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240613090033.2246907-3-yi.zhang@huaweicloud.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html On Thu, Jun 13, 2024 at 05:00:27PM +0800, Zhang Yi wrote: > From: Zhang Yi > > iomap_truncate_page() always assumes the block size of the truncating > inode is i_blocksize(), this is not always true for some filesystems, > e.g. XFS does extent size alignment for realtime inodes. Drop this > assumption and pass the block size for zeroing into > iomap_truncate_page(), allow filesystems to indicate the correct block > size. FYI, I still prefer to just kill iomap_truncate_page in it's current form instead. > #include "../internal.h" > @@ -1453,11 +1454,10 @@ iomap_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, > EXPORT_SYMBOL_GPL(iomap_zero_range); > > int > -iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, > - const struct iomap_ops *ops) > +iomap_truncate_page(struct inode *inode, loff_t pos, unsigned int blocksize, > + bool *did_zero, const struct iomap_ops *ops) > { > - unsigned int blocksize = i_blocksize(inode); > - unsigned int off = pos & (blocksize - 1); > + unsigned int off = rem_u64(pos, blocksize); > > /* Block boundary? Nothing to do */ > if (!off) > diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c > index 378342673925..32306804b01b 100644 > --- a/fs/xfs/xfs_iomap.c > +++ b/fs/xfs/xfs_iomap.c > @@ -1471,10 +1471,11 @@ xfs_truncate_page( > bool *did_zero) > { > struct inode *inode = VFS_I(ip); > + unsigned int blocksize = i_blocksize(inode); > > if (IS_DAX(inode)) > return dax_truncate_page(inode, pos, did_zero, > &xfs_dax_write_iomap_ops); > - return iomap_truncate_page(inode, pos, did_zero, > + return iomap_truncate_page(inode, pos, blocksize, did_zero, > &xfs_buffered_write_iomap_ops); > } > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index 6fc1c858013d..d67bf86ec582 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -273,8 +273,8 @@ int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len, > const struct iomap_ops *ops); > int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len, > bool *did_zero, const struct iomap_ops *ops); > -int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, > - const struct iomap_ops *ops); > +int iomap_truncate_page(struct inode *inode, loff_t pos, unsigned int blocksize, > + bool *did_zero, const struct iomap_ops *ops); > vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, > const struct iomap_ops *ops); > int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, > -- > 2.39.2 > > ---end quoted text---