From nobody Thu Apr 2 14:06:37 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 5464B34D923 for ; Sat, 28 Mar 2026 15:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711923; cv=none; b=ZzC4KMY7MC6vmJpV5/tQHRzJLgoW/9w8hxLIZnNCLktVuOqTPimY5VxotCcSy1Ddz5xe9H/CmaV4kEoR7nM5vriHE9BSLFdx7NxZ4/HrlB/DGBB9UEdBFQSs9mnhEzx8ETU/I+ZuuJTlv+GlU1zO/I2yM2leUNG4ap5bPYncasY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711923; c=relaxed/simple; bh=q6/M4OdZtc+alS1DwnvRyoUObRGRNii9NRUn255hTcA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HX0PnSJ4bLeQItIcN5GUDfvDhOMdlI5xvXhufCV+T45g7vpyKxyH+Bi+5DBtl50i6O2RThjBtYb0cUAPnFem1caCSD/EQPoSFcmWpiTozImUm5g90iGC/AKVuKiSr55NxoKM8SLuomlGOUEiIoWtvLJ3H9xvnR9VCOW9lIpe704= 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=om9yepfQ; arc=none smtp.client-ip=209.85.221.44 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="om9yepfQ" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-439b2965d4bso2251297f8f.2 for ; Sat, 28 Mar 2026 08:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774711921; x=1775316721; 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=ALuBtMTHfXISMz1y0xRBvnd5xru82Lmp3xXwNF/dfxA=; b=om9yepfQRr8klFNMvWLAWi2Kab1UlzKAjEjBAqi0HPoGBjhw5Mb3yaICWhsYG2GMTJ wiBrcbBaMavI+LxFOhKPf6guVOzUTLWV6/ARU3uUGhFlk2JZUyR3bkde7a1SF6jmw/ao eegKZfUTjeMx61exPWqMkWxo3Do/siBJZO/urJ8MYKenhux+hX8TiOnKXjx2wFyiPCyr FQhrUbGLpMwBJF88EsKSNqXnehFGEfO/K9N82HhK0FC+yVzh43TyOUS++UIwC59H6TWm VIxivIpIAwbGgdcaVlwQf2YjvapUjCkgbD6FG9UYbDrWB0YdWMZDA0eQUuZeoGj5LCzs GlMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774711921; x=1775316721; 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=ALuBtMTHfXISMz1y0xRBvnd5xru82Lmp3xXwNF/dfxA=; b=Net1zbIzUiyFa69FNDXk3Cgh9UNji5S91k2GPSV/26JMxxbO4oFawRHbxhgYtMRPur gy9tBLuH4eqICKJ+V0pSddOwQXIWvc34ebNwTNCFfhDW//X2T4KfpS8TSYRuFzbP02Dx YiDuDvjb+1HutJ5zhJGRHD3CcrR+zu3nPLqNNkh/Vax3+0AcriJHpACsE6HKAWlgo1M6 yUeYT165JRnJXRd1Er7cXEDutm+XIUSFobU2oaGUNe8ImOmFhaMm9P1fJcQuBKX0UKjt PZduG4L6IIsF+Sb7BoYfU9KABdmomIQ3g3NTEMDJIbq5mGIg4iYfujue49iB/dnmx7tn Es5g== X-Forwarded-Encrypted: i=1; AJvYcCWtpgtWlHXml6hDE+SBVjuHGy0Vb62xBL+LcXEYug49YM1vU6XOR3U9m9iUZiOoZxskYJnYIyrMWibI1m0=@vger.kernel.org X-Gm-Message-State: AOJu0YxQnH0pd2tBNr220SYzUoQoClhCbGx6WUw1imcA4UI2fboSoN+H uLmE/RDigs926aEQY6b9/jfUqNdCJ+MuVPTc2+klreGqmHoWSUTij9XT X-Gm-Gg: ATEYQzzParULJPhq+f48b+y5tCzcucrKUNTqiyg6nBnj+n/xncMg7PysxPPuZW086RW 4SQTaj61XQCNQEzxOwFNTaRuUSMm5kZZzTBaHqYWB7TgOPG/oJf3gsZXTMOcU38+uZJ7ReQcHqX cHDwCO35ECkw1gMnvOu3RHwMNqNMSVmZNfZIaQ1c1c+XBnbuWPpqTU0Mi3VBIJYnPDWmzrfMAnC oBxOVVNTeviSNWiv30K4yoVzaMJrcYji30kl54tysAvgF+TCtLmyihO7OYL5KQXgwjzy71q6S+T Wsc3KKXtkNjV5EyFf68TXdWD2yA0OO21EMQs8ibnmYlJarX56g4cCBpji6EgrFvdCwjrIfiYwZF mAcU+5IzC6RxEFjdfyUwPCyxmcWMZoLRVjTpg3U0FmhUYeYbPPkK8wrU3km2oWzrbQ4s9TGOiju tr5vag3TiCzM8Sir7ccLQ/+H2iQ6dMoFsr6ae35hA1+dx1JvH0adT995pp8M24MO1nxPHj5F+sL g== X-Received: by 2002:a05:6000:2013:b0:43b:8fa4:194d with SMTP id ffacd0b85a97d-43b9e9d5eacmr10558088f8f.6.1774711919377; Sat, 28 Mar 2026 08:31:59 -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.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:31:58 -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 1/5] fs: add icount_read_once() Date: Sat, 28 Mar 2026 16:31:41 +0100 Message-ID: <20260328153146.3368470-2-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" It will be used to denote the caller acknowledges how the count can change from under them. Signed-off-by: Mateusz Guzik --- include/linux/fs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 8afbe2ef2686..0cf27085a579 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2225,6 +2225,11 @@ static inline void mark_inode_dirty_sync(struct inod= e *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } =20 +static inline int icount_read_once(const struct inode *inode) +{ + return atomic_read(&inode->i_count); +} + static inline int icount_read(const struct inode *inode) { return atomic_read(&inode->i_count); --=20 2.48.1 From nobody Thu Apr 2 14:06:37 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 7BA61346E7B for ; Sat, 28 Mar 2026 15:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711927; cv=none; b=cBHS1TVTWg21+fy3Wkh2sx8PBbpFFLP3PMLqjP+NaOv5JbTZhV31W6J9fGDihN8p0HdG0mBQ70w5/AjX/A9bWbHm9q+SRzUHFr1l/zN80fZI7XQN38a9QeYBcZV1lSYzyq939V+wIXS340sT11dYG154BcxwcxZUMsNccs/cGP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711927; c=relaxed/simple; bh=8xxPYCYi3jBF56gf5sck7mIQAohhuUh0PXeHCMgHG/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KtUrYNKEed0o7waFYMhhvmEzE4ZRpG/hdD/Fn50jy/9ESzRmozede5HqYg9FGWlwxVaNWqtrfwr+ikv5C6iYnBjQTHTHcgyIHLXl1MsSeacd0ooxYHEC94pWcwitMz41PegCxhI9aQwg6E1cCqBMqCTZhwMZo9nO2m4lEbgg7W0= 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=q8bcC4eJ; arc=none smtp.client-ip=209.85.221.54 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="q8bcC4eJ" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43b40fb7f95so2619538f8f.3 for ; Sat, 28 Mar 2026 08:32:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774711924; x=1775316724; 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=a1fu/byEUJ6qDFBkZYB9aFVVTkqU/ACSQVsqGJXvhx0=; b=q8bcC4eJOQYbil8NGBdOt81HF/4vTAcwbEDFZ3scAR2+LuXvUXtcvaVP2mIGWdSFxc blBq6JEb3aHBflnt84K0U8/rmiCzGLQphGTmzdN44dum0FVnqSe3ZHsA9A1WT3QrmNNP wdYxd5mWj5HH55Tt8kuPVYctQwlGBlTdhddOsPKT+EElRutad8QI/pkkiv9FQuyZJTI1 aTs892ubAwUK0AJzT7NIqXqBH8k5ZGjlteKXJAMVxNGSLHwhifCQpJQF2o5cHX1wXWXC WBSqE9nrcu6L3R88IVZtXEW1CjArNA3pJ7KuINKTb5QsSJdC9ZSwNYk9B2VltlPkrq5Q OqoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774711924; x=1775316724; 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=a1fu/byEUJ6qDFBkZYB9aFVVTkqU/ACSQVsqGJXvhx0=; b=p7UTEDekImh2as9iulDk7GLTqXsBprAw3e2xobkBZfDoKaOrtTpzX3UcJKLaIDYC+Y smOXEYtCXOB90BInXttp/89S2ldCCBU3rN4hrQoe4Lo3QwXaLREF7jOmsQVc4v5aPKg/ V2eLaVpP5/owyljI6gQZ7MmBe6u+l/DjY4paIdU+ucrhkeeMdDB7xLDMiYgjvkThrspI QXTLM3V1zAHXQTHYdUSvJhpnuTKWAhPG0USANRHsP6VREa8G7TVqN+bOFdsZIHuS9r2W dwAtqMfhUUlj7eDSpFV1zZpyY9wUZMs3nRpmq9Qb7k5sKpdnksScJQNFyEkpWh+jupfS Jqig== X-Forwarded-Encrypted: i=1; AJvYcCU+wlgJApl8mDkWxfgYS/bfH5YhoR7HuqAsxp1wt7NIf/rZTAE26Vp1igAPoDUZ7puU1Xav9S/8cL7MClw=@vger.kernel.org X-Gm-Message-State: AOJu0Yyk6qE2OwTb7ZrqpsfKGumc71MMbZ1KxVq8ULB4XUrwX+P7eWno oNdlwRGSiiAPxzKUw3zvUSkDaCBTVUZMhz0zyj/BWLJkRvsMzmYfiTMh X-Gm-Gg: ATEYQzweDdu7lZM79Ta8hu1C2rtZ2pOVfXWIfKR/coqi6EqJzOROjhZS0CtcmVRgzyT kVdna8alieIp6iECr5gLpTLIUClRLMNcUZWywOL+wxqyyRe9hfvJ6tXca7bUeBfVTbIGaEXIO03 cCoArZQxiJBThJKJ3NaVqZfwLfZWsfDh2mFeo3/8DXunZId939FHuDi0EIxn9aY1LGI9C0KIN8u sbaQNsIu1nAVaDEcxY8ev/rNZmAu76xgl1NgQqQ6BMADeXgtGEBoZ8PblBsLiP3+qfUQqQ58TiG Bgn+O7UMuYLaA1B6cmTju+V3Y4MhMJ5wKYSFEFrRo0oG/8jR968qW5DKIt1FDAGRTkaOHbIZnhV ROKBXMORt32Dva8+4h1K+lPITO/rZoiMFXhpr8amApBPhAJlmlIEAtHuapYEhebSwOw67sQo1IR 0LhvEJmaZ7inT1+Gm9DulqHt9lIm/lsb+/0FNzhLH7w86kK66RVtgj4fjP3cwc/Bftvgz6rsWM8 A== X-Received: by 2002:a05:6000:4212:b0:439:b6ae:5d5f with SMTP id ffacd0b85a97d-43b9ea6267cmr10909586f8f.36.1774711923702; Sat, 28 Mar 2026 08:32:03 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:32:03 -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 2/5] Use icount_read() and icount_read_once() as appropriate. Date: Sat, 28 Mar 2026 16:31:43 +0100 Message-ID: <20260328153146.3368470-4-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" Don't open-code ->i_count access. This is expected to be a nop. Signed-off-by: Mateusz Guzik --- arch/powerpc/platforms/cell/spufs/file.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/mds_client.c | 2 +- fs/ext4/ialloc.c | 4 ++-- fs/hpfs/inode.c | 2 +- fs/inode.c | 12 ++++++------ fs/nfs/inode.c | 4 ++-- fs/smb/client/inode.c | 2 +- fs/ubifs/super.c | 2 +- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_trace.h | 2 +- include/trace/events/filelock.h | 2 +- security/landlock/fs.c | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platfo= rms/cell/spufs/file.c index 10fa9b844fcc..f6de8c1169d5 100644 --- a/arch/powerpc/platforms/cell/spufs/file.c +++ b/arch/powerpc/platforms/cell/spufs/file.c @@ -1430,7 +1430,7 @@ static int spufs_mfc_open(struct inode *inode, struct= file *file) if (ctx->owner !=3D current->mm) return -EINVAL; =20 - if (icount_read(inode) !=3D 1) + if (icount_read_once(inode) !=3D 1) return -EBUSY; =20 mutex_lock(&ctx->mapping_lock); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 8d97a8ad3858..f36c49e83c04 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4741,7 +4741,7 @@ static void btrfs_prune_dentries(struct btrfs_root *r= oot) =20 inode =3D btrfs_find_first_inode(root, min_ino); while (inode) { - if (icount_read(&inode->vfs_inode) > 1) + if (icount_read_once(&inode->vfs_inode) > 1) d_prune_aliases(&inode->vfs_inode); =20 min_ino =3D btrfs_ino(inode) + 1; diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index b1746273f186..2cb3c919d40d 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2223,7 +2223,7 @@ static int trim_caps_cb(struct inode *inode, int mds,= void *arg) int count; dput(dentry); d_prune_aliases(inode); - count =3D icount_read(inode); + count =3D icount_read_once(inode); if (count =3D=3D 1) (*remaining)--; doutc(cl, "%p %llx.%llx cap %p pruned, count now %d\n", diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 3fd8f0099852..8c80d5087516 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -252,10 +252,10 @@ void ext4_free_inode(handle_t *handle, struct inode *= inode) "nonexistent device\n", __func__, __LINE__); return; } - if (icount_read(inode) > 1) { + if (icount_read_once(inode) > 1) { ext4_msg(sb, KERN_ERR, "%s:%d: inode #%llu: count=3D%d", __func__, __LINE__, inode->i_ino, - icount_read(inode)); + icount_read_once(inode)); return; } if (inode->i_nlink) { diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 0e932cc8be1b..1b4fcf760aad 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c @@ -184,7 +184,7 @@ void hpfs_write_inode(struct inode *i) struct hpfs_inode_info *hpfs_inode =3D hpfs_i(i); struct inode *parent; if (i->i_ino =3D=3D hpfs_sb(i->i_sb)->sb_root) return; - if (hpfs_inode->i_rddir_off && !icount_read(i)) { + if (hpfs_inode->i_rddir_off && !icount_read_once(i)) { if (*hpfs_inode->i_rddir_off) pr_err("write_inode: some position still there\n"); kfree(hpfs_inode->i_rddir_off); diff --git a/fs/inode.c b/fs/inode.c index 5ad169d51728..1f5a383ccf27 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -907,7 +907,7 @@ void evict_inodes(struct super_block *sb) again: spin_lock(&sb->s_inode_list_lock); list_for_each_entry(inode, &sb->s_inodes, i_sb_list) { - if (icount_read(inode)) + if (icount_read_once(inode)) continue; =20 spin_lock(&inode->i_lock); @@ -1926,7 +1926,7 @@ static void iput_final(struct inode *inode) int drop; =20 WARN_ON(inode_state_read(inode) & I_NEW); - VFS_BUG_ON_INODE(atomic_read(&inode->i_count) !=3D 0, inode); + VFS_BUG_ON_INODE(icount_read(inode) !=3D 0, inode); =20 if (op->drop_inode) drop =3D op->drop_inode(inode); @@ -1945,7 +1945,7 @@ static void iput_final(struct inode *inode) * Re-check ->i_count in case the ->drop_inode() hooks played games. * Note we only execute this if the verdict was to drop the inode. */ - VFS_BUG_ON_INODE(atomic_read(&inode->i_count) !=3D 0, inode); + VFS_BUG_ON_INODE(icount_read(inode) !=3D 0, inode); =20 if (drop) { inode_state_set(inode, I_FREEING); @@ -1989,7 +1989,7 @@ void iput(struct inode *inode) * equal to one, then two CPUs racing to further drop it can both * conclude it's fine. */ - VFS_BUG_ON_INODE(atomic_read(&inode->i_count) < 1, inode); + VFS_BUG_ON_INODE(icount_read_once(inode) < 1, inode); =20 if (atomic_add_unless(&inode->i_count, -1, 1)) return; @@ -2023,7 +2023,7 @@ EXPORT_SYMBOL(iput); void iput_not_last(struct inode *inode) { VFS_BUG_ON_INODE(inode_state_read_once(inode) & (I_FREEING | I_CLEAR), in= ode); - VFS_BUG_ON_INODE(atomic_read(&inode->i_count) < 2, inode); + VFS_BUG_ON_INODE(icount_read_once(inode) < 2, inode); =20 WARN_ON(atomic_sub_return(1, &inode->i_count) =3D=3D 0); } @@ -3046,7 +3046,7 @@ void dump_inode(struct inode *inode, const char *reas= on) } =20 state =3D inode_state_read_once(inode); - count =3D atomic_read(&inode->i_count); + count =3D icount_read_once(inode); =20 if (!sb || get_kernel_nofault(s_type, &sb->s_type) || !s_type || diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 98a8f0de1199..22834eddd5b1 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -608,7 +608,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, st= ruct nfs_fattr *fattr) inode->i_sb->s_id, (unsigned long long)NFS_FILEID(inode), nfs_display_fhandle_hash(fh), - icount_read(inode)); + icount_read_once(inode)); =20 out: return inode; @@ -2261,7 +2261,7 @@ static int nfs_update_inode(struct inode *inode, stru= ct nfs_fattr *fattr) dfprintk(VFS, "NFS: %s(%s/%llu fh_crc=3D0x%08x ct=3D%d info=3D0x%llx)\n", __func__, inode->i_sb->s_id, inode->i_ino, nfs_display_fhandle_hash(NFS_FH(inode)), - icount_read(inode), fattr->valid); + icount_read_once(inode), fattr->valid); =20 if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) { /* Only a mounted-on-fileid? Just exit */ diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c index 888f9e35f14b..ab35e35b16d7 100644 --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -2842,7 +2842,7 @@ int cifs_revalidate_dentry_attr(struct dentry *dentry) } =20 cifs_dbg(FYI, "Update attributes: %s inode 0x%p count %d dentry: 0x%p d_t= ime %ld jiffies %ld\n", - full_path, inode, icount_read(inode), + full_path, inode, icount_read_once(inode), dentry, cifs_get_time(dentry), jiffies); =20 again: diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 9a77d8b64ffa..38972786817e 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -358,7 +358,7 @@ static void ubifs_evict_inode(struct inode *inode) goto out; =20 dbg_gen("inode %llu, mode %#x", inode->i_ino, (int)inode->i_mode); - ubifs_assert(c, !icount_read(inode)); + ubifs_assert(c, !icount_read_once(inode)); =20 truncate_inode_pages_final(&inode->i_data); =20 diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index beaa26ec62da..4f659eba6ae5 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1046,7 +1046,7 @@ xfs_itruncate_extents_flags( int error =3D 0; =20 xfs_assert_ilocked(ip, XFS_ILOCK_EXCL); - if (icount_read(VFS_I(ip))) + if (icount_read_once(VFS_I(ip))) xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); if (whichfork =3D=3D XFS_DATA_FORK) ASSERT(new_size <=3D XFS_ISIZE(ip)); diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 5e8190fe2be9..cbdec40826b3 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1156,7 +1156,7 @@ DECLARE_EVENT_CLASS(xfs_iref_class, TP_fast_assign( __entry->dev =3D VFS_I(ip)->i_sb->s_dev; __entry->ino =3D ip->i_ino; - __entry->count =3D icount_read(VFS_I(ip)); + __entry->count =3D icount_read_once(VFS_I(ip)); __entry->pincount =3D atomic_read(&ip->i_pincount); __entry->iflags =3D ip->i_flags; __entry->caller_ip =3D caller_ip; diff --git a/include/trace/events/filelock.h b/include/trace/events/fileloc= k.h index 116774886244..c8c8847bb6f6 100644 --- a/include/trace/events/filelock.h +++ b/include/trace/events/filelock.h @@ -190,7 +190,7 @@ TRACE_EVENT(generic_add_lease, __entry->i_ino =3D inode->i_ino; __entry->wcount =3D atomic_read(&inode->i_writecount); __entry->rcount =3D atomic_read(&inode->i_readcount); - __entry->icount =3D icount_read(inode); + __entry->icount =3D icount_read_once(inode); __entry->owner =3D fl->c.flc_owner; __entry->flags =3D fl->c.flc_flags; __entry->type =3D fl->c.flc_type; diff --git a/security/landlock/fs.c b/security/landlock/fs.c index c1ecfe239032..32d560f12dbd 100644 --- a/security/landlock/fs.c +++ b/security/landlock/fs.c @@ -1278,7 +1278,7 @@ static void hook_sb_delete(struct super_block *const = sb) struct landlock_object *object; =20 /* Only handles referenced inodes. */ - if (!icount_read(inode)) + if (!icount_read_once(inode)) continue; =20 /* --=20 2.48.1 From nobody Thu Apr 2 14:06:37 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 From nobody Thu Apr 2 14:06:37 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.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 D2F3334EEEE for ; Sat, 28 Mar 2026 15:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711935; cv=none; b=hl7h3vi9PpKC/ksOMEZLeUMPKILJ88CGqnnIoFlVSB0wTLdZlxep0h9q7C5doLcZn0cG51AO7QsDMcw6TBemOCKW9gAUUkrYFpfVcfcSVUcsWbhAULyqvfvOC0JOjVjueUUjaI5KeaZ2vnhJGVWnHJV8GLe5kizn3jjPtrf71EQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711935; c=relaxed/simple; bh=jKFU9ClukmgrQPWCuZbiDz6loGcaVsfq+0devSW3yqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RNiJA4pHTVKJ2BUifPiFHjzeeYzUghzpWqr7M+QQ0ooch80unLbVNezCOyGVK18D9k56g//gU2hteDih66BcmH0O5fgpoidiJ6+5dYL4CPJcMlRARfcEdZmReOkckDVK7F/C7OPWum4xiS3g+Z+EHN+jcyiarbRos0wgBB/RXb8= 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=dxgofVFi; arc=none smtp.client-ip=209.85.221.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="dxgofVFi" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-43b41b545d9so3298633f8f.2 for ; Sat, 28 Mar 2026 08:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774711928; x=1775316728; 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=VSDysc2SqFR5k0dxgouFFuDk3xltDf+gaI9kO7u+6DU=; b=dxgofVFikwbbfUGmAV2oys2keYy5+lYHw64IgnkA0JppqOiS73WB9MYU36St/kR9N8 EjLUljLEry11sj1yQJ6K/bxyeVpuWesbNMsh4oGyZlwFla9C2GQ0cVtDZQI3EOO4xblu JMRgCA7tz6EGEgXtOlWJ52PByzofecrhQMCOvr33wv+LB5zfIQJLRsFAQN1L0AlWTDj+ SQ8SbJaDYMSTC+ZlBiv0tlQJIQqTInWk0oH6epFOj2NEqmyRk4TcY6oj2w6aHXZK/68N TgiV+bmwNUPXhPNK2mkVj+G+6FtgoJbiAYzMkkSDTGZQ5JCPpaT8JI7KijF4QVcbPmR9 Hagg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774711928; x=1775316728; 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=VSDysc2SqFR5k0dxgouFFuDk3xltDf+gaI9kO7u+6DU=; b=jb9CvA+R5diPUNYQVyrCoZCvHSK2HlcAfHXJ/rH1A5Cj84nZk1fo0rccS3tAwYJGP0 2L2Bk7w45qh2jzMiKPlPUa6F5Bd8XfoIghBrOKTHocHguRJ1RVmwljAZrEkaNws+cSV6 iAQ3D6/IXF3olv8gCiAwAGH+k2NhhtMFnpJiLXgr4KePsNc7uQqgxDrFLnQVschzNwHn hWs9bsNkKo7ZYVnY7Q/TEoCjdtVU33gMPtwSXqo6wZTdf/1/8vWNEkSUzfqPWZLRG+Qc qwb297jB0t7lW891MN4lEijvYfvPo12ymkd6PjyP+27/R7Y7ZyfdMu6SYR97vJwrO2Lj Q7+Q== X-Forwarded-Encrypted: i=1; AJvYcCXQ8zVKW+Tc+WS04AaaFZJM0+QmfVGHot62lAvj2UIIhygKziRBxROlM6gX4DaX9p9Soj2KNUZCawUykWI=@vger.kernel.org X-Gm-Message-State: AOJu0YyWkK43q6Oa6ASBbZgz9Rfvcm/QrTXnGDqevNO5eV/c8Bq98g+m Ag0CzkAeLXFaN0DHkqGzad+5vQRdstHnOhlzbZVre1oGBTnXuMRNj4UT X-Gm-Gg: ATEYQzw5U9p+duVrpv3vJFHlVOqEZqcQ0BeNUfhXM3S/HcAmX9zljFMOXtGLtXhgHUR i6hyXpc55EupFepLtSikFE/NPiNQlqe5MojmCVVW3OzqnkLXEZDsguEdn6Q4oZXv6Cs7GIdChPm b/O23Yj8pkU/TgOthgosx5woQUdaaT+hWzZdRgZm34o/ihjyDf2B3XSORh8LIeIJBz4Isak+pVJ GOgdtC/MTwfZM8vSG/cUCBfg9wKtQKo4TdO4dIPOqjKC9mnnd+L+1eUAduuP1mGhvUNBLaEyGeS 6Sg7lDK4rg5CDliG0o7dLA5NTpvb06QFY1lQnWUuY9x8uJnOGbPKJ8JA/VI4ZQYgwXuBlucUeGi 2ZkWfaGV16O5rAA8nDk3R3MkbIFzv0tEqjGpOlAQb43wtfSJteFqjnGJNQrML9NCDy9qT5fB+O0 ua1KBlJSYZnDpOb5/F5nB9PITdTpjR/qLV+xV49SFIr5yvGNBeaVVio88W9EmG93OAbxEIXc45X g== X-Received: by 2002:a05:6000:40dd:b0:439:b8b2:fad0 with SMTP id ffacd0b85a97d-43b9e9da56amr10027000f8f.5.1774711928055; Sat, 28 Mar 2026 08:32:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:32:07 -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 4/5] fs: handle hypothetical filesystems hich use I_DONTCACHE and drop the lock in ->drop_inode Date: Sat, 28 Mar 2026 16:31:45 +0100 Message-ID: <20260328153146.3368470-6-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" f2fs and ntfs play games where they transitiong the refcount 0->1 and relea= se the inode spinlock, allowing other threads to grab a ref of their own. They also return 0 in that case, making this problem harmless. Should they start using the I_DONTCACHE machinery down the road while retaining the above, iput_final() will get a race where it can proceed to teardown an inode with references. Future-proof it. Developing better ->drop_inode and sanitizing all users is left as en exercise for the reader. Signed-off-by: Mateusz Guzik --- fs/inode.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 1f5a383ccf27..fc6045e6d43f 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1933,20 +1933,29 @@ static void iput_final(struct inode *inode) else drop =3D inode_generic_drop(inode); =20 - if (!drop && - !(inode_state_read(inode) & I_DONTCACHE) && - (sb->s_flags & SB_ACTIVE)) { + /* + * XXXCRAP: there are ->drop_inode hooks playing nasty games releasing the + * spinlock and temporarily grabbing refs. This opens a possibility someo= ne + * else will sneak in and grab a ref while it happens. + * + * If such a hook returns 0 (=3D=3D don't drop) this happens to be harmle= ss as long + * as the inode is not marked with I_DONTCACHE. Otherwise we are proceedi= ng with + * teardown despite references being present. + * + * Damage-control the problem by including the count in the decision. How= ever, + * assert no refs showed up if the hook decided to drop the inode. + */ + if (drop) + VFS_BUG_ON_INODE(icount_read(inode) !=3D 0, inode); + + if (icount_read(inode) > 0 || + (!drop && !(inode_state_read(inode) & I_DONTCACHE) && + (sb->s_flags & SB_ACTIVE))) { __inode_lru_list_add(inode, true); spin_unlock(&inode->i_lock); return; } =20 - /* - * Re-check ->i_count in case the ->drop_inode() hooks played games. - * Note we only execute this if the verdict was to drop the inode. - */ - VFS_BUG_ON_INODE(icount_read(inode) !=3D 0, inode); - if (drop) { inode_state_set(inode, I_FREEING); } else { --=20 2.48.1 From nobody Thu Apr 2 14:06:37 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 1813D34D4CC for ; Sat, 28 Mar 2026 15:32:14 +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=1774711935; cv=none; b=nJXVmbk48e8LiCGZftr8Sis6GPH+mCk7m/2r/ZB2bdTpcdq0/nW3cnqDE8+c2WeNBFP62VsadQ28zTaqUrsodbnrD5rhChFYnJVipThhC2KaAywnAlVUAbKeSWsMhuzZ/2XgF9/Hzxc/SWavxUKqsunNA0I7p7BpcOITq6JuxQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711935; c=relaxed/simple; bh=gmOLacFBLCNj5VvdypSCbBb3+/owFsIUDBdTNEiM7QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YD14hI88hHJa3VZSiO+k9Dq1dnE6Rq2HxnS4wqFXBJ+4LG5APuX1oFfWxr1GDHTYOFtPjsaJ0KPKwYWj0cQEahwylGF4LzZIw8xNn03FR6Kqhg2NcaGm1Kzl8nRJ37Yf5ks1u59qL5RdhEimdh5lIK4t1u6SnuqFW8uMIoLl7zk= 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=JKtJNYy0; 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="JKtJNYy0" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-43cf5d14d6eso312020f8f.0 for ; Sat, 28 Mar 2026 08:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774711930; x=1775316730; 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=KQLr+3qAuCwpPc4ueOptHqyuEcLu/FKN06xV1u7l/MM=; b=JKtJNYy091Ew3hS08qXDYPtAFUqHbPfMtU2JUA+4i+29AAk76nsZeVURnHc7cX2D+D Sfq5aDmo0AH9Wp4cs25DZo+rrFrq6OJhTajCg7NCwoXELxpU9sBermHLGpbXQ971NSKA pzZZfgQPv293FV9sVnZKmXarftUQ7NcwKk89eeNtJHy85eGTBWnqLBx3rhb2nJ8nPBqZ 6nnGDaWxugl+qgxRPyfRGl+Fc2U16PDGGBsAj3NA7DFHKVeZdp3wWDWuZ8mhVMXaX5/m dcF8q3njesLARMymAK6E9VE2GdUTUD96x6lK11FhqpUnZYakexirlJKOV98kIwlojUIn FlLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774711930; x=1775316730; 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=KQLr+3qAuCwpPc4ueOptHqyuEcLu/FKN06xV1u7l/MM=; b=RAWhWcWB6atBV/vmcfDpZS3I1sSqD9wglbTLrS0n0oXh//oABbqkm8WhfcPULuB5CX /3sGsEpx/U88cUN4XNhxoCEmxnBoGViA9pR5v0V0J5kb+Kz2DYJMNjszBiWCOp0L3yG+ pUKIR8d0RQwAxbyDLfW2eom2gOIwsC6PLTP1zE8MHsKNTya2OZmu1gjmzERYGOUvDtvH o/d0h9+yiKd+vxqY1c5WwpWmOt2yD6BuY8uo9UU3QANocpI3DxoacknnzDqnu4lSxPd2 EnD6gUbex8Mq1rE3A60T3kaoJQXvJjN3Mv1MG1I7OlaKen35Cbc/4A0yqho9iA93FRoF nPYA== X-Forwarded-Encrypted: i=1; AJvYcCXiR/3O3ivcf/94owNocEkHOTtrMQF7uKPS8S8TkI6lhjTYy75R/P1yCJTIFWfl2V8rXB3jd8z2UADyUbQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzhEzXBMdDWOWGlhYeoeNYx9w9t4azvIWo+0uEhgLhsJwQ/zFZP mJRKaxzdsRazGqBEBwfUxKU0iTalhVWVOkbQKIgbMdb+il5b8z9lk/U7sxX3FQ== X-Gm-Gg: ATEYQzyV2WJGhfJsgoS2DfORYmvWTKVp+aWXMSornlYvfLv8axYyQAFyTlZjYjcHRc7 0yh/QVt+PckhFHc90g3tLl/AyO8nsVWvlSbfPHRdh/qEbkoB9b6r7SpvvgLEk8O/D4Urx1sV+FT mbpTMYzDQdlvdeCk3BOElx9wRH+J3IFmtMH4lD58zpyXbTpqm6jLytA/NsmIO1g2UBGltBMemxi ecAQLH17OxWZRHqPHNsJiz5EjawujLeSf1/shBPFOClplNjxSS6lNqYYyqAmIRGqE3wtlvFSdDi vTbZW4DnIfsoRqU91kK/hZG5jBAFn/nLL8KjBEJF/GdmLrGpMXWpoHlhfj5VCwjbOOh85/QulOG 1N277Ci7Qv7Gkro2jaThObi05krzLoAqCuyUrUMdKeZ++mUh8kQsA7cPAucFISvx707GIhHikgJ lWGr98dNDst65BDT5mQ3ec7AKdwIAs7nTD2XH0gs8XWGTgejcjUP8qGRaohkzxLnuNskjmMCPfr g== X-Received: by 2002:a5d:5402:0:b0:43c:ef4f:79cd with SMTP id ffacd0b85a97d-43cef4f7b47mr3752356f8f.48.1774711930452; Sat, 28 Mar 2026 08:32:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:32:09 -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 5/5] fs: locklessly bump refs in igrab as long as it does not transition 0->1 Date: Sat, 28 Mar 2026 16:31:46 +0100 Message-ID: <20260328153146.3368470-7-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" The bump is gated by I_FREEING | I_WILL_FREE, but these flags can only legally show up if the count is 0. Consequently if the value is at least 1 and it succesfully CAS'ed to something higher, the flags must not be there. I verified all places which look at the refcount either only care about it staying 0 (and have the lock enforce it) or don't hold the inode lock to begin with. Thus the patch retains the invariant for correct consumers and does not make things worse for the rest. Signed-off-by: Mateusz Guzik --- fs/inode.c | 5 +++++ include/linux/fs.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index fc6045e6d43f..17b925887382 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1580,6 +1580,11 @@ EXPORT_SYMBOL(iunique); =20 struct inode *igrab(struct inode *inode) { + if (atomic_add_unless(&inode->i_count, 1, 0)) { + VFS_BUG_ON_INODE(inode_state_read_once(inode) & (I_FREEING | I_WILL_FREE= ), inode); + return inode; + } + spin_lock(&inode->i_lock); if (!(inode_state_read(inode) & (I_FREEING | I_WILL_FREE))) { __iget(inode); diff --git a/include/linux/fs.h b/include/linux/fs.h index 07363fce4406..119e0a3d2f42 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2234,8 +2234,8 @@ static inline int icount_read_once(const struct inode= *inode) } =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. + * returns the refcount on the inode. The lock guarantees no 0->1 or 1->0 = transitions + * of the count are going to take place, otherwise it changes arbitrarily. */ static inline int icount_read(const struct inode *inode) { --=20 2.48.1 From nobody Thu Apr 2 14:06:37 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 2BA4A34F48B for ; Sat, 28 Mar 2026 15:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711924; cv=none; b=IZZ7Tb161VDWu1KtGCKLOeELI5eDzzkoVbhFnTW8V4jyvYBMtVZ6zxcjxXJJgvYlpVKUqnL6mUPsEqtrzKrthACpWdLxzdfonIG1l+TpMLQnZVkrkErpgYRnT9d4mknNCv8huan4Y4SHYyzIiP8+0+cQ+gD9LbSbKH5kz8MsZVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774711924; c=relaxed/simple; bh=s/8IlebDzkbVB0x3ZPq6jRzAdKw0+tljoRl8W93Mw2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WlzwpIMdwj5ni6cn5EYWvW264nT/ZHurEq72FrmltC2mWYK6taXiTEstXSNcAODyysmHUrm0CBZ09aYYeWjfg2FQg+WlOh52GH4KjUguEOTVstefLCt8KQLQ+G59sjvosRw86jgYHBXOeK8VDMpo3Lc7E4AFnhB/d376nkVdJLc= 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=kQ9DhyGR; arc=none smtp.client-ip=209.85.221.44 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="kQ9DhyGR" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-43b40fb7f95so2619524f8f.3 for ; Sat, 28 Mar 2026 08:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774711922; x=1775316722; 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=cm/8dTd6WxBttMkVbYS0e9e3tXxe/ZGmXHRFHym+rA8=; b=kQ9DhyGR/H6HWDYXR4grXvLtF4yEj6LB4icExNiReYwFPzU8e/kP6Q2jVKjGZx/AL7 7HTa+hBJvpCEzfNVMcCA1tZeoRSMN+jDJOQKs4DzWHJevIi6clIeRDNUDnd8Y/fPKkLW 4NTh0mUJTukoik6xCAFANIHmOAQMp9VNw/zyrFYVRWEc3KpkburNrvkhk0pkntEUjv6B F9eh2EhALicSjv5dtHL1qU56IKJsPMWs9mt8MU0n74srj9E3KbNLFXI8KUM0+mmJsU/S ycfcw8LIfECSO6kYVPio7ShSuBD2TJb/OzxTN7izpehZ6Ai3M5QKVNggizfs2Bo9jtuR 4Dlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774711922; x=1775316722; 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=cm/8dTd6WxBttMkVbYS0e9e3tXxe/ZGmXHRFHym+rA8=; b=a63gJ5hrgWDtR8nRnKQqgTcn4VrUhwfToESAT7x4Ht6dm/0zQ1F5ypc2XEp3GIRkgs 7gH70qTtc4jUAs07oD0EVBCaLCJGZVx07oZL4C+Mb5cgkgXmJa52xB14C2no9FLnXTE8 iiVSWJ9ZQD0U6hXOghIiGO9B0F/mHyTM6O9cpjEkrFyegYh6ba/DHW1RYHHp5Y6lUbQg bmwAOn4JKMh7Rl0VKRU6IVyMNkc+nRTS0mGrSS/7kV/2ta/Lfg89EWKep9UppdiQ3pVy G9q3eBK67+U7v2Rdei9BkSbut9z6i6C5OVfza4HQUP16GJ1NKn3wmCGSVW7yqx3JwND2 lLNQ== X-Forwarded-Encrypted: i=1; AJvYcCVj6XEnWsqWyAP15kYEcrje2BFRbMMw2A1wVuytw4QwLqYEg0mV2sOzVIDKhJkKdEysmABnr5zchiq2+qc=@vger.kernel.org X-Gm-Message-State: AOJu0YwkM99weYsyOWxAZMdzfsFJIl6EVsOmYRo9sg4zPDzmUIu6vlH4 OwxAIP/oy9FWP8espdTV8I4IIrjJT5Av0UBuE9li6R9oCcpyaGHSqtn3AM9rSw== X-Gm-Gg: ATEYQzznVKr+HUXEoWgOfVzxf2es2wgFzejBk+WMRL2C9uDpHLyGvGtedXfYT44Pkmx 7CtXCbC6uySvd9IN8fPoayqRuv08TrskWnMR8PdAZrFUQQ+dVESMi8fXMplq9klqn10g5W7bbie yT6BWdz9tQSotTUuf0/ISUEiKwaK86wrzcxD/lTffrq403E8UFF5LXIxh2O1ru4LTkcMTCcNOXk dv1XyFuC+bcj5nyNCLcbrzfyweWUL2LHx7OxPoBar5d+XWkEVg2KVnCzM/pr5sJF5CKsfCqJv88 c3wqA7/bGDEv+SkYuIdlckUmDu4oRnOU+FmA2lqy5vBWTLZ/Rqe5ZOReqw4QoLThbyQHhQhEB98 ywoHd3US2ohX5kaYn2H+JItTuc034t9pCAbwlibwr80OJjrENP/ItGdnquYlMys/iEDuxpTtvO4 ScpgVDBmKhi+sRP5h8+KfST0llpVhhNathOFD5SGltzJqSxNgfx2m6AfP+YSW14yP+uCnJ0omtX 2ONz5s6vdeP X-Received: by 2002:a05:6000:238a:b0:439:ccd7:cdb6 with SMTP id ffacd0b85a97d-43b9e9ea0f9mr11085170f8f.14.1774711921583; Sat, 28 Mar 2026 08:32:01 -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.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2026 08:32:01 -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 , "Lai, Yi" Subject: [PATCH] fs: revert insert_inode_locked() eviction wait change and explain why Date: Sat, 28 Mar 2026 16:31:42 +0100 Message-ID: <20260328153146.3368470-3-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" It causes a deadlock, reproducer can be found here: https://lore.kernel.org/linux-fsdevel/abNvb2PcrKj1FBeC@ly-workstation/ The real bug is in ext4, but I'm not digging into it and a working order needs to be restored. Commentary is added as a warning sign for another sucker^Wdeveloper. Fixes: 88ec797c468097a8 ("fs: make insert_inode_locked() wait for inode des= truction") Reported-by: "Lai, Yi" Signed-off-by: Mateusz Guzik --- fs/inode.c | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index cc12b68e021b..5f7e76c9fb53 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1037,20 +1037,19 @@ long prune_icache_sb(struct super_block *sb, struct= shrink_control *sc) return freed; } =20 -static void __wait_on_freeing_inode(struct inode *inode, bool hash_locked,= bool rcu_locked); - +static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_has= h_locked); /* * Called with the inode lock held. */ static struct inode *find_inode(struct super_block *sb, struct hlist_head *head, int (*test)(struct inode *, void *), - void *data, bool hash_locked, + void *data, bool is_inode_hash_locked, bool *isnew) { struct inode *inode =3D NULL; =20 - if (hash_locked) + if (is_inode_hash_locked) lockdep_assert_held(&inode_hash_lock); else lockdep_assert_not_held(&inode_hash_lock); @@ -1064,7 +1063,7 @@ static struct inode *find_inode(struct super_block *s= b, continue; spin_lock(&inode->i_lock); if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE)) { - __wait_on_freeing_inode(inode, hash_locked, true); + __wait_on_freeing_inode(inode, is_inode_hash_locked); goto repeat; } if (unlikely(inode_state_read(inode) & I_CREATING)) { @@ -1088,11 +1087,11 @@ static struct inode *find_inode(struct super_block = *sb, */ static struct inode *find_inode_fast(struct super_block *sb, struct hlist_head *head, unsigned long ino, - bool hash_locked, bool *isnew) + bool is_inode_hash_locked, bool *isnew) { struct inode *inode =3D NULL; =20 - if (hash_locked) + if (is_inode_hash_locked) lockdep_assert_held(&inode_hash_lock); else lockdep_assert_not_held(&inode_hash_lock); @@ -1106,7 +1105,7 @@ static struct inode *find_inode_fast(struct super_blo= ck *sb, continue; spin_lock(&inode->i_lock); if (inode_state_read(inode) & (I_FREEING | I_WILL_FREE)) { - __wait_on_freeing_inode(inode, hash_locked, true); + __wait_on_freeing_inode(inode, is_inode_hash_locked); goto repeat; } if (unlikely(inode_state_read(inode) & I_CREATING)) { @@ -1842,13 +1841,28 @@ int insert_inode_locked(struct inode *inode) while (1) { struct inode *old =3D NULL; spin_lock(&inode_hash_lock); -repeat: hlist_for_each_entry(old, head, i_hash) { if (old->i_ino !=3D ino) continue; if (old->i_sb !=3D sb) continue; spin_lock(&old->i_lock); + /* + * FIXME: inodes awaiting eviction don't get waited for + * + * This is a bug because the hash can temporarily end up with duplicate= inodes. + * It happens to work becuase new inodes are inserted at the beginning = of the + * chain, meaning they will be found first should anyone do a lookup. + * + * Fixing the above results in deadlocks in ext4 due to journal handlin= g during + * inode creation and eviction -- the eviction side waits for creation = side to + * finish. Adding __wait_on_freeing_inode results in both sides waiting= on each + * other. + */ + if (inode_state_read(old) & (I_FREEING | I_WILL_FREE)) { + spin_unlock(&old->i_lock); + continue; + } break; } if (likely(!old)) { @@ -1859,11 +1873,6 @@ int insert_inode_locked(struct inode *inode) spin_unlock(&inode_hash_lock); return 0; } - if (inode_state_read(old) & (I_FREEING | I_WILL_FREE)) { - __wait_on_freeing_inode(old, true, false); - old =3D NULL; - goto repeat; - } if (unlikely(inode_state_read(old) & I_CREATING)) { spin_unlock(&old->i_lock); spin_unlock(&inode_hash_lock); @@ -2534,18 +2543,16 @@ EXPORT_SYMBOL(inode_needs_sync); * wake_up_bit(&inode->i_state, __I_NEW) after removing from the hash list * will DTRT. */ -static void __wait_on_freeing_inode(struct inode *inode, bool hash_locked,= bool rcu_locked) +static void __wait_on_freeing_inode(struct inode *inode, bool is_inode_has= h_locked) { struct wait_bit_queue_entry wqe; struct wait_queue_head *wq_head; =20 - VFS_BUG_ON(!hash_locked && !rcu_locked); - /* * Handle racing against evict(), see that routine for more details. */ if (unlikely(inode_unhashed(inode))) { - WARN_ON(hash_locked); + WARN_ON(is_inode_hash_locked); spin_unlock(&inode->i_lock); return; } @@ -2553,16 +2560,14 @@ static void __wait_on_freeing_inode(struct inode *i= node, bool hash_locked, bool wq_head =3D inode_bit_waitqueue(&wqe, inode, __I_NEW); prepare_to_wait_event(wq_head, &wqe.wq_entry, TASK_UNINTERRUPTIBLE); spin_unlock(&inode->i_lock); - if (rcu_locked) - rcu_read_unlock(); - if (hash_locked) + rcu_read_unlock(); + if (is_inode_hash_locked) spin_unlock(&inode_hash_lock); schedule(); finish_wait(wq_head, &wqe.wq_entry); - if (hash_locked) + if (is_inode_hash_locked) spin_lock(&inode_hash_lock); - if (rcu_locked) - rcu_read_lock(); + rcu_read_lock(); } =20 static __initdata unsigned long ihash_entries; --=20 2.48.1