Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp355557lqb; Tue, 28 May 2024 19:00:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3/tQ1QyzRdiWF5dWu9goAn+T4qdqxaJdExB4gURVCpQt3U/yO30/fh+6sSu/Lj7kCJcCxP32kYXa4iFw9v6MhbZpZhpDzwEWZXHeDbQ== X-Google-Smtp-Source: AGHT+IFneOnEAxEeyiy9TpY5pOGI4FKWLvMwP4/A3QeEUIqPXhZcfwokG7ZVFjr/Xz0qIS1otVGd X-Received: by 2002:a05:620a:60f2:b0:792:8dab:cc84 with SMTP id af79cd13be357-794ab099b2bmr1406516185a.38.1716948002994; Tue, 28 May 2024 19:00:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716948002; cv=pass; d=google.com; s=arc-20160816; b=cUHfOCe/WnUPffwraAfvJhNEkO/t8QAH+7z4Yzz28SYaR2rRFvuBzeZkU9FE5mH+8t ZDsgv2SB8MqX3aXMvf66d+HaRCktYrtyxu35nmDZZqOoWn7jCIKNXS1nxKXrsSA/CFFW KvcM8BxXkRrfcGDQMjhGiUUxFi7M+7LfWw2VTqcfynw4ItLnAaC8sMeMkUjEn0Txfr3N +CtE7AJmGxL7z3TVdjLaZxO9OjdYYsFOuZfi9bDBpOLb3XAWKJ6cGQJY34sGq/zB4+Xt +KerJmQ2HnCTy6P+Jalc+MEk+mF/+5oWxoeShf+aC0saFzxjSD+SywNpW4G5x3Ysot3y nxtQ== 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=0SMK7D95DwoE98925QYh+Y0blhHvUN0YJ4po+Sddgc8=; fh=pGQcdj9ofLeqSf09jKNKJQluDhfJR8D6kVh7BClADBY=; b=NPTfz2BgciXgdVVdlAH0auuTMNfLL2uY+2EfMJs3G039dHNC4OmYg5829ZvJFu0uk5 9WIWG4RYqgsk+CATgCimeMn1h5CAW0GmcTBxQ+HwFFsGq0nn04dKNWoalUWtYg1/3Uhi Uu3fY3QCQCTf7iGJfl1tBi9cKCTqOeWGw37lPYduOSqXG+LOfSkZr2DcYyri19u3tkis YzdebejKX+4UttbJOO6dSbugw1TAbBdOjJJghUGmZN6bVgg8gm7cxDSa1sIFd5x5F4mU LBWilzAA3YMRpbcxVNIZFMy+/B6aLcyIKoeCIj/UdkHbnNtEqrHa3ZR+f7SPLPg5zPTT Pi/A==; 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-kernel+bounces-193316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193316-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794abcac059si1151991685a.79.2024.05.28.19.00.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 19:00:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-193316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193316-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 B6B1C1C235A8 for ; Wed, 29 May 2024 02:00:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 614AD15B113; Wed, 29 May 2024 01:59:24 +0000 (UTC) Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (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 C791D15AAD7; Wed, 29 May 2024 01:59:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716947963; cv=none; b=htxsbibMeARNkIUHbTKqVD4VvM96lwHE/QvdtJ8f7Rr/jCXydcEXnmUzDzmWqQctLvrNK1+7Ysy6BoGiX265lKQNcnq26mQQ+pngT8P1baXqR7rBStNoBhKrxlj3hHzecRZK+dx3HF0ItlFmMmrbI5gZVd18Nw6LE0nd0d/KQlQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716947963; c=relaxed/simple; bh=afHJRbRc/fwFUeIfW0Vig/K+3WKRwJ2tZp8Ww3qk80o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TKMRjt8jpAeZiq8920ZJO1OsiW690XpDhsb35XXNS4KbkzOI3xMi2s+C6oBSzknBk5HVBGBdAGCcqU5+dBJmMVJcmDDGNUnwbWl2uuZ5TjEutDi0ytp6cR4wFIlDmoZbBloODekZB9vEVp52B6ZNYTbBxiuRx6GjhGc86MKTo1g= 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.56 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.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Vpsxn5T2zz4f3jHW; Wed, 29 May 2024 09:59:09 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 0F1521A058E; Wed, 29 May 2024 09:59:19 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn9g7wi1Zmr3XbNw--.12147S8; Wed, 29 May 2024 09:59:18 +0800 (CST) From: Zhang Yi To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, djwong@kernel.org, hch@infradead.org, brauner@kernel.org, david@fromorbit.com, chandanbabu@kernel.org, jack@suse.cz, willy@infradead.org, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [RFC PATCH v4 4/8] fsdax: pass blocksize to dax_truncate_page() Date: Wed, 29 May 2024 17:52:02 +0800 Message-Id: <20240529095206.2568162-5-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240529095206.2568162-1-yi.zhang@huaweicloud.com> References: <20240529095206.2568162-1-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-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAn9g7wi1Zmr3XbNw--.12147S8 X-Coremail-Antispam: 1UD129KBjvJXoWxuFyrKF15GF1kGr4kGw1rWFg_yoW5urWDpF 1DCa15G397Xryj9F1kWF12vw45t3WDCF409ryxArZ3Zr9Fqr1IyF1qkF1YkF4UKr48u3yj qF98Kr47Gr15AFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7M4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCj c4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4 CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1x MIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r 1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBI daVFxhVjvjDU0xZFpf9x0pRHa0PUUUUU= X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi dax_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 dax_truncate_page(), allow filesystems to indicate the correct block size. Suggested-by: Dave Chinner Signed-off-by: Zhang Yi --- fs/dax.c | 8 ++++---- fs/ext2/inode.c | 4 ++-- fs/xfs/xfs_iomap.c | 2 +- include/linux/dax.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index becb4a6920c6..4cbd94fd96ed 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS @@ -1403,11 +1404,10 @@ int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, } EXPORT_SYMBOL_GPL(dax_zero_range); -int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, - const struct iomap_ops *ops) +int dax_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/ext2/inode.c b/fs/ext2/inode.c index 0caa1650cee8..337349c94adf 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -1276,8 +1276,8 @@ static int ext2_setsize(struct inode *inode, loff_t newsize) inode_dio_wait(inode); if (IS_DAX(inode)) - error = dax_truncate_page(inode, newsize, NULL, - &ext2_iomap_ops); + error = dax_truncate_page(inode, newsize, i_blocksize(inode), + NULL, &ext2_iomap_ops); else error = block_truncate_page(inode->i_mapping, newsize, ext2_get_block); diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 32306804b01b..8cdfcbb5baa7 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1474,7 +1474,7 @@ xfs_truncate_page( unsigned int blocksize = i_blocksize(inode); if (IS_DAX(inode)) - return dax_truncate_page(inode, pos, did_zero, + return dax_truncate_page(inode, pos, blocksize, did_zero, &xfs_dax_write_iomap_ops); return iomap_truncate_page(inode, pos, blocksize, did_zero, &xfs_buffered_write_iomap_ops); diff --git a/include/linux/dax.h b/include/linux/dax.h index 9d3e3327af4c..4aa8ef7c8fd4 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -210,8 +210,8 @@ int dax_file_unshare(struct inode *inode, loff_t pos, loff_t len, const struct iomap_ops *ops); int dax_zero_range(struct inode *inode, loff_t pos, loff_t len, bool *did_zero, const struct iomap_ops *ops); -int dax_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, - const struct iomap_ops *ops); +int dax_truncate_page(struct inode *inode, loff_t pos, unsigned int blocksize, + bool *did_zero, const struct iomap_ops *ops); #if IS_ENABLED(CONFIG_DAX) int dax_read_lock(void); -- 2.39.2