From nobody Thu Apr 2 12:13:03 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 D366E3859F0 for ; Sun, 29 Mar 2026 17:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774804820; cv=none; b=rPL5/vTMQ4h8jERpzrDZoi5Tdsgb1pyndSQ6Hulm0p4IxNNamyQojPs5/aJ8kquXZ0N2hErEtIX/TQQ2stXwy1CX+L2/4oVCBfTAxtNYrY3+I5RqBkxLMqptvMwau37EvZH7OiXGCJl1jM7N0Dg+UjXP1Xg3xDdfI/bJ/tKwvCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774804820; c=relaxed/simple; bh=HZYHztId16pgGQ1AA2UfRM6DJRt8s7EcWewCjcgDwxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EuzrUQyCCMinyLS6dsIAKkGC9bZE7gfR7uVWpBHlBfio20t53K7fWAPDg5q1KMPjJZut2NDv9yEa24dIsfBMclvbFWVl4N9w6wtXba5VayFBoFLrSL3kibM1j6s/wJTtfQMYF3g+DMcZuECiS0WhG0fz8NnFEzuks1zCEcST5Y8= 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=niFPxUXC; arc=none smtp.client-ip=209.85.128.51 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="niFPxUXC" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4873ce69ba9so1095165e9.2 for ; Sun, 29 Mar 2026 10:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774804817; x=1775409617; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wqq43BIgVMA1uE3zJr5f2QtdxqeDEFGIZU0biEFlpEg=; b=niFPxUXC/63chZUq+K34EG3QtUOVNXVlgdYPHjrBa8ngLmDm6bQak9thHc5kGYqhgh gCgsQwhOu40Wb3SmYD/qxSgcMlmidwlLD96+rO55faYzrpFBe6uoei+/pK5rzUa+OJGI V9faHJ678PgPTWy6SPazkJdL1XPygDKbS/D3u9Stjcsy/35J7IYkAWaIXR26fcdfSIdG OyzBIYt/IYROOGfg2+tWrM5EodpHYa5qzsfBGJI2Tx643b4A5LUbv5Ee5VJRnilRArCo DmHSPSXr4Cfx82Une3NckzzqieQVqYGJNjZG3iPPb15QLzjweH2sAUQTZF+TWFqxmJzA LX9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774804817; x=1775409617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Wqq43BIgVMA1uE3zJr5f2QtdxqeDEFGIZU0biEFlpEg=; b=ZwaUx6ggm1OLAI25boI8dMVGZNNHJ0gkj0/p/Nb38iqd4VllSgBVwMULLLJ8Rom6Su 496OHy9oUROou6yTXuQNAFLBpW0ebnGr5KIUoU2smPJsqxlhAzXduvKUcLDL91Gi7p4z IZQO+fAK2UATN89PzxnECWWksBJrOeGnUWP2d0VfO1I4ocQEbmWUm6UxLmXVNOVENG0S JdyUFGtj+jLYSnp6cF3s4sPBmdY5kG2nblJBSFsBe6LkUULBZVCQeywyix+RHugKnM4J hTJAniJ8RLL29bh1h8xUx2b9CEYXEO+fciK81bz/7kjodooM5RmJBkCznicTLeJiLP4L OoqA== X-Forwarded-Encrypted: i=1; AJvYcCXLcnBAK1h1q/+JVYtKtj8YvbDAYWncVOA+dYOygL3D8uUOmuhEhy4OiaLZmPC6tcmdE39M3vfErV6CNyE=@vger.kernel.org X-Gm-Message-State: AOJu0YzzZMWkyFKh0/po5cfBlFx581OjYALXBPYah8it9DV8L50OOObX Lhr41Cckjj4ZxB7951u3HPscqkdaF0fw39tDvIl/lInLR6DvCyHSFVeE X-Gm-Gg: ATEYQzxEzXRk9yFtWoe1yMm+U3iqKUWZ1342f7sMHuSzGB7bfn5lOsIhNHiSDr6lhm+ ILcUuJksLrANAg0DvrFKG2th++OqWw7gzbU8R+XEL/11sFlmZVYrRxlAdgLPB3f21+MKMpQhbGj u/T/rypTLxvRFNjTTFihwFh2OGnV6aA6/Rw9DeZJQD5L667C0Zgj2PYAXXmER1PWfRE5BpsYkXq tR1g+hMq+OsvGFI+tZkNfS/lGXLV1HJJKhZAjsrRft/jVYdRdj9TbCLvBEKD7M5Z3LmCVvx/zma iFdTd52U7AQI2soVeur7V4s0LVA122ih7AAf5ehvxuoqnsQOc/rm2rf2yvay5KgMgZ9habHy6Pn jpMLpVWCkT9OS6JpsLGoMLUfbwz1E8G/Is8udsc6a46gwFkvZoZJTdCBRppZn5Wnn1wpFd7Ekzi N6x5po6GU2NFKvK0xqQ3BEDJfIrJIKNm7vrcl3AuYJyun8xboMpTxaiuSD2twVqe4W/+SvUXPDK A== X-Received: by 2002:a05:600c:45c4:b0:486:fe45:483 with SMTP id 5b1f17b1804b1-48727efbed2mr164015635e9.22.1774804817218; Sun, 29 Mar 2026 10:20:17 -0700 (PDT) Received: from f.. (cst-prg-89-171.cust.vodafone.cz. [46.135.89.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4873cd7d039sm9776805e9.15.2026.03.29.10.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 10:20:16 -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 v3 3/7] fs: enforce locking in icount_read(), add some commentary Date: Sun, 29 Mar 2026 19:19:58 +0200 Message-ID: <20260329172002.3557801-4-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260329172002.3557801-1-mjguzik@gmail.com> References: <20260329172002.3557801-1-mjguzik@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Mateusz Guzik --- include/linux/fs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 0cf27085a579..07363fce4406 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2225,13 +2225,21 @@ static inline void mark_inode_dirty_sync(struct ino= de *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } =20 +/* + * returns the refcount on the inode. it can change arbitrarily. + */ static inline int icount_read_once(const struct inode *inode) { return atomic_read(&inode->i_count); } =20 +/* + * returns the refcount on the inode. The lock guarantees no new references + * are added, but references can be dropped as long as the result is > 0. + */ static inline int icount_read(const struct inode *inode) { + lockdep_assert_held(&inode->i_lock); return atomic_read(&inode->i_count); } =20 --=20 2.48.1