Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5327367rdb; Wed, 13 Dec 2023 05:53:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHtFNN44obMmT6NTTvOmPLnnwMzr8T/C+4M6Rm6sOIlxf2v1I+81kYlKVJn+De9hkQa4B8 X-Received: by 2002:a05:6a20:bb14:b0:191:8955:ce4c with SMTP id fc20-20020a056a20bb1400b001918955ce4cmr2498595pzb.60.1702475626720; Wed, 13 Dec 2023 05:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702475626; cv=none; d=google.com; s=arc-20160816; b=sd4iD19kW19uvbosdPEUHTA4X0Ps+mR1zsxzqyZa+2gFWVPwG1Gx8vBprij+OIUKcp avImwun2XW9OHGnEyNwIETmdgDtdWlc8vl297cX5q1pETgWxmWiyX7kqiH5KGCP+p+wT Pww+IJLlLMy6McRQIEFsNcxsWydZ+RLHP71Wz0wjT/J63Wk8q7K1MpQZi9Ebna0gze92 e70vT0AyBA0DGx6t1gRDURpY7vwgI2viQppEzYQLSPASo/LB9fQAQi5QyI6nlKjRvZ8o 2L/RLwI/sAg19/Wvzkv/jfmQzhGZbZl/1qcQ7NBGrjxd7Ow6AuIN4fmvDtH40yoJTHZw Y8vw== 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=opKh9OQ+SZyyTWeahPHV3sMgxBB7G/9x2ua+B2R2PzA=; fh=9hT4l0EMR1D2zdgUoRXiqFwsybSJyrmM/FC/blQlPsI=; b=eGzLBKyzs5m81YnyHRWCHNfvDOxge3+fikwRuki+jrvHeAGcz0WkJpKAGq2rYmJJte HAjQ2f4YzUY/gmz/9dDl/91v3tck+idh2FQ95d4t3p2Ms6BBT2VMXjScUwqHlXrxjeA0 UteGZeqBpn6HZSFEsw6rSbcqxPpAhKlsKNJiIskYe/mou721PzQr1o1V3UV7Hb/uzJo9 6hmYYQa9pZpvSEJjrfOpzflL2d3X9neP8xRcaQ/KlGMxgxCUIWcErs7wKlO6y8Kc+TyS 5SFEid0gYboHqXaVvQDH5eoWlSEzEg8aVeOsXOMDpsJJDjUzELh7KvtbOau0hE8KwYKT Mc1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hA2Odo+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id 28-20020a63175c000000b005c6bab48f48si9374455pgx.111.2023.12.13.05.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:53:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hA2Odo+F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id E31CC80B5A3A; Wed, 13 Dec 2023 05:53:29 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235432AbjLMNwZ (ORCPT + 99 others); Wed, 13 Dec 2023 08:52:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379340AbjLMNvf (ORCPT ); Wed, 13 Dec 2023 08:51:35 -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 8A156D5D for ; Wed, 13 Dec 2023 05:50:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702475458; 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=opKh9OQ+SZyyTWeahPHV3sMgxBB7G/9x2ua+B2R2PzA=; b=hA2Odo+F0qa8r6qhxmwUtv8u/XqmGwz2B8GShvHnNRDiQzUUyB73lBkbR9TJX5txK4cdMO z3+hUTbUqY0WgGT5nWIzfONdrcgN9+34V184aHCEw+2pMNT1H0B+HUbqkOJRK0eQpXQcky FIRYwaolqeJys1O0X8m+ACa4l9yo4bg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-AWp5BQAIMaq7AOiKaEhetw-1; Wed, 13 Dec 2023 08:50:53 -0500 X-MC-Unique: AWp5BQAIMaq7AOiKaEhetw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 E79F91C05EB5; Wed, 13 Dec 2023 13:50:52 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29D3A492BE6; Wed, 13 Dec 2023 13:50:52 +0000 (UTC) From: David Howells To: Marc Dionne Cc: David Howells , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 29/40] afs: Combine the endpoint state bools into a bitmask Date: Wed, 13 Dec 2023 13:49:51 +0000 Message-ID: <20231213135003.367397-30-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.10 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:53:30 -0800 (PST) Combine the endpoint state bool-type members into a bitmask so that some of them can be waited upon more easily. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/fs_probe.c | 30 +++++++++++++++--------------- fs/afs/internal.h | 12 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fs/afs/fs_probe.c b/fs/afs/fs_probe.c index a669aee033c5..c00d38b98a67 100644 --- a/fs/afs/fs_probe.c +++ b/fs/afs/fs_probe.c @@ -77,7 +77,7 @@ static void afs_schedule_fs_probe(struct afs_net *net, static void afs_finished_fs_probe(struct afs_net *net, struct afs_server *server, struct afs_endpoint_state *estate) { - bool responded = estate->responded; + bool responded = test_bit(AFS_ESTATE_RESPONDED, &estate->flags); write_seqlock(&net->fs_lock); if (responded) { @@ -121,7 +121,7 @@ static void afs_fs_probe_not_done(struct afs_net *net, trace_afs_io_error(0, -ENOMEM, afs_io_error_fs_probe_fail); spin_lock(&server->probe_lock); - estate->local_failure = true; + set_bit(AFS_ESTATE_LOCAL_FAILURE, &estate->flags); if (estate->error == 0) estate->error = -ENOMEM; @@ -156,7 +156,7 @@ void afs_fileserver_probe_result(struct afs_call *call) estate->error = 0; goto responded; case -ECONNABORTED: - if (!estate->responded) { + if (!test_bit(AFS_ESTATE_RESPONDED, &estate->flags)) { estate->abort_code = call->abort_code; estate->error = ret; } @@ -164,7 +164,7 @@ void afs_fileserver_probe_result(struct afs_call *call) case -ENOMEM: case -ENONET: clear_bit(index, &estate->responsive_set); - estate->local_failure = true; + set_bit(AFS_ESTATE_LOCAL_FAILURE, &estate->flags); trace_afs_io_error(call->debug_id, ret, afs_io_error_fs_probe_fail); goto out; case -ECONNRESET: /* Responded, but call expired. */ @@ -179,7 +179,7 @@ void afs_fileserver_probe_result(struct afs_call *call) default: clear_bit(index, &estate->responsive_set); set_bit(index, &estate->failed_set); - if (!estate->responded && + if (!test_bit(AFS_ESTATE_RESPONDED, &estate->flags) && (estate->error == 0 || estate->error == -ETIMEDOUT || estate->error == -ETIME)) @@ -192,13 +192,13 @@ void afs_fileserver_probe_result(struct afs_call *call) clear_bit(index, &estate->failed_set); if (call->service_id == YFS_FS_SERVICE) { - estate->is_yfs = true; + set_bit(AFS_ESTATE_IS_YFS, &estate->flags); set_bit(AFS_SERVER_FL_IS_YFS, &server->flags); server->service_id = call->service_id; } else { - estate->not_yfs = true; - if (!estate->is_yfs) { - estate->is_yfs = false; + set_bit(AFS_ESTATE_NOT_YFS, &estate->flags); + if (!test_bit(AFS_ESTATE_IS_YFS, &estate->flags)) { + clear_bit(AFS_SERVER_FL_IS_YFS, &server->flags); server->service_id = call->service_id; } cap0 = ntohl(call->tmp); @@ -216,7 +216,7 @@ void afs_fileserver_probe_result(struct afs_call *call) } smp_wmb(); /* Set rtt before responded. */ - estate->responded = true; + set_bit(AFS_ESTATE_RESPONDED, &estate->flags); set_bit(index, &estate->responsive_set); set_bit(AFS_SERVER_FL_RESPONDING, &server->flags); out: @@ -264,7 +264,7 @@ void afs_fs_probe_fileserver(struct afs_net *net, struct afs_server *server, atomic_set(&estate->nr_probing, alist->nr_addrs); rcu_assign_pointer(server->endpoint_state, estate); - old->superseded = true; + set_bit(AFS_ESTATE_SUPERSEDED, &old->flags); write_unlock(&server->fs_lock); trace_afs_estate(estate->server_id, estate->probe_seq, refcount_read(&estate->ref), @@ -317,7 +317,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried) estate = rcu_dereference(server->endpoint_state); if (!atomic_read(&estate->nr_probing)) __clear_bit(i, &untried); - if (estate->responded) + if (test_bit(AFS_ESTATE_RESPONDED, &estate->flags)) have_responders = true; } } @@ -344,7 +344,7 @@ int afs_wait_for_fs_probes(struct afs_server_list *slist, unsigned long untried) for (i = 0; i < slist->nr_servers; i++) { if (test_bit(i, &untried)) { server = slist->servers[i].server; - if (estate->responded) + if (test_bit(AFS_ESTATE_RESPONDED, &estate->flags)) goto stop; if (atomic_read(&estate->nr_probing)) still_probing = true; @@ -521,7 +521,7 @@ int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_sta prepare_to_wait_event(&server->probe_wq, &wait, is_intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); if (timo == 0 || - estate->responded || + test_bit(AFS_ESTATE_RESPONDED, &estate->flags) || atomic_read(&estate->nr_probing) == 0 || (is_intr && signal_pending(current))) break; @@ -531,7 +531,7 @@ int afs_wait_for_one_fs_probe(struct afs_server *server, struct afs_endpoint_sta finish_wait(&server->probe_wq, &wait); dont_wait: - if (estate->responded) + if (test_bit(AFS_ESTATE_RESPONDED, &estate->flags)) return 0; if (is_intr && signal_pending(current)) return -ERESTARTSYS; diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 4d42f84a8da4..96c1074fe78d 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -534,16 +534,16 @@ struct afs_endpoint_state { refcount_t ref; unsigned int server_id; /* Debug ID of server */ unsigned int probe_seq; /* Probe sequence (from server::probe_counter) */ - atomic_t nr_probing; /* Number of outstanding probes */ unsigned int rtt; /* Best RTT in uS (or UINT_MAX) */ s32 abort_code; short error; - bool responded:1; - bool is_yfs:1; - bool not_yfs:1; - bool local_failure:1; - bool superseded:1; /* Set if has been superseded */ + unsigned long flags; +#define AFS_ESTATE_RESPONDED 0 /* Set if the server responded */ +#define AFS_ESTATE_SUPERSEDED 1 /* Set if this record has been superseded */ +#define AFS_ESTATE_IS_YFS 2 /* Set if probe upgraded to YFS */ +#define AFS_ESTATE_NOT_YFS 3 /* Set if probe didn't upgrade to YFS */ +#define AFS_ESTATE_LOCAL_FAILURE 4 /* Set if there was a local failure (eg. ENOMEM) */ }; /*