Whamcloud - gitweb
LU-3659 llog: missed dt_try_as_dir() in llog_osd_dir_get() 67/7267/5
authorNiu Yawei <yawei.niu@intel.com>
Thu, 8 Aug 2013 05:02:33 +0000 (01:02 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 26 Aug 2013 15:09:34 +0000 (15:09 +0000)
dt_try_as_dir() should be called in llog_osd_dir_get() to make sure
the do_index_ops being initialized.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I879c47bb59fbd28f3351f61e59cff2a6666e7d7a
Reviewed-on: http://review.whamcloud.com/7267
Tested-by: Hudson
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mgs/mgs_fs.c
lustre/mgs/mgs_llog.c
lustre/obdclass/llog_osd.c

index e621bf0..6d237c4 100644 (file)
@@ -151,6 +151,11 @@ int mgs_fs_setup(const struct lu_env *env, struct mgs_device *mgs)
        if (IS_ERR(o))
                GOTO(out_root, rc = PTR_ERR(o));
 
+       if (!dt_try_as_dir(env, o)) {
+               lu_object_put(env, &o->do_lu);
+               GOTO(out_root, rc = -ENOTDIR);
+       }
+
        mgs->mgs_configs_dir = o;
 
        /* create directory to store nid table versions */
index 6303c4c..ebd4fbc 100644 (file)
@@ -67,9 +67,6 @@ int class_dentry_readdir(const struct lu_env *env,
 
        CFS_INIT_LIST_HEAD(list);
 
-       if (!dt_try_as_dir(env, dir))
-               GOTO(out, rc = -ENOTDIR);
-
        LASSERT(dir);
        LASSERT(dir->do_index_ops);
 
@@ -122,7 +119,6 @@ next:
 
 fini:
        iops->fini(env, it);
-out:
        if (rc)
                CERROR("%s: key failed when listing %s: rc = %d\n",
                       mgs->mgs_obd->obd_name, MOUNT_CONFIGS_DIR, rc);
index de7c0b5..57dcd76 100644 (file)
@@ -774,6 +774,11 @@ struct dt_object *llog_osd_dir_get(const struct lu_env *env,
                if (rc)
                        return ERR_PTR(rc);
                dir = dt_locate(env, dt, &dti->dti_fid);
+
+               if (!IS_ERR(dir) && !dt_try_as_dir(env, dir)) {
+                       lu_object_put(env, &dir->do_lu);
+                       return ERR_PTR(-ENOTDIR);
+               }
        } else {
                lu_object_get(&ctxt->loc_dir->do_lu);
                dir = ctxt->loc_dir;