Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1117925lqd; Thu, 25 Apr 2024 06:37:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVl3+PEDic+HhMO4Kk+WD1ZFgx0/eGHoYeRwvR7v9AcK/eWyK4x690s2x84nP9fUTjWX6epOc3+Slq+ZZKeiG9hfyoGCxhSnVohNzY7FA== X-Google-Smtp-Source: AGHT+IGLpmHHeao8YCDoLtaI+iRnvOI7e9UaenDtJ2xUu6lwJbaitl/3uGIa4gLwVxhjnZenJwgY X-Received: by 2002:a05:6a21:151a:b0:1ad:9413:d5c3 with SMTP id nq26-20020a056a21151a00b001ad9413d5c3mr2466872pzb.17.1714052266200; Thu, 25 Apr 2024 06:37:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714052266; cv=pass; d=google.com; s=arc-20160816; b=a9nmN3j+f1O+oVd36g42WnlP7c36Lr+5xMDX0qp540rBBVmA+YsY016u9kVVltq7wy ga8Esg4fYadRBoCzIypzI1YL2rMyR07dpkuj/8lQKK5cZjfpF3v1bAYp855YG/JYgE/y jP8NP6zZY+Wgs+Hmx1eMo9Paht36ZyLkoRUqwPqfTXa/tFgahTCQuk/aq2VnpDBLoWa+ ZuTSeIRF+36TL8htYGMbqXyqwe9TH6S0QPIT0QYjWrqnWRi37a6Y+dVJ1tbSovlSiUF+ avbBOhc2QYE0R+2/0oU5+ke7lROn2s3OpLzz39CfjQUzh6MEn99v8kgO6RUcIZj7qeVf +Lpg== 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=hHrsglxT8YPI2uazHxnA3aAB6Xtiqkekln6cQpXKBnc=; fh=gVqSn+gMOZkzbuzl7fujuMh2YVkiKU3c6mFoNhCnODI=; b=In1tR4zi8tsIuQuWLgTofhE8DRRJJZz8NybArX1LY2zGD/+8V9Y40hBj2qUzj2c714 1mNnvQww+B8+zPcbthHDFAZZGMg9ZTj+0V/IVWJYM/9S3aw4P97aZPryXur31/MOwAiL q9pDtGTTowvVgDusaLL4JFrk+JrjJK+hM7sou2wtRncVxHQYNDYmIjxyta4h5bgUjAbf 1+7y3qvbLYQ/50dQ+cO1yuZD7d5ZH5mn+JriG9OAU5EXPdy4xsf5iaxcE66/xYlEC60t 9WIf3JQRmaftjvPKpy4xcMTf5Tmd6eQzNdL5pqBL9KtPJP9wCjMPUc1QxvkxZpTlLFov tF/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-158585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158585-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f37-20020a631f25000000b005dc84ba3c3asi13016576pgf.287.2024.04.25.06.37.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 06:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-158585-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158585-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0ECBDB24538 for ; Thu, 25 Apr 2024 13:23:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21846149E19; Thu, 25 Apr 2024 13:23:09 +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 F0B33149C6F; Thu, 25 Apr 2024 13:23:06 +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=1714051388; cv=none; b=iq/je82E5cnk8mZ+Rn0gLdGr3pLgDgJGpp5hUAeiznXIvZoXG4gsM90vnH4c6Tf35R4b4hCWb9H/mRhaAgv4i+PefcXzLAnATIit5FERrwqKusD7MNERqjkSGXBEZiDURwy4LbjMUagpNBhJ2j/DcOg96kBkQKpe2pGBAGps75Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714051388; c=relaxed/simple; bh=mYB4cFXRObkdFIe0Jj7buZre0nnGhVmuslvweIRKqtY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QDez+V8qBTlEIqezqkTQz4mbJozIvtyNpsLYueQBHUukyqmG3Y32GoicG7leanEb46IwdJkdfEvKmcCHbTggW+3CPZ4AmKvop/aY9294wtYcnwDKpyPpMiwc6U30GAcTwpkbuC7KQ6k7Z1EuK0Zl5etuaQqfgU0BvVKGzszOL7o= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VQGkQ3qpdz4f3n6Y; Thu, 25 Apr 2024 21:22:54 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id C26EF1A0568; Thu, 25 Apr 2024 21:23:03 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXaBEqWSpmHu+2Kw--.61462S5; Thu, 25 Apr 2024 21:23:03 +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, tytso@mit.edu, jack@suse.cz, yi.zhang@huawei.com, yi.zhang@huaweicloud.com, chengzhihao1@huawei.com, yukuai3@huawei.com Subject: [PATCH v5 1/9] xfs: match lock mode in xfs_buffered_write_iomap_begin() Date: Thu, 25 Apr 2024 21:13:27 +0800 Message-Id: <20240425131335.878454-2-yi.zhang@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240425131335.878454-1-yi.zhang@huaweicloud.com> References: <20240425131335.878454-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:cCh0CgCXaBEqWSpmHu+2Kw--.61462S5 X-Coremail-Antispam: 1UD129KBjvJXoW7KF43tw1xXrW7trWrAryUtrb_yoW8uryDpr n7K3yDW39agrn0vF10gryYyw1Ik3W7Jw18Ar1rWa93uw1ktr43KF40va1rC3W8JrsFya4v gF4UCr1kua43AFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JU4T5dUUUUU = 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 Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- 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 4087af7f3c9f..236ee78aa75b 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1158,13 +1158,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: @@ -1174,17 +1174,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