Whamcloud - gitweb
cleanup usage obd_set_info_async, obd_get_info.
authorshadow <shadow>
Wed, 2 Jul 2008 06:01:57 +0000 (06:01 +0000)
committershadow <shadow>
Wed, 2 Jul 2008 06:01:57 +0000 (06:01 +0000)
fix KEY_IS macro

Branch HEAD
b=14032
i=umka
i=deen

22 files changed:
lustre/include/obd.h
lustre/include/obd_support.h
lustre/ldlm/ldlm_lib.c
lustre/liblustre/rw.c
lustre/liblustre/super.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/llite/lproc_llite.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/lov/lov_pack.c
lustre/mdd/mdd_device.c
lustre/mdd/mdd_dir.c
lustre/mds/lproc_mds.c
lustre/mds/mds_lov.c
lustre/mgc/mgc_request.c
lustre/obdclass/obd_mount.c
lustre/obdfilter/filter.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/ptlrpc/import.c

index e69ac77..0db6e51 100644 (file)
@@ -1020,9 +1020,19 @@ enum obd_cleanup_stage {
 #define KEY_REVIMP_UPD          "revimp_update"
 #define KEY_LOV_IDX             "lov_idx"
 #define KEY_LAST_ID             "last_id"
+#define KEY_READONLY            "read-only"
 #define KEY_LOCK_TO_STRIPE      "lock_to_stripe"
+#define KEY_CHECKSUM            "checksum"
+#define KEY_UNLINKED            "unlinked"
+#define KEY_EVICT_BY_NID        "evict_by_nid"
+#define KEY_REGISTER_TARGET     "register_target"
+#define KEY_SET_FS              "set_fs"
+#define KEY_CLEAR_FS            "clear_fs"
 #define KEY_BLOCKSIZE           "blocksize"
 #define KEY_BLOCKSIZE_BITS      "blocksize_bits"
+/* XXX unused ?*/
+#define KEY_INTERMDS            "inter_mds"
+#define KEY_ASYNC               "async"
 
 struct lu_context;
 
index 853e7a8..646e579 100644 (file)
@@ -756,7 +756,8 @@ do {                                                                          \
 #define OBD_SLAB_FREE_PTR(ptr, slab)                                          \
         OBD_SLAB_FREE((ptr), (slab), sizeof *(ptr))
 
-#define KEY_IS(str) (keylen >= strlen(str) && strncmp(key, str, keylen) == 0)
+#define KEY_IS(str) \
+        (keylen >= (sizeof(str)-1) && memcmp(key, str, (sizeof(str)-1)) == 0)
 
 /* Wrapper for contiguous page frame allocation */
 #define OBD_PAGES_ALLOC(ptr, order, gfp_mask)                                 \
index 4ae8d06..8b0a493 100644 (file)
@@ -922,7 +922,7 @@ dont_check_exports:
 
         if (export->exp_imp_reverse != NULL) {
                 /* destroyed import can be still referenced in ctxt */
-                obd_set_info_async(export, strlen(KEY_REVIMP_UPD),
+                obd_set_info_async(export, sizeof(KEY_REVIMP_UPD),
                                    KEY_REVIMP_UPD, 0, NULL, NULL);
 
                 /* in some recovery senarios, previous ctx init rpc handled
index d3e4a9f..7287e77 100644 (file)
@@ -94,7 +94,7 @@ static int llu_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock
                 char name[16];
                 struct ldlm_lock *lock;
                 struct lov_stripe_md *lsm;
-        } key = { .name = "lock_to_stripe", .lock = lock, .lsm = lsm };
+        } key = { .name = KEY_LOCK_TO_STRIPE, .lock = lock, .lsm = lsm };
         __u32 stripe, vallen = sizeof(stripe);
         int rc;
         ENTRY;
index 48d5efa..fae94f2 100644 (file)
@@ -1958,7 +1958,7 @@ llu_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
         __u32 stripes;
         ENTRY;
 
-        rc = obd_get_info(dt_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC,
+        rc = obd_get_info(dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
                           &valsize, &desc);
         if (rc)
                 RETURN(rc);
@@ -2072,7 +2072,7 @@ llu_fsswop_mount(const char *source,
                 CERROR("MDC %s: not setup or attached\n", mdc);
                 GOTO(out_free, err = -EINVAL);
         }
-        obd_set_info_async(obd->obd_self_export, strlen("async"), "async",
+        obd_set_info_async(obd->obd_self_export, sizeof(KEY_ASYNC), KEY_ASYNC,
                            sizeof(async), &async, NULL);
 
         ocd.ocd_connect_flags = OBD_CONNECT_IBITS | OBD_CONNECT_VERSION |
@@ -2105,7 +2105,7 @@ llu_fsswop_mount(const char *source,
                 CERROR("OSC %s: not setup or attached\n", osc);
                 GOTO(out_md, err = -EINVAL);
         }
-        obd_set_info_async(obd->obd_self_export, strlen("async"), "async",
+        obd_set_info_async(obd->obd_self_export, sizeof(KEY_ASYNC), KEY_ASYNC,
                            sizeof(async), &async, NULL);
 
         obd->obd_upcall.onu_owner = &sbi->ll_lco;
index dc8a211..b854067 100644 (file)
@@ -507,7 +507,7 @@ int ll_send_mgc_param(struct obd_export *mgc, char *string)
                 return -ENOMEM;
 
         strncpy(msp->mgs_param, string, MGS_PARAM_MAXLEN);
-        rc = obd_set_info_async(mgc, strlen(KEY_SET_INFO), KEY_SET_INFO,
+        rc = obd_set_info_async(mgc, sizeof(KEY_SET_INFO), KEY_SET_INFO,
                                 sizeof(struct mgs_send_param), msp, NULL);
         if (rc)
                 CERROR("Failed to set parameter: %d\n", rc);
index 5c384d0..e51a9b1 100644 (file)
@@ -748,7 +748,7 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock)
                 char name[16];
                 struct ldlm_lock *lock;
                 struct lov_stripe_md *lsm;
-        } key = { .name = "lock_to_stripe", .lock = lock, .lsm = lsm };
+        } key = { .name = KEY_LOCK_TO_STRIPE, .lock = lock, .lsm = lsm };
         __u32 stripe, vallen = sizeof(stripe);
         int rc;
         ENTRY;
index 0d2e1ca..59c857a 100644 (file)
@@ -146,7 +146,7 @@ static int ll_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp)
         __u32 stripes;
         ENTRY;
 
-        rc = obd_get_info(dt_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC,
+        rc = obd_get_info(dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC,
                           &valsize, &desc);
         if (rc)
                 RETURN(rc);
@@ -270,7 +270,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
                 GOTO(out_md_fid, err);
 
         size = sizeof(*data);
-        err = obd_get_info(sbi->ll_md_exp, strlen(KEY_CONN_DATA),
+        err = obd_get_info(sbi->ll_md_exp, sizeof(KEY_CONN_DATA),
                            KEY_CONN_DATA,  &size, data);
         if (err) {
                 CERROR("Get connect data failed: %d \n", err);
@@ -531,8 +531,9 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
 #endif
 
         checksum = sbi->ll_flags & LL_SBI_CHECKSUM;
-        err = obd_set_info_async(sbi->ll_dt_exp, strlen("checksum"),"checksum",
-                                 sizeof(checksum), &checksum, NULL);
+        err = obd_set_info_async(sbi->ll_dt_exp, sizeof(KEY_CHECKSUM),
+                                 KEY_CHECKSUM, sizeof(checksum), &checksum,
+                                 NULL);
 
         sb->s_root = d_alloc_root(root);
         if (data != NULL)
@@ -570,8 +571,8 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize)
 
         *lmmsize = obd_size_diskmd(sbi->ll_dt_exp, NULL);
         size = sizeof(int);
-        rc = obd_get_info(sbi->ll_md_exp, strlen("max_easize"), "max_easize",
-                          &size, lmmsize);
+        rc = obd_get_info(sbi->ll_md_exp, sizeof(KEY_MAX_EASIZE),
+                          KEY_MAX_EASIZE, &size, lmmsize);
         if (rc)
                 CERROR("Get max mdsize error rc %d \n", rc);
 
@@ -2021,10 +2022,10 @@ int ll_flush_ctx(struct inode *inode)
         CDEBUG(D_SEC, "flush context for user %d\n", current->uid);
 
         obd_set_info_async(sbi->ll_md_exp,
-                           sizeof(KEY_FLUSH_CTX) - 1, KEY_FLUSH_CTX,
+                           sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX,
                            0, NULL, NULL);
         obd_set_info_async(sbi->ll_dt_exp,
-                           sizeof(KEY_FLUSH_CTX) - 1, KEY_FLUSH_CTX,
+                           sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX,
                            0, NULL, NULL);
         return 0;
 }
@@ -2098,7 +2099,7 @@ int ll_remount_fs(struct super_block *sb, int *flags, char *data)
         if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
                 read_only = *flags & MS_RDONLY;
                 err = obd_set_info_async(sbi->ll_md_exp,
-                                         sizeof(KEY_READ_ONLY) - 1,
+                                         sizeof(KEY_READ_ONLY),
                                          KEY_READ_ONLY, sizeof(read_only),
                                          &read_only, NULL);
                 if (err) {
index 4e785a3..fd3ac47 100644 (file)
@@ -361,8 +361,8 @@ static int ll_wr_checksum(struct file *file, const char *buffer,
         else
                 sbi->ll_flags &= ~LL_SBI_CHECKSUM;
 
-        rc = obd_set_info_async(sbi->ll_dt_exp, strlen("checksum"), "checksum",
-                                sizeof(val), &val, NULL);
+        rc = obd_set_info_async(sbi->ll_dt_exp, sizeof(KEY_CHECKSUM),
+                                KEY_CHECKSUM, sizeof(val), &val, NULL);
         if (rc)
                 CWARN("Failed to set OSC checksum flags: %d\n", rc);
 
index 1374c1f..13aac50 100644 (file)
@@ -297,8 +297,8 @@ static void lmv_set_timeouts(struct obd_device *obd)
                 if (tgts->ltd_exp == NULL)
                         continue;
 
-                obd_set_info_async(tgts->ltd_exp, strlen("inter_mds"),
-                                   "inter_mds", 0, NULL, NULL);
+                obd_set_info_async(tgts->ltd_exp, sizeof(KEY_INTERMDS),
+                                   KEY_INTERMDS, 0, NULL, NULL);
         }
 }
 
index 161800e..4466bd1 100644 (file)
@@ -2609,11 +2609,11 @@ static int lov_set_info_async(struct obd_export *exp, obd_count keylen,
                 incr = sizeof(struct obd_id_info);
                 do_inactive = 1;
                 next_id = 1;
-        } else if (KEY_IS("checksum")) {
+        } else if (KEY_IS(KEY_CHECKSUM)) {
                 do_inactive = 1;
-        } else if (KEY_IS("unlinked")) {
+        } else if (KEY_IS(KEY_UNLINKED)) {
                 check_uuid = val ? 1 : 0;
-        } else if (KEY_IS("evict_by_nid")) {
+        } else if (KEY_IS(KEY_EVICT_BY_NID)) {
                 /* use defaults:  do_inactive = incr = 0; */
         } else if (KEY_IS(KEY_MDS_CONN)) {
                 mds_con = 1;
index 0f0ff06..5f37203 100644 (file)
@@ -393,7 +393,7 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp,
         for (i = 0; i < lump->lmm_stripe_count; i++) {
                 __u32 len = sizeof(last_id);
                 oexp = lov->lov_tgts[lump->lmm_objects[i].l_ost_idx]->ltd_exp;
-                rc = obd_get_info(oexp, strlen("last_id"), "last_id",
+                rc = obd_get_info(oexp, sizeof(KEY_LAST_ID), KEY_LAST_ID,
                                   &len, &last_id);
                 if (rc)
                         RETURN(rc);
index f9dc257..7621820 100644 (file)
@@ -291,7 +291,7 @@ static int mdd_update_capa_key(const struct lu_env *env,
         int rc;
         ENTRY;
 
-        rc = obd_set_info_async(lov_exp, strlen(KEY_CAPA_KEY), KEY_CAPA_KEY,
+        rc = obd_set_info_async(lov_exp, sizeof(KEY_CAPA_KEY), KEY_CAPA_KEY,
                                 sizeof(*key), key, NULL);
         RETURN(rc);
 }
index ba4b1e3..bcb0eac 100644 (file)
@@ -679,7 +679,7 @@ static int mdd_unlink(const struct lu_env *env, struct md_object *pobj,
 
         if (rc == 0)
                 obd_set_info_async(mdd2obd_dev(mdd)->u.mds.mds_osc_exp,
-                                   strlen("unlinked"), "unlinked", 0,
+                                   sizeof(KEY_UNLINKED), KEY_UNLINKED, 0,
                                    NULL, NULL);
         EXIT;
 cleanup:
index 594e8e9..fee8b1f 100644 (file)
@@ -88,9 +88,10 @@ static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
                 return -ENOMEM;
 
         if (obd->u.mds.mds_evict_ost_nids) {
-                rc = obd_set_info_async(mds->mds_osc_exp,strlen("evict_by_nid"),
-                                        "evict_by_nid", strlen(tmpbuf + 4) + 1,
-                                         tmpbuf + 4, set);
+                rc = obd_set_info_async(mds->mds_osc_exp,
+                                        sizeof(KEY_EVICT_BY_NID),
+                                        KEY_EVICT_BY_NID, strlen(tmpbuf + 4) + 1,
+                                        tmpbuf + 4, set);
                 if (rc)
                         CERROR("Failed to evict nid %s from OSTs: rc %d\n",
                                tmpbuf + 4, rc);
index d4ec371..e5a074b 100644 (file)
@@ -614,7 +614,7 @@ static int mds_propagate_capa_keys(struct mds_obd *mds)
                 key = &mds->mds_capa_keys[i];
                 DEBUG_CAPA_KEY(D_SEC, key, "propagate");
 
-                rc = obd_set_info_async(mds->mds_osc_exp, strlen(KEY_CAPA_KEY),
+                rc = obd_set_info_async(mds->mds_osc_exp, sizeof(KEY_CAPA_KEY),
                                         KEY_CAPA_KEY, sizeof(*key), key, NULL);
                 if (rc) {
                         DEBUG_CAPA_KEY(D_ERROR, key,
index dab9001..37135c5 100644 (file)
@@ -814,7 +814,7 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
         /* FIXME move this to mgc_process_config */
-        if (KEY_IS("register_target")) {
+        if (KEY_IS(KEY_REGISTER_TARGET)) {
                 struct mgs_target_info *mti;
                 if (vallen != sizeof(struct mgs_target_info))
                         RETURN(-EINVAL);
@@ -824,7 +824,7 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen,
                 rc =  mgc_target_register(exp, mti);
                 RETURN(rc);
         }
-        if (KEY_IS("set_fs")) {
+        if (KEY_IS(KEY_SET_FS)) {
                 struct super_block *sb = (struct super_block *)val;
                 struct lustre_sb_info *lsi;
                 if (vallen != sizeof(struct super_block))
@@ -836,7 +836,7 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen,
                 }
                 RETURN(rc);
         }
-        if (KEY_IS("clear_fs")) {
+        if (KEY_IS(KEY_CLEAR_FS)) {
                 if (vallen != 0)
                         RETURN(-EINVAL);
                 rc = mgc_fs_cleanup(exp->exp_obd);
index ee12d1d..58dc3bf 100644 (file)
@@ -615,7 +615,7 @@ static int lustre_start_mgc(struct super_block *sb)
                 recov_bk++;
                 CDEBUG(D_MOUNT, "%s: Set MGC reconnect %d\n", mgcname,recov_bk);
                 rc = obd_set_info_async(obd->obd_self_export,
-                                        strlen(KEY_INIT_RECOV_BACKUP),
+                                        sizeof(KEY_INIT_RECOV_BACKUP),
                                         KEY_INIT_RECOV_BACKUP,
                                         sizeof(recov_bk), &recov_bk, NULL);
                 GOTO(out, rc = 0);
@@ -716,7 +716,7 @@ static int lustre_start_mgc(struct super_block *sb)
         /* Try all connections, but only once. */
         recov_bk = 1;
         rc = obd_set_info_async(obd->obd_self_export,
-                                strlen(KEY_INIT_RECOV_BACKUP),
+                                sizeof(KEY_INIT_RECOV_BACKUP),
                                 KEY_INIT_RECOV_BACKUP,
                                 sizeof(recov_bk), &recov_bk, NULL);
         if (rc)
@@ -830,7 +830,7 @@ static int server_mgc_set_fs(struct obd_device *mgc, struct super_block *sb)
 
         /* cl_mgc_sem in mgc insures we sleep if the mgc_fs is busy */
         rc = obd_set_info_async(mgc->obd_self_export,
-                                strlen("set_fs"), "set_fs",
+                                sizeof(KEY_SET_FS), KEY_SET_FS,
                                 sizeof(*sb), sb, NULL);
         if (rc) {
                 CERROR("can't set_fs %d\n", rc);
@@ -847,7 +847,7 @@ static int server_mgc_clear_fs(struct obd_device *mgc)
         CDEBUG(D_MOUNT, "Unassign mgc disk\n");
 
         rc = obd_set_info_async(mgc->obd_self_export,
-                                strlen("clear_fs"), "clear_fs",
+                                sizeof(KEY_CLEAR_FS), KEY_CLEAR_FS,
                                 0, NULL, NULL);
         RETURN(rc);
 }
@@ -975,7 +975,7 @@ int server_register_target(struct super_block *sb)
         /* Register the target */
         /* FIXME use mgc_process_config instead */
         rc = obd_set_info_async(mgc->u.cli.cl_mgc_mgsexp,
-                                strlen("register_target"), "register_target",
+                                sizeof(KEY_REGISTER_TARGET), KEY_REGISTER_TARGET,
                                 sizeof(*mti), mti, NULL);
         if (rc)
                 GOTO(out, rc);
index 101c234..b451ff8 100644 (file)
@@ -3960,7 +3960,7 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen,
                 RETURN(-EINVAL);
         }
 
-        if (KEY_IS("blocksize")) {
+        if (KEY_IS(KEY_BLOCKSIZE)) {
                 __u32 *blocksize = val;
                 if (blocksize) {
                         if (*vallen < sizeof(*blocksize))
@@ -3971,7 +3971,7 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen,
                 RETURN(0);
         }
 
-        if (KEY_IS("blocksize_bits")) {
+        if (KEY_IS(KEY_BLOCKSIZE_BITS)) {
                 __u32 *blocksize_bits = val;
                 if (blocksize_bits) {
                         if (*vallen < sizeof(*blocksize_bits))
@@ -3982,7 +3982,7 @@ static int filter_get_info(struct obd_export *exp, __u32 keylen,
                 RETURN(0);
         }
 
-        if (KEY_IS("last_id")) {
+        if (KEY_IS(KEY_LAST_ID)) {
                 obd_id *last_id = val;
                 /* FIXME: object groups */
                 if (last_id) {
index 5e37f69..0899811 100644 (file)
@@ -3621,7 +3621,7 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
-        if (KEY_IS("unlinked")) {
+        if (KEY_IS(KEY_UNLINKED)) {
                 struct osc_creator *oscc = &obd->u.cli.cl_oscc;
                 spin_lock(&oscc->oscc_lock);
                 oscc->oscc_flags &= ~OSCC_FLAG_NOSPC;
@@ -3641,7 +3641,7 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
-        if (KEY_IS("checksum")) {
+        if (KEY_IS(KEY_CHECKSUM)) {
                 if (vallen != sizeof(int))
                         RETURN(-EINVAL);
                 exp->exp_obd->u.cli.cl_checksum = (*(int *)val) ? 1 : 0;
index b7a14f1..65b361d 100644 (file)
@@ -1270,7 +1270,7 @@ static int ost_set_info(struct obd_export *exp, struct ptlrpc_request *req)
         if (vallen)
                 val = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF + 1, 0);
 
-        if (KEY_IS("evict_by_nid")) {
+        if (KEY_IS(KEY_EVICT_BY_NID)) {
                 if (val && vallen)
                         obd_export_evict_by_nid(exp->exp_obd, val);
 
index 869c56a..345b2b6 100644 (file)
@@ -489,7 +489,7 @@ int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
                         /* Don't retry if connect fails */
                         rc = 0;
                         obd_set_info_async(obd->obd_self_export,
-                                           strlen(KEY_INIT_RECOV),
+                                           sizeof(KEY_INIT_RECOV),
                                            KEY_INIT_RECOV,
                                            sizeof(rc), &rc, NULL);
                 }