Whamcloud - gitweb
LU-1445 ofd: remove ofd_seq_count and add ocd_seq
authorwangdi <di.wang@whamcloud.com>
Tue, 24 Sep 2013 09:47:06 +0000 (02:47 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 12 Jan 2013 04:54:00 +0000 (23:54 -0500)
Remove ofd_seq_count from the disk, so ofd_seq will
not be initialized during setup,  only be created during
connection or reconnection.

Change-Id: I6dad9aa960897f46afb0a5ea96d8330a227f36e4
Signed-off-by: Wang Di <di.wang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/4325
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/include/lustre_fid.h
lustre/ofd/ofd_fs.c
lustre/ofd/ofd_internal.h
lustre/ofd/ofd_obd.c

index 4efa9ed..23af14f 100644 (file)
@@ -268,8 +268,7 @@ static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq)
                fid->f_seq = fid_idif_seq(0, 0);
        } else {
                LASSERTF(fid_seq_is_norm(seq) || fid_seq_is_echo(seq) ||
-                        fid_seq_is_llog(seq) || fid_seq_is_idif(seq),
-                        LPX64"\n", seq);
+                        fid_seq_is_idif(seq), LPX64"\n", seq);
                fid->f_seq = seq;
        }
        fid->f_oid = 0;
index fc720e7..cdfd40f 100644 (file)
@@ -142,6 +142,7 @@ static struct ofd_seq *ofd_seq_add(const struct lu_env *env,
        }
        cfs_atomic_inc(&new_seq->os_refc);
        cfs_list_add_tail(&new_seq->os_list, &ofd->ofd_seq_list);
+       ofd->ofd_seq_count++;
        write_unlock(&ofd->ofd_seq_list_lock);
        return new_seq;
 }
@@ -188,26 +189,6 @@ int ofd_seq_last_oid_write(const struct lu_env *env, struct ofd_device *ofd,
        RETURN(rc);
 }
 
-static int ofd_seq_count_write(const struct lu_env *env, struct ofd_device *ofd)
-{
-       struct ofd_thread_info  *info = ofd_info(env);
-       obd_seq                  tmp;
-       int                      rc;
-
-       ENTRY;
-
-       info->fti_buf.lb_buf = &tmp;
-       info->fti_buf.lb_len = sizeof(tmp);
-       info->fti_off = 0;
-
-       tmp = cpu_to_le32(ofd->ofd_seq_count);
-
-       rc = ofd_record_write(env, ofd, ofd->ofd_seq_count_file,
-                             &info->fti_buf, &info->fti_off);
-
-       RETURN(rc);
-}
-
 void ofd_seqs_fini(const struct lu_env *env, struct ofd_device *ofd)
 {
        struct ofd_seq  *oseq;
@@ -282,7 +263,6 @@ struct ofd_seq *ofd_seq_load(const struct lu_env *env, struct ofd_device *ofd,
                /* object is just created, initialize last id */
                oseq->os_last_oid = OFD_INIT_OBJID;
                ofd_seq_last_oid_write(env, ofd, oseq);
-               ofd_seq_count_write(env, ofd);
        } else if (info->fti_attr.la_size == sizeof(lastid)) {
                info->fti_off = 0;
                info->fti_buf.lb_buf = &lastid;
@@ -311,65 +291,10 @@ cleanup:
 /* object sequence management */
 int ofd_seqs_init(const struct lu_env *env, struct ofd_device *ofd)
 {
-       struct ofd_thread_info  *info = ofd_info(env);
-       unsigned long           seq_count_size;
-       obd_seq                 seq_count;
-       int                     rc = 0;
-       int                     i;
-
-       ENTRY;
-
        rwlock_init(&ofd->ofd_seq_list_lock);
        CFS_INIT_LIST_HEAD(&ofd->ofd_seq_list);
-
-       rc = dt_attr_get(env, ofd->ofd_seq_count_file,
-                        &info->fti_attr, BYPASS_CAPA);
-       if (rc)
-               GOTO(cleanup, rc);
-
-       seq_count_size = (unsigned long)info->fti_attr.la_size;
-
-       if (seq_count_size == sizeof(seq_count)) {
-               info->fti_off = 0;
-               info->fti_buf.lb_buf = &seq_count;
-               info->fti_buf.lb_len = sizeof(seq_count);
-
-               rc = dt_record_read(env, ofd->ofd_seq_count_file,
-                                   &info->fti_buf, &info->fti_off);
-               if (rc) {
-                       CERROR("%s: can't read LAST_GROUP: rc = %d\n",
-                              ofd_name(ofd), rc);
-                       GOTO(cleanup, rc);
-               }
-
-               ofd->ofd_seq_count = le64_to_cpu(seq_count);
-       } else if (seq_count_size == 0) {
-               ofd->ofd_seq_count = 0;
-       } else {
-               CERROR("%s: seqs file is corrupted? size = %lu\n",
-                      ofd_name(ofd), seq_count_size);
-               GOTO(cleanup, rc = -EIO);
-       }
-
-       for (i = 0; i <= ofd->ofd_seq_count; i++) {
-               struct ofd_seq *oseq;
-
-               oseq = ofd_seq_load(env, ofd, i);
-               if (IS_ERR(oseq)) {
-                       CERROR("%s: can't load seq %d: rc = %d\n",
-                              ofd_name(ofd), i, rc);
-                       /* Clean all previously set seqs */
-                       ofd_seqs_fini(env, ofd);
-                       GOTO(cleanup, rc);
-               } else {
-                       ofd_seq_put(env, oseq);
-               }
-       }
-
-       CDEBUG(D_OTHER, "%s: %u seqs initialized\n", ofd_name(ofd),
-              ofd->ofd_seq_count + 1);
-cleanup:
-       RETURN(rc);
+       ofd->ofd_seq_count = 0;
+       return 0;
 }
 
 int ofd_clients_data_init(const struct lu_env *env, struct ofd_device *ofd,
@@ -608,26 +533,11 @@ int ofd_fs_setup(const struct lu_env *env, struct ofd_device *ofd,
 
        ofd->ofd_health_check_file = fo;
 
-       lu_local_obj_fid(&info->fti_fid, OFD_LAST_GROUP_OID);
-       memset(&info->fti_attr, 0, sizeof(info->fti_attr));
-       info->fti_attr.la_valid = LA_MODE;
-       info->fti_attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR;
-       info->fti_dof.dof_type = dt_mode_to_dft(S_IFREG);
-
-       fo = dt_find_or_create(env, ofd->ofd_osd, &info->fti_fid,
-                              &info->fti_dof, &info->fti_attr);
-       if (IS_ERR(fo))
-               GOTO(out_hc, rc = PTR_ERR(fo));
-
-       ofd->ofd_seq_count_file = fo;
-
        rc = ofd_seqs_init(env, ofd);
        if (rc)
-               GOTO(out_lg, rc);
+               GOTO(out_hc, rc);
 
        RETURN(0);
-out_lg:
-       lu_object_put(env, &ofd->ofd_seq_count_file->do_lu);
 out_hc:
        lu_object_put(env, &ofd->ofd_health_check_file->do_lu);
 out:
@@ -652,11 +562,6 @@ void ofd_fs_cleanup(const struct lu_env *env, struct ofd_device *ofd)
        /* Remove transaction callback */
        dt_txn_callback_del(ofd->ofd_osd, &ofd->ofd_txn_cb);
 
-       if (ofd->ofd_seq_count_file) {
-               lu_object_put(env, &ofd->ofd_seq_count_file->do_lu);
-               ofd->ofd_seq_count_file = NULL;
-       }
-
        if (ofd->ofd_health_check_file) {
                lu_object_put(env, &ofd->ofd_health_check_file->do_lu);
                ofd->ofd_health_check_file = NULL;
index 5617008..128bcfc 100644 (file)
@@ -129,7 +129,6 @@ struct ofd_device {
 
        /* last_rcvd file */
        struct lu_target         ofd_lut;
-       struct dt_object        *ofd_seq_count_file;
        struct dt_object        *ofd_health_check_file;
 
        int                      ofd_subdir_count;
index af49a50..82f5492 100644 (file)
@@ -274,7 +274,6 @@ static int ofd_obd_connect(const struct lu_env *env, struct obd_export **_exp,
        struct ofd_device       *ofd;
        struct lustre_handle     conn = { 0 };
        int                      rc;
-       obd_seq                 seq;
        ENTRY;
 
        if (_exp == NULL || obd == NULL || cluuid == NULL)
@@ -301,7 +300,6 @@ static int ofd_obd_connect(const struct lu_env *env, struct obd_export **_exp,
        if (rc)
                GOTO(out, rc);
 
-       seq = data->ocd_group;
        if (obd->obd_replayable) {
                struct tg_export_data *ted = &exp->exp_target_data;
 
@@ -312,23 +310,9 @@ static int ofd_obd_connect(const struct lu_env *env, struct obd_export **_exp,
                        GOTO(out, rc);
                ofd_export_stats_init(ofd, exp, localdata);
        }
-       if (seq == 0)
-               GOTO(out, rc = 0);
 
-       /* init new seq */
-       if (seq > ofd->ofd_seq_count) {
-               struct ofd_seq *oseq;
-
-               ofd->ofd_seq_count = seq;
-               oseq = ofd_seq_load(env, ofd, seq);
-               if (IS_ERR(oseq)) {
-                       CERROR("%s: load oseq "LPX64" error: rc = %ld\n",
-                              ofd_name(ofd), oseq->os_seq, PTR_ERR(oseq));
-                       GOTO(out, rc = PTR_ERR(oseq));
-               } else {
-                       ofd_seq_put(env, oseq);
-               }
-       }
+       CDEBUG(D_HA, "%s: get connection from MDS %d\n", obd->obd_name,
+              data->ocd_group);
 
 out:
        if (rc != 0) {
@@ -570,7 +554,13 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp,
                obd_id *last_id = val;
                struct ofd_seq *oseq;
 
-               oseq = ofd_seq_get(ofd, exp->exp_filter_data.fed_group);
+               if (val == NULL) {
+                       *vallen = sizeof(obd_id);
+                       RETURN(0);
+               }
+               ofd_info_init(env, exp);
+               oseq = ofd_seq_load(env, ofd,
+                                   (obd_seq)exp->exp_filter_data.fed_group);
                LASSERT(oseq != NULL);
                if (last_id) {
                        if (*vallen < sizeof(*last_id)) {
@@ -1143,7 +1133,7 @@ int ofd_create(const struct lu_env *env, struct obd_export *exp,
        CDEBUG(D_INFO, "ofd_create(oa->o_seq="LPU64",oa->o_id="LPU64")\n",
               seq, oa->o_id);
 
-       oseq = ofd_seq_get(ofd, seq);
+       oseq = ofd_seq_load(env, ofd, seq);
        if (oseq == NULL) {
                CERROR("%s: Can't find oseq "LPX64"\n", ofd_name(ofd), seq);
                RETURN(-EINVAL);