staging: lustre: lmv: assume a real connection in lmv_connect()
authorJohn L. Hammond <john.hammond@intel.com>
Wed, 26 Jul 2017 15:22:22 +0000 (11:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 30 Jul 2017 15:08:31 +0000 (08:08 -0700)
Assume a real connection in lmv_connect(). Mark OBD_CONNECT_REAL
obsolete. Remove the then unnecessary refcount and exp members of
struct lmv_obd. Remove calls to lmv_check_connect(). Disconnect the
export in the appropriate error path of lmv_connect().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7669
Reviewed-on: http://review.whamcloud.com/18018
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
drivers/staging/lustre/lustre/include/obd.h
drivers/staging/lustre/lustre/llite/llite_lib.c
drivers/staging/lustre/lustre/lmv/lmv_intent.c
drivers/staging/lustre/lustre/lmv/lmv_internal.h
drivers/staging/lustre/lustre/lmv/lmv_obd.c

index 77995fa4769151a6abeb231c0fb9a44631a2e7c2..441a2e33f1ed41457eddbb1c3249b3e89fbc890f 100644 (file)
@@ -1122,7 +1122,7 @@ struct ptlrpc_body_v2 {
 #define OBD_CONNECT_AT             0x1000000ULL /*client uses AT */
 #define OBD_CONNECT_LRU_RESIZE      0x2000000ULL /*LRU resize feature. */
 #define OBD_CONNECT_MDS_MDS        0x4000000ULL /*MDS-MDS connection */
-#define OBD_CONNECT_REAL           0x8000000ULL /*real connection */
+#define OBD_CONNECT_REAL           0x8000000ULL /* obsolete since 2.8 */
 #define OBD_CONNECT_CHANGE_QS      0x10000000ULL /*Not used since 2.4 */
 #define OBD_CONNECT_CKSUM         0x20000000ULL /*support several cksum algos*/
 #define OBD_CONNECT_FID                   0x40000000ULL /*FID is supported by server */
index 4ce85064f9d0767af24bda848d1b846d5c5bfbf8..4dfc31e2960b39897dd13771a3778e2955e9e188 100644 (file)
@@ -404,12 +404,10 @@ struct lmv_tgt_desc {
 };
 
 struct lmv_obd {
-       int                     refcount;
        struct lu_client_fld    lmv_fld;
        spinlock_t              lmv_lock;
        struct lmv_desc         desc;
        struct obd_uuid         cluuid;
-       struct obd_export       *exp;
 
        struct mutex            lmv_init_mutex;
        int                     connected;
index 974a05d6c969f5230b2a3e48b6ceb5968f01e49b..69d895d3f9f80db20728054c91d3c5023798828c 100644 (file)
@@ -222,9 +222,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
        else
                sbi->ll_fop = &ll_file_operations_noflock;
 
-       /* real client */
-       data->ocd_connect_flags |= OBD_CONNECT_REAL;
-
        /* always ping even if server suppress_pings */
        if (sbi->ll_flags & LL_SBI_ALWAYS_PING)
                data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS;
index f49db6c232179cd5a007762ca3a53f6f8ed0629f..5f01a0cfc809b3cd19c0ce752d6803fc46a538c9 100644 (file)
@@ -474,7 +474,6 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
                    ldlm_blocking_callback cb_blocking,
                    __u64 extra_lock_flags)
 {
-       struct obd_device *obd = exp->exp_obd;
        int             rc;
 
        LASSERT(fid_is_sane(&op_data->op_fid1));
@@ -484,10 +483,6 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
               (int)op_data->op_namelen, op_data->op_name,
               PFID(&op_data->op_fid1));
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT))
                rc = lmv_intent_lookup(exp, op_data, it, reqp, cb_blocking,
                                       extra_lock_flags);
index 12731a17e263499444daa925477c1661333220a1..e839b831a7c52e6806caf146f4053c52a7f2e100 100644 (file)
@@ -42,8 +42,6 @@
 #define LL_IT2STR(it)                                  \
        ((it) ? ldlm_it2str((it)->it_op) : "0")
 
-int lmv_check_connect(struct obd_device *obd);
-
 int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
                    struct lookup_intent *it, struct ptlrpc_request **reqp,
                    ldlm_blocking_callback cb_blocking,
index 64fcaef0bacd90efaeea4ff5f9637a067399d2cb..1c9ff2493423feec1c51b8ccd69546a907ec47e7 100644 (file)
@@ -53,6 +53,8 @@
 #include "../include/lustre_kernelcomm.h"
 #include "lmv_internal.h"
 
+static int lmv_check_connect(struct obd_device *obd);
+
 static void lmv_activate_target(struct lmv_obd *lmv,
                                struct lmv_tgt_desc *tgt,
                                int activate)
@@ -183,59 +185,44 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched,
        return rc;
 }
 
-/**
- * This is fake connect function. Its purpose is to initialize lmv and say
- * caller that everything is okay. Real connection will be performed later.
- */
 static int lmv_connect(const struct lu_env *env,
-                      struct obd_export **exp, struct obd_device *obd,
+                      struct obd_export **pexp, struct obd_device *obd,
                       struct obd_uuid *cluuid, struct obd_connect_data *data,
                       void *localdata)
 {
        struct lmv_obd  *lmv = &obd->u.lmv;
        struct lustre_handle  conn = { 0 };
+       struct obd_export *exp;
        int                 rc = 0;
 
-       /*
-        * We don't want to actually do the underlying connections more than
-        * once, so keep track.
-        */
-       lmv->refcount++;
-       if (lmv->refcount > 1) {
-               *exp = NULL;
-               return 0;
-       }
-
        rc = class_connect(&conn, obd, cluuid);
        if (rc) {
                CERROR("class_connection() returned %d\n", rc);
                return rc;
        }
 
-       *exp = class_conn2export(&conn);
-       class_export_get(*exp);
+       exp = class_conn2export(&conn);
 
-       lmv->exp = *exp;
        lmv->connected = 0;
        lmv->cluuid = *cluuid;
-
-       if (data)
-               lmv->conn_data = *data;
+       lmv->conn_data = *data;
 
        lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds",
                                                    &obd->obd_kobj);
-       /*
-        * All real clients should perform actual connection right away, because
-        * it is possible, that LMV will not have opportunity to connect targets
-        * and MDC stuff will be called directly, for instance while reading
-        * ../mdc/../kbytesfree procfs file, etc.
-        */
-       if (data && data->ocd_connect_flags & OBD_CONNECT_REAL)
-               rc = lmv_check_connect(obd);
+       rc = lmv_check_connect(obd);
+       if (rc)
+               goto out_sysfs;
+
+       *pexp = exp;
 
-       if (rc && lmv->lmv_tgts_kobj)
+       return rc;
+
+out_sysfs:
+       if (lmv->lmv_tgts_kobj)
                kobject_put(lmv->lmv_tgts_kobj);
 
+       class_disconnect(exp);
+
        return rc;
 }
 
@@ -475,7 +462,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
        return rc;
 }
 
-int lmv_check_connect(struct obd_device *obd)
+static int lmv_check_connect(struct obd_device *obd)
 {
        struct lmv_obd       *lmv = &obd->u.lmv;
        struct lmv_tgt_desc  *tgt;
@@ -519,7 +506,6 @@ int lmv_check_connect(struct obd_device *obd)
                        goto out_disc;
        }
 
-       class_export_put(lmv->exp);
        lmv->connected = 1;
        easize = lmv_mds_md_size(lmv->desc.ld_tgt_count, LMV_MAGIC);
        lmv_init_ea_size(obd->obd_self_export, easize, 0);
@@ -543,7 +529,7 @@ int lmv_check_connect(struct obd_device *obd)
                        }
                }
        }
-       class_disconnect(lmv->exp);
+
        mutex_unlock(&lmv->lmv_init_mutex);
        return rc;
 }
@@ -598,13 +584,6 @@ static int lmv_disconnect(struct obd_export *exp)
        if (!lmv->tgts)
                goto out_local;
 
-       /*
-        * Only disconnect the underlying layers on the final disconnect.
-        */
-       lmv->refcount--;
-       if (lmv->refcount != 0)
-               goto out_local;
-
        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
                if (!lmv->tgts[i] || !lmv->tgts[i]->ltd_exp)
                        continue;
@@ -623,8 +602,7 @@ out_local:
        if (!lmv->connected)
                class_export_put(exp);
        rc = class_disconnect(exp);
-       if (lmv->refcount == 0)
-               lmv->connected = 0;
+       lmv->connected = 0;
        return rc;
 }
 
@@ -1122,7 +1100,8 @@ hsm_req_err:
                        err = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
                        if (err) {
                                if (tgt->ltd_active) {
-                                       CERROR("error: iocontrol MDC %s on MDTidx %d cmd %x: err = %d\n",
+                                       CERROR("%s: error: iocontrol MDC %s on MDTidx %d cmd %x: err = %d\n",
+                                              lmv2obd_dev(lmv)->obd_name,
                                               tgt->ltd_uuid.uuid, i, cmd, err);
                                        if (!rc)
                                                rc = err;
@@ -1368,10 +1347,6 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
        int                 rc = 0;
        u32 i;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        temp = kzalloc(sizeof(*temp), GFP_NOFS);
        if (!temp)
                return -ENOMEM;
@@ -1418,11 +1393,6 @@ static int lmv_getstatus(struct obd_export *exp,
 {
        struct obd_device    *obd = exp->exp_obd;
        struct lmv_obd       *lmv = &obd->u.lmv;
-       int                rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        return md_getstatus(lmv->tgts[0]->ltd_exp, fid);
 }
@@ -1435,11 +1405,6 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
        struct obd_device      *obd = exp->exp_obd;
        struct lmv_obd   *lmv = &obd->u.lmv;
        struct lmv_tgt_desc    *tgt;
-       int                  rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        tgt = lmv_find_target(lmv, fid);
        if (IS_ERR(tgt))
@@ -1458,11 +1423,6 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
        struct obd_device      *obd = exp->exp_obd;
        struct lmv_obd   *lmv = &obd->u.lmv;
        struct lmv_tgt_desc    *tgt;
-       int                  rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        tgt = lmv_find_target(lmv, fid);
        if (IS_ERR(tgt))
@@ -1479,11 +1439,6 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd    *lmv = &obd->u.lmv;
        struct lmv_tgt_desc     *tgt;
-       int                   rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        tgt = lmv_find_target(lmv, &op_data->op_fid1);
        if (IS_ERR(tgt))
@@ -1502,11 +1457,6 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid)
        struct obd_device   *obd = exp->exp_obd;
        struct lmv_obd      *lmv = &obd->u.lmv;
        u32 i;
-       int               rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        CDEBUG(D_INODE, "CBDATA for " DFID "\n", PFID(fid));
 
@@ -1530,11 +1480,6 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
        struct obd_device     *obd = exp->exp_obd;
        struct lmv_obd  *lmv = &obd->u.lmv;
        struct lmv_tgt_desc   *tgt;
-       int                 rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        tgt = lmv_find_target(lmv, &op_data->op_fid1);
        if (IS_ERR(tgt))
@@ -1661,10 +1606,6 @@ static int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
        struct lmv_tgt_desc     *tgt;
        int                   rc;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        if (!lmv->desc.ld_active_tgt_count)
                return -EIO;
 
@@ -1718,11 +1659,6 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd     *lmv = &obd->u.lmv;
        struct lmv_tgt_desc      *tgt;
-       int                    rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        CDEBUG(D_INODE, "ENQUEUE '%s' on " DFID "\n",
               LL_IT2STR(it), PFID(&op_data->op_fid1));
@@ -1749,10 +1685,6 @@ lmv_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
        struct mdt_body  *body;
        int                   rc;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
        if (IS_ERR(tgt))
                return PTR_ERR(tgt);
@@ -1845,10 +1777,6 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
        struct lmv_tgt_desc     *tgt;
        int                   rc;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        LASSERT(op_data->op_namelen != 0);
 
        CDEBUG(D_INODE, "LINK " DFID ":%*s to " DFID "\n",
@@ -1907,10 +1835,6 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
               (int)newlen, new, PFID(&op_data->op_fid2),
               op_data->op_mea2 ? op_data->op_mea2->lsm_md_stripe_count : 0);
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid());
        op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid());
        op_data->op_cap = cfs_curproc_cap_pack();
@@ -2063,11 +1987,6 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd    *lmv = &obd->u.lmv;
        struct lmv_tgt_desc     *tgt;
-       int                   rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        CDEBUG(D_INODE, "SETATTR for " DFID ", valid 0x%x\n",
               PFID(&op_data->op_fid1), op_data->op_attr.ia_valid);
@@ -2086,11 +2005,6 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
        struct obd_device        *obd = exp->exp_obd;
        struct lmv_obd      *lmv = &obd->u.lmv;
        struct lmv_tgt_desc       *tgt;
-       int                     rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        tgt = lmv_find_target(lmv, fid);
        if (IS_ERR(tgt))
@@ -2272,7 +2186,6 @@ static int lmv_read_striped_page(struct obd_export *exp,
 {
        struct inode *master_inode = op_data->op_data;
        struct lu_fid master_fid = op_data->op_fid1;
-       struct obd_device *obd = exp->exp_obd;
        __u64 hash_offset = offset;
        __u32 ldp_flags;
        struct page *min_ent_page = NULL;
@@ -2286,10 +2199,6 @@ static int lmv_read_striped_page(struct obd_export *exp,
        void *area;
        int rc;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        /*
         * Allocate a page and read entries from all of stripes and fill
         * the page by hash order
@@ -2408,11 +2317,6 @@ static int lmv_read_page(struct obd_export *exp, struct md_op_data *op_data,
        struct obd_device *obd = exp->exp_obd;
        struct lmv_obd *lmv = &obd->u.lmv;
        struct lmv_tgt_desc *tgt;
-       int rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        if (unlikely(lsm))
                return lmv_read_striped_page(exp, op_data, cb_op, offset, ppage);
@@ -2460,9 +2364,6 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data,
        int stripe_index = 0;
        int                  rc;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 retry_unlink:
        /* For striped dir, we need to locate the parent as well */
        if (lsm) {
@@ -2647,10 +2548,6 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
        if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
                int i;
 
-               rc = lmv_check_connect(obd);
-               if (rc)
-                       return rc;
-
                LASSERT(*vallen == sizeof(__u32));
                for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
                        struct lmv_tgt_desc *tgt = lmv->tgts[i];
@@ -2669,10 +2566,6 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
        } else if (KEY_IS(KEY_MAX_EASIZE) ||
                   KEY_IS(KEY_DEFAULT_EASIZE) ||
                   KEY_IS(KEY_CONN_DATA)) {
-               rc = lmv_check_connect(obd);
-               if (rc)
-                       return rc;
-
                /*
                 * Forwarding this request to first MDS, it should know LOV
                 * desc.
@@ -3021,15 +2914,10 @@ static int lmv_intent_getattr_async(struct obd_export *exp,
        struct lmv_obd    *lmv = &obd->u.lmv;
        struct lmv_tgt_desc *ptgt = NULL;
        struct lmv_tgt_desc *ctgt = NULL;
-       int                   rc;
 
        if (!fid_is_sane(&op_data->op_fid2))
                return -EINVAL;
 
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
-
        ptgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
        if (IS_ERR(ptgt))
                return PTR_ERR(ptgt);
@@ -3056,11 +2944,6 @@ static int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
        struct obd_device       *obd = exp->exp_obd;
        struct lmv_obd    *lmv = &obd->u.lmv;
        struct lmv_tgt_desc     *tgt;
-       int                   rc;
-
-       rc = lmv_check_connect(obd);
-       if (rc)
-               return rc;
 
        tgt = lmv_find_target(lmv, fid);
        if (IS_ERR(tgt))