Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1648763rdb; Mon, 8 Jan 2024 06:12:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/f42FolN0gzasgJ9c8vUckBH2MmCQBUudfNuXvTU8ihcmJSkQiFQRwIoydbBe5kMBZV8U X-Received: by 2002:a17:902:e850:b0:1d4:79b6:101a with SMTP id t16-20020a170902e85000b001d479b6101amr4747819plg.41.1704723167380; Mon, 08 Jan 2024 06:12:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704723167; cv=none; d=google.com; s=arc-20160816; b=kgR2A3Dk8Mb3IgWj/dsX6yKJNl1i0LaUL6VD1JjUagCzoE3v+LcilZ45MJcygnX7nD LYw/XW9v6DvxB25LOrvFj5y0qeEFCt2u+npYrslC6DTI/Qkcn20Fxy4OKMXaMTOpDeNH rO8FNcJrXTHK0WIQt2GpV8M6QyW9Uw/YIXut/GJQVVCRgtk0agQYaKzArd/IOM4CpGQx ywomgFYaR+5rZ+0G1GBKzvHYnKgvAXnQwAbz3pZlgoy2dntygpEynskcePHspK82ra3k owj4I11M1lza7iQkZ7ZKRggLas6vCVruXNtnRv6uhvS23Cp2jHgkeoIMhLWpbvVC0IIA x1jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=qUnqiwO9jqRxDAvWuslAhxFCBtV0dHNuvNIeqCCLqSI=; fh=fyIAIvIrovnOXo0ihsG8DXJ52cp2rFyydtAgtZiT7vg=; b=HeC+nBf9KHbk+4FwZT/5joeVR51cI3J9Gt3pqoExw1ddmv6T0AUPZSWQd3JuOfYj6g LiNzbxQ7JPcqF1yseJCgjmPeuov0Zx+vWLbtLKO87wU15kz56DwHjNdUwRtNkh+EkbzU 0HR7enixLx+drjhot5SI5Y8JgkGjnK9wstmt0dLEVBbedEUmcxW53jt+nTAXuLbiit1k L3RH93PadFFAmztzEBq3l2vrAqLEtoBLAXFF5MRboTzJ6HmOVt65n/J2Vwt2YQVQP/rf u3WvqRGaTiPNR0CsS3tIp8mNN/UFgpEaqb0VhelqHDy0cvch1n9qgN6zfuX53KyEUNBh wBVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=btwPkE6Q; spf=pass (google.com: domain of linux-kernel+bounces-19682-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c8-20020a170902b68800b001bdd0d0530dsi5925979pls.129.2024.01.08.06.12.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 06:12:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19682-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=btwPkE6Q; spf=pass (google.com: domain of linux-kernel+bounces-19682-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19682-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4CCBCB21C9B for ; Mon, 8 Jan 2024 14:12:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB55846424; Mon, 8 Jan 2024 14:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="btwPkE6Q" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 16D6745BE3 for ; Mon, 8 Jan 2024 14:12:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A946DC433C7 for ; Mon, 8 Jan 2024 14:12:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704723156; bh=pD5SBbFuLG2AhTBrtzXTDBmE5eg/gBHBBfJ6Kj9j4ng=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=btwPkE6QvmiWgtuZEjFqP5R4G19IDfgzIpVMB5snR2MhwaHgA7LXwcOAnUVHo22pb D1gAijxbl53cOhBiiBGz2CDuDzN5nAyJSaiE1SYWI1mcOD1RQn2PZKAJHmB6uvQlhw FlEQHW3VVOGrTghU2+MujtqbFaLhwEaJwYGVoQyD/YkSFDPVyoESqsAKZ/h6thTYUH rZtxUH/gfqFvO9jX1sKWhkA7YLSE2QJ3hUcavz9ZFWPYWNHW22c3ofTj/hNLK0U/zS UOALce8k+/x1LZEv6bvc1glNhSxwC7huD7JJq2uX7GnsufvYPPEXA+TU0KKhnavCQm QrZ64Rijit4BQ== Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-db3fa47c2f7so1082206276.0 for ; Mon, 08 Jan 2024 06:12:36 -0800 (PST) X-Gm-Message-State: AOJu0YzgRkn0mynXhm7QugfypAltCE2/QHxO2k051bHhCpFNpnSrCnu3 XjDZsjjtSq1OxWRRxSn1ymDee7KB3Dx7MYaEk9Y= X-Received: by 2002:a05:6902:562:b0:dbd:5536:33f3 with SMTP id a2-20020a056902056200b00dbd553633f3mr1392931ybt.39.1704723155968; Mon, 08 Jan 2024 06:12:35 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240107-fix-nlink-handling-v1-1-8b1f65ebc9b2@kernel.org> <8004884.rDQMAZhJ5Z@silver> In-Reply-To: <8004884.rDQMAZhJ5Z@silver> From: Eric Van Hensbergen Date: Mon, 8 Jan 2024 08:12:24 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] fs/9p: fix inode nlink accounting To: Christian Schoenebeck Cc: asmadeus@codewreck.org, linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, rminnich@gmail.com, lucho@ionkov.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jan 8, 2024 at 6:08=E2=80=AFAM Christian Schoenebeck wrote: > > On Monday, January 8, 2024 12:19:34 PM CET asmadeus@codewreck.org wrote: > > Eric Van Hensbergen wrote on Sun, Jan 07, 2024 at 07:07:52PM +0000: > > > I was running some regressions and noticed a (race-y) kernel warning = that > > > happens when nlink becomes less than zero. Looking through the code > > > it looks like we aren't good about protecting the inode lock when > > > manipulating nlink and some code that was added several years ago to > > > protect against bugs in underlying file systems nlink handling didn't > > > look quite right either. I took a look at what NFS was doing and tri= ed to > > > follow similar approaches in the 9p code. > > > > I was about to say the set/inc/etc_nlink helpers could probably just be > > using atomic (there's an atomic_dec_if_postive that we could have used > > for the v9fs_dec_count warning), but this isn't our code so not much to > > do about that -- I agree it needs a lock. > > > > I didn't take the time to check if you missed any, but it won't be wors= e > > than what we have right now: > > Acked-by: Dominique Martinet > > That's actually a good point. For these tasks atomic inc/sub/etc are usua= lly > used instead of locks. > > I would at least add local wrapper functions that would do these spinlock= s for > us. > I'm good with adding local wrapper functions, 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). -eric