Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp908751lql; Tue, 12 Mar 2024 01:18:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtItF0ZX8Nv00mLTaRFnm8G61Thl78qRHCYz/M6FqCly88xGVSsc7Mc6alWAOVGnFMxbjcvl9XAkytQSslsESPTWixU5j4EicSmVqMCg== X-Google-Smtp-Source: AGHT+IEpyRHyhWrrGx2wtiOFNfXLhsvWjAtvB7iWgfFQALDwzQXu+2kuCbfAVk6IJJGikoIpsqTu X-Received: by 2002:a25:4607:0:b0:dcd:1b8f:e6d3 with SMTP id t7-20020a254607000000b00dcd1b8fe6d3mr838810yba.48.1710231537368; Tue, 12 Mar 2024 01:18:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710231537; cv=pass; d=google.com; s=arc-20160816; b=i9fvaBPHrwCGxLO9tBi0bEbRbEcoqFgCpGRoQSVNeEHS24pjBs9s6ppJZ/k4JdBVAG Uz2jPV8Z5S7zubdAtbQs09H8qqcwxi8Y0FLy/Wvg8BaHTrHTbp5DH8wZDVTKny5Ed2pG bD1DcDpGlPSiPfPzchFkePi0v0k5z7XZtIYnqPGa0f8c6W13xSub2FxyC6wzq57O68dZ 0WGEnkY0mGqG+bM1yXNZ+vyWiNNDg4Asxxt7/oWCmVyrSUNgXZg8YaJNcpLFfQzqbQcI ARs8eoZd7dOT0A339dzXfBo7v1Jxvv4P/McPoX0r816XHqEhRdfGOtehRb1rtB2SQLGn wosw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=CKsVccIzaKcYEYjjYw2nVBFQ7v4MUbGpaXbjnvGVmwc=; fh=+dID43e+zysSUQt2Cn5xtLzOUM3ZysVQHoyNPERjLwE=; b=gCKOQa6Ebx/3PAXF1kkWGQoB2cTEJyl4O6mjgelR3abHO8a0hNWYgwh4SIc74oLlbp TYxxBD8cTHFPKX8OrfaYWRLVSIF5cQJxtARghPrrBEhgICvskYuwfVfxKZPczW0gRMQ+ rGcDb0zTS1SUF91Ahl/lZmGZVvxQN6IwqaLhWJA2Pj3vy4NFPNWydtWxElLvXknukfiG S8wDgBAXpJweDsvtktWxu6JCdK9p+cosP1E0MhNc4OhKG98xAQOlU5K5MhOmoIxP+BgX eXwF6NtfrT7v0A1bS+deuGWbV4VZ3VHhF3IU/4tnYHuEbJLh6qizMH+LQ93JY907JeK+ iumQ==; 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-99946-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99946-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 y10-20020a05622a164a00b0042eecf805f8si7197990qtj.224.2024.03.12.01.18.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 01:18:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99946-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-99946-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99946-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 0479D1C21676 for ; Tue, 12 Mar 2024 08:18:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 90FAF69D12; Tue, 12 Mar 2024 08:18:48 +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 4E5D8D30B; Tue, 12 Mar 2024 08:18:44 +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=1710231528; cv=none; b=FcF241yVgTlNjZaBFNEbnRhtpbTyI1IB1qaEb80clHK2kXVUKCyUZhn6qVMqsD8mRFSTNII85GPFVAHBQC57H6LgNZZciDfosrR2S3bnYO7XdP+AK3AEccCPMlYJvvRIdCOExygrLV2WUorusm/VWbLMBoLafY9ivz4tV5/j6Rg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710231528; c=relaxed/simple; bh=hPd+xJ5jOSC8o1CG2r+WXG2uyyLrv5AmWrxsGZg+GLg=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=EUXlMogEXL2ovJiojKypNOGRL5R5+89FqNZSc3qX8JCo2Nh0FO/1Jow95Jt7dwbUafTIhku9q+2XHWXgLP2D6+lgcgHLNdQKaFfzkpyrIarovWRLgSH4u8IcnBj8aqnVunv8tbtgXHqc4MfZ09UEKCs+npmMJwVoGdV8xXTIguY= 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 4Tv63W6RRPz4f3jqP; Tue, 12 Mar 2024 16:18:31 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 8ADC71A0199; Tue, 12 Mar 2024 16:18:35 +0800 (CST) Received: from [10.174.176.34] (unknown [10.174.176.34]) by APP1 (Coremail) with SMTP id cCh0CgBXKBHZD_BlXa7TGg--.10688S3; Tue, 12 Mar 2024 16:18:35 +0800 (CST) Subject: Re: [PATCH 1/4] xfs: match lock mode in xfs_buffered_write_iomap_begin() To: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, hch@infradead.org, brauner@kernel.org, david@fromorbit.com, tytso@mit.edu, jack@suse.cz, yi.zhang@huawei.com, chengzhihao1@huawei.com, yukuai3@huawei.com References: <20240311122255.2637311-1-yi.zhang@huaweicloud.com> <20240311122255.2637311-2-yi.zhang@huaweicloud.com> <20240311153415.GS1927156@frogsfrogsfrogs> From: Zhang Yi Message-ID: <04c14e02-9968-3fda-39a6-c3b44c78a2ba@huaweicloud.com> Date: Tue, 12 Mar 2024 16:18:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240311153415.GS1927156@frogsfrogsfrogs> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID:cCh0CgBXKBHZD_BlXa7TGg--.10688S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJFyUAr4xCr47JryDuFy8Zrb_yoW5XF15pr n7KayqkrZ2vF1Yv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 at 08:22:52PM +0800, Zhang Yi wrote: >> 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") > > AFAICT, xfs_ilock_for_iomap can change lockmode from SHARED->EXCL, but > never changed away from EXCL, right? Yes. > And xfs_buffered_write_iomap_begin > sets it to EXCL (and never changes it), right? Yes. > > This seems like more of a code cleanup/logic bomb removal than an actual > defect that someone could actually hit, correct? > Yes, it's not a real problem. > If the answers are {yes, yes, yes} then: > Reviewed-by: Darrick J. Wong > > --D > > >> 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 >> >>