[v2,01/40] afs: fix the usage of read_seqbegin_or_lock() in afs_lookup_volume_rcu()
Message ID | 20231213135003.367397-2-dhowells@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp7787241dys; Wed, 13 Dec 2023 05:51:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+FAQ8O+HqkW6CwDe/uYnqfGBDJiALph2fhJi9MohHkaJwySPv2K6Q6zj2WRQsO/wIbMxW X-Received: by 2002:a05:6a00:2394:b0:6ce:4047:7a6b with SMTP id f20-20020a056a00239400b006ce40477a6bmr8785680pfc.28.1702475472836; Wed, 13 Dec 2023 05:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475472; cv=none; d=google.com; s=arc-20160816; b=uneKSzEnHEubgYbzgaXxOTpf3KLBk2lBPZpFzQrLg/4UwEZy0Va/RlX9o8LGSLJ1Hs zMwLcobBtdHMdixjLbklKVPzqJTTolN83gqAXwOoUzX0Sg2hWhM7XQVRMYXG5MFWmqwg OOjkKMfGK7KH1grM8k1VwTEJVTPbnpxaCKQj8nHTwj4A/MdwkNBje0WlrXx7+MLeQYYu ib5MuWNRP6nTHkU7zp9vzpEgfQbYRcJA0EIajf73yUXSV+cnTQdZvQH35Chg+iYktdc0 mIDOf5MkSI52tTlKrbPgP5cDHDrT/k8Ey2Hqm+6N2ybeqT0CrVn+3PGfYO5mFFuRmvwD 2eHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i4ME/XIpRFu9lqWi6l0Lhi5Qaw7MTTiMqknldjpYnCU=; fh=9eDgTo8aIuwg9MpGeudPwJT3CA93x8I1cKC8E1Wz3RU=; b=rpdwOs7a6+XLgzjIBetozkDK0Gms0HxJodDlkf5yrE5QNKLkZueODvVLFySV0XsjrA ZLhnuE+JxSUYhbMDkz4jUe32+zhihahB4eKhRzHBQerQQ6XC3T4OFvnccjhzBCYx7dlf 89mYaYY4XZwR0AKC+MyUvAJV4aVH7/DvB42QGZjyE6esv05eQ718D1J5tFWNqeQaICuz g5QSBvWuPwvKOP9QIsbMQPUNeg4tL6n47MA02FZbV53SPF3XQ4ysLsjU6hmGwWodanSX 1I1kxektUS4iFO6LN5Z/iZWj7qPxEhDm+LdGn+ak7YaiBYJUlv+YcC8LhJF9Q8uYt9Vw lfgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cTWboUxL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id s13-20020a65690d000000b005c1cc53612dsi9481946pgq.500.2023.12.13.05.51.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:51:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cTWboUxL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 24BB380B9F84; Wed, 13 Dec 2023 05:50:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379052AbjLMNuH (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 13 Dec 2023 08:50:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378960AbjLMNuG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Dec 2023 08:50:06 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C4A9C for <linux-kernel@vger.kernel.org>; Wed, 13 Dec 2023 05:50:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702475412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i4ME/XIpRFu9lqWi6l0Lhi5Qaw7MTTiMqknldjpYnCU=; b=cTWboUxL7kK5Hp1oFYGEdSqXcuNXQJsIfasMcEQZ0Sfpx3J4b7ncZ1f/PluD7B9n3W1ywI b7eeIeSuQGoXCH/GTgjczY3liDPDMM5BXVH6wKTPII180HdepwnMFxHx22OycFCbiJNd3N 3wt3u5ikb3bJFcGsgFMSYQZqSaxeMbg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-SYx12FEyMpiqyNK_cS8-rQ-1; Wed, 13 Dec 2023 08:50:08 -0500 X-MC-Unique: SYx12FEyMpiqyNK_cS8-rQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7997185A597; Wed, 13 Dec 2023 13:50:08 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82A58C1596E; Wed, 13 Dec 2023 13:50:07 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: Marc Dionne <marc.dionne@auristor.com> Cc: David Howells <dhowells@redhat.com>, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov <oleg@redhat.com> Subject: [PATCH v2 01/40] afs: fix the usage of read_seqbegin_or_lock() in afs_lookup_volume_rcu() Date: Wed, 13 Dec 2023 13:49:23 +0000 Message-ID: <20231213135003.367397-2-dhowells@redhat.com> In-Reply-To: <20231213135003.367397-1-dhowells@redhat.com> References: <20231213135003.367397-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:50:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785174921211949802 X-GMAIL-MSGID: 1785174921211949802 |
Series |
afs: Fix probe handling, server rotation and RO volume callback handling
|
|
Commit Message
David Howells
Dec. 13, 2023, 1:49 p.m. UTC
From: Oleg Nesterov <oleg@redhat.com> David Howells says: (2) afs_lookup_volume_rcu(). There can be a lot of volumes known by a system. A thousand would require a 10-step walk and this is drivable by remote operation, so I think this should probably take a lock on the second pass too. Make the "seq" counter odd on the 2nd pass, otherwise read_seqbegin_or_lock() never takes the lock. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: linux-afs@lists.infradead.org Link: https://lore.kernel.org/r/20231130115606.GA21571@redhat.com/ --- fs/afs/callback.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/afs/callback.c b/fs/afs/callback.c index a484fa642808..90f9b2a46ff4 100644 --- a/fs/afs/callback.c +++ b/fs/afs/callback.c @@ -110,13 +110,14 @@ static struct afs_volume *afs_lookup_volume_rcu(struct afs_cell *cell, { struct afs_volume *volume = NULL; struct rb_node *p; - int seq = 0; + int seq = 1; do { /* Unfortunately, rbtree walking doesn't give reliable results * under just the RCU read lock, so we have to check for * changes. */ + seq++; /* 2 on the 1st/lockless path, otherwise odd */ read_seqbegin_or_lock(&cell->volume_lock, &seq); p = rcu_dereference_raw(cell->volumes.rb_node);