From patchwork Sun Feb 18 13:33:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 202794 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp781379dyc; Sun, 18 Feb 2024 05:34:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWdMYs4HqBN1vA6cE9sIoIQ3KoxhvKdzxz7d9lGURIKCSWgRExozszz88e+iHDoJjq7XOeBYRPwxmS6Y443vHtTOGmjvA== X-Google-Smtp-Source: AGHT+IHzR7290/hj5hsOIuOZkdM0fPQCsv0x9tw5x4qxHQ8sDEHXop2Xbh0aA0H7HfuOMEBXlAQj X-Received: by 2002:a6b:c853:0:b0:7be:f7e5:44fc with SMTP id y80-20020a6bc853000000b007bef7e544fcmr10426093iof.21.1708263243356; Sun, 18 Feb 2024 05:34:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708263243; cv=pass; d=google.com; s=arc-20160816; b=NG0rC9fFtTHXuoTGf6DtsDfr/GYFIz7twu7kd2QgRes+OpnOQUjMeQjV8BRLA9xYcf LVoGCLqEZKVX3LICgDr7Uf5RJ5K8n8y1gLhwOnVPH+9FqpTjoAOMHhruYiDqT4hkZYR0 kaQvdlaqFjM+cHD2O8f7goCFXSMYDaTdoBKLJF1E0D/v3iE7QCr6LezhyeAQZD/Yz5EN xT/1Eq4dAX4O3aiZa3NkR6kBHg288lIgKo13RrRAXbT+1gs7HMCblT+1PE2AnDrHUyGX 2CcTmTwPmrxZW+O72OmU/tLq23UPelFSaV/xyb8Xci/9zEsoaSeMcMbk0a2qPkg2Gy6M adMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=9/1ws/0lnaPHCYO+6PlDCIrUoIpOQfjqCziy9bLGyC4=; fh=uH1v7i7e9ySz/BC2QiheANIP7IZ5kLIsusRmeBJ7NpU=; b=GfN5iRk/WOBF4HnrjQZkvou9/vpeq3M2/pCKOhMEiHbJSLAJ//a1IFe+WQyBsdrVNT W9TO/ujT+ifaW9998GxmPa3SjkEfnKWiaV/gOKk7IFz0QZVAc/T+odtnDEWVJeu9sNLV D0eDsfp61hAYUO5H1/vVvSwkMmYCRH4v54nVtfDJigXvPPNqYiL98mBesBrdANhvRKUw 9KiG4ulfr2YuM3tOr2tRX84SXOzs8wSC5nGpyAhly5GhE1W+zxKkKjgw0PTQ8qhUm/Op vPLmP7y32eExnx9OTZ5S9ToJ5qrRvDLtY0o2K2gXbymQMGXeBE7DIj0uVmp7Kw539Db6 EHMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A5AnTcbZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-70400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70400-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id dq15-20020a056a020f8f00b005dc87fb54d3si2891134pgb.674.2024.02.18.05.34.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 05:34:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A5AnTcbZ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-70400-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70400-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 2DCFFB211B1 for ; Sun, 18 Feb 2024 13:33:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B2C76BFC1; Sun, 18 Feb 2024 13:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A5AnTcbZ" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8ED2131A66; Sun, 18 Feb 2024 13:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708263218; cv=none; b=nfyMYK5SRQbk3jYsgi5rJkX/TbdIvxPccPLY4cwqYP9pShVocX/TeFACtuR36dIJ4DEkzMZgR61ZFlN4fQk8KE+zQOXsNIqK9AMi7BxfSDXcb7x4I2JNYuFt5DmCTL7h6o1uNg0jJniHUi32jrhWJ2jBeZNxBDmallszlJXLU7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708263218; c=relaxed/simple; bh=IDweYqBpmZlAsv7IhKK3kBhul5F5hUUql81YNN0YZ1Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=JGBsDDJ2fDJERkpcc5GFObHG4aZHbQonFSn5xPyOhp3tjJj+aapDU3RPYtrj0FdoCoLqCG9k78Qb+NbmBkQ7mODbw4bg41rBpP+tikxDFcGTf3MGC5mR4FPuEsMxxVox6bqf4S6U/MFtUU3HJe321g8JwUAPmag1ewxXR6kLe8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A5AnTcbZ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FB8AC433F1; Sun, 18 Feb 2024 13:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708263218; bh=IDweYqBpmZlAsv7IhKK3kBhul5F5hUUql81YNN0YZ1Q=; h=From:Date:Subject:To:Cc:From; b=A5AnTcbZVZwx5KC449LPsCqwMUWmYNN8yYfvxOOuPTApiuyUwV6PIHDQgpjZiNFnB FXgDtAQiAzDyEX3CZs1rwWVzKiQ64icSCkM0ulDOWCtuhmhaYcwIiRvOJ4Q0iT88Tx fQHzPGEOB2Y9MoFGNNOC1vnt1GIeEsXKn3UoXpG9pYylwOHeIyt5jljfpCaN1A/sH8 WGB9t8fQV/wYCgfvDNSGbPpg8YVBopBB0YkA76sQtHv1f1T1xaDsDZLuJ/UYjYLqH/ aCIIXDyc4wLFsu9snrIGPAso35O5ZHFOQsqLs5+mDWhOmxWlAV8XixfLnUuaNFNyE7 KCoZyj2xbYMPg== From: Jeff Layton Date: Sun, 18 Feb 2024 08:33:28 -0500 Subject: [PATCH] filelock: fix deadlock detection in POSIX locking Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240218-flsplit4-v1-1-26454fc090f2@kernel.org> X-B4-Tracking: v=1; b=H4sIACcH0mUC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDI0ML3bSc4oKczBIT3VQLE2NTY7M0k2RDQyWg8oKi1LTMCrBR0bG1tQB y/KxWWgAAAA== To: Christian Brauner Cc: Alexander Viro , NeilBrown , Alexander Aring , Chuck Lever , Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot , Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1902; i=jlayton@kernel.org; h=from:subject:message-id; bh=IDweYqBpmZlAsv7IhKK3kBhul5F5hUUql81YNN0YZ1Q=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBl0gcq+QwOhaWuQJAls6+uG0WF8F76TKJ6MfEug DeeIqVt6B6JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZdIHKgAKCRAADmhBGVaC FTbLEACbVUKzyO1ficrtYrsnH14RnDccj6+5uQ2KLn2lxHDrjViEHMOw7JqIDwqk+d7KmlITzFO mARHJd1kLBhW6LZrEuvsZp7DOG11qFrdg1RxuYoFPxs/u6vpmS3r8ZXv1Ie3EjipQ0qgf1CAP4W 5HhxmhacHgOafjFDR9tKtogkQK6cW78LDRHgj3m3LUn3hn6keyXIBWQk3IxWYV2uir1QhSGb0kG M3nO9Z25j7zdITcYoaLBiumZfAX9vM6Yd+jp297vgGaLaovXkQ+VNgJWOEG4EEaT11za5Zd830X BDoqqyEctFwxiLN+dUcu/cob3KCRf8jEMrKG3kPiKZ0fGeuXMRZpCg+tyjAoB7AARe3Jb0JwsR/ xISfawginnqn4b7NJRmqKEESb58qi7fNmxYjYY9dFZCDfCbxBSe8AoNKmXCxe+wMBY92g3yUERM +wDBitj1MWUmTVIJnJh4HUI+vCymUW4ZNJtVQnP99gTR9cqHo3DLbRv7OjeDW/Q+GGAPDxvhq81 91nwpL5QCDcNNfpIvHt8TGPBdmb4KWmxdTl0OAmLys8dNCQj4zlcHFv2C/DklKnMyhLDVw1VvKz rTfJH6FSoSyJAAfCMvag9lWWASJtmADB4M75ehtju+pWb0Vqpwm2KBJUJ4aKVkdF4npBlz0O8cY mJClbxOtcjg3nDw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791243838701441111 X-GMAIL-MSGID: 1791243838701441111 The FL_POSIX check in __locks_insert_block was inadvertantly broken recently and is now inserting only OFD locks instead of only legacy POSIX locks. This breaks deadlock detection in POSIX locks, and may also be the root cause of a performance regression noted by the kernel test robot. Restore the proper sense of the test. Fixes: b6be3714005c ("filelock: convert __locks_insert_block, conflict and deadlock checks to use file_lock_core") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202402181229.f8147f40-oliver.sang@intel.com Signed-off-by: Jeff Layton Reviewed-by: NeilBrown --- Disregard what I said earlier about this bug being harmless. It broke deadlock detection in POSIX locks (LTP fcntl17 shows the bug). This patch fixes it. It may be best to squash this into the patch that introduced the regression. I'm not certain if this fixes the performance regression that the KTR noticed recently in this patch, but that's what got me looking more closely, so I'll give it credit for reporting this. Hopefully it'll confirm that result for us. --- fs/locks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 292fcaa1f937345cb65f3af82a1ee6692c8df9eb change-id: 20240218-flsplit4-e843536f4c11 Best regards, diff --git a/fs/locks.c b/fs/locks.c index 26d52ef5314a..90c8746874de 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -812,7 +812,7 @@ static void __locks_insert_block(struct file_lock_core *blocker, list_add_tail(&waiter->flc_blocked_member, &blocker->flc_blocked_requests); - if ((blocker->flc_flags & (FL_POSIX|FL_OFDLCK)) == (FL_POSIX|FL_OFDLCK)) + if ((blocker->flc_flags & (FL_POSIX|FL_OFDLCK)) == FL_POSIX) locks_insert_global_blocked(waiter); /* The requests in waiter->flc_blocked are known to conflict with