Whamcloud - gitweb
LU-3808 ptlrpc: Return a meaningful status from ptlrpcd_init() 22/7522/4
authorSwapnil Pimpale <spimpale@ddn.com>
Mon, 2 Sep 2013 07:21:32 +0000 (12:51 +0530)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 18 Sep 2013 09:04:25 +0000 (09:04 +0000)
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>
Change-Id: I684b5603b33d469f4e7566d07f52cb49b05c8ec6
Reviewed-on: http://review.whamcloud.com/7522
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/mdc/mdc_request.c
lustre/mgc/libmgc.c
lustre/mgc/mgc_request.c
lustre/ptlrpc/ptlrpcd.c

index 0f7a9c9..b435b07 100644 (file)
@@ -2460,21 +2460,23 @@ struct ldlm_valblock_ops inode_lvbo = {
 
 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 {
-        struct client_obd *cli = &obd->u.cli;
-        struct lprocfs_static_vars lvars = { 0 };
-        int rc;
-        ENTRY;
+       struct client_obd               *cli = &obd->u.cli;
+       struct lprocfs_static_vars      lvars = { 0 };
+       int                             rc;
+       ENTRY;
 
         OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
         if (!cli->cl_rpc_lock)
                 RETURN(-ENOMEM);
         mdc_init_rpc_lock(cli->cl_rpc_lock);
 
-        ptlrpcd_addref();
+       rc = ptlrpcd_addref();
+       if (rc < 0)
+               GOTO(err_rpc_lock, rc);
 
         OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
         if (!cli->cl_close_lock)
-                GOTO(err_rpc_lock, rc = -ENOMEM);
+                GOTO(err_ptlrpcd_decref, rc = -ENOMEM);
         mdc_init_rpc_lock(cli->cl_close_lock);
 
         rc = client_obd_setup(obd, cfg);
@@ -2500,9 +2502,10 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
 
 err_close_lock:
         OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
+err_ptlrpcd_decref:
+        ptlrpcd_decref();
 err_rpc_lock:
         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
-        ptlrpcd_decref();
         RETURN(rc);
 }
 
index b156ebb..c639da8 100644 (file)
@@ -56,7 +56,9 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         int rc;
         ENTRY;
 
-        ptlrpcd_addref();
+       rc = ptlrpcd_addref();
+       if (rc < 0)
+               RETURN(rc);
 
         rc = client_obd_setup(obd, lcfg);
         if (rc)
index 4ea58a0..5c130be 100644 (file)
@@ -888,11 +888,13 @@ static int mgc_cleanup(struct obd_device *obd)
 
 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
-        struct lprocfs_static_vars lvars;
-        int rc;
+       struct lprocfs_static_vars      lvars;
+       int                             rc;
         ENTRY;
 
-        ptlrpcd_addref();
+       rc = ptlrpcd_addref();
+       if (rc < 0)
+               RETURN(rc);
 
         rc = client_obd_setup(obd, lcfg);
         if (rc)
index 56f56ff..ee2c15f 100644 (file)
@@ -828,9 +828,9 @@ static void ptlrpcd_fini(void)
 
 static int ptlrpcd_init(void)
 {
-       int nthreads = num_online_cpus();
-       char name[16];
-       int size, i = -1, j, rc = 0;
+       int     nthreads = num_online_cpus();
+       char    name[16];
+       int     size, i = -1, j, rc = 0;
        ENTRY;
 
 #ifdef __KERNEL__
@@ -892,7 +892,7 @@ out:
                 ptlrpcds = NULL;
         }
 
-        RETURN(0);
+       RETURN(rc);
 }
 
 int ptlrpcd_addref(void)
@@ -901,8 +901,11 @@ int ptlrpcd_addref(void)
         ENTRY;
 
        mutex_lock(&ptlrpcd_mutex);
-        if (++ptlrpcd_users == 1)
-                rc = ptlrpcd_init();
+        if (++ptlrpcd_users == 1) {
+               rc = ptlrpcd_init();
+               if (rc < 0)
+                       ptlrpcd_users--;
+       }
        mutex_unlock(&ptlrpcd_mutex);
         RETURN(rc);
 }