Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3050913lqo; Tue, 14 May 2024 19:39:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWLUpEMKanwQO+lcye+LbRRBR4FwY23etFw363tE7+h/hwA71oayRYJSjcQzsosGCe/A3WKKvWsQxKddxdLe7ZfVRwGGt5x9jovwTXJKw== X-Google-Smtp-Source: AGHT+IG4sxJKQH8FaQhJvvOvf5KEQXEFcQP0np9GE1RXGrkxjsU/3VpMKnoVAGR4dRqltW3EiTQ8 X-Received: by 2002:a05:6214:328e:b0:6a0:5c0c:d1be with SMTP id 6a1803df08f44-6a168140aa8mr157839396d6.3.1715740754346; Tue, 14 May 2024 19:39:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715740754; cv=pass; d=google.com; s=arc-20160816; b=M/MBzQrmbOo337dLqe3VFWI+sCVYsfBgpAdO7DAkjdXaFic39GHUPWVLc4L3tbXPnZ RGnVeGdIX7g860dqxh8NhKtb0jO0nJfMr5E8/mr08eVfMsFccL3e1xys5uP7OY1VnDNK meJmdQOv7nasL/zv38KF5dYkEcphhdL0Mlu7uLJfJvI4gAUpLpHlf6V4LJ4Xof50X/yS FiuYJGju1CqlxLwNLVgh3kxjIB1wh67VI4sTF1yG1EL7sr9gTBnaDvATFBmyE6TRhSRZ 2Dq/MpSeRdQIq8cX/o6RvrakCAM1WDhgdF0k/+2dqRJan7URYK7S5e9yi2CQIACA3EXJ KjPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zUjb0Qo1pzv9eH7u5yenbtBp1qGx9Y5Ly5qhOAgGMdM=; fh=0HaASOXEjGqpxPrGhdU7uT3vKkOGyiI675Dvy1SUF+c=; b=LOl8J+iD+JtyBQmVoLg2TeDfLaNhCvQHTHeexH/Ru1hYxB3HJjDpnx6qhkj/pP7cHQ /r9EkqB4BLTm8K6Kd4Tx4wOdSpV2s56ZuOTwgkiuxSyP1otfHm6OfcqSLAXlbISKqD66 OI1jCaEcmbLWKP+RQOiuLbdOQKfXW7d8Mv9dF390px8CxaPt7NJZTTubugGmVr+1oHv8 uPo0o2T6yWJCystygpG6Nb3pjyOqgaa+edsRtH7w3gK5gj368FYghgJVmYDderAn+kQY eEajhP1HSHUQPxB8tIC32PB3g2FNjSifyMX7tux8QjBErlNM/OMtro4EqtR6o4HIUvbA ZB8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2514-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2514-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e157d1330si63162641cf.576.2024.05.14.19.39.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 19:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2514-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-ext4+bounces-2514-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2514-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0BFFC1C21222 for ; Wed, 15 May 2024 02:39:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E50D2374D1; Wed, 15 May 2024 02:39:05 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (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 69D121BC5C; Wed, 15 May 2024 02:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715740745; cv=none; b=eubk0Mq2PlLl89cFPjPyotr8KQPcuR75aIRJPyufPyKxbfdw4tfsDFacm1jtchZAkU8Z43HIZcnfD/w/aaHYC7EAAQmQEw5DmUFvmSS0Bycj7MkaNdp8ZOSrvvt3DnVMho9g0T/+AIFdi96GeiZua6myGWAKlYyXHgKAK+2IvSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715740745; c=relaxed/simple; bh=+1e1oNfgfqnwV71IA8G7FJFE9eAGlnj2iTdZeejW4mY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q43uI3WwEVv+kjbbtqSDoPJs76eI2N7BaDVYTBd3fjS9OJCx06rgRknQhfuTlSkYiyYRikz7JOaFYG67T7WtEVnYaSIEcqxjopxOUdzoBSzb66/Y+idsOaDXBVVEXl3i90X0b/c0ak3EZEJDgk2MM6JKyhOCUxMxOHkDl5nUTtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VfHV14W9Tz4f3lW1; Wed, 15 May 2024 10:38:49 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id C40EE1A08D4; Wed, 15 May 2024 10:38:59 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBE8IERmRFzIMg--.49754S5; Wed, 15 May 2024 10:38:59 +0800 (CST) From: Zhang Yi To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-ext4@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, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH 1/3] iomap: pass blocksize to iomap_truncate_page() Date: Wed, 15 May 2024 10:28:27 +0800 Message-Id: <20240515022829.2455554-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240515022829.2455554-1-yi.zhang@huaweicloud.com> References: <20240515022829.2455554-1-yi.zhang@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgBXKBE8IERmRFzIMg--.49754S5 X-Coremail-Antispam: 1UD129KBjvJXoWxuFyrKF15GFykZr4xWw1rJFb_yoW5Wr4rpF 1qkF45Gw4fXry09F1kWFyUZw1YyFn8Cr40kry8GrZxZr1vqr1IyFn2ka1jvF1jqr4xur4j qFZ8K3y8Xr15ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUSYLPUUUUU = X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ 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 do 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. Suggested-by: Dave Chinner Signed-off-by: Zhang Yi --- fs/iomap/buffered-io.c | 7 +++---- fs/xfs/xfs_iomap.c | 3 ++- include/linux/iomap.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 0926d216a5af..4cfe0a4b3325 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1445,11 +1445,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, loff_t blocksize, + bool *did_zero, const struct iomap_ops *ops) { - unsigned int blocksize = i_blocksize(inode); - unsigned int off = pos & (blocksize - 1); + unsigned int off = pos % blocksize; /* Block boundary? Nothing to do */ if (!off) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 2857ef1b0272..31ac07bb8425 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1467,10 +1467,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..27d59e464502 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, loff_t 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