Whamcloud - gitweb
LU-12072 lov: remove KEY_CACHE_SET to simplify the code 19/34419/4
authorYang Sheng <ys@whamcloud.com>
Thu, 7 Mar 2019 19:35:12 +0000 (11:35 -0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Apr 2019 05:35:58 +0000 (05:35 +0000)
We must invoke obd_set_info_async with KEY_CACHE_SET after
obd_connect for OSC device. In fact, It can be combined
in obd_connect to simplify the code.

Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: I8cf235658a3e4af1685a7454ebfe887e5a28eccc
Reviewed-on: https://review.whamcloud.com/34419
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/llite/llite_lib.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/osc/osc_request.c

index 286779d..0d04870 100644 (file)
@@ -451,6 +451,7 @@ struct lmv_obd {
 
        struct obd_connect_data conn_data;
        struct kobject          *lmv_tgts_kobj;
 
        struct obd_connect_data conn_data;
        struct kobject          *lmv_tgts_kobj;
+       void                    *lmv_cache;
 };
 
 /* Minimum sector size is 512 */
 };
 
 /* Minimum sector size is 512 */
@@ -779,7 +780,6 @@ struct obd_device {
 /*      KEY_SET_INFO in lustre_idl.h */
 #define KEY_SPTLRPC_CONF        "sptlrpc_conf"
 
 /*      KEY_SET_INFO in lustre_idl.h */
 #define KEY_SPTLRPC_CONF        "sptlrpc_conf"
 
-#define KEY_CACHE_SET          "cache_set"
 #define KEY_CACHE_LRU_SHRINK   "cache_lru_shrink"
 #define KEY_OSP_CONNECTED      "osp_connected"
 
 #define KEY_CACHE_LRU_SHRINK   "cache_lru_shrink"
 #define KEY_OSP_CONNECTED      "osp_connected"
 
index e112c20..00e1542 100644 (file)
@@ -39,6 +39,7 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <cl_object.h>
 #include <linux/jiffies.h>
 #include <linux/kthread.h>
 #include <libcfs/libcfs.h>
 #include <linux/jiffies.h>
 #include <linux/kthread.h>
 #include <libcfs/libcfs.h>
@@ -625,6 +626,19 @@ out_ldlm:
 out_sem:
        up_write(&cli->cl_sem);
 
 out_sem:
        up_write(&cli->cl_sem);
 
+       if (!rc && localdata) {
+               LASSERT(cli->cl_cache == NULL); /* only once */
+               cli->cl_cache = (struct cl_client_cache *)localdata;
+               cl_cache_incref(cli->cl_cache);
+               cli->cl_lru_left = &cli->cl_cache->ccc_lru_left;
+
+               /* add this osc into entity list */
+               LASSERT(list_empty(&cli->cl_lru_osc));
+               spin_lock(&cli->cl_cache->ccc_lru_lock);
+               list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru);
+               spin_unlock(&cli->cl_cache->ccc_lru_lock);
+       }
+
        return rc;
 }
 EXPORT_SYMBOL(client_connect_import);
        return rc;
 }
 EXPORT_SYMBOL(client_connect_import);
index 83d9b8c..7ec8695 100644 (file)
@@ -281,7 +281,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
        data->ocd_brw_size = MD_MAX_BRW_SIZE;
 
        err = obd_connect(NULL, &sbi->ll_md_exp, sbi->ll_md_obd,
        data->ocd_brw_size = MD_MAX_BRW_SIZE;
 
        err = obd_connect(NULL, &sbi->ll_md_exp, sbi->ll_md_obd,
-                         &sbi->ll_sb_uuid, data, NULL);
+                         &sbi->ll_sb_uuid, data, sbi->ll_cache);
         if (err == -EBUSY) {
                 LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing "
                                    "recovery, of which this client is not a "
         if (err == -EBUSY) {
                 LCONSOLE_ERROR_MSG(0x14f, "An MDT (md %s) is performing "
                                    "recovery, of which this client is not a "
@@ -469,7 +469,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
        data->ocd_brw_size = DT_MAX_BRW_SIZE;
 
        err = obd_connect(NULL, &sbi->ll_dt_exp, sbi->ll_dt_obd,
        data->ocd_brw_size = DT_MAX_BRW_SIZE;
 
        err = obd_connect(NULL, &sbi->ll_dt_exp, sbi->ll_dt_obd,
-                         &sbi->ll_sb_uuid, data, NULL);
+                         &sbi->ll_sb_uuid, data, sbi->ll_cache);
        if (err == -EBUSY) {
                LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing "
                                   "recovery, of which this client is not a "
        if (err == -EBUSY) {
                LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing "
                                   "recovery, of which this client is not a "
@@ -591,15 +591,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
        }
        cl_sb_init(sb);
 
        }
        cl_sb_init(sb);
 
-       err = obd_set_info_async(NULL, sbi->ll_dt_exp, sizeof(KEY_CACHE_SET),
-                                KEY_CACHE_SET, sizeof(*sbi->ll_cache),
-                                sbi->ll_cache, NULL);
-       if (err) {
-               CERROR("%s: Set cache_set failed: rc = %d\n",
-                      sbi->ll_dt_exp->exp_obd->obd_name, err);
-               GOTO(out_root, err);
-       }
-
        sb->s_root = d_make_root(root);
        if (sb->s_root == NULL) {
                CERROR("%s: can't make root dentry\n",
        sb->s_root = d_make_root(root);
        if (sb->s_root == NULL) {
                CERROR("%s: can't make root dentry\n",
index cc0fd5d..b04d5a3 100644 (file)
@@ -212,6 +212,7 @@ static int lmv_connect(const struct lu_env *env,
 
        lmv->connected = 0;
        lmv->conn_data = *data;
 
        lmv->connected = 0;
        lmv->conn_data = *data;
+       lmv->lmv_cache = localdata;
 
        lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds",
                                                    &obd->obd_kset.kobj);
 
        lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds",
                                                    &obd->obd_kset.kobj);
@@ -310,7 +311,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
         }
 
        rc = obd_connect(NULL, &mdc_exp, mdc_obd, &obd->obd_uuid,
         }
 
        rc = obd_connect(NULL, &mdc_exp, mdc_obd, &obd->obd_uuid,
-                        &lmv->conn_data, NULL);
+                        &lmv->conn_data, lmv->lmv_cache);
         if (rc) {
                 CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc);
                 RETURN(rc);
         if (rc) {
                 CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc);
                 RETURN(rc);
index fbe7eb6..e151cc9 100644 (file)
@@ -113,7 +113,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                      enum obd_notify_event ev);
 
 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
                      enum obd_notify_event ev);
 
-int lov_connect_obd(struct obd_device *obd, u32 index, int activate,
+int lov_connect_osc(struct obd_device *obd, u32 index, int activate,
                    struct obd_connect_data *data)
 {
        struct lov_obd *lov = &obd->u.lov;
                    struct obd_connect_data *data)
 {
        struct lov_obd *lov = &obd->u.lov;
@@ -160,15 +160,14 @@ int lov_connect_obd(struct obd_device *obd, u32 index, int activate,
                 RETURN(rc);
         }
 
                 RETURN(rc);
         }
 
+       if (imp->imp_invalid) {
+               CDEBUG(D_CONFIG, "%s: not connecting - administratively disabled\n",
+                      obd_uuid2str(tgt_uuid));
+               RETURN(0);
+       }
 
 
-        if (imp->imp_invalid) {
-                CDEBUG(D_CONFIG, "not connecting OSC %s; administratively "
-                       "disabled\n", obd_uuid2str(tgt_uuid));
-                RETURN(0);
-        }
-
-        rc = obd_connect(NULL, &lov->lov_tgts[index]->ltd_exp, tgt_obd,
-                         &lov_osc_uuid, data, NULL);
+       rc = obd_connect(NULL, &lov->lov_tgts[index]->ltd_exp, tgt_obd,
+                        &lov_osc_uuid, data, lov->lov_cache);
         if (rc || !lov->lov_tgts[index]->ltd_exp) {
                 CERROR("Target %s connect error %d\n",
                        obd_uuid2str(tgt_uuid), rc);
         if (rc || !lov->lov_tgts[index]->ltd_exp) {
                 CERROR("Target %s connect error %d\n",
                        obd_uuid2str(tgt_uuid), rc);
@@ -225,12 +224,17 @@ static int lov_connect(const struct lu_env *env,
 
        lov_tgts_getref(obd);
 
 
        lov_tgts_getref(obd);
 
-        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
-                tgt = lov->lov_tgts[i];
-                if (!tgt || obd_uuid_empty(&tgt->ltd_uuid))
-                        continue;
-                /* Flags will be lowest common denominator */
-                rc = lov_connect_obd(obd, i, tgt->ltd_activate, &lov->lov_ocd);
+       if (localdata) {
+               lov->lov_cache = localdata;
+               cl_cache_incref(lov->lov_cache);
+       }
+
+       for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+               tgt = lov->lov_tgts[i];
+               if (!tgt || obd_uuid_empty(&tgt->ltd_uuid))
+                       continue;
+               /* Flags will be lowest common denominator */
+               rc = lov_connect_osc(obd, i, tgt->ltd_activate, &lov->lov_ocd);
                 if (rc) {
                         CERROR("%s: lov connect tgt %d failed: %d\n",
                                obd->obd_name, i, rc);
                 if (rc) {
                         CERROR("%s: lov connect tgt %d failed: %d\n",
                                obd->obd_name, i, rc);
@@ -380,16 +384,10 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid,
                        struct obd_uuid lov_osc_uuid = {"LOV_OSC_UUID"};
 
                        rc = obd_connect(NULL, &tgt->ltd_exp, tgt->ltd_obd,
                        struct obd_uuid lov_osc_uuid = {"LOV_OSC_UUID"};
 
                        rc = obd_connect(NULL, &tgt->ltd_exp, tgt->ltd_obd,
-                                        &lov_osc_uuid, &lov->lov_ocd, NULL);
+                                        &lov_osc_uuid, &lov->lov_ocd,
+                                        lov->lov_cache);
                        if (rc || tgt->ltd_exp == NULL)
                                GOTO(out, index = rc);
                        if (rc || tgt->ltd_exp == NULL)
                                GOTO(out, index = rc);
-                       rc = obd_set_info_async(NULL, tgt->ltd_exp,
-                                               sizeof(KEY_CACHE_SET),
-                                               KEY_CACHE_SET,
-                                               sizeof(struct cl_client_cache),
-                                               lov->lov_cache, NULL);
-                       if (rc < 0)
-                               GOTO(out, index = rc);
                }
 
                 if (lov->lov_tgts[index]->ltd_activate == activate) {
                }
 
                 if (lov->lov_tgts[index]->ltd_activate == activate) {
@@ -572,16 +570,16 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
         CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n",
                 index, tgt->ltd_gen, lov->desc.ld_tgt_count);
 
         CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n",
                 index, tgt->ltd_gen, lov->desc.ld_tgt_count);
 
-        if (lov->lov_connects == 0) {
-                /* lov_connect hasn't been called yet. We'll do the
-                   lov_connect_obd on this target when that fn first runs,
-                   because we don't know the connect flags yet. */
-                RETURN(0);
-        }
+       if (lov->lov_connects == 0) {
+               /* lov_connect hasn't been called yet. We'll do the
+                  lov_connect_osc on this target when that fn first runs,
+                  because we don't know the connect flags yet. */
+               RETURN(0);
+       }
 
        lov_tgts_getref(obd);
 
 
        lov_tgts_getref(obd);
 
-        rc = lov_connect_obd(obd, index, active, &lov->lov_ocd);
+       rc = lov_connect_osc(obd, index, active, &lov->lov_ocd);
         if (rc)
                 GOTO(out, rc);
 
         if (rc)
                 GOTO(out, rc);
 
@@ -589,15 +587,6 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
         if (!tgt->ltd_exp)
                 GOTO(out, rc = 0);
 
         if (!tgt->ltd_exp)
                 GOTO(out, rc = 0);
 
-       if (lov->lov_cache != NULL) {
-               rc = obd_set_info_async(NULL, tgt->ltd_exp,
-                               sizeof(KEY_CACHE_SET), KEY_CACHE_SET,
-                               sizeof(struct cl_client_cache), lov->lov_cache,
-                               NULL);
-               if (rc < 0)
-                       GOTO(out, rc);
-       }
-
        rc = lov_notify(obd, tgt->ltd_exp->exp_obd,
                        active ? OBD_NOTIFY_CONNECT : OBD_NOTIFY_INACTIVE);
 
        rc = lov_notify(obd, tgt->ltd_exp->exp_obd,
                        active ? OBD_NOTIFY_CONNECT : OBD_NOTIFY_INACTIVE);
 
@@ -1218,14 +1207,8 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp,
 
        lov_tgts_getref(obddev);
 
 
        lov_tgts_getref(obddev);
 
-       if (KEY_IS(KEY_CHECKSUM)) {
-               do_inactive = true;
-       } else if (KEY_IS(KEY_CACHE_SET)) {
-               LASSERT(lov->lov_cache == NULL);
-               lov->lov_cache = val;
+       if (KEY_IS(KEY_CHECKSUM))
                do_inactive = true;
                do_inactive = true;
-               cl_cache_incref(lov->lov_cache);
-       }
 
        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                tgt = lov->lov_tgts[i];
 
        for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                tgt = lov->lov_tgts[i];
index 29a3c16..a44e8b7 100644 (file)
@@ -2893,23 +2893,6 @@ int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
                 RETURN(0);
         }
 
                 RETURN(0);
         }
 
-       if (KEY_IS(KEY_CACHE_SET)) {
-               struct client_obd *cli = &obd->u.cli;
-
-               LASSERT(cli->cl_cache == NULL); /* only once */
-               cli->cl_cache = (struct cl_client_cache *)val;
-               cl_cache_incref(cli->cl_cache);
-               cli->cl_lru_left = &cli->cl_cache->ccc_lru_left;
-
-               /* add this osc into entity list */
-               LASSERT(list_empty(&cli->cl_lru_osc));
-               spin_lock(&cli->cl_cache->ccc_lru_lock);
-               list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru);
-               spin_unlock(&cli->cl_cache->ccc_lru_lock);
-
-               RETURN(0);
-       }
-
        if (KEY_IS(KEY_CACHE_LRU_SHRINK)) {
                struct client_obd *cli = &obd->u.cli;
                long nr = atomic_long_read(&cli->cl_lru_in_list) >> 1;
        if (KEY_IS(KEY_CACHE_LRU_SHRINK)) {
                struct client_obd *cli = &obd->u.cli;
                long nr = atomic_long_read(&cli->cl_lru_in_list) >> 1;
@@ -3355,7 +3338,7 @@ static struct obd_ops osc_obd_ops = {
        .o_cleanup              = osc_cleanup_common,
         .o_add_conn             = client_import_add_conn,
         .o_del_conn             = client_import_del_conn,
        .o_cleanup              = osc_cleanup_common,
         .o_add_conn             = client_import_add_conn,
         .o_del_conn             = client_import_del_conn,
-        .o_connect              = client_connect_import,
+       .o_connect              = client_connect_import,
         .o_reconnect            = osc_reconnect,
         .o_disconnect           = osc_disconnect,
         .o_statfs               = osc_statfs,
         .o_reconnect            = osc_reconnect,
         .o_disconnect           = osc_disconnect,
         .o_statfs               = osc_statfs,