Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp436706lqj; Sun, 2 Jun 2024 05:37:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUlNdnXwpayX7FX7hijwfvWC5+JRC2cV1CupfLHfkzNONIm9BibPjOjnk2x1cdDAy+cNPhyYUnnk4uE8vggxixvCCk0OmO33Z2Nlg5fUQ== X-Google-Smtp-Source: AGHT+IFZRwm6XM0xVPu3N/og/G9qNO00vSdoy6IiUgeLsT34gkj7lcJfYqcihU2pusvX/mYZ6ZX6 X-Received: by 2002:a50:d683:0:b0:578:5d4c:9408 with SMTP id 4fb4d7f45d1cf-57a363de38fmr4021192a12.23.1717331864951; Sun, 02 Jun 2024 05:37:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717331864; cv=pass; d=google.com; s=arc-20160816; b=ATia2kDqkXJ63CKXNZwRT68aIU7R5z+qJ/0AfJXqvBw4EeXF1jzMs0ptfzfuM2P4qw JXlldEO2M/XhoUAhI96K4HDGisygWLufwfcfMeOoFMcRmUYi7oleOWFkPLtYLWBNGGFL x9XkvInsb3bz8bTo1FMjfid85PPWhxhfV21SwtzHNGsQGIsKCyf50HRIXwuKG6AtI8Nu Tgre70wgjqp7Sg4+qgSzUYVdWPllK15OuCO4L+K/Rw7tGXBdINgydRKEC3qaurjl/iIZ gEguVqJKs3X+0bVDOTSbf9DZGl6RTBH3NcBBhB+QagfgO1rlmIsmElNqsE/syDGiGsZY aKbg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=jMVpBdm/RCzwpbeUfndCQVwoxC4l89U2dNUnW0vsaEI=; fh=Fvzcu4UZSbGZi4urVQytO9VR0vjtmNG9X/khgizm5cw=; b=f0Gu62mL2vrRcCuAfs0h2108JKKkz5CtIE0Fd2dmXC46oyc9vCV7FgpEtIwTV0Mluw VJgln6DGRmTX6uThZTlvujnBbolz3bvzVQwaZ5m3jraQcka/bSBbCWj55Qa0VRAefMLE r1nYKLGNR06nKmvvjJdmSGittmq2k/gxB/GIV0L5JFOJElbVIMB1LB9SltQpc6sjbIeT yHoMsYpqIh8+bg9+mM6c2gkPZWJ6isOGzGkmYhvoH3RpNhkuJYOCOSCUxg4qSGRsN8sd 9KXCbHOzXXqKp3ut+E3F+yvQuSOkTWqhE6Q3miruVNdd2Ya+jpax/yssV1L0gDyMpKFV /Ubw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=T0q06Qgj; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-198233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31cade09si3091694a12.585.2024.06.02.05.37.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 05:37:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=T0q06Qgj; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-198233-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 AA8A31F21A5D for ; Sun, 2 Jun 2024 12:37:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50EF23B2BB; Sun, 2 Jun 2024 12:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T0q06Qgj" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 004BE1BF3F; Sun, 2 Jun 2024 12:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717331852; cv=none; b=gw2f7a5b26cRK2I4dcxsiNdFgmLxCv+ZFr1lPaQN9G51wJmXiVqnfzLT8BWzAEgly7M3IyLrLieqt4vprYIiLWwORUpNeGAlyTcih41smRyzjQnm9ia3ebXYx3a7itauvF610Pjxto/0VWCFHQUQv0r2YPHXr/AL3YcOn0rs6Fs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717331852; c=relaxed/simple; bh=t3lhITYihlyBuINvTQDldM9iS91lFh6g6ieokskjtOI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pYsjjN/C3io4aev8Auao43qWEmAldW9kXWmay9z+XYmWGhF9/nO5WaZ8BpA2cnmy+qmCNt/oUI+sZwsmdkoddZv+RqUdMIj+H1ycnPNco9FfDVbzhsxR/blQHP8Ch/OKTgYjw+XJcjTyfj9+iaJzUzAMSBBSKND/+0kzQyLxRLA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T0q06Qgj; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a6302bdb54aso440553366b.0; Sun, 02 Jun 2024 05:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717331849; x=1717936649; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jMVpBdm/RCzwpbeUfndCQVwoxC4l89U2dNUnW0vsaEI=; b=T0q06Qgj+rwuEfVvNBlS/B0EYcJDFcgV0NKACv2XGRN6slp1HS6unix1++qgCgz79X QF0VjKPe9cXIfOfhZCDamGMsk4VcZ1HatCS11nME+42kj6gZGaflWYSAHPegVB5f1Ti1 K0kdm8hU9GpRGfWj0YUsjir0mYc+GDGWdDvlLbtBKvYBQWH0EknvQXYotAnSsACW4/74 84NVm/LLHTSyS2MWqGXDsAjzJUNlDnmMXZ5En0o6OK6SbcGUwCM1aAlvHVvQpoXZxqsV prbpf196/GWwwSDm0h2bRd9FURKWiX94XEwy792MhqKCNso2Ibsg5msnrI5X0szTIjLr XIsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717331849; x=1717936649; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jMVpBdm/RCzwpbeUfndCQVwoxC4l89U2dNUnW0vsaEI=; b=Z1tGn1mlojkUA8JQ7Y6MBMEx+POCmRJNC0eOUn1lndLvORQNibSPH3yxXENgv+Ta4U ZLxaWnnHEjxL+UcdxJyAVKivmhbhjX855mCRBTDucqCFINNHYWm5PMfIgweaEM9KVx3W M9nzosrxmuMJZVup9Ini6oQYi5N2WC3ox1C6lil+uZGec59ZeHziCLJag53ttRyWh3XG 52IkfW+N2UuKtsBVaPcqIz/HsBVu6039av+Bstq7qBY1xLrdOxSRmBhYhi7BNMeunWJP Py+BHq6NJzwao9lXCL2tAUkpdA8Yg2YcyOsc6zAKV5krxhS9KwBVnQaHO+uCFBAheXuR bEvQ== X-Forwarded-Encrypted: i=1; AJvYcCX+0yDoMHr0WCMHIwlgv9ruHfu0pomyQO/u9JjMMBcizHraQsjvt23/8MyMNUxEgVLhW+OMsxPQIHyTwAwrPprLwCFYUT9BRc5vGHuVmXldtcC4jeVwcT65g8hkrIa6Ix7K1GIBJhBKYvXsFw== X-Gm-Message-State: AOJu0YyR3ct5pCZdVYHMYcilJhSLMzbk9fuS4/ZbcFbG8M1NFF9zmgho T0uV0vKF7s5ZnZswvuBQzRweB2IdpglrS6hnw6mVevNe6fm5SUKA X-Received: by 2002:a17:906:fa90:b0:a68:4804:1eab with SMTP id a640c23a62f3a-a6848042247mr383998866b.69.1717331849130; Sun, 02 Jun 2024 05:37:29 -0700 (PDT) Received: from f.. (cst-prg-8-232.cust.vodafone.cz. [46.135.8.232]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68a1dc4e8csm230644466b.225.2024.06.02.05.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 05:37:28 -0700 (PDT) From: Mateusz Guzik To: brauner@kernel.org Cc: viro@zeniv.linux.org.uk, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Mateusz Guzik Subject: [PATCH] vfs: replace WARN(down_read_trylock, ...) abuse with proper asserts Date: Sun, 2 Jun 2024 14:37:19 +0200 Message-ID: <20240602123720.775702-1-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Note the macro used here works regardless of LOCKDEP. Signed-off-by: Mateusz Guzik --- fs/dcache.c | 2 +- fs/quota/dquot.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 407095188f83..a0a944fd3a1c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1548,7 +1548,7 @@ void shrink_dcache_for_umount(struct super_block *sb) { struct dentry *dentry; - WARN(down_read_trylock(&sb->s_umount), "s_umount should've been locked"); + rwsem_assert_held_write(&sb->s_umount); dentry = sb->s_root; sb->s_root = NULL; diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 627eb2f72ef3..a2b256dac36e 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2246,9 +2246,7 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags) int cnt; struct quota_info *dqopt = sb_dqopt(sb); - /* s_umount should be held in exclusive mode */ - if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount))) - up_read(&sb->s_umount); + rwsem_assert_held_write(&sb->s_umount); /* Cannot turn off usage accounting without turning off limits, or * suspend quotas and simultaneously turn quotas off. */ @@ -2510,9 +2508,7 @@ int dquot_resume(struct super_block *sb, int type) int ret = 0, cnt; unsigned int flags; - /* s_umount should be held in exclusive mode */ - if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount))) - up_read(&sb->s_umount); + rwsem_assert_held_write(&sb->s_umount); for (cnt = 0; cnt < MAXQUOTAS; cnt++) { if (type != -1 && cnt != type) -- 2.39.2