Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1581495rdb; Mon, 8 Jan 2024 04:08:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHmWNIIi1nkAW+Ct2GVZETmC/s2RXcFfdCYiNWksot7czwP5rhp65eWkfWxfXSVFoX9hI2 X-Received: by 2002:a62:e711:0:b0:6da:345f:6a63 with SMTP id s17-20020a62e711000000b006da345f6a63mr3667049pfh.5.1704715731577; Mon, 08 Jan 2024 04:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704715731; cv=none; d=google.com; s=arc-20160816; b=BV0OL+FW42AvyXr7LJrdqJrI/L7XllYvUMyFn3/50oMFM81onPElm1Uswxk6Qz2+qO Ex7wTPozkX+Wl1bo4B/qReb5o2Bn2Y+quYFvp2t0jS125hpwrWD6RU+/rmHYzaamyW/4 P+DDaqLdp7/IWBU4BCYroB86Y5MoNIjbc+M17SalyzbDrMfoE8+FR57oBVlBZBb8L0BU zxPgeX0N4cB0PV/t3ss7zggzrD/NSLRTApxmIsh+V0/rjAzoqUZiLQPAD+nzNplnu6tL OcUi11TbdHUAbK8UKntJb1ndPLHF6yBKac0GAokLzwMR9/M8J3G9VIXbvTvi70SHuiZa HiXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cagyf7j04cToSXabvYW43dze5arP+lifLYmlhSYnUZ8=; fh=4t611zNujiZUcUHzHBWkDJshKdwVuI3aq47HpMbfqD4=; b=DDTo0I5Sc+oy2ZMkcXQXq6bjK+WDSYnFE+vHmeE4Ghc1D+BZBilJQws//0BuCRe5EM XbpWIQzB60iOWK044LwnyovA0flmNUWzgDdTtA1wt607GzuEtXdNPzdbaeB4vOjESyml sR9M5XrDbiMl0+8/cmjf9YY7hEXVasv2KTxzsn8j9mr8UUq3RYYJ713lRTeg1QOqXgse GlR0BQJk8jRpTUDHj+2RjeXn2xrgwb8J5ikPBXXH8ktNG9KKuHApnY6PeOPMDX4Liew2 Ij5A1vTZVtFp81UUUIQWXLZsx+S4iPfLmNeZazZLpwnJMPN/4ppTEeoZO336r4jH3wyy mbmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=kylie header.b=akIgN35X; spf=pass (google.com: domain of linux-kernel+bounces-19469-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19469-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r9-20020a632b09000000b005cdfc9ab80csi5724836pgr.396.2024.01.08.04.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:08:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19469-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@crudebyte.com header.s=kylie header.b=akIgN35X; spf=pass (google.com: domain of linux-kernel+bounces-19469-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19469-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 35688283723 for ; Mon, 8 Jan 2024 12:08:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55C3F24A16; Mon, 8 Jan 2024 12:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=crudebyte.com header.i=@crudebyte.com header.b="akIgN35X" X-Original-To: linux-kernel@vger.kernel.org Received: from kylie.crudebyte.com (kylie.crudebyte.com [5.189.157.229]) (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 DF3292575B; Mon, 8 Jan 2024 12:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=crudebyte.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=cagyf7j04cToSXabvYW43dze5arP+lifLYmlhSYnUZ8=; b=akIgN35X1P9RGr00+WcbSHEpBA klW5ykJiJY05ljY+rZoWhILwOYxxB5r64OavHvm4Mje2AG/MKG48BzUAc+MPr+y8h5ThPd7K5s7ns wVBJ2PgIt7UT6nSxYuZx65QN6OVPQpYm+53lSlmUhkto9Gj4XtQLXy+OKwcFL//MWdWpTHOF1AtnZ kET5KB9UikjlWEuwPbZRQn4ro6TqGSxi8S4qttZW4qAVl/DbTlF9UDqpD9hM57PDFa3bq+S3P0L82 deh4802xgtgzU2y3C67DKzHPgJJfJgEVR23qMs0jnspYyo+X5xA206XwzB9aOhJC2PXIaXEAVuT2S Wq+hliOs1vmiDVlzGD2Nqva6eedM/0/NIB1zYRFJM61FxEXLA1z83PIqINokjzDsSxU3HvwHBvK96 C1kktiEoGfhm788/YST6bb5IW5hC9mNuIoCS00Ov0J9jtP2BCWPKdIep2zV+LktCw7Q2fKeJ/zg97 mWJkHtXud5ApC9XPMfPGcSFf+panICrd6rQrgUHxCAuEcyiYNWZRDLCOxS3NinDc+VzBoaMEbOKIv i6KbywucrpnD+2lrY27plMaBE0AIcD37WhVnE/j7TKHUchJYfKaubZ8ZQh3pQW1TBL3W0lq5aKHMi hr7s7BZRrWVcM/8gK6nb41bF80Vo3NWbGJB/XNndY=; From: Christian Schoenebeck To: Eric Van Hensbergen , asmadeus@codewreck.org Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, rminnich@gmail.com, lucho@ionkov.net Subject: Re: [PATCH] fs/9p: fix inode nlink accounting Date: Mon, 08 Jan 2024 13:08:31 +0100 Message-ID: <8004884.rDQMAZhJ5Z@silver> In-Reply-To: References: <20240107-fix-nlink-handling-v1-1-8b1f65ebc9b2@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 tried 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 worse > than what we have right now: > Acked-by: Dominique Martinet That's actually a good point. For these tasks atomic inc/sub/etc are usually used instead of locks. I would at least add local wrapper functions that would do these spinlocks for us. However would it be too bold to change those inode functions to use atomic operations directly on their end? /Christian