Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp356066lqb; Tue, 28 May 2024 19:01:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRZK+yOc8b/KKMZOq1puPc7/xNgJhlBvkoqk+z9XhbdGg1YWZogRE5I9aOihkR8bU+z5+tiWKxOkZvqRBuedCqTNoyxtoqHrnnMfrrzQ== X-Google-Smtp-Source: AGHT+IFqKHI88udKoQvPn7trQlmC9vF35wwZ8ZsAi+VKT+tg8c82vOQF6jg2MKI7D7kGpWUAB4jt X-Received: by 2002:a05:620a:56d9:b0:792:bf91:3d41 with SMTP id af79cd13be357-794ab048955mr1394403885a.15.1716948068120; Tue, 28 May 2024 19:01:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716948068; cv=pass; d=google.com; s=arc-20160816; b=IeieMNdMR1DTBCw//B49PFviFfIfRoWdl3GynZQG91Impwp+EGo1VtBEiQJ0/4kQQI A0+6RhvBQiquBqt9TEQUNos5kJHPcFahV6pq5QkWMGJvhFTXEJ93Dzpil2dGwgumffZV sNyyjG+zyVpV9UyEB3V+uVrtFSF1zdrkVFNXq5bRxOWnRcwmr8f7e7tGt/IseBZDUI+w WSDmMBoL/f/ITgrA5ZgyAxVU8to0/fGNm3ShdYN1IvmkqndyDUYSqzb0XuE9sHDEyqbZ GI6O5nX9rsJNssbJVucmPCOJAiXCi/02V1m83gIEof0YNaCboYbhNrSwu8PEe/2HZvf8 7GRg== 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=o+S18GXSiqc+hszUT0ejTbNGqjQhpXLTXQwGdw0g6fQ=; fh=pGQcdj9ofLeqSf09jKNKJQluDhfJR8D6kVh7BClADBY=; b=JPEMEGV6UymFZxpV/vjiYLzXewqI53hwDIV9CX5tfa/DQQSerbgf1OPsYReN1N23pk Wziv0Va1PrU3yfD42NWgLvvBocuFjAlozPuFnbu8Hdk1REjNBxdpA3OBAXLGaQUj3RHt oyN5qSKwdPjMkBH+TefnpKfAOVaGC2rlOD165nI8383JGdW+cn1yJuqUMCzvoi14vLAz HpXZLdn2iosg95yygcc5vss1hZAlbSMMIjIbWgSDvn6/jk1SVD2UifIp+lGsJPiu1EVF ds0ugDKJsnZ6cfx6ZASLbAa0eaYSfu1TCnZinEdH6mS5YxrEO0khBTkLCnoaOXF2XH/3 m2xg==; 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-193320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193320-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 af79cd13be357-794abd3c3edsi1138757485a.409.2024.05.28.19.01.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 19:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193320-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-kernel+bounces-193320-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193320-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 D2E141C22AA4 for ; Wed, 29 May 2024 02:01:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38E9215B979; Wed, 29 May 2024 01:59:26 +0000 (UTC) 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 6310615AD9A; Wed, 29 May 2024 01:59:23 +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=1716947965; cv=none; b=Yhe1+j65tpFB/7LS6GaJN5KwnWQ+qOCjhlKkwKMsKvhK+KpnTLjywvvjsRy5bFtzspIU/0uWOQJzyNNk/eWD1L/Ez50arpZakVj8ygkUIJgsSLX1l5v+spAhixl7PyzSqsNmWKAKhRuTC51kDL8GPvrM4J8GFcl3Jaab0XPmiRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716947965; c=relaxed/simple; bh=fQvZYnRp+sSZHSTlH4EKlMFqwqDwCAfksYi/u5y+mCc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TO2iQKcTnq5xZgMREkYXqwg5t2MEdUnZUYv4RV+S13ntsSMEDSUlIDC5JOsdF+hWhMrEbZNiryp40SbN4mwY7gRcaDign17acCTAxEUMR3Veyif/uNj2kwCjcdZIpk8+koOGc8SFjXve5FtBEPV/kKiKyTfVdoCUTv3yH4AeQV4= 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.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Vpsxn5h6lz4f3nZx; 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 91C3A1A0185; Wed, 29 May 2024 09:59:20 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAn9g7wi1Zmr3XbNw--.12147S11; Wed, 29 May 2024 09:59:20 +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 7/8] xfs: reserve blocks for truncating realtime inode Date: Wed, 29 May 2024 17:52:05 +0800 Message-Id: <20240529095206.2568162-8-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--.12147S11 X-Coremail-Antispam: 1UD129KBjvJXoW7ArW8AFy5urWUZr45Aw1fZwb_yoW8Gr18pF n7C3Z8WFs3Ww1jkayxAF1Fyw1UAa4vqr4jkFW8Gwnavw4DGr1ftrnYv3y8K3WUGrW2qw4F gr13J395Zw15ZF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmv14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7M4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCj c4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4 CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4U MIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJV WUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUv cSsGvfC2KfnxnUUI43ZEXa7sRilksDUUUUU== X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi On a realtime inode, __xfs_bunmapi() could convert the unaligned extra blocks to unwritten state, but it couldn't work as expected on truncate down since the reserved block is zero in xfs_setattr_size(), fix this by reserved XFS_IS_REALTIME_INODE blocks for realtime inode. Signed-off-by: Zhang Yi --- fs/xfs/xfs_iops.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ec7b7bdf8825..c53de5e6ef66 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -17,6 +17,8 @@ #include "xfs_da_btree.h" #include "xfs_attr.h" #include "xfs_trans.h" +#include "xfs_trans_space.h" +#include "xfs_bmap_btree.h" #include "xfs_trace.h" #include "xfs_icache.h" #include "xfs_symlink.h" @@ -811,6 +813,7 @@ xfs_setattr_size( struct xfs_trans *tp; int error; uint lock_flags = 0; + uint resblks; bool did_zeroing = false; bool write_back = false; @@ -932,7 +935,9 @@ xfs_setattr_size( } } - error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); + resblks = XFS_IS_REALTIME_INODE(ip) ? XFS_DIOSTRAT_SPACE_RES(mp, 0) : 0; + error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, resblks, + 0, 0, &tp); if (error) return error; -- 2.39.2