Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1884403rdb; Mon, 8 Jan 2024 13:37:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUj5D8rzxrGgW9or30uEXiwfHIEJ1UlMkhVlF8uanESpYRWXiBxpr2oXn2GbSX/UBINeoh X-Received: by 2002:ac2:4c04:0:b0:50e:3f70:a492 with SMTP id t4-20020ac24c04000000b0050e3f70a492mr1563261lfq.104.1704749863421; Mon, 08 Jan 2024 13:37:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704749863; cv=none; d=google.com; s=arc-20160816; b=fBX2mDQXrcZsvNylbfrfS9DhWorOPHlovK5kzje4hldNyaUDo2/IiSt1V0afCfyXb4 bl8kwDM68IX5Cg0SHviLXt4N6BTvxlYguKF7mvQ8a8VF83oh58BfWPYEJo1v3I2dtwof U5FY2JeLFnFVa6bFaZNYOgpNvTFk3YjvPVwaHhOEN83Wi60/9dn2Fd6ORumwIXYmV0qx jFbwcwofDm0aD+nZv8CxfrbAa7Pc/SLuXcuYTwgCWYL07iJnZULFKwLKQHfIGMUkvIg7 LPWYGkM3D4tAFd4fakEitlaAuyOQdkkNYc84wHA+wIDAUHSxEDl2+1zuaOt4eCNAyEFo alZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=T6pq3oYZAwBjvYhcZTgNrAtF5tCRRgkDFhYs7BfLir8=; fh=1GMex9E3jbho7p7MRXqMGvAcIC0eIwn0/gpuc3imu3k=; b=LIqUuIt69A9mKy82Wvg0T4JdUIyEntegK3I3nf6dHAI6fx2nbXYEoxtaycksZBlvwS jV4BrkS6wqG3WIhpiLZPkzqhMmFzoA76OaP6Oa1dmttla/DkUGtAAmU7uoYbxuUDD0tS 4ysC3xKHzNhJVgbOYp5x4B3v3bIuvf44VVuldXT2fNONqEBmCjfwjStGiu7JRZ9SHU7T NNINNFX2i2b0kG+vO9KoDoVvUUZpfJoccQt2bZ3Zh/ld1E6FF+ELHQEdXGhrQEBTDho4 yOpvOiW2pmJI9R0DSkwwhuKEP4s3KKoqpifdOGGI07nZuG07RUt9hrd0tiH48NdR3GyE ayTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=ITQDZ6iq; dkim=pass header.i=@codewreck.org header.s=2 header.b=ITQDZ6iq; spf=pass (google.com: domain of linux-kernel+bounces-20131-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20131-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v5-20020a056402174500b005559fc3cb7asi225117edx.3.2024.01.08.13.37.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 13:37:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-20131-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=ITQDZ6iq; dkim=pass header.i=@codewreck.org header.s=2 header.b=ITQDZ6iq; spf=pass (google.com: domain of linux-kernel+bounces-20131-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-20131-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org 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 286D41F23781 for ; Mon, 8 Jan 2024 21:37:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15E8456457; Mon, 8 Jan 2024 21:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b="ITQDZ6iq"; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b="ITQDZ6iq" X-Original-To: linux-kernel@vger.kernel.org Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C73F156450 for ; Mon, 8 Jan 2024 21:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codewreck.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codewreck.org Received: by nautica.notk.org (Postfix, from userid 108) id 97CB6C01C; Mon, 8 Jan 2024 22:37:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1704749850; bh=T6pq3oYZAwBjvYhcZTgNrAtF5tCRRgkDFhYs7BfLir8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ITQDZ6iqaLfLHC5UUsHqjfFvbktxVVqYvTxfWjlL41MS8MMqR47N4UEeUwszv2tEG m0VVtwgBombUEUOH5wNIannU7ZRT3RSf3Mo2tDf4DLrOPKL7dsAuuBm8zIZ338IYal UcMBOAe1j/2eudAhTBXPgAevEemDm7AtA4bvVniJmjJtjdVK5D0xFrndUjXklSB62G rLhKozO5UgF5lcx0jYCInqIqRfF0rd5I3djmnsxlkFWnW5NZp+DiqbJJv90u7DkZMY UBIyFGFUfaEMUlEyaB37QEXPfWNmuNK/G7K1he3T+N7OF4KHwBk6ij2dNuq/uOf8or XFHphi5/bLXrw== X-Spam-Level: Received: from gaia (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 2FE59C009; Mon, 8 Jan 2024 22:37:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1704749850; bh=T6pq3oYZAwBjvYhcZTgNrAtF5tCRRgkDFhYs7BfLir8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ITQDZ6iqaLfLHC5UUsHqjfFvbktxVVqYvTxfWjlL41MS8MMqR47N4UEeUwszv2tEG m0VVtwgBombUEUOH5wNIannU7ZRT3RSf3Mo2tDf4DLrOPKL7dsAuuBm8zIZ338IYal UcMBOAe1j/2eudAhTBXPgAevEemDm7AtA4bvVniJmjJtjdVK5D0xFrndUjXklSB62G rLhKozO5UgF5lcx0jYCInqIqRfF0rd5I3djmnsxlkFWnW5NZp+DiqbJJv90u7DkZMY UBIyFGFUfaEMUlEyaB37QEXPfWNmuNK/G7K1he3T+N7OF4KHwBk6ij2dNuq/uOf8or XFHphi5/bLXrw== Received: from localhost (gaia [local]) by gaia (OpenSMTPD) with ESMTPA id 1df35907; Mon, 8 Jan 2024 21:37:25 +0000 (UTC) Date: Tue, 9 Jan 2024 06:37:09 +0900 From: asmadeus@codewreck.org To: Christian Schoenebeck Cc: Eric Van Hensbergen , linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, rminnich@gmail.com, lucho@ionkov.net Subject: Re: [PATCH] fs/9p: fix inode nlink accounting Message-ID: References: <20240107-fix-nlink-handling-v1-1-8b1f65ebc9b2@kernel.org> <8004884.rDQMAZhJ5Z@silver> <7785659.j189Hiylts@silver> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <7785659.j189Hiylts@silver> Christian Schoenebeck wrote on Mon, Jan 08, 2024 at 03:55:53PM +0100: > > I'm good with adding local wrapper functions, (Agreed having a local wrapper that locks + use these is better than this current patch -- v2 looks much better, thanks!) > > I imagine these aren't > > used in the kernel because for regular file-systems maybe you want the > > warning that your inode link accounting is wrong. > > I suppose we could be naughty and not use the kernel functions (which > > themselves are basically wrappers). > > Well, one half of that code is actually using atomic operations to increment/ > decrement the private counter. Which means to me those kernel functions were > intended to be called from a concurrent context. So I don't get why the other > variable is not atomic there. They should be I think. I think the key difference is inode level vs superblock level -- the inode is local and holding a lock can be faster if manipulations are grouped together (x atomic operations are usually slower than a spinlock and x normal operations), while the sb potentially has contentions and would be more likely to use atomic... > I would probably try and send a patch for changing those kernel functions and > see if people are fine with that. But up to you. With that said I just checked ext4 and it looks just as racy as we do in particular the rmdir/unlink case doesn't seem to take any lock, so it's definitely worth raising the subject on fsdevel! I'll see how work is busy and ask later today if time allows -- Dominique Martinet | Asmadeus