Whamcloud - gitweb
LU-2747 mdt: use of mdt_XXX helpers
authorjcl <jacques-charles.lafoucriere@cea.fr>
Mon, 4 Feb 2013 18:09:51 +0000 (19:09 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 24 Apr 2013 22:06:34 +0000 (18:06 -0400)
replace explicit use of some obd fields by mdt helpers:
mdt_obd_name() mdt2obd_dev() mdt_lu_site() mdt_seq_site()

Signed-off-by: JC Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Change-Id: I1a67145478a143bf6444c9a248c5cc213dc91687
Reviewed-on: http://review.whamcloud.com/5261
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_hsm.c
lustre/mdt/mdt_idmap.c
lustre/mdt/mdt_lproc.c
lustre/mdt/mdt_lvb.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_recovery.c
lustre/mdt/mdt_reint.c
lustre/mdt/mdt_xattr.c

index fe38cb5..f42fda5 100644 (file)
@@ -3724,8 +3724,8 @@ static int mdt_intent_layout(enum mdt_it_code opcode,
        ENTRY;
 
        if (opcode != MDT_IT_LAYOUT) {
        ENTRY;
 
        if (opcode != MDT_IT_LAYOUT) {
-               CERROR("%s: Unknown intent (%d)\n",
-                       info->mti_exp->exp_obd->obd_name, opcode);
+               CERROR("%s: Unknown intent (%d)\n", mdt_obd_name(info->mti_mdt),
+                       opcode);
                RETURN(-EINVAL);
        }
 
                RETURN(-EINVAL);
        }
 
@@ -3743,7 +3743,7 @@ static int mdt_intent_layout(enum mdt_it_code opcode,
                RETURN(0);
 
        CERROR("%s: Unsupported layout intent (%d)\n",
                RETURN(0);
 
        CERROR("%s: Unsupported layout intent (%d)\n",
-               info->mti_exp->exp_obd->obd_name, layout->li_opc);
+               mdt_obd_name(info->mti_mdt), layout->li_opc);
        RETURN(-EINVAL);
 }
 
        RETURN(-EINVAL);
 }
 
@@ -4145,7 +4145,7 @@ static void mdt_stack_pre_fini(const struct lu_env *env,
         * objects (some of them are pinned by osd, for example *
         * the proper solution should be a model where object used
         * by osd only doesn't have mdt/mdd slices -bzzz */
         * objects (some of them are pinned by osd, for example *
         * the proper solution should be a model where object used
         * by osd only doesn't have mdt/mdd slices -bzzz */
-       lustre_cfg_bufs_reset(bufs, obd->obd_name);
+       lustre_cfg_bufs_reset(bufs, mdt_obd_name(m));
        lustre_cfg_bufs_set_string(bufs, 1, NULL);
        lcfg = lustre_cfg_new(LCFG_PRE_CLEANUP, bufs);
        if (!lcfg) {
        lustre_cfg_bufs_set_string(bufs, 1, NULL);
        lcfg = lustre_cfg_new(LCFG_PRE_CLEANUP, bufs);
        if (!lcfg) {
@@ -4158,44 +4158,44 @@ static void mdt_stack_pre_fini(const struct lu_env *env,
 }
 
 static void mdt_stack_fini(const struct lu_env *env,
 }
 
 static void mdt_stack_fini(const struct lu_env *env,
-                           struct mdt_device *m, struct lu_device *top)
+                          struct mdt_device *m, struct lu_device *top)
 {
 {
-        struct obd_device       *obd = mdt2obd_dev(m);
-        struct lustre_cfg_bufs  *bufs;
-        struct lustre_cfg       *lcfg;
-        struct mdt_thread_info  *info;
-        char flags[3]="";
-        ENTRY;
+       struct obd_device       *obd = mdt2obd_dev(m);
+       struct lustre_cfg_bufs  *bufs;
+       struct lustre_cfg       *lcfg;
+       struct mdt_thread_info  *info;
+       char                     flags[3] = "";
+       ENTRY;
 
 
-        info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
-        LASSERT(info != NULL);
+       info = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
+       LASSERT(info != NULL);
 
        lu_dev_del_linkage(top->ld_site, top);
 
        lu_site_purge(env, top->ld_site, -1);
 
 
        lu_dev_del_linkage(top->ld_site, top);
 
        lu_site_purge(env, top->ld_site, -1);
 
-        bufs = &info->mti_u.bufs;
-        /* process cleanup, pass mdt obd name to get obd umount flags */
+       bufs = &info->mti_u.bufs;
+       /* process cleanup, pass mdt obd name to get obd umount flags */
        /* another purpose is to let all layers to release their objects */
        /* another purpose is to let all layers to release their objects */
-        lustre_cfg_bufs_reset(bufs, obd->obd_name);
-        if (obd->obd_force)
-                strcat(flags, "F");
-        if (obd->obd_fail)
-                strcat(flags, "A");
-        lustre_cfg_bufs_set_string(bufs, 1, flags);
-        lcfg = lustre_cfg_new(LCFG_CLEANUP, bufs);
-        if (!lcfg) {
-                CERROR("Cannot alloc lcfg!\n");
-                return;
-        }
-        LASSERT(top);
-        top->ld_ops->ldo_process_config(env, top, lcfg);
-        lustre_cfg_free(lcfg);
+       lustre_cfg_bufs_reset(bufs, mdt_obd_name(m));
+       if (obd->obd_force)
+               strcat(flags, "F");
+       if (obd->obd_fail)
+               strcat(flags, "A");
+       lustre_cfg_bufs_set_string(bufs, 1, flags);
+       lcfg = lustre_cfg_new(LCFG_CLEANUP, bufs);
+       if (!lcfg) {
+               CERROR("Cannot alloc lcfg!\n");
+               return;
+       }
+       LASSERT(top);
+       top->ld_ops->ldo_process_config(env, top, lcfg);
+       lustre_cfg_free(lcfg);
 
        lu_site_purge(env, top->ld_site, -1);
 
 
        lu_site_purge(env, top->ld_site, -1);
 
-        m->mdt_child = NULL;
-        m->mdt_bottom = NULL;
+       m->mdt_child = NULL;
+       m->mdt_bottom = NULL;
 
        obd_disconnect(m->mdt_child_exp);
        m->mdt_child_exp = NULL;
 
        obd_disconnect(m->mdt_child_exp);
        m->mdt_child_exp = NULL;
@@ -4219,7 +4219,7 @@ static int mdt_connect_to_next(const struct lu_env *env, struct mdt_device *m,
        obd = class_name2obd(next);
        if (obd == NULL) {
                CERROR("%s: can't locate next device: %s\n",
        obd = class_name2obd(next);
        if (obd == NULL) {
                CERROR("%s: can't locate next device: %s\n",
-                      m->mdt_md_dev.md_lu_dev.ld_obd->obd_name, next);
+                      mdt_obd_name(m), next);
                GOTO(out, rc = -ENOTCONN);
        }
 
                GOTO(out, rc = -ENOTCONN);
        }
 
@@ -4229,7 +4229,7 @@ static int mdt_connect_to_next(const struct lu_env *env, struct mdt_device *m,
        rc = obd_connect(NULL, exp, obd, &obd->obd_uuid, data, NULL);
        if (rc) {
                CERROR("%s: cannot connect to next dev %s (%d)\n",
        rc = obd_connect(NULL, exp, obd, &obd->obd_uuid, data, NULL);
        if (rc) {
                CERROR("%s: cannot connect to next dev %s (%d)\n",
-                      m->mdt_md_dev.md_lu_dev.ld_obd->obd_name, next, rc);
+                      mdt_obd_name(m), next, rc);
                GOTO(out, rc);
        }
 
                GOTO(out, rc);
        }
 
@@ -4345,7 +4345,7 @@ static int mdt_stack_init(const struct lu_env *env, struct mdt_device *mdt,
 
        site = mdt->mdt_child_exp->exp_obd->obd_lu_dev->ld_site;
        LASSERT(site);
 
        site = mdt->mdt_child_exp->exp_obd->obd_lu_dev->ld_site;
        LASSERT(site);
-       LASSERT(mdt->mdt_md_dev.md_lu_dev.ld_site == NULL);
+       LASSERT(mdt_lu_site(mdt) == NULL);
        mdt->mdt_md_dev.md_lu_dev.ld_site = site;
        site->ls_top_dev = &mdt->mdt_md_dev.md_lu_dev;
        mdt->mdt_child = lu2md_dev(mdt->mdt_child_exp->exp_obd->obd_lu_dev);
        mdt->mdt_md_dev.md_lu_dev.ld_site = site;
        site->ls_top_dev = &mdt->mdt_md_dev.md_lu_dev;
        mdt->mdt_child = lu2md_dev(mdt->mdt_child_exp->exp_obd->obd_lu_dev);
@@ -4579,40 +4579,40 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m)
         cfs_timer_disarm(&m->mdt_ck_timer);
         mdt_ck_thread_stop(m);
 
         cfs_timer_disarm(&m->mdt_ck_timer);
         mdt_ck_thread_stop(m);
 
-        /*
-         * Finish the stack
-         */
-        mdt_stack_fini(env, m, md2lu_dev(m->mdt_child));
+       /*
+        * Finish the stack
+        */
+       mdt_stack_fini(env, m, md2lu_dev(m->mdt_child));
 
 
-        LASSERT(cfs_atomic_read(&d->ld_ref) == 0);
+       LASSERT(cfs_atomic_read(&d->ld_ref) == 0);
 
 
-       server_put_mount(mdt2obd_dev(m)->obd_name, NULL);
+       server_put_mount(mdt_obd_name(m), NULL);
 
 
-        EXIT;
+       EXIT;
 }
 
 static int mdt_adapt_sptlrpc_conf(struct obd_device *obd, int initial)
 {
 }
 
 static int mdt_adapt_sptlrpc_conf(struct obd_device *obd, int initial)
 {
-        struct mdt_device       *m = mdt_dev(obd->obd_lu_dev);
-        struct sptlrpc_rule_set  tmp_rset;
-        int                      rc;
+       struct mdt_device       *m = mdt_dev(obd->obd_lu_dev);
+       struct sptlrpc_rule_set  tmp_rset;
+       int                      rc;
 
 
-        sptlrpc_rule_set_init(&tmp_rset);
-        rc = sptlrpc_conf_target_get_rules(obd, &tmp_rset, initial);
-        if (rc) {
-                CERROR("mdt %s: failed get sptlrpc rules: %d\n",
-                       obd->obd_name, rc);
-                return rc;
-        }
+       sptlrpc_rule_set_init(&tmp_rset);
+       rc = sptlrpc_conf_target_get_rules(obd, &tmp_rset, initial);
+       if (rc) {
+               CERROR("mdt %s: failed get sptlrpc rules: %d\n",
+                      mdt_obd_name(m), rc);
+               return rc;
+       }
 
 
-        sptlrpc_target_update_exp_flavor(obd, &tmp_rset);
+       sptlrpc_target_update_exp_flavor(obd, &tmp_rset);
 
        write_lock(&m->mdt_sptlrpc_lock);
 
        write_lock(&m->mdt_sptlrpc_lock);
-        sptlrpc_rule_set_free(&m->mdt_sptlrpc_rset);
-        m->mdt_sptlrpc_rset = tmp_rset;
+       sptlrpc_rule_set_free(&m->mdt_sptlrpc_rset);
+       m->mdt_sptlrpc_rset = tmp_rset;
        write_unlock(&m->mdt_sptlrpc_lock);
 
        write_unlock(&m->mdt_sptlrpc_lock);
 
-        return 0;
+       return 0;
 }
 
 int mdt_postrecov(const struct lu_env *, struct mdt_device *);
 }
 
 int mdt_postrecov(const struct lu_env *, struct mdt_device *);
@@ -4700,12 +4700,13 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
        /* init the stack */
        rc = mdt_stack_init((struct lu_env *)env, m, cfg);
        if (rc) {
        /* init the stack */
        rc = mdt_stack_init((struct lu_env *)env, m, cfg);
        if (rc) {
-               CERROR("Can't init device stack, rc %d\n", rc);
+               CERROR("%s: Can't init device stack, rc %d\n",
+                      mdt_obd_name(m), rc);
                GOTO(err_lmi, rc);
        }
 
                GOTO(err_lmi, rc);
        }
 
-       s = m->mdt_md_dev.md_lu_dev.ld_site;
-       ss_site = &m->mdt_seq_site;
+       s = mdt_lu_site(m);
+       ss_site = mdt_seq_site(m);
        s->ld_seq_site = ss_site;
        ss_site->ss_lu = s;
 
        s->ld_seq_site = ss_site;
        ss_site->ss_lu = s;
 
@@ -4720,23 +4721,23 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         /* No connection accepted until configurations will finish */
         obd->obd_no_conn = 1;
 
         /* No connection accepted until configurations will finish */
         obd->obd_no_conn = 1;
 
-        if (cfg->lcfg_bufcount > 4 && LUSTRE_CFG_BUFLEN(cfg, 4) > 0) {
-                char *str = lustre_cfg_string(cfg, 4);
-                if (strchr(str, 'n')) {
-                        CWARN("%s: recovery disabled\n", obd->obd_name);
-                        obd->obd_replayable = 0;
-                }
-        }
+       if (cfg->lcfg_bufcount > 4 && LUSTRE_CFG_BUFLEN(cfg, 4) > 0) {
+               char *str = lustre_cfg_string(cfg, 4);
+               if (strchr(str, 'n')) {
+                       CWARN("%s: recovery disabled\n", mdt_obd_name(m));
+                       obd->obd_replayable = 0;
+               }
+       }
 
         rc = tgt_init(env, &m->mdt_lut, obd, m->mdt_bottom);
         if (rc)
                 GOTO(err_fini_stack, rc);
 
 
         rc = tgt_init(env, &m->mdt_lut, obd, m->mdt_bottom);
         if (rc)
                 GOTO(err_fini_stack, rc);
 
-       rc = mdt_fld_init(env, obd->obd_name, m);
+       rc = mdt_fld_init(env, mdt_obd_name(m), m);
        if (rc)
                GOTO(err_lut, rc);
 
        if (rc)
                GOTO(err_lut, rc);
 
-       rc = mdt_seq_init(env, obd->obd_name, m);
+       rc = mdt_seq_init(env, mdt_obd_name(m), m);
        if (rc)
                GOTO(err_fini_fld, rc);
 
        if (rc)
                GOTO(err_fini_fld, rc);
 
@@ -4784,18 +4785,19 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         else
                 m->mdt_opts.mo_acl = 0;
 
         else
                 m->mdt_opts.mo_acl = 0;
 
-        /* XXX: to support suppgid for ACL, we enable identity_upcall
-         * by default, otherwise, maybe got unexpected -EACCESS. */
-        if (m->mdt_opts.mo_acl)
-                identity_upcall = MDT_IDENTITY_UPCALL_PATH;
-
-        m->mdt_identity_cache = upcall_cache_init(obd->obd_name,identity_upcall,
-                                                &mdt_identity_upcall_cache_ops);
-        if (IS_ERR(m->mdt_identity_cache)) {
-                rc = PTR_ERR(m->mdt_identity_cache);
-                m->mdt_identity_cache = NULL;
+       /* XXX: to support suppgid for ACL, we enable identity_upcall
+        * by default, otherwise, maybe got unexpected -EACCESS. */
+       if (m->mdt_opts.mo_acl)
+               identity_upcall = MDT_IDENTITY_UPCALL_PATH;
+
+       m->mdt_identity_cache = upcall_cache_init(mdt_obd_name(m),
+                                               identity_upcall,
+                                               &mdt_identity_upcall_cache_ops);
+       if (IS_ERR(m->mdt_identity_cache)) {
+               rc = PTR_ERR(m->mdt_identity_cache);
+               m->mdt_identity_cache = NULL;
                GOTO(err_llog_cleanup, rc);
                GOTO(err_llog_cleanup, rc);
-        }
+       }
 
         rc = mdt_procfs_init(m, dev);
         if (rc) {
 
         rc = mdt_procfs_init(m, dev);
         if (rc) {
@@ -5148,7 +5150,7 @@ static int mdt_connect_internal(struct obd_export *exp,
                               "unexpectedly zero, network data "
                               "corruption? Refusing connection of this"
                               " client\n",
                               "unexpectedly zero, network data "
                               "corruption? Refusing connection of this"
                               " client\n",
-                              exp->exp_obd->obd_name,
+                              mdt_obd_name(mdt),
                               exp->exp_client_uuid.uuid,
                               exp, data->ocd_connect_flags, data->ocd_version,
                               data->ocd_grant, data->ocd_index);
                               exp->exp_client_uuid.uuid,
                               exp, data->ocd_connect_flags, data->ocd_version,
                               data->ocd_grant, data->ocd_index);
@@ -5173,7 +5175,7 @@ static int mdt_connect_internal(struct obd_export *exp,
 
        if ((data->ocd_connect_flags & OBD_CONNECT_FID) == 0) {
                CWARN("%s: MDS requires FID support, but client not\n",
 
        if ((data->ocd_connect_flags & OBD_CONNECT_FID) == 0) {
                CWARN("%s: MDS requires FID support, but client not\n",
-                     mdt->mdt_md_dev.md_lu_dev.ld_obd->obd_name);
+                     mdt_obd_name(mdt));
                return -EBADE;
        }
 
                return -EBADE;
        }
 
@@ -5182,7 +5184,7 @@ static int mdt_connect_internal(struct obd_export *exp,
                                         OBD_CONNECT_MDS_MDS |
                                         OBD_CONNECT_SOM))) {
                CWARN("%s: MDS has SOM enabled, but client does not support "
                                         OBD_CONNECT_MDS_MDS |
                                         OBD_CONNECT_SOM))) {
                CWARN("%s: MDS has SOM enabled, but client does not support "
-                     "it\n", mdt->mdt_md_dev.md_lu_dev.ld_obd->obd_name);
+                     "it\n", mdt_obd_name(mdt));
                return -EBADE;
        }
 
                return -EBADE;
        }
 
@@ -5680,7 +5682,6 @@ static int mdt_fid2path(struct mdt_thread_info *info,
                        struct getinfo_fid2path *fp)
 {
        struct mdt_device *mdt = info->mti_mdt;
                        struct getinfo_fid2path *fp)
 {
        struct mdt_device *mdt = info->mti_mdt;
-       struct obd_device *obd = mdt2obd_dev(mdt);
        struct mdt_object *obj;
        int    rc;
        ENTRY;
        struct mdt_object *obj;
        int    rc;
        ENTRY;
@@ -5693,15 +5694,15 @@ static int mdt_fid2path(struct mdt_thread_info *info,
 
        if (!fid_is_namespace_visible(&fp->gf_fid)) {
                CWARN("%s: "DFID" is invalid, sequence should be "
 
        if (!fid_is_namespace_visible(&fp->gf_fid)) {
                CWARN("%s: "DFID" is invalid, sequence should be "
-                       ">= "LPX64"\n", obd->obd_name,
-                       PFID(&fp->gf_fid), (__u64)FID_SEQ_NORMAL);
+                     ">= "LPX64"\n", mdt_obd_name(mdt),
+                     PFID(&fp->gf_fid), (__u64)FID_SEQ_NORMAL);
                RETURN(-EINVAL);
        }
 
        obj = mdt_object_find(info->mti_env, mdt, &fp->gf_fid);
        if (obj == NULL || IS_ERR(obj)) {
                CDEBUG(D_IOCTL, "no object "DFID": %ld\n", PFID(&fp->gf_fid),
                RETURN(-EINVAL);
        }
 
        obj = mdt_object_find(info->mti_env, mdt, &fp->gf_fid);
        if (obj == NULL || IS_ERR(obj)) {
                CDEBUG(D_IOCTL, "no object "DFID": %ld\n", PFID(&fp->gf_fid),
-                       PTR_ERR(obj));
+                      PTR_ERR(obj));
                RETURN(-EINVAL);
        }
 
                RETURN(-EINVAL);
        }
 
@@ -5715,7 +5716,7 @@ static int mdt_fid2path(struct mdt_thread_info *info,
        if (rc < 0) {
                mdt_object_put(info->mti_env, obj);
                CDEBUG(D_IOCTL, "nonlocal object "DFID": %d\n",
        if (rc < 0) {
                mdt_object_put(info->mti_env, obj);
                CDEBUG(D_IOCTL, "nonlocal object "DFID": %d\n",
-                       PFID(&fp->gf_fid), rc);
+                      PFID(&fp->gf_fid), rc);
                RETURN(rc);
        }
 
                RETURN(rc);
        }
 
@@ -5887,11 +5888,11 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
         case OBD_IOC_SET_READONLY:
                 rc = dt->dd_ops->dt_ro(&env, dt);
                 break;
         case OBD_IOC_SET_READONLY:
                 rc = dt->dd_ops->dt_ro(&env, dt);
                 break;
-        case OBD_IOC_ABORT_RECOVERY:
-                CERROR("Aborting recovery for device %s\n", obd->obd_name);
-                target_stop_recovery_thread(obd);
-                rc = 0;
-                break;
+       case OBD_IOC_ABORT_RECOVERY:
+               CERROR("%s: Aborting recovery for device\n", mdt_obd_name(mdt));
+               target_stop_recovery_thread(obd);
+               rc = 0;
+               break;
         case OBD_IOC_CHANGELOG_REG:
         case OBD_IOC_CHANGELOG_DEREG:
         case OBD_IOC_CHANGELOG_CLEAR:
         case OBD_IOC_CHANGELOG_REG:
         case OBD_IOC_CHANGELOG_DEREG:
         case OBD_IOC_CHANGELOG_CLEAR:
@@ -5923,11 +5924,11 @@ static int mdt_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 rc = mdt_ioc_version_get(mti, karg);
                 break;
         }
                 rc = mdt_ioc_version_get(mti, karg);
                 break;
         }
-        default:
-                CERROR("Not supported cmd = %d for device %s\n",
-                       cmd, obd->obd_name);
-                rc = -EOPNOTSUPP;
-        }
+       default:
+               rc = -EOPNOTSUPP;
+               CERROR("%s: Not supported cmd = %d, rc = %d\n",
+                       mdt_obd_name(mdt), cmd, rc);
+       }
 
         lu_env_fini(&env);
         RETURN(rc);
 
         lu_env_fini(&env);
         RETURN(rc);
index 55c1069..9aa2ed3 100644 (file)
@@ -393,7 +393,7 @@ int mdt_hsm_action(struct mdt_thread_info *info)
        hal->hal_version = HAL_VERSION;
        hal->hal_archive_id = 0;
        hal->hal_flags = 0;
        hal->hal_version = HAL_VERSION;
        hal->hal_archive_id = 0;
        hal->hal_flags = 0;
-       obd_uuid2fsname(hal->hal_fsname, mdt2obd_dev(info->mti_mdt)->obd_name,
+       obd_uuid2fsname(hal->hal_fsname, mdt_obd_name(info->mti_mdt),
                        MTI_NAME_MAXLEN);
        hal->hal_count = 1;
        hai = hai_zero(hal);
                        MTI_NAME_MAXLEN);
        hal->hal_count = 1;
        hai = hai_zero(hal);
@@ -432,7 +432,7 @@ int mdt_hsm_action(struct mdt_thread_info *info)
        default:
                hca->hca_action = HUA_NONE;
                CERROR("%s: Unknown hsm action: %d on "DFID"\n",
        default:
                hca->hca_action = HUA_NONE;
                CERROR("%s: Unknown hsm action: %d on "DFID"\n",
-                      mdt2obd_dev(info->mti_mdt)->obd_name,
+                      mdt_obd_name(info->mti_mdt),
                       hai->hai_action, PFID(&hai->hai_fid));
                break;
        }
                       hai->hai_action, PFID(&hai->hai_fid));
                break;
        }
@@ -532,7 +532,7 @@ int mdt_hsm_request(struct mdt_thread_info *info)
        hal->hal_version = HAL_VERSION;
        hal->hal_archive_id = hr->hr_archive_id;
        hal->hal_flags = hr->hr_flags;
        hal->hal_version = HAL_VERSION;
        hal->hal_archive_id = hr->hr_archive_id;
        hal->hal_flags = hr->hr_flags;
-       obd_uuid2fsname(hal->hal_fsname, mdt2obd_dev(info->mti_mdt)->obd_name,
+       obd_uuid2fsname(hal->hal_fsname, mdt_obd_name(info->mti_mdt),
                        MTI_NAME_MAXLEN);
 
        hal->hal_count = hr->hr_itemcount;
                        MTI_NAME_MAXLEN);
 
        hal->hal_count = hr->hr_itemcount;
index acb9dbb..bc3e85f 100644 (file)
@@ -79,94 +79,101 @@ do {                                                                    \
 
 int mdt_init_sec_level(struct mdt_thread_info *info)
 {
 
 int mdt_init_sec_level(struct mdt_thread_info *info)
 {
-        struct mdt_device *mdt = info->mti_mdt;
-        struct ptlrpc_request *req = mdt_info_req(info);
-        char *client = libcfs_nid2str(req->rq_peer.nid);
-        struct obd_export *exp = req->rq_export;
-        struct obd_device *obd = exp->exp_obd;
-        struct obd_connect_data *data, *reply;
-        int rc = 0, remote;
-        ENTRY;
-
-        data = req_capsule_client_get(info->mti_pill, &RMF_CONNECT_DATA);
-        reply = req_capsule_server_get(info->mti_pill, &RMF_CONNECT_DATA);
-        if (data == NULL || reply == NULL)
-                RETURN(-EFAULT);
-
-        /* connection from MDT is always trusted */
-        if (req->rq_auth_usr_mdt) {
-                mdt_init_sec_none(reply, exp);
-                RETURN(0);
-        }
-
-        /* no GSS support case */
-        if (!req->rq_auth_gss) {
-                if (mdt->mdt_sec_level > LUSTRE_SEC_NONE) {
-                        CWARN("client %s -> target %s does not user GSS, "
-                              "can not run under security level %d.\n",
-                              client, obd->obd_name, mdt->mdt_sec_level);
-                        RETURN(-EACCES);
-                } else {
-                        mdt_init_sec_none(reply, exp);
-                        RETURN(0);
-                }
-        }
-
-        /* old version case */
-        if (unlikely(!(data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT) ||
-                     !(data->ocd_connect_flags & OBD_CONNECT_MDS_CAPA) ||
-                     !(data->ocd_connect_flags & OBD_CONNECT_OSS_CAPA))) {
-                if (mdt->mdt_sec_level > LUSTRE_SEC_NONE) {
-                        CWARN("client %s -> target %s uses old version, "
-                              "can not run under security level %d.\n",
-                              client, obd->obd_name, mdt->mdt_sec_level);
-                        RETURN(-EACCES);
-                } else {
-                        CWARN("client %s -> target %s uses old version, "
-                              "run under security level %d.\n",
-                              client, obd->obd_name, mdt->mdt_sec_level);
-                        mdt_init_sec_none(reply, exp);
-                        RETURN(0);
-                }
-        }
-
-        remote = data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT_FORCE;
-        if (remote) {
-                if (!req->rq_auth_remote)
-                        CDEBUG(D_SEC, "client (local realm) %s -> target %s "
-                               "asked to be remote.\n", client, obd->obd_name);
-        } else if (req->rq_auth_remote) {
-                remote = 1;
-                CDEBUG(D_SEC, "client (remote realm) %s -> target %s is set "
-                       "as remote by default.\n", client, obd->obd_name);
-        }
-
-        if (remote) {
-                if (!mdt->mdt_opts.mo_oss_capa) {
-                        CDEBUG(D_SEC, "client %s -> target %s is set as remote,"
-                               " but OSS capabilities are not enabled: %d.\n",
-                               client, obd->obd_name, mdt->mdt_opts.mo_oss_capa);
-                        RETURN(-EACCES);
-                }
-        } else {
-                if (req->rq_auth_uid == INVALID_UID) {
-                        CDEBUG(D_SEC, "client %s -> target %s: user is not "
-                               "authenticated!\n", client, obd->obd_name);
-                        RETURN(-EACCES);
-                }
-        }
-
-        switch (mdt->mdt_sec_level) {
-        case LUSTRE_SEC_NONE:
-                if (!remote) {
-                        mdt_init_sec_none(reply, exp);
-                        break;
-                } else {
-                        CDEBUG(D_SEC, "client %s -> target %s is set as remote, "
-                               "can not run under security level %d.\n",
-                               client, obd->obd_name, mdt->mdt_sec_level);
-                        RETURN(-EACCES);
-                }
+       struct mdt_device *mdt = info->mti_mdt;
+       struct ptlrpc_request *req = mdt_info_req(info);
+       char *client = libcfs_nid2str(req->rq_peer.nid);
+       struct obd_connect_data *data, *reply;
+       int rc = 0, remote;
+       ENTRY;
+
+       data = req_capsule_client_get(info->mti_pill, &RMF_CONNECT_DATA);
+       reply = req_capsule_server_get(info->mti_pill, &RMF_CONNECT_DATA);
+       if (data == NULL || reply == NULL)
+               RETURN(-EFAULT);
+
+       /* connection from MDT is always trusted */
+       if (req->rq_auth_usr_mdt) {
+               mdt_init_sec_none(reply, exp);
+               RETURN(0);
+       }
+
+       /* no GSS support case */
+       if (!req->rq_auth_gss) {
+               if (mdt->mdt_sec_level > LUSTRE_SEC_NONE) {
+                       CWARN("%s: client %s -> target %s does not user GSS, "
+                             "can not run under security level %d.\n",
+                             mdt_obd_name(mdt), client, mdt_obd_name(mdt),
+                             mdt->mdt_sec_level);
+                       RETURN(-EACCES);
+               } else {
+                       mdt_init_sec_none(reply, exp);
+                       RETURN(0);
+               }
+       }
+
+       /* old version case */
+       if (unlikely(!(data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT) ||
+                    !(data->ocd_connect_flags & OBD_CONNECT_MDS_CAPA) ||
+                    !(data->ocd_connect_flags & OBD_CONNECT_OSS_CAPA))) {
+               if (mdt->mdt_sec_level > LUSTRE_SEC_NONE) {
+                       CWARN("%s: client %s -> target %s uses old version, "
+                             "can not run under security level %d.\n",
+                             mdt_obd_name(mdt), client, mdt_obd_name(mdt),
+                             mdt->mdt_sec_level);
+                       RETURN(-EACCES);
+               } else {
+                       CWARN("%s: client %s -> target %s uses old version, "
+                             "run under security level %d.\n",
+                             mdt_obd_name(mdt), client, mdt_obd_name(mdt),
+                             mdt->mdt_sec_level);
+                       mdt_init_sec_none(reply, exp);
+                       RETURN(0);
+               }
+       }
+
+       remote = data->ocd_connect_flags & OBD_CONNECT_RMT_CLIENT_FORCE;
+       if (remote) {
+               if (!req->rq_auth_remote)
+                       CDEBUG(D_SEC, "%s: client (local realm) %s -> "
+                              "target %s asked to be remote.\n",
+                              mdt_obd_name(mdt), client, mdt_obd_name(mdt));
+       } else if (req->rq_auth_remote) {
+               remote = 1;
+               CDEBUG(D_SEC, "%s: client (remote realm) %s -> "
+                      "target %s is set as remote by default.\n",
+                      mdt_obd_name(mdt), client, mdt_obd_name(mdt));
+       }
+
+       if (remote) {
+               if (!mdt->mdt_opts.mo_oss_capa) {
+                       CDEBUG(D_SEC, "%s: client %s -> target %s is set as "
+                              "remote,but OSS capabilities are not enabled: "
+                              "%d.\n",
+                              mdt_obd_name(mdt), client, mdt_obd_name(mdt),
+                              mdt->mdt_opts.mo_oss_capa);
+                       RETURN(-EACCES);
+               }
+       } else {
+               if (req->rq_auth_uid == INVALID_UID) {
+                       CDEBUG(D_SEC, "%s: client %s -> target %s: user is not "
+                              "authenticated!\n",
+                              mdt_obd_name(mdt), client, mdt_obd_name(mdt));
+                       RETURN(-EACCES);
+               }
+       }
+
+       switch (mdt->mdt_sec_level) {
+       case LUSTRE_SEC_NONE:
+               if (!remote) {
+                       mdt_init_sec_none(reply, exp);
+                       break;
+               } else {
+                       CDEBUG(D_SEC, "%s: client %s -> target %s is set as "
+                              "remote, can not run under security level %d.\n",
+                              mdt_obd_name(mdt), client, mdt_obd_name(mdt),
+                              mdt->mdt_sec_level);
+                       RETURN(-EACCES);
+               }
         case LUSTRE_SEC_REMOTE:
                 if (!remote)
                         mdt_init_sec_none(reply, exp);
         case LUSTRE_SEC_REMOTE:
                 if (!remote)
                         mdt_init_sec_none(reply, exp);
@@ -190,41 +197,43 @@ int mdt_init_sec_level(struct mdt_thread_info *info)
 
 int mdt_init_idmap(struct mdt_thread_info *info)
 {
 
 int mdt_init_idmap(struct mdt_thread_info *info)
 {
-        struct ptlrpc_request *req = mdt_info_req(info);
-        struct mdt_export_data *med = mdt_req2med(req);
-        struct obd_export *exp = req->rq_export;
-        char *client = libcfs_nid2str(req->rq_peer.nid);
-        struct obd_device *obd = exp->exp_obd;
-        int rc = 0;
-        ENTRY;
-
-        if (exp_connect_rmtclient(exp)) {
+       struct ptlrpc_request *req = mdt_info_req(info);
+       struct mdt_export_data *med = mdt_req2med(req);
+       struct obd_export *exp = req->rq_export;
+       char *client = libcfs_nid2str(req->rq_peer.nid);
+       int rc = 0;
+       ENTRY;
+
+       if (exp_connect_rmtclient(exp)) {
                mutex_lock(&med->med_idmap_mutex);
                mutex_lock(&med->med_idmap_mutex);
-                if (!med->med_idmap)
-                        med->med_idmap = lustre_idmap_init();
+               if (!med->med_idmap)
+                       med->med_idmap = lustre_idmap_init();
                mutex_unlock(&med->med_idmap_mutex);
 
                mutex_unlock(&med->med_idmap_mutex);
 
-                if (IS_ERR(med->med_idmap)) {
-                        long err = PTR_ERR(med->med_idmap);
-
-                        med->med_idmap = NULL;
-                        CERROR("client %s -> target %s "
-                               "failed to init idmap [%ld]!\n",
-                               client, obd->obd_name, err);
-                        RETURN(err);
-                } else if (!med->med_idmap) {
-                        CERROR("client %s -> target %s "
-                               "failed to init(2) idmap!\n",
-                               client, obd->obd_name);
-                        RETURN(-ENOMEM);
-                }
-
-                CDEBUG(D_SEC, "client %s -> target %s is remote.\n",
-                       client, obd->obd_name);
-                /* NB, MDS_CONNECT establish root idmap too! */
-                rc = mdt_handle_idmap(info);
-        }
-        RETURN(rc);
+               if (IS_ERR(med->med_idmap)) {
+                       long err = PTR_ERR(med->med_idmap);
+
+                       med->med_idmap = NULL;
+                       CERROR("%s: client %s -> target %s "
+                              "failed to init idmap [%ld]!\n",
+                              mdt_obd_name(info->mti_mdt), client,
+                              mdt_obd_name(info->mti_mdt), err);
+                       RETURN(err);
+               } else if (!med->med_idmap) {
+                       CERROR("%s: client %s -> target %s "
+                              "failed to init(2) idmap!\n",
+                              mdt_obd_name(info->mti_mdt), client,
+                              mdt_obd_name(info->mti_mdt));
+                       RETURN(-ENOMEM);
+               }
+
+               CDEBUG(D_SEC, "%s: client %s -> target %s is remote.\n",
+                       mdt_obd_name(info->mti_mdt), client,
+                       mdt_obd_name(info->mti_mdt));
+               /* NB, MDS_CONNECT establish root idmap too! */
+               rc = mdt_handle_idmap(info);
+       }
+       RETURN(rc);
 }
 
 void mdt_cleanup_idmap(struct mdt_export_data *med)
 }
 
 void mdt_cleanup_idmap(struct mdt_export_data *med)
index e9163cc..a9cd967 100644 (file)
@@ -162,14 +162,12 @@ LPROC_SEQ_FOPS(mdt_rename_stats);
 
 static int lproc_mdt_attach_rename_seqstat(struct mdt_device *mdt)
 {
 
 static int lproc_mdt_attach_rename_seqstat(struct mdt_device *mdt)
 {
-       struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
-       struct obd_device *obd = ld->ld_obd;
        int i;
 
        for (i = 0; i < RENAME_LAST; i++)
                spin_lock_init(&mdt->mdt_rename_stats.hist[i].oh_lock);
 
        int i;
 
        for (i = 0; i < RENAME_LAST; i++)
                spin_lock_init(&mdt->mdt_rename_stats.hist[i].oh_lock);
 
-       return lprocfs_obd_seq_create(obd, "rename_stats", 0644,
+       return lprocfs_obd_seq_create(mdt2obd_dev(mdt), "rename_stats", 0644,
                                      &mdt_rename_stats_fops, mdt);
 }
 
                                      &mdt_rename_stats_fops, mdt);
 }
 
@@ -188,8 +186,7 @@ void mdt_rename_counter_tally(struct mdt_thread_info *info,
         rc = mo_attr_get(info->mti_env, mdt_object_child(src), ma);
         if (rc) {
                 CERROR("%s: "DFID" attr_get, rc = %d\n",
         rc = mo_attr_get(info->mti_env, mdt_object_child(src), ma);
         if (rc) {
                 CERROR("%s: "DFID" attr_get, rc = %d\n",
-                      req->rq_export->exp_obd->obd_name,
-                      PFID(mdt_object_fid(src)), rc);
+                      mdt_obd_name(mdt), PFID(mdt_object_fid(src)), rc);
                 return;
         }
 
                 return;
         }
 
@@ -209,8 +206,7 @@ void mdt_rename_counter_tally(struct mdt_thread_info *info,
         rc = mo_attr_get(info->mti_env, mdt_object_child(tgt), ma);
         if (rc) {
                 CERROR("%s: "DFID" attr_get, rc = %d\n",
         rc = mo_attr_get(info->mti_env, mdt_object_child(tgt), ma);
         if (rc) {
                 CERROR("%s: "DFID" attr_get, rc = %d\n",
-                      req->rq_export->exp_obd->obd_name,
-                      PFID(mdt_object_fid(tgt)), rc);
+                      mdt_obd_name(mdt), PFID(mdt_object_fid(tgt)), rc);
                 return;
         }
 
                 return;
         }
 
@@ -220,29 +216,28 @@ void mdt_rename_counter_tally(struct mdt_thread_info *info,
 
 int mdt_procfs_init(struct mdt_device *mdt, const char *name)
 {
 
 int mdt_procfs_init(struct mdt_device *mdt, const char *name)
 {
-        struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
-        struct obd_device *obd = ld->ld_obd;
-        struct lprocfs_static_vars lvars;
-        int rc;
-        ENTRY;
+       struct obd_device               *obd = mdt2obd_dev(mdt);
+       struct lprocfs_static_vars       lvars;
+       int                              rc;
+       ENTRY;
 
 
-        LASSERT(name != NULL);
+       LASSERT(name != NULL);
 
 
-        lprocfs_mdt_init_vars(&lvars);
-        rc = lprocfs_obd_setup(obd, lvars.obd_vars);
-        if (rc) {
-                CERROR("Can't init lprocfs, rc %d\n", rc);
-                return rc;
-        }
-        ptlrpc_lprocfs_register_obd(obd);
-
-        obd->obd_proc_exports_entry = proc_mkdir("exports",
-                                                 obd->obd_proc_entry);
-        if (obd->obd_proc_exports_entry)
-                lprocfs_add_simple(obd->obd_proc_exports_entry,
-                                   "clear", lprocfs_nid_stats_clear_read,
-                                   lprocfs_nid_stats_clear_write, obd, NULL);
-        rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
+       lprocfs_mdt_init_vars(&lvars);
+       rc = lprocfs_obd_setup(obd, lvars.obd_vars);
+       if (rc) {
+               CERROR("Can't init lprocfs, rc %d\n", rc);
+               return rc;
+       }
+       ptlrpc_lprocfs_register_obd(obd);
+
+       obd->obd_proc_exports_entry = proc_mkdir("exports",
+                                                obd->obd_proc_entry);
+       if (obd->obd_proc_exports_entry)
+               lprocfs_add_simple(obd->obd_proc_exports_entry,
+                                  "clear", lprocfs_nid_stats_clear_read,
+                                  lprocfs_nid_stats_clear_write, obd, NULL);
+       rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST);
        if (rc)
                return rc;
        mdt_stats_counter_init(obd->md_stats);
        if (rc)
                return rc;
        mdt_stats_counter_init(obd->md_stats);
@@ -250,18 +245,17 @@ int mdt_procfs_init(struct mdt_device *mdt, const char *name)
        rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST,
                                    mdt_stats_counter_init);
 
        rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST,
                                    mdt_stats_counter_init);
 
-        rc = lproc_mdt_attach_rename_seqstat(mdt);
-        if (rc)
-                CERROR("%s: MDT can not create rename stats rc = %d\n",
-                       obd->obd_name, rc);
+       rc = lproc_mdt_attach_rename_seqstat(mdt);
+       if (rc)
+               CERROR("%s: MDT can not create rename stats rc = %d\n",
+                      mdt_obd_name(mdt), rc);
 
 
-        RETURN(rc);
+       RETURN(rc);
 }
 
 void mdt_procfs_fini(struct mdt_device *mdt)
 {
 }
 
 void mdt_procfs_fini(struct mdt_device *mdt)
 {
-        struct lu_device *ld = &mdt->mdt_md_dev.md_lu_dev;
-        struct obd_device *obd = ld->ld_obd;
+       struct obd_device *obd = mdt2obd_dev(mdt);
 
         if (obd->obd_proc_exports_entry) {
                 lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
 
         if (obd->obd_proc_exports_entry) {
                 lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry);
@@ -346,45 +340,46 @@ static int lprocfs_rd_identity_upcall(char *page, char **start, off_t off,
 }
 
 static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer,
-                                      unsigned long count, void *data)
+                                     unsigned long count, void *data)
 {
 {
-        struct obd_device *obd = data;
-        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-        struct upcall_cache *hash = mdt->mdt_identity_cache;
-        int rc;
-        char *kernbuf;
-
-        if (count >= UC_CACHE_UPCALL_MAXPATH) {
-                CERROR("%s: identity upcall too long\n", obd->obd_name);
-                return -EINVAL;
-        }
-        OBD_ALLOC(kernbuf, count + 1);
-        if (kernbuf == NULL)
-                GOTO(failed, rc = -ENOMEM);
-        if (cfs_copy_from_user(kernbuf, buffer, count))
-                GOTO(failed, rc = -EFAULT);
-
-        /* Remove any extraneous bits from the upcall (e.g. linefeeds) */
+       struct obd_device       *obd = data;
+       struct mdt_device       *mdt = mdt_dev(obd->obd_lu_dev);
+       struct upcall_cache     *hash = mdt->mdt_identity_cache;
+       int                      rc;
+       char                    *kernbuf;
+
+       if (count >= UC_CACHE_UPCALL_MAXPATH) {
+               CERROR("%s: identity upcall too long\n", mdt_obd_name(mdt));
+               return -EINVAL;
+       }
+       OBD_ALLOC(kernbuf, count + 1);
+       if (kernbuf == NULL)
+               GOTO(failed, rc = -ENOMEM);
+       if (cfs_copy_from_user(kernbuf, buffer, count))
+               GOTO(failed, rc = -EFAULT);
+
+       /* Remove any extraneous bits from the upcall (e.g. linefeeds) */
        write_lock(&hash->uc_upcall_rwlock);
        sscanf(kernbuf, "%s", hash->uc_upcall);
        write_unlock(&hash->uc_upcall_rwlock);
 
        write_lock(&hash->uc_upcall_rwlock);
        sscanf(kernbuf, "%s", hash->uc_upcall);
        write_unlock(&hash->uc_upcall_rwlock);
 
-        if (strcmp(hash->uc_name, obd->obd_name) != 0)
-                CWARN("%s: write to upcall name %s\n",
-                      obd->obd_name, hash->uc_upcall);
+       if (strcmp(hash->uc_name, mdt_obd_name(mdt)) != 0)
+               CWARN("%s: write to upcall name %s\n",
+                     mdt_obd_name(mdt), hash->uc_upcall);
 
 
-        if (strcmp(hash->uc_upcall, "NONE") == 0 && mdt->mdt_opts.mo_acl)
-                CWARN("%s: disable \"identity_upcall\" with ACL enabled maybe "
-                      "cause unexpected \"EACCESS\"\n", obd->obd_name);
+       if (strcmp(hash->uc_upcall, "NONE") == 0 && mdt->mdt_opts.mo_acl)
+               CWARN("%s: disable \"identity_upcall\" with ACL enabled maybe "
+                     "cause unexpected \"EACCESS\"\n", mdt_obd_name(mdt));
 
 
-        CWARN("%s: identity upcall set to %s\n", obd->obd_name, hash->uc_upcall);
-        OBD_FREE(kernbuf, count + 1);
-        RETURN(count);
+       CWARN("%s: identity upcall set to %s\n", mdt_obd_name(mdt),
+             hash->uc_upcall);
+       OBD_FREE(kernbuf, count + 1);
+       RETURN(count);
 
  failed:
 
  failed:
-        if (kernbuf)
-                OBD_FREE(kernbuf, count + 1);
-        RETURN(rc);
+       if (kernbuf)
+               OBD_FREE(kernbuf, count + 1);
+       RETURN(rc);
 }
 
 static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
@@ -403,66 +398,68 @@ static int lprocfs_wr_identity_flush(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_identity_info(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_identity_info(struct file *file, const char *buffer,
-                                    unsigned long count, void *data)
+                                   unsigned long count, void *data)
 {
 {
-        struct obd_device *obd = data;
-        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-        struct identity_downcall_data *param;
-        int size = sizeof(*param), rc, checked = 0;
+       struct obd_device *obd = data;
+       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       struct identity_downcall_data *param;
+       int size = sizeof(*param), rc, checked = 0;
 
 again:
 
 again:
-        if (count < size) {
-                CERROR("%s: invalid data count = %lu, size = %d\n",
-                       obd->obd_name, count, size);
-                return -EINVAL;
-        }
-
-        OBD_ALLOC(param, size);
-        if (param == NULL)
-                return -ENOMEM;
-
-        if (cfs_copy_from_user(param, buffer, size)) {
-                CERROR("%s: bad identity data\n", obd->obd_name);
-                GOTO(out, rc = -EFAULT);
-        }
-
-        if (checked == 0) {
-                checked = 1;
-                if (param->idd_magic != IDENTITY_DOWNCALL_MAGIC) {
-                        CERROR("%s: MDS identity downcall bad params\n",
-                               obd->obd_name);
-                        GOTO(out, rc = -EINVAL);
-                }
-
-                if (param->idd_nperms > N_PERMS_MAX) {
-                        CERROR("%s: perm count %d more than maximum %d\n",
-                               obd->obd_name, param->idd_nperms, N_PERMS_MAX);
-                        GOTO(out, rc = -EINVAL);
-                }
-
-                if (param->idd_ngroups > NGROUPS_MAX) {
-                        CERROR("%s: group count %d more than maximum %d\n",
-                               obd->obd_name, param->idd_ngroups, NGROUPS_MAX);
-                        GOTO(out, rc = -EINVAL);
-                }
-
-                if (param->idd_ngroups) {
-                        rc = param->idd_ngroups; /* save idd_ngroups */
-                        OBD_FREE(param, size);
-                        size = offsetof(struct identity_downcall_data,
-                                        idd_groups[rc]);
-                        goto again;
-                }
-        }
-
-        rc = upcall_cache_downcall(mdt->mdt_identity_cache, param->idd_err,
-                                   param->idd_uid, param);
+       if (count < size) {
+               CERROR("%s: invalid data count = %lu, size = %d\n",
+                      mdt_obd_name(mdt), count, size);
+               return -EINVAL;
+       }
+
+       OBD_ALLOC(param, size);
+       if (param == NULL)
+               return -ENOMEM;
+
+       if (cfs_copy_from_user(param, buffer, size)) {
+               CERROR("%s: bad identity data\n", mdt_obd_name(mdt));
+               GOTO(out, rc = -EFAULT);
+       }
+
+       if (checked == 0) {
+               checked = 1;
+               if (param->idd_magic != IDENTITY_DOWNCALL_MAGIC) {
+                       CERROR("%s: MDS identity downcall bad params\n",
+                              mdt_obd_name(mdt));
+                       GOTO(out, rc = -EINVAL);
+               }
+
+               if (param->idd_nperms > N_PERMS_MAX) {
+                       CERROR("%s: perm count %d more than maximum %d\n",
+                              mdt_obd_name(mdt), param->idd_nperms,
+                              N_PERMS_MAX);
+                       GOTO(out, rc = -EINVAL);
+               }
+
+               if (param->idd_ngroups > NGROUPS_MAX) {
+                       CERROR("%s: group count %d more than maximum %d\n",
+                              mdt_obd_name(mdt), param->idd_ngroups,
+                              NGROUPS_MAX);
+                       GOTO(out, rc = -EINVAL);
+               }
+
+               if (param->idd_ngroups) {
+                       rc = param->idd_ngroups; /* save idd_ngroups */
+                       OBD_FREE(param, size);
+                       size = offsetof(struct identity_downcall_data,
+                                       idd_groups[rc]);
+                       goto again;
+               }
+       }
+
+       rc = upcall_cache_downcall(mdt->mdt_identity_cache, param->idd_err,
+                                  param->idd_uid, param);
 
 out:
 
 out:
-        if (param != NULL)
-                OBD_FREE(param, size);
+       if (param != NULL)
+               OBD_FREE(param, size);
 
 
-        return rc ? rc : count;
+       return rc ? rc : count;
 }
 
 /* for debug only */
 }
 
 /* for debug only */
@@ -478,42 +475,42 @@ static int lprocfs_rd_capa(char *page, char **start, off_t off,
 }
 
 static int lprocfs_wr_capa(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_capa(struct file *file, const char *buffer,
-                           unsigned long count, void *data)
+                          unsigned long count, void *data)
 {
 {
-        struct obd_device *obd = data;
-        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-        int val, rc;
-
-        rc = lprocfs_write_helper(buffer, count, &val);
-        if (rc)
-                return rc;
-
-        if (val < 0 || val > 3) {
-                CERROR("invalid capability mode, only 0/2/3 is accepted.\n"
-                       " 0:  disable fid capability\n"
-                       " 2:  enable MDS fid capability\n"
-                       " 3:  enable both MDS and OSS fid capability\n");
-                return -EINVAL;
-        }
+       struct obd_device *obd = data;
+       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       int val, rc;
 
 
-        /* OSS fid capability needs enable both MDS and OSS fid capability on
-         * MDS */
-        if (val == 1) {
-                CERROR("can't enable OSS fid capability only, you should use "
-                       "'3' to enable both MDS and OSS fid capability.\n");
-                return -EINVAL;
-        }
+       rc = lprocfs_write_helper(buffer, count, &val);
+       if (rc)
+               return rc;
 
 
-        mdt->mdt_opts.mo_oss_capa = (val & 0x1);
-        mdt->mdt_opts.mo_mds_capa = !!(val & 0x2);
-        mdt->mdt_capa_conf = 1;
-        LCONSOLE_INFO("MDS %s %s MDS fid capability.\n",
-                      obd->obd_name,
-                      mdt->mdt_opts.mo_mds_capa ? "enabled" : "disabled");
-        LCONSOLE_INFO("MDS %s %s OSS fid capability.\n",
-                      obd->obd_name,
-                      mdt->mdt_opts.mo_oss_capa ? "enabled" : "disabled");
-        return count;
+       if (val < 0 || val > 3) {
+               CERROR("invalid capability mode, only 0/2/3 is accepted.\n"
+                      " 0:  disable fid capability\n"
+                      " 2:  enable MDS fid capability\n"
+                      " 3:  enable both MDS and OSS fid capability\n");
+               return -EINVAL;
+       }
+
+       /* OSS fid capability needs enable both MDS and OSS fid capability on
+        * MDS */
+       if (val == 1) {
+               CERROR("can't enable OSS fid capability only, you should use "
+                      "'3' to enable both MDS and OSS fid capability.\n");
+               return -EINVAL;
+       }
+
+       mdt->mdt_opts.mo_oss_capa = (val & 0x1);
+       mdt->mdt_opts.mo_mds_capa = !!(val & 0x2);
+       mdt->mdt_capa_conf = 1;
+       LCONSOLE_INFO("MDS %s %s MDS fid capability.\n",
+                     mdt_obd_name(mdt),
+                     mdt->mdt_opts.mo_mds_capa ? "enabled" : "disabled");
+       LCONSOLE_INFO("MDS %s %s OSS fid capability.\n",
+                     mdt_obd_name(mdt),
+                     mdt->mdt_opts.mo_oss_capa ? "enabled" : "disabled");
+       return count;
 }
 
 static int lprocfs_rd_capa_count(char *page, char **start, off_t off,
 }
 
 static int lprocfs_rd_capa_count(char *page, char **start, off_t off,
@@ -703,61 +700,61 @@ static int safe_strtoul(const char *str, char **endp, unsigned long *res)
 }
 
 static int lprocfs_wr_root_squash(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_root_squash(struct file *file, const char *buffer,
-                                  unsigned long count, void *data)
+                                 unsigned long count, void *data)
 {
 {
-        struct obd_device *obd = data;
-        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-        int rc;
-        char kernbuf[50], *tmp, *end, *errmsg;
-        unsigned long uid, gid;
-        int nouid, nogid;
-        ENTRY;
-
-        if (count >= sizeof(kernbuf)) {
-                errmsg = "string too long";
-                GOTO(failed, rc = -EINVAL);
-        }
-        if (cfs_copy_from_user(kernbuf, buffer, count)) {
-                errmsg = "bad address";
-                GOTO(failed, rc = -EFAULT);
-        }
-        kernbuf[count] = '\0';
-
-        nouid = nogid = 0;
-        if (safe_strtoul(buffer, &tmp, &uid)) {
-                uid = mdt->mdt_squash_uid;
-                nouid = 1;
-        }
-
-        /* skip ':' */
-        if (*tmp == ':') {
-                tmp++;
-                if (safe_strtoul(tmp, &end, &gid)) {
-                        gid = mdt->mdt_squash_gid;
-                        nogid = 1;
-                }
-        } else {
-                gid = mdt->mdt_squash_gid;
-                nogid = 1;
-        }
-
-        mdt->mdt_squash_uid = uid;
-        mdt->mdt_squash_gid = gid;
-
-        if (nouid && nogid) {
-                errmsg = "needs uid:gid format";
-                GOTO(failed, rc = -EINVAL);
-        }
-
-        LCONSOLE_INFO("%s: root_squash is set to %u:%u\n",
-                      obd->obd_name,
-                      mdt->mdt_squash_uid,  mdt->mdt_squash_gid);
-        RETURN(count);
-
- failed:
-        CWARN("%s: failed to set root_squash to \"%s\", %s: rc %d\n",
-              obd->obd_name, buffer, errmsg, rc);
-        RETURN(rc);
+       struct obd_device *obd = data;
+       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       int rc;
+       char kernbuf[50], *tmp, *end, *errmsg;
+       unsigned long uid, gid;
+       int nouid, nogid;
+       ENTRY;
+
+       if (count >= sizeof(kernbuf)) {
+               errmsg = "string too long";
+               GOTO(failed, rc = -EINVAL);
+       }
+       if (cfs_copy_from_user(kernbuf, buffer, count)) {
+               errmsg = "bad address";
+               GOTO(failed, rc = -EFAULT);
+       }
+       kernbuf[count] = '\0';
+
+       nouid = nogid = 0;
+       if (safe_strtoul(buffer, &tmp, &uid)) {
+               uid = mdt->mdt_squash_uid;
+               nouid = 1;
+       }
+
+       /* skip ':' */
+       if (*tmp == ':') {
+               tmp++;
+               if (safe_strtoul(tmp, &end, &gid)) {
+                       gid = mdt->mdt_squash_gid;
+                       nogid = 1;
+               }
+       } else {
+               gid = mdt->mdt_squash_gid;
+               nogid = 1;
+       }
+
+       mdt->mdt_squash_uid = uid;
+       mdt->mdt_squash_gid = gid;
+
+       if (nouid && nogid) {
+               errmsg = "needs uid:gid format";
+               GOTO(failed, rc = -EINVAL);
+       }
+
+       LCONSOLE_INFO("%s: root_squash is set to %u:%u\n",
+                     mdt_obd_name(mdt),
+                     mdt->mdt_squash_uid,  mdt->mdt_squash_gid);
+       RETURN(count);
+
+failed:
+       CWARN("%s: failed to set root_squash to \"%s\", %s: rc %d\n",
+             mdt_obd_name(mdt), buffer, errmsg, rc);
+       RETURN(rc);
 }
 
 static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off,
 }
 
 static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off,
@@ -772,69 +769,69 @@ static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off,
 }
 
 static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer,
-                                    unsigned long count, void *data)
+                                   unsigned long count, void *data)
 {
 {
-        struct obd_device *obd = data;
-        struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
-        int rc;
-        char *kernbuf, *errmsg;
-        cfs_list_t tmp;
-        ENTRY;
-
-        OBD_ALLOC(kernbuf, count + 1);
-        if (kernbuf == NULL) {
-                errmsg = "no memory";
-                GOTO(failed, rc = -ENOMEM);
-        }
-        if (cfs_copy_from_user(kernbuf, buffer, count)) {
-                errmsg = "bad address";
-                GOTO(failed, rc = -EFAULT);
-        }
-        kernbuf[count] = '\0';
-
-        if (!strcmp(kernbuf, "NONE") || !strcmp(kernbuf, "clear")) {
-                /* empty string is special case */
+       struct obd_device *obd = data;
+       struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
+       int rc;
+       char *kernbuf, *errmsg;
+       cfs_list_t tmp;
+       ENTRY;
+
+       OBD_ALLOC(kernbuf, count + 1);
+       if (kernbuf == NULL) {
+               errmsg = "no memory";
+               GOTO(failed, rc = -ENOMEM);
+       }
+       if (cfs_copy_from_user(kernbuf, buffer, count)) {
+               errmsg = "bad address";
+               GOTO(failed, rc = -EFAULT);
+       }
+       kernbuf[count] = '\0';
+
+       if (!strcmp(kernbuf, "NONE") || !strcmp(kernbuf, "clear")) {
+               /* empty string is special case */
                down_write(&mdt->mdt_squash_sem);
                down_write(&mdt->mdt_squash_sem);
-                if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
-                        cfs_free_nidlist(&mdt->mdt_nosquash_nids);
-                        OBD_FREE(mdt->mdt_nosquash_str,
-                                 mdt->mdt_nosquash_strlen);
-                        mdt->mdt_nosquash_str = NULL;
-                        mdt->mdt_nosquash_strlen = 0;
-                }
+               if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
+                       cfs_free_nidlist(&mdt->mdt_nosquash_nids);
+                       OBD_FREE(mdt->mdt_nosquash_str,
+                                mdt->mdt_nosquash_strlen);
+                       mdt->mdt_nosquash_str = NULL;
+                       mdt->mdt_nosquash_strlen = 0;
+               }
                up_write(&mdt->mdt_squash_sem);
                up_write(&mdt->mdt_squash_sem);
-                LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
-                              obd->obd_name);
-                OBD_FREE(kernbuf, count + 1);
-                RETURN(count);
-        }
-
-        CFS_INIT_LIST_HEAD(&tmp);
-        if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
-                errmsg = "can't parse";
-                GOTO(failed, rc = -EINVAL);
-        }
+               LCONSOLE_INFO("%s: nosquash_nids is cleared\n",
+                             mdt_obd_name(mdt));
+               OBD_FREE(kernbuf, count + 1);
+               RETURN(count);
+       }
+
+       CFS_INIT_LIST_HEAD(&tmp);
+       if (cfs_parse_nidlist(kernbuf, count, &tmp) <= 0) {
+               errmsg = "can't parse";
+               GOTO(failed, rc = -EINVAL);
+       }
 
        down_write(&mdt->mdt_squash_sem);
 
        down_write(&mdt->mdt_squash_sem);
-        if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
-                cfs_free_nidlist(&mdt->mdt_nosquash_nids);
-                OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
-        }
-        mdt->mdt_nosquash_str = kernbuf;
-        mdt->mdt_nosquash_strlen = count + 1;
-        cfs_list_splice(&tmp, &mdt->mdt_nosquash_nids);
-
-        LCONSOLE_INFO("%s: nosquash_nids is set to %s\n",
-                      obd->obd_name, kernbuf);
+       if (!cfs_list_empty(&mdt->mdt_nosquash_nids)) {
+               cfs_free_nidlist(&mdt->mdt_nosquash_nids);
+               OBD_FREE(mdt->mdt_nosquash_str, mdt->mdt_nosquash_strlen);
+       }
+       mdt->mdt_nosquash_str = kernbuf;
+       mdt->mdt_nosquash_strlen = count + 1;
+       cfs_list_splice(&tmp, &mdt->mdt_nosquash_nids);
+
+       LCONSOLE_INFO("%s: nosquash_nids is set to %s\n",
+                     mdt_obd_name(mdt), kernbuf);
        up_write(&mdt->mdt_squash_sem);
        up_write(&mdt->mdt_squash_sem);
-        RETURN(count);
-
- failed:
-        CWARN("%s: failed to set nosquash_nids to \"%s\", %s: rc %d\n",
-              obd->obd_name, kernbuf, errmsg, rc);
-        if (kernbuf)
-                OBD_FREE(kernbuf, count + 1);
-        RETURN(rc);
+       RETURN(count);
+
+failed:
+       CWARN("%s: failed to set nosquash_nids to \"%s\", %s: rc %d\n",
+             mdt_obd_name(mdt), kernbuf, errmsg, rc);
+       if (kernbuf)
+               OBD_FREE(kernbuf, count + 1);
+       RETURN(rc);
 }
 
 static int lprocfs_rd_mdt_som(char *page, char **start, off_t off,
 }
 
 static int lprocfs_rd_mdt_som(char *page, char **start, off_t off,
@@ -899,50 +896,50 @@ static int lprocfs_wr_mdt_som(struct file *file, const char *buffer,
 
 /* Temporary; for testing purposes only */
 static int lprocfs_mdt_wr_mdc(struct file *file, const char *buffer,
 
 /* Temporary; for testing purposes only */
 static int lprocfs_mdt_wr_mdc(struct file *file, const char *buffer,
-                              unsigned long count, void *data)
+                             unsigned long count, void *data)
 {
 {
-        struct obd_device *obd = data;
-        struct obd_export *exp = NULL;
-        struct obd_uuid   *uuid;
-        char              *kbuf;
-        char              *tmpbuf;
-
-        OBD_ALLOC(kbuf, UUID_MAX);
-        if (kbuf == NULL)
-                return -ENOMEM;
-
-        /*
-         * OBD_ALLOC() will zero kbuf, but we only copy UUID_MAX - 1
-         * bytes into kbuf, to ensure that the string is NUL-terminated.
-         * UUID_MAX should include a trailing NUL already.
-         */
-        if (cfs_copy_from_user(kbuf, buffer,
-                               min_t(unsigned long, UUID_MAX - 1, count))) {
-                count = -EFAULT;
-                goto out;
-        }
-        tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, UUID_MAX - 1, count));
-
-        OBD_ALLOC(uuid, UUID_MAX);
-        if (uuid == NULL) {
-                count = -ENOMEM;
-                goto out;
-        }
-
-        obd_str2uuid(uuid, tmpbuf);
-        exp = cfs_hash_lookup(obd->obd_uuid_hash, uuid);
-        if (exp == NULL) {
-                CERROR("%s: no export %s found\n",
-                       obd->obd_name, obd_uuid2str(uuid));
-        } else {
-                mdt_hsm_copytool_send(exp);
-                class_export_put(exp);
-        }
-
-        OBD_FREE(uuid, UUID_MAX);
+       struct obd_device *obd = data;
+       struct obd_export *exp = NULL;
+       struct obd_uuid   *uuid;
+       char              *kbuf;
+       char              *tmpbuf;
+
+       OBD_ALLOC(kbuf, UUID_MAX);
+       if (kbuf == NULL)
+               return -ENOMEM;
+
+       /*
+        * OBD_ALLOC() will zero kbuf, but we only copy UUID_MAX - 1
+        * bytes into kbuf, to ensure that the string is NUL-terminated.
+        * UUID_MAX should include a trailing NUL already.
+        */
+       if (cfs_copy_from_user(kbuf, buffer,
+                              min_t(unsigned long, UUID_MAX - 1, count))) {
+               count = -EFAULT;
+               goto out;
+       }
+       tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, UUID_MAX - 1, count));
+
+       OBD_ALLOC(uuid, UUID_MAX);
+       if (uuid == NULL) {
+               count = -ENOMEM;
+               goto out;
+       }
+
+       obd_str2uuid(uuid, tmpbuf);
+       exp = cfs_hash_lookup(obd->obd_uuid_hash, uuid);
+       if (exp == NULL) {
+               CERROR("%s: no export %s found\n",
+                      obd->obd_name, obd_uuid2str(uuid));
+       } else {
+               mdt_hsm_copytool_send(exp);
+               class_export_put(exp);
+       }
+
+       OBD_FREE(uuid, UUID_MAX);
 out:
 out:
-        OBD_FREE(kbuf, UUID_MAX);
-        return count;
+       OBD_FREE(kbuf, UUID_MAX);
+       return count;
 }
 
 static int lprocfs_rd_enable_remote_dir(char *page, char **start, off_t off,
 }
 
 static int lprocfs_rd_enable_remote_dir(char *page, char **start, off_t off,
index 6396d5c..6e03e69 100644 (file)
@@ -154,7 +154,7 @@ static int mdt_lvbo_fill(struct ldlm_lock *lock, void *lvb, int lvblen)
 
                if (lvblen < rc) {
                        CERROR("%s: expected %d actual %d.\n",
 
                if (lvblen < rc) {
                        CERROR("%s: expected %d actual %d.\n",
-                               info->mti_exp->exp_obd->obd_name, rc, lvblen);
+                               mdt_obd_name(mdt), rc, lvblen);
                        GOTO(out, rc = -ERANGE);
                }
 
                        GOTO(out, rc = -ERANGE);
                }
 
index e1717dd..3359d5e 100644 (file)
@@ -582,10 +582,9 @@ static void mdt_empty_transno(struct mdt_thread_info *info, int rc)
                        struct obd_export *exp = req->rq_export;
 
                        CERROR("%s: replay trans "LPU64" NID %s: rc = %d\n",
                        struct obd_export *exp = req->rq_export;
 
                        CERROR("%s: replay trans "LPU64" NID %s: rc = %d\n",
-                               mdt->mdt_md_dev.md_lu_dev.ld_obd->obd_name,
-                               info->mti_transno,
-                               libcfs_nid2str(exp->exp_connection->c_peer.nid),
-                               rc);
+                              mdt_obd_name(mdt), info->mti_transno,
+                              libcfs_nid2str(exp->exp_connection->c_peer.nid),
+                              rc);
                        RETURN_EXIT;
                }
        } else if (info->mti_transno == 0) {
                        RETURN_EXIT;
                }
        } else if (info->mti_transno == 0) {
@@ -597,18 +596,18 @@ static void mdt_empty_transno(struct mdt_thread_info *info, int rc)
        }
        spin_unlock(&mdt->mdt_lut.lut_translock);
 
        }
        spin_unlock(&mdt->mdt_lut.lut_translock);
 
-        CDEBUG(D_INODE, "transno = "LPU64", last_committed = "LPU64"\n",
-                        info->mti_transno,
-                        req->rq_export->exp_obd->obd_last_committed);
+       CDEBUG(D_INODE, "transno = "LPU64", last_committed = "LPU64"\n",
+              info->mti_transno,
+              req->rq_export->exp_obd->obd_last_committed);
 
 
-        req->rq_transno = info->mti_transno;
-        lustre_msg_set_transno(req->rq_repmsg, info->mti_transno);
+       req->rq_transno = info->mti_transno;
+       lustre_msg_set_transno(req->rq_repmsg, info->mti_transno);
 
 
-        /* update lcd in memory only for resent cases */
-        ted = &req->rq_export->exp_target_data;
-        LASSERT(ted);
+       /* update lcd in memory only for resent cases */
+       ted = &req->rq_export->exp_target_data;
+       LASSERT(ted);
        mutex_lock(&ted->ted_lcd_lock);
        mutex_lock(&ted->ted_lcd_lock);
-        lcd = ted->ted_lcd;
+       lcd = ted->ted_lcd;
        if (info->mti_transno < lcd->lcd_last_transno &&
            info->mti_transno != 0) {
                /* This should happen during replay. Do not update
        if (info->mti_transno < lcd->lcd_last_transno &&
            info->mti_transno != 0) {
                /* This should happen during replay. Do not update
@@ -617,8 +616,8 @@ static void mdt_empty_transno(struct mdt_thread_info *info, int rc)
                 * be checked correctly by xid */
                mutex_unlock(&ted->ted_lcd_lock);
                CDEBUG(D_HA, "%s: transno = "LPU64" < last_transno = "LPU64"\n",
                 * be checked correctly by xid */
                mutex_unlock(&ted->ted_lcd_lock);
                CDEBUG(D_HA, "%s: transno = "LPU64" < last_transno = "LPU64"\n",
-                       mdt->mdt_md_dev.md_lu_dev.ld_obd->obd_name,
-                       info->mti_transno, lcd->lcd_last_transno);
+                      mdt_obd_name(mdt), info->mti_transno,
+                      lcd->lcd_last_transno);
                RETURN_EXIT;
        }
 
                RETURN_EXIT;
        }
 
@@ -1301,7 +1300,7 @@ int mdt_open_by_fid_lock(struct mdt_thread_info *info, struct ldlm_reply *rep,
 
        if (mdt_object_remote(o)) {
                CDEBUG(D_INFO, "%s: "DFID" is on remote MDT.\n",
 
        if (mdt_object_remote(o)) {
                CDEBUG(D_INFO, "%s: "DFID" is on remote MDT.\n",
-                      info->mti_mdt->mdt_md_dev.md_lu_dev.ld_obd->obd_name,
+                      mdt_obd_name(info->mti_mdt),
                       PFID(rr->rr_fid2));
                GOTO(out, rc = -EREMOTE);
        } else if (!mdt_object_exists(o)) {
                       PFID(rr->rr_fid2));
                GOTO(out, rc = -EREMOTE);
        } else if (!mdt_object_exists(o)) {
index 9102eaa..88de204 100644 (file)
@@ -194,10 +194,10 @@ static int mdt_server_data_init(const struct lu_env *env,
         CLASSERT(offsetof(struct lsd_client_data, lcd_padding) +
                 sizeof(lcd->lcd_padding) == LR_CLIENT_SIZE);
 
         CLASSERT(offsetof(struct lsd_client_data, lcd_padding) +
                 sizeof(lcd->lcd_padding) == LR_CLIENT_SIZE);
 
-       rc = server_name2index(obd->obd_name, &index, NULL);
+       rc = server_name2index(mdt_obd_name(mdt), &index, NULL);
        if (rc < 0) {
                CERROR("%s: Can not get index from obd_name: rc = %d\n",
        if (rc < 0) {
                CERROR("%s: Can not get index from obd_name: rc = %d\n",
-                      obd->obd_name, rc);
+                      mdt_obd_name(mdt), rc);
                RETURN(rc);
        }
 
                RETURN(rc);
        }
 
@@ -210,105 +210,106 @@ static int mdt_server_data_init(const struct lu_env *env,
         if (rc)
                 RETURN(rc);
 
         if (rc)
                 RETURN(rc);
 
-        last_rcvd_size = (unsigned long)la->la_size;
-
-        if (last_rcvd_size == 0) {
-                LCONSOLE_WARN("%s: new disk, initializing\n", obd->obd_name);
-
-                memcpy(lsd->lsd_uuid, obd->obd_uuid.uuid,
-                       sizeof(lsd->lsd_uuid));
-                lsd->lsd_last_transno = 0;
-                lsd->lsd_mount_count = 0;
-                lsd->lsd_server_size = LR_SERVER_SIZE;
-                lsd->lsd_client_start = LR_CLIENT_START;
-                lsd->lsd_client_size = LR_CLIENT_SIZE;
-                lsd->lsd_feature_compat = OBD_COMPAT_MDT;
-                lsd->lsd_feature_rocompat = OBD_ROCOMPAT_LOVOBJID;
+       last_rcvd_size = (unsigned long)la->la_size;
+
+       if (last_rcvd_size == 0) {
+               LCONSOLE_WARN("%s: new disk, initializing\n",
+                             mdt_obd_name(mdt));
+
+               memcpy(lsd->lsd_uuid, obd->obd_uuid.uuid,
+                      sizeof(lsd->lsd_uuid));
+               lsd->lsd_last_transno = 0;
+               lsd->lsd_mount_count = 0;
+               lsd->lsd_server_size = LR_SERVER_SIZE;
+               lsd->lsd_client_start = LR_CLIENT_START;
+               lsd->lsd_client_size = LR_CLIENT_SIZE;
+               lsd->lsd_feature_compat = OBD_COMPAT_MDT;
+               lsd->lsd_feature_rocompat = OBD_ROCOMPAT_LOVOBJID;
                lsd->lsd_feature_incompat = OBD_INCOMPAT_MDT |
                                            OBD_INCOMPAT_COMMON_LR |
                                            OBD_INCOMPAT_MULTI_OI;
                lsd->lsd_osd_index = index;
        } else {
                lsd->lsd_feature_incompat = OBD_INCOMPAT_MDT |
                                            OBD_INCOMPAT_COMMON_LR |
                                            OBD_INCOMPAT_MULTI_OI;
                lsd->lsd_osd_index = index;
        } else {
-               LCONSOLE_WARN("%s: used disk, loading\n", obd->obd_name);
+               LCONSOLE_WARN("%s: used disk, loading\n", mdt_obd_name(mdt));
                rc = tgt_server_data_read(env, &mdt->mdt_lut);
                rc = tgt_server_data_read(env, &mdt->mdt_lut);
-                if (rc) {
-                        CERROR("error reading MDS %s: rc %d\n", LAST_RCVD, rc);
-                        GOTO(out, rc);
-                }
-                if (strcmp(lsd->lsd_uuid, obd->obd_uuid.uuid) != 0) {
-                        LCONSOLE_ERROR_MSG(0x157, "Trying to start OBD %s using"
-                                           "the wrong disk %s. Were the /dev/ "
-                                           "assignments rearranged?\n",
-                                           obd->obd_uuid.uuid, lsd->lsd_uuid);
-                        GOTO(out, rc = -EINVAL);
-                }
-                lsd->lsd_feature_compat |= OBD_COMPAT_MDT;
-                lsd->lsd_feature_incompat |= OBD_INCOMPAT_MDT |
-                                             OBD_INCOMPAT_COMMON_LR;
+               if (rc) {
+                       CERROR("error reading MDS %s: rc %d\n", LAST_RCVD, rc);
+                       GOTO(out, rc);
+               }
+               if (strcmp(lsd->lsd_uuid, obd->obd_uuid.uuid) != 0) {
+                       LCONSOLE_ERROR_MSG(0x157, "Trying to start OBD %s using"
+                                          "the wrong disk %s. Were the /dev/ "
+                                          "assignments rearranged?\n",
+                                          obd->obd_uuid.uuid, lsd->lsd_uuid);
+                       GOTO(out, rc = -EINVAL);
+               }
+               lsd->lsd_feature_compat |= OBD_COMPAT_MDT;
+               lsd->lsd_feature_incompat |= OBD_INCOMPAT_MDT |
+                                               OBD_INCOMPAT_COMMON_LR;
                if (lsd->lsd_osd_index != index) {
                        LCONSOLE_ERROR_MSG(0x157, "%s: index %d in last rcvd is"
                                           "different with the index %d in"
                                           "config log, It might be disk"
                if (lsd->lsd_osd_index != index) {
                        LCONSOLE_ERROR_MSG(0x157, "%s: index %d in last rcvd is"
                                           "different with the index %d in"
                                           "config log, It might be disk"
-                                          "corruption!\n", obd->obd_name,
+                                          "corruption!\n", mdt_obd_name(mdt),
                                           lsd->lsd_osd_index, index);
                        GOTO(out, rc = -EINVAL);
                }
        }
                                           lsd->lsd_osd_index, index);
                        GOTO(out, rc = -EINVAL);
                }
        }
-        mount_count = lsd->lsd_mount_count;
+       mount_count = lsd->lsd_mount_count;
 
 
-        if (lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP) {
-                CERROR("%s: unsupported incompat filesystem feature(s) %x\n",
-                       obd->obd_name,
-                       lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP);
-                GOTO(out, rc = -EINVAL);
-        }
-        if (lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP) {
-                CERROR("%s: unsupported read-only filesystem feature(s) %x\n",
-                       obd->obd_name,
-                       lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP);
-                /* XXX: Do something like remount filesystem read-only */
-                GOTO(out, rc = -EINVAL);
-        }
-        /** Interop: evict all clients at first boot with 1.8 last_rcvd */
-        if (!(lsd->lsd_feature_compat & OBD_COMPAT_20)) {
-                if (last_rcvd_size > lsd->lsd_client_start) {
-                        LCONSOLE_WARN("Mounting %s at first time on 1.8 FS, "
-                                      "remove all clients for interop needs\n",
-                                      obd->obd_name);
+       if (lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP) {
+               CERROR("%s: unsupported incompat filesystem feature(s) %x\n",
+                      mdt_obd_name(mdt),
+                      lsd->lsd_feature_incompat & ~MDT_INCOMPAT_SUPP);
+               GOTO(out, rc = -EINVAL);
+       }
+       if (lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP) {
+               CERROR("%s: unsupported read-only filesystem feature(s) %x\n",
+                      mdt_obd_name(mdt),
+                      lsd->lsd_feature_rocompat & ~MDT_ROCOMPAT_SUPP);
+               /* XXX: Do something like remount filesystem read-only */
+               GOTO(out, rc = -EINVAL);
+       }
+       /** Interop: evict all clients at first boot with 1.8 last_rcvd */
+       if (!(lsd->lsd_feature_compat & OBD_COMPAT_20)) {
+               if (last_rcvd_size > lsd->lsd_client_start) {
+                       LCONSOLE_WARN("Mounting %s at first time on 1.8 FS, "
+                                     "remove all clients for interop needs\n",
+                                     mdt_obd_name(mdt));
                        rc = tgt_truncate_last_rcvd(env, &mdt->mdt_lut,
                                                    lsd->lsd_client_start);
                        if (rc)
                                GOTO(out, rc);
                        rc = tgt_truncate_last_rcvd(env, &mdt->mdt_lut,
                                                    lsd->lsd_client_start);
                        if (rc)
                                GOTO(out, rc);
-                        last_rcvd_size = lsd->lsd_client_start;
-                }
-                /** set 2.0 flag to upgrade/downgrade between 1.8 and 2.0 */
-                lsd->lsd_feature_compat |= OBD_COMPAT_20;
-        }
+                       last_rcvd_size = lsd->lsd_client_start;
+               }
+               /** set 2.0 flag to upgrade/downgrade between 1.8 and 2.0 */
+               lsd->lsd_feature_compat |= OBD_COMPAT_20;
+       }
 
 
-        lsd->lsd_feature_incompat |= OBD_INCOMPAT_FID;
+       lsd->lsd_feature_incompat |= OBD_INCOMPAT_FID;
 
        spin_lock(&mdt->mdt_lut.lut_translock);
        mdt->mdt_lut.lut_last_transno = lsd->lsd_last_transno;
        spin_unlock(&mdt->mdt_lut.lut_translock);
 
 
        spin_lock(&mdt->mdt_lut.lut_translock);
        mdt->mdt_lut.lut_last_transno = lsd->lsd_last_transno;
        spin_unlock(&mdt->mdt_lut.lut_translock);
 
-        CDEBUG(D_INODE, "========BEGIN DUMPING LAST_RCVD========\n");
-        CDEBUG(D_INODE, "%s: server last_transno: "LPU64"\n",
-               obd->obd_name, mdt->mdt_lut.lut_last_transno);
-        CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
-               obd->obd_name, mount_count + 1);
-        CDEBUG(D_INODE, "%s: server data size: %u\n",
-               obd->obd_name, lsd->lsd_server_size);
-        CDEBUG(D_INODE, "%s: per-client data start: %u\n",
-               obd->obd_name, lsd->lsd_client_start);
-        CDEBUG(D_INODE, "%s: per-client data size: %u\n",
-               obd->obd_name, lsd->lsd_client_size);
-        CDEBUG(D_INODE, "%s: last_rcvd size: %lu\n",
-               obd->obd_name, last_rcvd_size);
-        CDEBUG(D_INODE, "%s: last_rcvd clients: %lu\n", obd->obd_name,
-               last_rcvd_size <= lsd->lsd_client_start ? 0 :
-               (last_rcvd_size - lsd->lsd_client_start) /
-                lsd->lsd_client_size);
-        CDEBUG(D_INODE, "========END DUMPING LAST_RCVD========\n");
+       CDEBUG(D_INODE, "=======,=BEGIN DUMPING LAST_RCVD========\n");
+       CDEBUG(D_INODE, "%s: server last_transno: "LPU64"\n",
+              mdt_obd_name(mdt), mdt->mdt_lut.lut_last_transno);
+       CDEBUG(D_INODE, "%s: server mount_count: "LPU64"\n",
+              mdt_obd_name(mdt), mount_count + 1);
+       CDEBUG(D_INODE, "%s: server data size: %u\n",
+              mdt_obd_name(mdt), lsd->lsd_server_size);
+       CDEBUG(D_INODE, "%s: per-client data start: %u\n",
+              mdt_obd_name(mdt), lsd->lsd_client_start);
+       CDEBUG(D_INODE, "%s: per-client data size: %u\n",
+              mdt_obd_name(mdt), lsd->lsd_client_size);
+       CDEBUG(D_INODE, "%s: last_rcvd size: %lu\n",
+              mdt_obd_name(mdt), last_rcvd_size);
+       CDEBUG(D_INODE, "%s: last_rcvd clients: %lu\n", mdt_obd_name(mdt),
+              last_rcvd_size <= lsd->lsd_client_start ? 0 :
+              (last_rcvd_size - lsd->lsd_client_start) /
+               lsd->lsd_client_size);
+       CDEBUG(D_INODE, "========END DUMPING LAST_RCVD========\n");
 
         if (!lsd->lsd_server_size || !lsd->lsd_client_start ||
             !lsd->lsd_client_size) {
 
         if (!lsd->lsd_server_size || !lsd->lsd_client_start ||
             !lsd->lsd_client_size) {
@@ -457,7 +458,7 @@ static int mdt_last_rcvd_update(struct mdt_thread_info *mti,
                        err = tgt_server_data_write(mti->mti_env, tg, th);
        } else if (off <= 0) {
                CERROR("%s: client idx %d has offset %lld\n",
                        err = tgt_server_data_write(mti->mti_env, tg, th);
        } else if (off <= 0) {
                CERROR("%s: client idx %d has offset %lld\n",
-                      mdt2obd_dev(mdt)->obd_name, ted->ted_lr_idx, off);
+                      mdt_obd_name(mdt), ted->ted_lr_idx, off);
                mutex_unlock(&ted->ted_lcd_lock);
                err = -EINVAL;
        } else {
                mutex_unlock(&ted->ted_lcd_lock);
                err = -EINVAL;
        } else {
index 38bd0ad..f7d7407 100644 (file)
@@ -318,8 +318,7 @@ static int mdt_md_create(struct mdt_thread_info *info)
                                               " permitted for administrator or"
                                               " set mdt_enable_remote_dir_gid:"
                                               " rc = %d\n",
                                               " permitted for administrator or"
                                               " set mdt_enable_remote_dir_gid:"
                                               " rc = %d\n",
-                                               mdt2obd_dev(mdt)->obd_name,
-                                               -EPERM);
+                                               mdt_obd_name(mdt), -EPERM);
                                        GOTO(out_put_child, rc = -EPERM);
                                }
                        }
                                        GOTO(out_put_child, rc = -EPERM);
                                }
                        }
@@ -330,7 +329,7 @@ static int mdt_md_create(struct mdt_thread_info *info)
                                CERROR("%s: remote dir is only permitted on"
                                       " MDT0 or set_param"
                                       " mdt.*.enable_remote_dir=1\n",
                                CERROR("%s: remote dir is only permitted on"
                                       " MDT0 or set_param"
                                       " mdt.*.enable_remote_dir=1\n",
-                                      mdt2obd_dev(mdt)->obd_name);
+                                      mdt_obd_name(mdt));
                                GOTO(out_put_child, rc = -EPERM);
                        }
                        if (!mdt_is_dne_client(mdt_info_req(info)->rq_export)) {
                                GOTO(out_put_child, rc = -EPERM);
                        }
                        if (!mdt_is_dne_client(mdt_info_req(info)->rq_export)) {
@@ -654,7 +653,7 @@ static int mdt_reint_create(struct mdt_thread_info *info,
                break;
        default:
                CERROR("%s: Unsupported mode %o\n",
                break;
        default:
                CERROR("%s: Unsupported mode %o\n",
-                      mdt2obd_dev(info->mti_mdt)->obd_name,
+                      mdt_obd_name(info->mti_mdt),
                       info->mti_attr.ma_attr.la_mode);
                RETURN(err_serious(-EOPNOTSUPP));
        }
                       info->mti_attr.ma_attr.la_mode);
                RETURN(err_serious(-EOPNOTSUPP));
        }
@@ -772,12 +771,12 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
 
                if (!fid_is_zero(rr->rr_fid2)) {
                        CDEBUG(D_INFO, "%s: name %s can not find "DFID"\n",
 
                if (!fid_is_zero(rr->rr_fid2)) {
                        CDEBUG(D_INFO, "%s: name %s can not find "DFID"\n",
-                              mdt2obd_dev(info->mti_mdt)->obd_name,
+                              mdt_obd_name(info->mti_mdt),
                               (char *)rr->rr_name, PFID(mdt_object_fid(mc)));
                        GOTO(put_child, rc = -ENOENT);
                }
                CDEBUG(D_INFO, "%s: name %s: "DFID" is another MDT\n",
                               (char *)rr->rr_name, PFID(mdt_object_fid(mc)));
                        GOTO(put_child, rc = -ENOENT);
                }
                CDEBUG(D_INFO, "%s: name %s: "DFID" is another MDT\n",
-                      mdt2obd_dev(info->mti_mdt)->obd_name,
+                      mdt_obd_name(info->mti_mdt),
                       (char *)rr->rr_name, PFID(mdt_object_fid(mc)));
 
                if (!mdt_is_dne_client(req->rq_export))
                       (char *)rr->rr_name, PFID(mdt_object_fid(mc)));
 
                if (!mdt_is_dne_client(req->rq_export))
@@ -790,7 +789,7 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
                        if (!md_capable(uc, CFS_CAP_SYS_ADMIN)) {
                                CERROR("%s: unlink remote entry is only "
                                       "permitted for administrator: rc = %d\n",
                        if (!md_capable(uc, CFS_CAP_SYS_ADMIN)) {
                                CERROR("%s: unlink remote entry is only "
                                       "permitted for administrator: rc = %d\n",
-                                       mdt2obd_dev(info->mti_mdt)->obd_name,
+                                       mdt_obd_name(info->mti_mdt),
                                        -EPERM);
                                GOTO(put_child, rc = -EPERM);
                        }
                                        -EPERM);
                                GOTO(put_child, rc = -EPERM);
                        }
@@ -816,7 +815,7 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
                GOTO(unlock_child, rc = -EREMOTE);
        } else if (info->mti_spec.sp_rm_entry) {
                CERROR("%s: lfs rmdir should not be used on local dir %s\n",
                GOTO(unlock_child, rc = -EREMOTE);
        } else if (info->mti_spec.sp_rm_entry) {
                CERROR("%s: lfs rmdir should not be used on local dir %s\n",
-                      mdt2obd_dev(info->mti_mdt)->obd_name,
+                      mdt_obd_name(info->mti_mdt),
                       (char *)rr->rr_name);
                GOTO(put_child, rc = -EPERM);
        }
                       (char *)rr->rr_name);
                GOTO(put_child, rc = -EPERM);
        }
index 6164810..a2cd10c 100644 (file)
@@ -354,15 +354,15 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
         if (rc)
                 GOTO(out_unlock, rc);
 
         if (rc)
                 GOTO(out_unlock, rc);
 
-        if (unlikely(!(valid & OBD_MD_FLCTIME))) {
-                /* This isn't strictly an error, but all current clients
-                 * should set OBD_MD_FLCTIME when setting attributes. */
-                CWARN("%s: client miss to set OBD_MD_FLCTIME when "
-                      "setxattr %s: [object "DFID"] [valid "LPU64"]\n",
-                      info->mti_exp->exp_obd->obd_name, xattr_name,
-                      PFID(rr->rr_fid1), valid);
-                attr->la_ctime = cfs_time_current_sec();
-        }
+       if (unlikely(!(valid & OBD_MD_FLCTIME))) {
+               /* This isn't strictly an error, but all current clients
+                * should set OBD_MD_FLCTIME when setting attributes. */
+               CWARN("%s: client miss to set OBD_MD_FLCTIME when "
+                     "setxattr %s: [object "DFID"] [valid "LPU64"]\n",
+                     mdt_obd_name(info->mti_mdt), xattr_name,
+                     PFID(rr->rr_fid1), valid);
+               attr->la_ctime = cfs_time_current_sec();
+       }
         attr->la_valid = LA_CTIME;
         child = mdt_object_child(obj);
         if (valid & OBD_MD_FLXATTR) {
         attr->la_valid = LA_CTIME;
         child = mdt_object_child(obj);
         if (valid & OBD_MD_FLXATTR) {