Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp370153lql; Mon, 11 Mar 2024 05:30:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXs+CHYcKO4tRMNydeFxonTFMRQxMgk09+Djxjqm8pveohxBofvcPLsxOgZmcMXXKuDPeL0nCBVd/iqcpbpzmgTyeZbNwhJAvHkhfjWTg== X-Google-Smtp-Source: AGHT+IFWoB/8wTkINjQnOcxp1kkw3aNUG/t6IEez93NC/mSuJ3w6FXNk89qTesZEBKKCzs+yFHIk X-Received: by 2002:a17:902:7ed0:b0:1dd:5f85:1191 with SMTP id p16-20020a1709027ed000b001dd5f851191mr5347184plb.53.1710160221281; Mon, 11 Mar 2024 05:30:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710160221; cv=pass; d=google.com; s=arc-20160816; b=UQDm1KXoHSsXCqhL+jKZTWk+Bkb7axRxCgCgAtRO5CCQW/2D5fHdLONDK+ODhI2BjC vvsFfUPT17//60NW7Y3FFlmekiMzgTJWxF23mr9vkgeagecaC/I4fq+CxP2OWtnIT40z y0RVwWsVFyVw2cmD3UA4zq3geDyO4MJxE5GBPwOVOqYfOdfsCBmzwRGHk0JiWcw28Oct YV3QipVbD6ihvfwmDnncFdqHTJQkknVIgq/Z2Hc3lY2aGPwD+LIyVfAzDlTrfz851zix DIABkPzhZyNiH5ux6eOg/QRGibNXrM99EXyOuOjWCWEo8iccZYQsxSvPAw9PoNMXKFbF 1f9g== 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=4FD2YnXpcJRPV+O9ZATGa6UwKOffR8GLJoD2G3PQPz0=; fh=5dB93T9RUScPXiJBPgMY9ddAKXpKWIKqxrLOkZR5g5k=; b=WWmq/u4XLzsnAO5Yqcl+Azxa+ZViXwWstGxzlQPosU/35p+hn/NG8I6JJCkRtMeBDG xvGeLdzxWBSZwlI13FVH0N8Zil6DbMLrKGCZ9EH++YXnZLPtjPYEFxNB2ZIdb+ertvMq hoLO7clCaHADLhV118WSRFfzhA0cak2cDnegDlmXVah1LE0+zXW4gdRBGHnorVWxbfGF lP3wcbq7MAXHNPiatigXLlLc3YYc1Iy341ezet9H9unHeVWnm+plJrJMf+Kz/VsyWBBk iXLGYIDtHFY40xW1SFe2k+8cY4MwRn3EX6nWK1kUfvUkLoT2akGC3QLw5O8OhQBPxcwJ UCcA==; 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-98826-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98826-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d1-20020a170902cec100b001dda17fe7b6si1422397plg.590.2024.03.11.05.30.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 05:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98826-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-98826-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98826-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 F13E92820EA for ; Mon, 11 Mar 2024 12:30:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 021443D993; Mon, 11 Mar 2024 12:30:05 +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 DBB4B3C478; Mon, 11 Mar 2024 12:30:01 +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=1710160204; cv=none; b=bp6BY4FjQMrfRG+phscCH1G/bFgznIO/qjIYc1oLkaBstZVdWB8TzM8b4ovjdXyz3Cv4v1dtv0LnZNSNwReHBQ7nij3uXmck0xAICEK67PeF32z5yjXy7bbsyVXfq+Wo3sywK+OK7XcwEQb1Rqbw28bnlo1O9CNraqwkyi2qLXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710160204; c=relaxed/simple; bh=5x2jUS69btnG358xEvklJtqtctnoWjAA0CGJVtMNkbQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CeVdfWxov47fEDVYvm0eNW7qBG2T+ni7ZiLw+nloJ8HR7G//A/NqfTeDX3JdThmyoAfwDJN+s6bXY+Nu70LtSQVoZ3h00enSUHqeU4eLY3gIhpzRvKwOcJIomK6d/vpbrjtZMgvUqjzd5c8tMtm9SFvZlBmyloLnLsaqTxSR0/Y= 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 4Ttbh20n6Wz4f3jZd; Mon, 11 Mar 2024 20:29:54 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B80821A01A7; Mon, 11 Mar 2024 20:29:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDHlxAt+e5lAE9+Gg--.62739S5; Mon, 11 Mar 2024 20:29:57 +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, tytso@mit.edu, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH 1/4] xfs: match lock mode in xfs_buffered_write_iomap_begin() Date: Mon, 11 Mar 2024 20:22:52 +0800 Message-Id: <20240311122255.2637311-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240311122255.2637311-1-yi.zhang@huaweicloud.com> References: <20240311122255.2637311-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:cCh0CgDHlxAt+e5lAE9+Gg--.62739S5 X-Coremail-Antispam: 1UD129KBjvJXoW7KF43tw1xXrW7trWrAryUtrb_yoW8ZF17pr n7K3yDG392qrn0vr10qryYyr1Ik3W7Jw18Ar15Wa93uw1ktr4xKr4093WrC3W8JrsFy34v gF4UGr1kua43AFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBK14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjA9NDUUUUU= = X-CM-SenderInfo: d1lo6xhdqjqx5xdzvxpfor3voofrz/ From: Zhang Yi Commit 1aa91d9c9933 ("xfs: Add async buffered write support") replace xfs_ilock(XFS_ILOCK_EXCL) with xfs_ilock_for_iomap() when locking the writing inode, and a new variable lockmode is used to indicate the lock mode. Although the lockmode should always be XFS_ILOCK_EXCL, it's still better to use this variable instead of useing XFS_ILOCK_EXCL directly when unlocking the inode. Fixes: 1aa91d9c9933 ("xfs: Add async buffered write support") Signed-off-by: Zhang Yi --- fs/xfs/xfs_iomap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 18c8f168b153..ccf83e72d8ca 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1149,13 +1149,13 @@ xfs_buffered_write_iomap_begin( * them out if the write happens to fail. */ seq = xfs_iomap_inode_sequence(ip, IOMAP_F_NEW); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); trace_xfs_iomap_alloc(ip, offset, count, allocfork, &imap); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, IOMAP_F_NEW, seq); found_imap: seq = xfs_iomap_inode_sequence(ip, 0); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, 0, seq); found_cow: @@ -1165,17 +1165,17 @@ xfs_buffered_write_iomap_begin( if (error) goto out_unlock; seq = xfs_iomap_inode_sequence(ip, IOMAP_F_SHARED); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, IOMAP_F_SHARED, seq); } xfs_trim_extent(&cmap, offset_fsb, imap.br_startoff - offset_fsb); - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &cmap, flags, 0, seq); out_unlock: - xfs_iunlock(ip, XFS_ILOCK_EXCL); + xfs_iunlock(ip, lockmode); return error; } -- 2.39.2