staging: lustre: ptlrpc: return a meaningful status from ptlrpcd_init()
authorSwapnil Pimpale <spimpale@ddn.com>
Tue, 12 Apr 2016 20:14:09 +0000 (16:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Apr 2016 22:13:13 +0000 (15:13 -0700)
This patch has the following:
1) Fix for the return value from ptlrpcd_init(). It will now return a
   correct status instead of returning zero always.
2) ptlrpcd_addref() should not increment ptlrpcd_users on error.
3) Added code in a mdc_setup() and mgc_setup() to test the return
   value of ptlrpcd_addref() and return on error.

Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3808
Reviewed-on: http://review.whamcloud.com/7522
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/mdc/mdc_request.c
drivers/staging/lustre/lustre/mgc/mgc_request.c
drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c

index 6023c2c1386bdbbf6d3f6ceca3983e85b5306209..5f1ac58c6fe265bead55f692abef3b82909ecabc 100644 (file)
@@ -2314,12 +2314,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
                return -ENOMEM;
        mdc_init_rpc_lock(cli->cl_rpc_lock);
 
-       ptlrpcd_addref();
+       rc = ptlrpcd_addref();
+       if (rc < 0)
+               goto err_rpc_lock;
 
        cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS);
        if (!cli->cl_close_lock) {
                rc = -ENOMEM;
-               goto err_rpc_lock;
+               goto err_ptlrpcd_decref;
        }
        mdc_init_rpc_lock(cli->cl_close_lock);
 
@@ -2345,9 +2347,10 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 
 err_close_lock:
        kfree(cli->cl_close_lock);
+err_ptlrpcd_decref:
+       ptlrpcd_decref();
 err_rpc_lock:
        kfree(cli->cl_rpc_lock);
-       ptlrpcd_decref();
        return rc;
 }
 
index 0c3bd1648a888070c9bcddce0625cbf517d61b6e..933f6f628350783684b7bf068bfc11b88c2237d4 100644 (file)
@@ -734,7 +734,9 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
        struct task_struct *task;
        int rc;
 
-       ptlrpcd_addref();
+       rc = ptlrpcd_addref();
+       if (rc < 0)
+               goto err_noref;
 
        rc = client_obd_setup(obd, lcfg);
        if (rc)
@@ -773,6 +775,7 @@ err_cleanup:
        client_obd_cleanup(obd);
 err_decref:
        ptlrpcd_decref();
+err_noref:
        return rc;
 }
 
index dbc3376328cdd3f61d581e641875284ab64c7249..76a355a9db8b9e1a8d3bbf2385beeda9dc8b3d8d 100644 (file)
@@ -909,8 +909,11 @@ int ptlrpcd_addref(void)
        int rc = 0;
 
        mutex_lock(&ptlrpcd_mutex);
-       if (++ptlrpcd_users == 1)
+       if (++ptlrpcd_users == 1) {
                rc = ptlrpcd_init();
+               if (rc < 0)
+                       ptlrpcd_users--;
+       }
        mutex_unlock(&ptlrpcd_mutex);
        return rc;
 }