From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 1919A3C873E for ; Mon, 30 Mar 2026 12:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774873572; cv=none; b=pUHvHJyQMEvDb0rGBEj79+D+1gZ/CKs972c7jN8f75UF/mAP9+4yaI+qwL2LHE2uJNRMVGd1YXr0aixRZkE2hUOiwW3AQDp75FVbpoSK3G3mO5oNFKMUBotnm+B8SiojmrumouRhaw/CQtdn2QeFFeHRFjyiT07fl4Q3W2kure4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774873572; c=relaxed/simple; bh=iXZRS7tiXpDFQsNbOnWsu8ZHvevn+YRlxfwIYQTCMUU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PtAxapRjIOqUY/0sma4lVJrDfR93rvyZK3/RGGsw2XR1i+ftMaXw40Jsq9l021++8HubTJjZNM4B9JELqmxxnPZDxibe6zENLCS9JEmr7257vjWXR8J8Hn/0Dm1MyQZ6RtPz1VsraAutnG+PDfQEv8tASMAvWRCxl5W69A9e+N0= 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=rueg9ULm; arc=none smtp.client-ip=209.85.128.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="rueg9ULm" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-486fc4725f0so43427345e9.1 for ; Mon, 30 Mar 2026 05:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774873569; x=1775478369; 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=zkFTfIqiJxetZvwdSO3/FnYRN42npo/iAp2MLQjkxsk=; b=rueg9ULmhmAVfDu8zLUXCcBro9ROm/q/IiQqZGKvDH+zCBQ8fEHoVuQUvGq/Wp6Ayj KwfBR5jE/PWOBs8rtEIQxvcPIk4cXps32lqbbu6cdEZ0XMvPJ2uLoWsmauhNdN4mklqr dyVV7aAHYwwXtCJtgrOtmS6eak6dJBTZtFZyyhUDCUd+WH77DnMBP73cIDzWRGAtm2Oj D+rCv795BA8XvG1XxpdDQR6M4stF4QG7K+5hRPKNQj8hC+ohugH+jbP/DE6NNmWwSMHR 2aiv0z3UoV8FTIcsE8ITnZkmcvvQXi+VVr/mY/S8m5qnN1GUbgvcmYfZtnUqk3LOHD7u w0DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774873569; x=1775478369; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zkFTfIqiJxetZvwdSO3/FnYRN42npo/iAp2MLQjkxsk=; b=pf9G/Wn3Mk8xgnU0J2E+/seVP2fEX+o2Uf5xAXsoGGOx5D+O9UZAdafEH5TgM0vL3P IZi5enggwTCIoSR97B3qMUbY38QD+EUUTID9Gt84yvmncEJ5UiwmsUaZmmIdGHzJM4Jx t48M8Ofbii3EyXsnSQUDLO7LhWK2WpdbudLiIentbbEj1WJF1AFq2paRPrYtVLzzbEHr ET8Y1npNbYX7t70xJyr4o5vWL5gh+r4ihMIMOniiu30uzmKm/kI2T3r96eLKv1e6wZ16 R2d8LcjvVqeB/Oqmg1iI9cQIgTqV9sVVRMGPEgsiYfPYpPmpG3vEUanEQ6oKWYhQOB30 O35Q== X-Forwarded-Encrypted: i=1; AJvYcCV9oDssMZpvNEK1zilH4kwJaLKyqOTFcG/u2VjrO1ksfnK01Vg8ZJq7h058Cfbx0OuAAmzco1BJbYvB4N8=@vger.kernel.org X-Gm-Message-State: AOJu0YyClXb+p5KywcTR79Z83XBW+F50avhv5Uci5WsC6pEsvdHqcLyW kQpS2JCYxdcZZM44U7N3XMy6LceLkGC7f/8eXF0WQEjmX1/7j7pnzaRM X-Gm-Gg: ATEYQzzLz7EMm349TQmOH8KWUMhWX5Yn/eLBzZDPj8lzbYbh8zUPWuWPxFiesul7bCd 7B+pLjZU70ZRUBFPAtwb63rnXyhMe8CwTFgfpgI+S1mIIzGQs/rnHcBZMPWSW1+lA5ZsU+e9/+E k5OWulHzOtw/mD+yuFdV37R/ABypOXt4tvQpvZ+0ZeNr+Pw7CGYZy5Jt69JSIG6tNPUwADI3qTf YbzvnNvkKnY3obvEQFQ1w2sDRYf9ROZsowwiKj04yxvVzH/YoXaUbUggatFScuzL+66hJgvKwQB lF6ne2y3ORYTa/OpeEHDcclpVW2gqskZzCvAxKjXbW3JO5K0CrQ28nxBGvwDZ9BYsECnm4oQT6r w+pv8ije/WQAuFA+aYJzDEhZSiq8OfahFK+m8tq3yPsE3oN3BTi7Mz44TSb/phkvQXGat6opVum jQw9tcypowfiW+90EoEXgpuYQ79fVgM9i6gpDEu9jTmMtq8j2GkpZ+ILRLP8NB9XEK72scPc5zR A== X-Received: by 2002:a05:600c:4e0b:b0:485:fbd2:f72 with SMTP id 5b1f17b1804b1-487290a9254mr182445395e9.1.1774873569098; Mon, 30 Mar 2026 05:26:09 -0700 (PDT) Received: from f.. (cst-prg-89-171.cust.vodafone.cz. [46.135.89.171]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48725da0333sm113541525e9.2.2026.03.30.05.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 05:26:08 -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 v4 0/4] assorted ->i_count changes + extension of lockless handling Date: Mon, 30 Mar 2026 14:25:58 +0200 Message-ID: <20260330122602.3659417-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 The stock kernel support partial lockless in handling in that iput() can decrement any value > 1. Any ref acquire however requires the spinlock. With this patchset ref acquires when the value was already at least 1 also become lockless. That is, only transitions 0->1 and 1->0 take the lock. I verified when nfs calls into the hash taking the lock is typically avoided. Similarly, btrfs likes to igrab() and avoids the lock. However, I have to fully admit I did not perform any benchmarks. While cleaning stuff up I noticed lockless operation is almost readily available so I went for it. Clean-up wise, the icount_read_once() stuff lines up with inode_state_read_once(). The prefix is different but I opted to not change it due to igrab(), ihold() et al. There is a future-proofing change in iput_final(). I am not going to strongly insist on it, but at the very least the problem it sorts out needs to be noted in a comment. v4: - squash icount_read patches - use icount_read_once in the new ihold assert, reported by syzbot - squash lockless ref acquire patches, rewrite new comments v3: - tidy up ihold - add lockless handling to the hash Mateusz Guzik (4): fs: add icount_read_once() and stop open-coding ->i_count loads fs: relocate and tidy up ihold() fs: handle potential filesystems which use I_DONTCACHE and drop the lock in ->drop_inode fs: allow lockless ->i_count bumps as long as it does not transition 0->1 arch/powerpc/platforms/cell/spufs/file.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/mds_client.c | 2 +- fs/dcache.c | 4 + fs/ext4/ialloc.c | 4 +- fs/hpfs/inode.c | 2 +- fs/inode.c | 122 ++++++++++++++++++----- 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/linux/fs.h | 13 +++ include/trace/events/filelock.h | 2 +- security/landlock/fs.c | 2 +- 15 files changed, 130 insertions(+), 37 deletions(-) -- 2.48.1