Whamcloud - gitweb
LU-9416 hsm: add kkuc before sending registration RPCs 87/29687/2
authorHenri Doreau <henri.doreau@cea.fr>
Wed, 23 Aug 2017 15:16:25 +0000 (17:16 +0200)
committerJohn L. Hammond <john.hammond@intel.com>
Tue, 24 Oct 2017 21:38:46 +0000 (21:38 +0000)
This avoids a situation where the registration completes and the CDT
sends HSM actions just before the kkuc registration happens. In this
case the client drops the actions because there are no CT pipes in the
kkuc list.

Lustre-change: https://review.whamcloud.com/28751
Lustre-commit: bdb04079570dd2de3b9310221e0206d64efb9ecc

Change-Id: Icbd6575f04c0ca7e8f731ee8481ec72a9ff4f2e1
Signed-off-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Signed-off-by: Minh Diep <minh.diep@intel.com>
Reviewed-on: https://review.whamcloud.com/29687
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/lmv/lmv_obd.c

index 78160ad..8364def 100644 (file)
@@ -822,11 +822,25 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
 {
        struct file             *filp;
        __u32                    i, j;
-       int                      err, rc;
+       int                      err;
        bool                     any_set = false;
-       struct kkuc_ct_data      kcd = { 0 };
+       struct kkuc_ct_data      kcd = {
+               .kcd_magic   = KKUC_CT_DATA_MAGIC,
+               .kcd_uuid    = lmv->cluuid,
+               .kcd_archive = lk->lk_data
+       };
+       int                      rc = 0;
        ENTRY;
 
+       filp = fget(lk->lk_wfd);
+       if (!filp)
+               RETURN(-EBADF);
+
+       rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group,
+                                  &kcd, sizeof(kcd));
+       if (rc)
+               GOTO(err_fput, rc);
+
        /* All or nothing: try to register to all MDS.
         * In case of failure, unregister from previous MDS,
         * except if it because of inactive target. */
@@ -835,6 +849,7 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
 
                if (tgt == NULL || tgt->ltd_exp == NULL)
                        continue;
+
                err = obd_iocontrol(cmd, tgt->ltd_exp, len, lk, uarg);
                if (err) {
                        if (tgt->ltd_active) {
@@ -853,7 +868,7 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
                                        obd_iocontrol(cmd, tgt->ltd_exp, len,
                                                      lk, uarg);
                                }
-                               RETURN(rc);
+                               GOTO(err_kkuc_rem, rc);
                        }
                        /* else: transient error.
                         * kuc will register to the missing MDT
@@ -865,23 +880,16 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len,
 
        if (!any_set)
                /* no registration done: return error */
-               RETURN(-ENOTCONN);
+               GOTO(err_kkuc_rem, rc = -ENOTCONN);
 
-       /* at least one registration done, with no failure */
-       filp = fget(lk->lk_wfd);
-       if (filp == NULL)
-               RETURN(-EBADF);
+       RETURN(0);
 
-       kcd.kcd_magic = KKUC_CT_DATA_MAGIC;
-       kcd.kcd_uuid = lmv->cluuid;
-       kcd.kcd_archive = lk->lk_data;
+err_kkuc_rem:
+       libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group);
 
-       rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group,
-                                  &kcd, sizeof(kcd));
-       if (rc != 0)
-               fput(filp);
-
-       RETURN(rc);
+err_fput:
+       fput(filp);
+       return rc;
 }