Whamcloud - gitweb
LU-17022 obdclass: convert obd_conn_inprogress to atomic_t 06/51906/3
authorMr NeilBrown <neilb@suse.de>
Sun, 25 Feb 2024 23:41:46 +0000 (18:41 -0500)
committerOleg Drokin <green@whamcloud.com>
Mon, 4 Mar 2024 20:02:08 +0000 (20:02 +0000)
Using atomic_t for obd_conn_inprogress means we don't need to take a
spinlock.
Also send wakeup when value reaches zero, and wait for the wakeup
instead of using a yield() loop.

Change-Id: I9af29e068203cde951e592c408906d121702fa18
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51906
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/obdclass/genops.c
lustre/obdclass/obd_config.c

index 9f38cff..774b151 100644 (file)
@@ -740,7 +740,7 @@ struct obd_device {
        __u64                           obd_pool_slv;
        int                             obd_pool_limit;
 
-       int                             obd_conn_inprogress;
+       atomic_t                        obd_conn_inprogress;
 
        /**
         * List of outstanding class_incref()'s fo this OBD. For debugging. */
index b2dd5d5..e480736 100644 (file)
@@ -1121,13 +1121,9 @@ int target_handle_connect(struct ptlrpc_request *req)
                GOTO(out, rc = -ENODEV);
        }
 
-       spin_lock(&target->obd_dev_lock);
-
-       target->obd_conn_inprogress++;
+       atomic_inc(&target->obd_conn_inprogress);
 
        if (target->obd_stopping || !target->obd_set_up) {
-               spin_unlock(&target->obd_dev_lock);
-
                deuuidify(str, NULL, &target_start, &target_len);
                LCONSOLE_INFO("%.*s: Not available for connect from %s (%s)\n",
                              target_len, target_start,
@@ -1138,16 +1134,12 @@ int target_handle_connect(struct ptlrpc_request *req)
        }
 
        if (target->obd_no_conn) {
-               spin_unlock(&target->obd_dev_lock);
-
                CDEBUG(D_INFO,
                       "%s: Temporarily refusing client connection from %s\n",
                       target->obd_name, libcfs_nidstr(&req->rq_peer.nid));
                GOTO(out, rc = -EAGAIN);
        }
 
-       spin_unlock(&target->obd_dev_lock);
-
        str = req_capsule_client_get(&req->rq_pill, &RMF_CLUUID);
        if (str == NULL) {
                DEBUG_REQ(D_ERROR, req, "bad client UUID for connect");
@@ -1624,10 +1616,9 @@ out:
 
                class_export_put(export);
        }
-       if (target != NULL) {
-               spin_lock(&target->obd_dev_lock);
-               target->obd_conn_inprogress--;
-               spin_unlock(&target->obd_dev_lock);
+       if (target) {
+               if (atomic_dec_and_test(&target->obd_conn_inprogress))
+                       wake_up_var(&target->obd_conn_inprogress);
                class_decref(target, "find", current);
        }
        if (pcon)
index 0118971..0607064 100644 (file)
@@ -410,7 +410,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
        lu_ref_init(&newdev->obd_reference);
        lu_ref_add(&newdev->obd_reference, "newdev", newdev);
 
-       newdev->obd_conn_inprogress = 0;
+       atomic_set(&newdev->obd_conn_inprogress, 0);
 
        strncpy(newdev->obd_uuid.uuid, uuid, UUID_MAX);
 
index 89a5804..72947f8 100644 (file)
@@ -846,8 +846,8 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
        spin_unlock(&obd->obd_dev_lock);
 
        /* wait for already-arrived-connections to finish. */
-       while (obd->obd_conn_inprogress > 0)
-               yield();
+       wait_var_event(&obd->obd_conn_inprogress,
+                      atomic_read(&obd->obd_conn_inprogress) == 0);
        smp_rmb();
 
        if (lcfg->lcfg_bufcount >= 2 && LUSTRE_CFG_BUFLEN(lcfg, 1) > 0) {