Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp646332rdb; Sun, 18 Feb 2024 05:33:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXe2Fi8DMMjuTbsB+WA7cecMtT1u6mpq8ZbqONp1WASkwPTFvvS+FsnFGRAuRhBk9bjS+fVrpwOlZ///UjqIZhwqW6VrNHMmOzoH4GZuQ== X-Google-Smtp-Source: AGHT+IFOAccmE9F0W8ZcxxsbPKpBSwM77i1SVeZxQnA1UAeqd6F6uez+7Y7/QAiAPoH5Zo7zrKbd X-Received: by 2002:a17:906:b0d9:b0:a3d:6eb4:9769 with SMTP id bk25-20020a170906b0d900b00a3d6eb49769mr8484381ejb.15.1708263228637; Sun, 18 Feb 2024 05:33:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708263228; cv=pass; d=google.com; s=arc-20160816; b=lKjjkgcLZqzd/ELHU6cLIdoVP0H3lhZ2OSquStAoI1ugQf94pedvG1j4sot/GMkttY gCj2f87l+YTsWPXf8vT3fBDZaaUOWGs/0iYdLge6zsgglziK6MvqV84M9r1PQT0Vfi1O bmN7pLkh1BgLFLXTVdNLcOxb0mS4Hcq/sqUY/B6xRLkPlaBRcw9oq3ADNw7D3QYj4gRN hCTyhklFEgSXSwgiDrbN5lvR6kli1Dwr+VnozCmjs4IRYgDkVvbPnYYN3x4h/+MmMvh4 nGH/hNd8dXpyQGaBcZRfN6aUjsgQJ5iDyQzU1cTcU/jqfY5qWL2he62OWwjhOWdBH6X0 U4cw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w16-20020a1709062f9000b00a3d6bff77e6si1657696eji.878.2024.02.18.05.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 05:33:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70400-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70400-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6027A1F21795 for ; Sun, 18 Feb 2024 13:33:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6825F6BFAA; Sun, 18 Feb 2024 13:33:39 +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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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 --- 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(-) 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 --- base-commit: 292fcaa1f937345cb65f3af82a1ee6692c8df9eb change-id: 20240218-flsplit4-e843536f4c11 Best regards, -- Jeff Layton