Whamcloud - gitweb
LU-3149 llog: separate named and unnamed llog sequences
authorMikhail Pershin <mike.pershin@intel.com>
Mon, 15 Apr 2013 02:57:25 +0000 (06:57 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 20 Apr 2013 16:40:44 +0000 (12:40 -0400)
unnamed llogs are placed in O/seq/d<n> like OST objects,
that adds them to the namesapace. At the same time named llogs
don't need that. Patch introduces new sequence for named llogs
FID_SEQ_LLOG_NAME, so they can be distinguished and not placed
into O/seq/d..
This allows to remove technical debts code releated to the
named llogs handling.

Signed-off-by: Mikhail Pershin <mike.pershin@intel.com>
Change-Id: I5e6edbf02ae0c34ed616833530957ba4afc40f97
Reviewed-on: http://review.whamcloud.com/6053
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
lustre/include/lustre/lustre_idl.h
lustre/obdclass/llog_osd.c
lustre/obdclass/local_storage.c
lustre/tests/conf-sanity.sh

index 176b747..12956bb 100644 (file)
@@ -425,10 +425,11 @@ static inline obd_id fid_ver_oid(const struct lu_fid *fid)
  */
 enum fid_seq {
        FID_SEQ_OST_MDT0        = 0,
-       FID_SEQ_LLOG            = 1,
+       FID_SEQ_LLOG            = 1, /* unnamed llogs */
        FID_SEQ_ECHO            = 2,
        FID_SEQ_OST_MDT1        = 3,
        FID_SEQ_OST_MAX         = 9, /* Max MDT count before OST_on_FID */
+       FID_SEQ_LLOG_NAME       = 10, /* named llogs */
        FID_SEQ_RSVD            = 11,
        FID_SEQ_IGIF            = 12,
        FID_SEQ_IGIF_MAX        = 0x0ffffffffULL,
@@ -500,7 +501,8 @@ static inline int fid_seq_is_llog(obd_seq seq)
 
 static inline int fid_is_llog(const struct lu_fid *fid)
 {
-       return fid_seq_is_llog(fid_seq(fid));
+       /* file with OID == 1 is not llog but contains last oid */
+       return fid_seq_is_llog(fid_seq(fid)) && fid_oid(fid) > 1;
 }
 
 static inline int fid_seq_is_rsvd(const __u64 seq)
index 75f558a..d91ca75 100644 (file)
@@ -812,7 +812,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle,
                RETURN(PTR_ERR(ls));
 
        mutex_lock(&ls->ls_los_mutex);
-       los = dt_los_find(ls, FID_SEQ_LLOG);
+       los = dt_los_find(ls, name != NULL ? FID_SEQ_LLOG_NAME : FID_SEQ_LLOG);
        mutex_unlock(&ls->ls_los_mutex);
        LASSERT(los);
        ls_device_put(env, ls);
@@ -918,7 +918,6 @@ static int llog_osd_declare_create(const struct lu_env *env,
                llog_dir = llog_osd_dir_get(env, res->lgh_ctxt);
                if (IS_ERR(llog_dir))
                        RETURN(PTR_ERR(llog_dir));
-               dt_declare_ref_add(env, o, th);
                logid_to_fid(&res->lgh_id, &lgi->lgi_fid);
                rc = dt_declare_insert(env, llog_dir,
                                       (struct dt_rec *)&lgi->lgi_fid,
@@ -960,8 +959,7 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res,
                rc = llog_osd_create_new_object(env, los, o, th);
        else
                rc = -EEXIST;
-       if (res->lgh_name)
-               dt_ref_add(env, o, th);
+
        dt_write_unlock(env, o);
        if (rc)
                RETURN(rc);
@@ -1013,7 +1011,6 @@ static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle)
 static int llog_osd_destroy(const struct lu_env *env,
                            struct llog_handle *loghandle)
 {
-       struct llog_thread_info *lgi = llog_info(env);
        struct llog_ctxt        *ctxt;
        struct dt_object        *o, *llog_dir = NULL;
        struct dt_device        *d;
@@ -1042,7 +1039,6 @@ static int llog_osd_destroy(const struct lu_env *env,
                if (IS_ERR(llog_dir))
                        GOTO(out_trans, rc = PTR_ERR(llog_dir));
 
-               dt_declare_ref_del(env, o, th);
                name = loghandle->lgh_name;
                rc = dt_declare_delete(env, llog_dir,
                                       (struct dt_key *)name, th);
@@ -1063,7 +1059,6 @@ static int llog_osd_destroy(const struct lu_env *env,
        dt_write_lock(env, o, 0);
        if (dt_object_exists(o)) {
                if (name) {
-                       dt_ref_del(env, o, th);
                        dt_read_lock(env, llog_dir, 0);
                        rc = dt_delete(env, llog_dir,
                                       (struct dt_key *) name,
@@ -1076,18 +1071,7 @@ static int llog_osd_destroy(const struct lu_env *env,
                                GOTO(out_unlock, rc);
                        }
                }
-               /*
-                * XXX: compatibility bits
-                *      on old filesystems llogs are referenced by the name
-                *      on the new ones they are referenced by OI and by
-                *      the name
-                */
-               rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL);
-               if (rc)
-                       GOTO(out_unlock, rc);
-               LASSERT(lgi->lgi_attr.la_nlink < 2);
-               if (lgi->lgi_attr.la_nlink == 1)
-                       dt_ref_del(env, o, th);
+               dt_ref_del(env, o, th);
                rc = dt_destroy(env, o, th);
                if (rc)
                        GOTO(out_unlock, rc);
@@ -1125,6 +1109,14 @@ static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd,
        lgi->lgi_fid.f_ver = 0;
        rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
                                    &lgi->lgi_fid, &los);
+       if (rc < 0)
+               return rc;
+
+       lgi->lgi_fid.f_seq = FID_SEQ_LLOG_NAME;
+       lgi->lgi_fid.f_oid = 1;
+       lgi->lgi_fid.f_ver = 0;
+       rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
+                                   &lgi->lgi_fid, &los);
        llog_ctxt_put(ctxt);
        return rc;
 }
@@ -1133,7 +1125,7 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 {
        struct dt_device                *dt;
        struct ls_device                *ls;
-       struct local_oid_storage        *los;
+       struct local_oid_storage        *los, *nlos;
 
        LASSERT(ctxt->loc_exp->exp_obd);
        dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
@@ -1143,11 +1135,16 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
 
        mutex_lock(&ls->ls_los_mutex);
        los = dt_los_find(ls, FID_SEQ_LLOG);
+       nlos = dt_los_find(ls, FID_SEQ_LLOG_NAME);
        mutex_unlock(&ls->ls_los_mutex);
        if (los != NULL) {
                dt_los_put(los);
                local_oid_storage_fini(env, los);
        }
+       if (nlos != NULL) {
+               dt_los_put(nlos);
+               local_oid_storage_fini(env, nlos);
+       }
        ls_device_put(env, ls);
        return 0;
 }
index aefcb8e..80d0439 100644 (file)
@@ -783,22 +783,12 @@ int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev,
                rc = dt_record_write(env, o, &dti->dti_lb, &dti->dti_off, th);
                if (rc)
                        GOTO(out_lock, rc);
-#if LUSTRE_VERSION_CODE >= OBD_OCD_VERSION(2, 3, 90, 0)
-#error "fix this before release"
-#endif
-               /*
-                * there is one technical debt left in Orion:
-                * proper hanlding of named vs no-name objects.
-                * Llog objects have name always as they are placed in O/d/...
-                */
-               if (fid_seq(&dti->dti_fid) != FID_SEQ_LLOG) {
-                       rc = dt_insert(env, root,
-                                      (const struct dt_rec *)&dti->dti_fid,
-                                      (const struct dt_key *)dti->dti_buf,
-                                      th, BYPASS_CAPA, 1);
-                       if (rc)
-                               GOTO(out_lock, rc);
-               }
+               rc = dt_insert(env, root,
+                              (const struct dt_rec *)&dti->dti_fid,
+                              (const struct dt_key *)dti->dti_buf,
+                              th, BYPASS_CAPA, 1);
+               if (rc)
+                       GOTO(out_lock, rc);
 out_lock:
                dt_write_unlock(env, o);
                dt_write_unlock(env, root);
index e346b52..9ebe087 100644 (file)
@@ -3388,14 +3388,21 @@ test_58() { # bug 22658
        createmany -o $DIR/$tdir/$tfile-%d 100
        # make sure that OSTs do not cancel llog cookies before we unmount the MDS
 #define OBD_FAIL_OBD_LOG_CANCEL_NET      0x601
-       do_facet mds "lctl set_param fail_loc=0x601"
+       do_facet $SINGLEMDS "lctl set_param fail_loc=0x601"
        unlinkmany $DIR/$tdir/$tfile-%d 100
-       stop mds
-       local MNTDIR=$(facet_mntpt mds)
+       stop_mds
+
+       local MNTDIR=$(facet_mntpt $SINGLEMDS)
+       local devname=$(mdsdevname ${SINGLEMDS//mds/})
+       local opts=""
+       if ! do_facet $SINGLEMDS "test -b $devname"; then
+               opts="-o loop"
+       fi
+
        # remove all files from the OBJECTS dir
-       do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
-       do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
-       do_facet mds "umount $MNTDIR"
+       do_facet $SINGLEMDS "mount -t ldiskfs $opts $devname $MNTDIR"
+       do_facet $SINGLEMDS "find $MNTDIR/O/1/d* -type f -delete"
+       do_facet $SINGLEMDS "umount $MNTDIR"
        # restart MDS with missing llog files
        start_mds
        do_facet mds "lctl set_param fail_loc=0"