From nobody Thu Apr 2 15:41:24 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 C63153542F4 for ; Sat, 28 Mar 2026 15:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711931; cv=none; b=QUcIqPuTlVJBcWkMB1wu7D+arr4I87L8s02f3TY4Sx41ixN64jbZwvoulIhehPTGFPm+o4UVZ7S+/Xhwd72jx5xDSiqWazjeSwetvu5dvRe/CfKZ3HVKrrp5lD2gbdeSQ70LU3SLkrJ0eWzi/ERdti/XTK12HG0iW6RFms+Dynk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711931; c=relaxed/simple; bh=HZYHztId16pgGQ1AA2UfRM6DJRt8s7EcWewCjcgDwxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pMpN1fgFwalNRIyUPifHPxd0yPGaFWsNv0jCajm5BVnac8e+rzi0fo2ShNxI8WHdaP1S6jHK3lHZFJNRDUz5K2CjdJPpQ9ITFMWqJ07CYCSNBDBsve4hcbY2Wcizx6Ax8mRH0X+UKGBcAOSOFMj7lhUPuDGcpsDYE0hFV+ObVxQ= 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=stEAyY38; arc=none smtp.client-ip=209.85.221.47 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="stEAyY38" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-439d8df7620so2176755f8f.0 for ; Sat, 28 Mar 2026 08:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774711926; x=1775316726; 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=stEAyY38LClzvvWKclpz3DZabw2nR6TzJsIrlr2SgGzHS1SKf0ShCnLbMm6tZjIODO FgBXVk480vqoK395NMSa05xB1OfhtLW72HVS/Vtak4lY4cW9Kpg3wh046HRc+iFkTGfa 65JFPnAB47nUFAoAJuJgnDCh0O9QQYye1HwuMBafR6ZzS8HJuEni4Eu5EDvTUHx5WzQK Fv7Ol4lSMlXmJ6Tt66eYI095aykBCRMw7zlXn54MISppnGBtZVt9RcdtcYYGJCfLgn90 YxnZNx868mEGsbi6f/MnFsHFCr9GV+q+u6nR+iF1ioGrHpWIDhi6ykxK1TGO/b0IPrgC ZATg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774711926; x=1775316726; 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=hq+X+l11W3Gs9Bh6m9hs2/SjBqJJS4+KtvtG0DnViN0dwoi/pkwXSBPyV/NrwLPsvh quoOiNzcINr4PZaHFVEbHvIVgGUhMmESdrw7hLWEmETFhPkzl0S95DzV35+pf7mQtFVX NVKKY9+O4a12Wj8BcDamyCbjpyoK8VenVSwu6Roqa8SOFGVCxVIdsAKovyC76HaJn6C0 LR1QzC6PlbuGBeidvHvnAGaUxoCdxbKCMOt37YYgGv4AEOXOxxq+uNHgWhnwjCAogJK2 uAED5I4fhCgiQgF+bj1/kXaMxGel4FJnH1yiYIdL3tmGKBz78oW8lH4/pcoWElPSUL2K WdFA== X-Forwarded-Encrypted: i=1; AJvYcCUIP2Ij4isRkLyDF66qCJBqOts0Cd3avHUD2j3yvDY3uI/KQOBY7s4tlFd1DD85Eu0d8V/OT7O7m1n9BGU=@vger.kernel.org X-Gm-Message-State: AOJu0YyRfHrB3Cwa1UXNm/ACMUvREqvWapk6gP/bU9V75Pk+KsoKP+HB 1QEorftiDl9s0Z3f4a3Cw0X28VxtdZCcI0dKpjlIhLcakn52JmWTkho+ X-Gm-Gg: ATEYQzwcwJqR8JVseIloROanrDvjHn4ClebeTyWRdFebfTX7LfbyMXJWWoDC6Sh44Kh yd7nDs9o9hTlgqR73S4amvbWNWpbKWXwAR+nvMushsV1D12fWxfoRgV1OmaTcFsT8wW91sN1wc+ vL1CwVYS5RZe0u7ECttit3/aGc1ofGmPkn/z1Pw7pFEgGMeN4zxbmPph0M/Qy/s5+UFp0GKa4Pq POHDJbZr/lVEmSAkvXz09RJpb9H7w3SzFgT8dj4OkjcpepHjWdSs7AF9UO4392LwZqvSPW3BUlB zyicONbBVBi864FOxhdGoN4lukQZ//Gh3z25PSSxcIcF+NCtXk+GVHWacE3MAY5g9Jd+o2pAXR1 2CsYu61JPnTd+lZ706hxt8nPROKGQ/VWBsI6pgC0oBSofBk4/zLhWSuPqcNYHip44+/9jRk290b Pw375IbF3YE943FhZlhCL7yqutVGfViSs8KeqCT2CRiT+KMmGCxJSeZ5ZVEYUnjr/HL6IemZlmM MBvIq62v+ql X-Received: by 2002:a05:6000:2c10:b0:439:bcc2:bf0a with SMTP id ffacd0b85a97d-43b9e9f9d91mr11294450f8f.23.1774711926113; Sat, 28 Mar 2026 08:32:06 -0700 (PDT) Received: from f.. (cst-prg-89-171.cust.vodafone.cz. [46.135.89.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43cf245f8a3sm6725310f8f.24.2026.03.28.08.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:32:05 -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 3/5] fs: enforce locking in icount_read(), add some commentary Date: Sat, 28 Mar 2026 16:31:44 +0100 Message-ID: <20260328153146.3368470-5-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260328153146.3368470-1-mjguzik@gmail.com> References: <20260328153146.3368470-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