Whamcloud - gitweb
LU-1445 osd: replace OFD_GROUP0_LAST_OID with [seq, 0]
authorwangdi <di.wang@whamcloud.com>
Tue, 24 Sep 2013 09:45:31 +0000 (02:45 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 12 Jan 2013 04:52:47 +0000 (23:52 -0500)
Replace OFD_GROUP0_LAST_OID with [seq, 0], so LAST_ID of each
sequence will be identified by [seq,0].

Change-Id: Ieca4eb0cf367e59b6fca044367e4c7e223f79025
Signed-off-by: Wang Di <di.wang@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/4324
Tested-by: Hudson
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
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/lustre_idl.h
lustre/include/lustre_fid.h
lustre/ofd/ofd_fs.c
lustre/osd-ldiskfs/osd_compat.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_oi.c
lustre/osd-zfs/osd_oi.c

index 7807e79..797d2c9 100644 (file)
@@ -466,6 +466,26 @@ static inline int fid_seq_is_mdt(const __u64 seq)
                (seq >= FID_SEQ_OST_MDT1 && seq <= FID_SEQ_OST_MAX);
 };
 
+static inline int fid_seq_is_echo(obd_seq seq)
+{
+       return (seq == FID_SEQ_ECHO);
+}
+
+static inline int fid_is_echo(const struct lu_fid *fid)
+{
+       return fid_seq_is_echo(fid_seq(fid));
+}
+
+static inline int fid_seq_is_llog(obd_seq seq)
+{
+       return (seq == FID_SEQ_LLOG);
+}
+
+static inline int fid_is_llog(const struct lu_fid *fid)
+{
+       return fid_seq_is_llog(fid_seq(fid));
+}
+
 static inline int fid_seq_is_rsvd(const __u64 seq)
 {
         return (seq > FID_SEQ_OST_MDT0 && seq <= FID_SEQ_RSVD);
@@ -679,6 +699,13 @@ static inline obd_id ostid_id(struct ost_id *ostid)
         return ostid->oi_id;
 }
 
+/* Check whether the fid is for LAST_ID */
+static inline int fid_is_last_id(const struct lu_fid *fid)
+{
+       return (fid_is_idif(fid) || fid_is_norm(fid) || fid_is_echo(fid)) &&
+               fid_oid(fid) == 0;
+}
+
 /**
  * Get inode number from a igif.
  * \param fid a igif to get inode number from.
@@ -768,11 +795,10 @@ static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
 
 static inline int fid_is_sane(const struct lu_fid *fid)
 {
-        return
-                fid != NULL &&
-                ((fid_seq(fid) >= FID_SEQ_START && fid_oid(fid) != 0
-                                                && fid_ver(fid) == 0) ||
-                fid_is_igif(fid) || fid_seq_is_rsvd(fid_seq(fid)));
+       return fid != NULL &&
+              ((fid_seq(fid) >= FID_SEQ_START && fid_ver(fid) == 0) ||
+              fid_is_igif(fid) || fid_is_idif(fid) ||
+              fid_seq_is_rsvd(fid_seq(fid)));
 }
 
 static inline int fid_is_zero(const struct lu_fid *fid)
index 78207ca..4efa9ed 100644 (file)
@@ -200,30 +200,32 @@ enum {
 
 /** special OID for local objects */
 enum local_oid {
-        /** \see fld_mod_init */
-        FLD_INDEX_OID           = 3UL,
-        /** \see fid_mod_init */
-        FID_SEQ_CTL_OID         = 4UL,
-        FID_SEQ_SRV_OID         = 5UL,
-        /** \see mdd_mod_init */
-        MDD_ROOT_INDEX_OID      = 6UL,
-        MDD_ORPHAN_OID          = 7UL,
-        MDD_LOV_OBJ_OID         = 8UL,
-        MDD_CAPA_KEYS_OID       = 9UL,
-        /** \see mdt_mod_init */
-        MDT_LAST_RECV_OID       = 11UL,
-        OSD_FS_ROOT_OID         = 13UL,
-        ACCT_USER_OID           = 15UL,
-        ACCT_GROUP_OID          = 16UL,
+       /** \see fld_mod_init */
+       FLD_INDEX_OID           = 3UL,
+       /** \see fid_mod_init */
+       FID_SEQ_CTL_OID         = 4UL,
+       FID_SEQ_SRV_OID         = 5UL,
+       /** \see mdd_mod_init */
+       MDD_ROOT_INDEX_OID      = 6UL,
+       MDD_ORPHAN_OID          = 7UL,
+       MDD_LOV_OBJ_OID         = 8UL,
+       MDD_CAPA_KEYS_OID       = 9UL,
+       /** \see mdt_mod_init */
+       MDT_LAST_RECV_OID       = 11UL,
+       OSD_FS_ROOT_OID         = 13UL,
+       ACCT_USER_OID           = 15UL,
+       ACCT_GROUP_OID          = 16UL,
        LFSCK_BOOKMARK_OID      = 17UL,
        OTABLE_IT_OID           = 18UL,
-        OFD_LAST_RECV_OID       = 19UL,
-        OFD_GROUP0_LAST_OID     = 20UL,
-        OFD_GROUP4K_LAST_OID    = 20UL+4096,
-        OFD_LAST_GROUP_OID      = 4117UL,
-        LLOG_CATALOGS_OID       = 4118UL,
-        MGS_CONFIGS_OID         = 4119UL,
-        OFD_HEALTH_CHECK_OID    = 4120UL,
+       OFD_LAST_RECV_OID       = 19UL,
+       /* These two definitions are obsolete
+        * OFD_GROUP0_LAST_OID     = 20UL,
+        * OFD_GROUP4K_LAST_OID    = 20UL+4096,
+        */
+       OFD_LAST_GROUP_OID      = 4117UL,
+       LLOG_CATALOGS_OID       = 4118UL,
+       MGS_CONFIGS_OID         = 4119UL,
+       OFD_HEALTH_CHECK_OID    = 4120UL,
        MDD_LOV_OBJ_OSEQ        = 4121UL,
 };
 
@@ -260,6 +262,20 @@ static inline int fid_is_quota(const struct lu_fid *fid)
               fid_seq(fid) == FID_SEQ_QUOTA_GLB;
 }
 
+static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq)
+{
+       if (fid_seq_is_mdt0(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->f_seq = seq;
+       }
+       fid->f_oid = 0;
+       fid->f_ver = 0;
+}
+
 enum lu_mgr_type {
         LUSTRE_SEQ_SERVER,
         LUSTRE_SEQ_CONTROLLER
index c022af7..fc720e7 100644 (file)
@@ -250,8 +250,7 @@ struct ofd_seq *ofd_seq_load(const struct lu_env *env, struct ofd_device *ofd,
        if (oseq == NULL)
                RETURN(ERR_PTR(-ENOMEM));
 
-       lu_local_obj_fid(&info->fti_fid, OFD_GROUP0_LAST_OID + seq);
-
+       lu_last_id_fid(&info->fti_fid, seq);
        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;
index 2a79ae1..e1a04db 100644 (file)
@@ -636,9 +636,9 @@ int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd,
        int                     rc = 0;
        ENTRY;
 
-        if (fid_oid(fid) >= OFD_GROUP0_LAST_OID &&
-            fid_oid(fid) < OFD_GROUP4K_LAST_OID) {
+       if (fid_is_last_id(fid)) {
                struct osd_obj_seq      *osd_seq;
+
                /* on creation of LAST_ID we create O/<seq> hierarchy */
                LASSERT(map);
                osd_seq = osd_seq_load(osd, fid_seq(fid));
@@ -667,8 +667,7 @@ int osd_obj_spec_lookup(struct osd_thread_info *info, struct osd_device *osd,
        int            rc = -ENOENT;
        ENTRY;
 
-       if (fid_oid(fid) >= OFD_GROUP0_LAST_OID &&
-           fid_oid(fid) < OFD_GROUP4K_LAST_OID) {
+       if (fid_is_last_id(fid)) {
                struct osd_obj_seq *osd_seq;
 
                osd_seq = osd_seq_load(osd, fid_seq(fid));
index e62af79..bd3f9e3 100644 (file)
@@ -763,6 +763,7 @@ static inline struct osd_oi *osd_fid2oi(struct osd_device *osd,
                                         const struct lu_fid *fid)
 {
        LASSERTF(!fid_is_idif(fid), DFID"\n", PFID(fid));
+       LASSERTF(!fid_is_last_id(fid), DFID"\n", PFID(fid));
        LASSERTF(!fid_is_igif(fid), DFID"\n", PFID(fid));
        LASSERT(osd->od_oi_table != NULL && osd->od_oi_count >= 1);
        /* It can work even od_oi_count equals to 1 although it's unexpected,
index 30d2f54..ef67a79 100644 (file)
@@ -498,29 +498,30 @@ int __osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd,
 }
 
 int osd_oi_lookup(struct osd_thread_info *info, struct osd_device *osd,
-                  const struct lu_fid *fid, struct osd_inode_id *id)
+                 const struct lu_fid *fid, struct osd_inode_id *id)
 {
-        int                  rc = 0;
+       int                  rc = 0;
 
-        if (fid_is_idif(fid) || fid_seq(fid) == FID_SEQ_LLOG) {
-                /* old OSD obj id */
+       if ((fid_is_idif(fid) && !fid_is_last_id(fid)) ||
+            fid_is_llog(fid)) {
+               /* old OSD obj id */
                /* FIXME: actually for all of the OST object */
                rc = osd_obj_map_lookup(info, osd, fid, id);
-        } else if (fid_is_igif(fid)) {
-                lu_igif_to_id(fid, id);
-        } else if (fid_is_fs_root(fid)) {
+       } else if (fid_is_igif(fid)) {
+               lu_igif_to_id(fid, id);
+       } else if (fid_is_fs_root(fid)) {
                osd_id_gen(id, osd_sb(osd)->s_root->d_inode->i_ino,
                           osd_sb(osd)->s_root->d_inode->i_generation);
        } else {
                if (unlikely(fid_is_acct(fid)))
                        return osd_acct_obj_lookup(info, osd, fid, id);
-
-               if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE))
+               else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE) ||
+                        fid_is_last_id(fid))
                        return osd_obj_spec_lookup(info, osd, fid, id);
 
                rc = __osd_oi_lookup(info, osd, fid, id);
-        }
-        return rc;
+       }
+       return rc;
 }
 
 static int osd_oi_iam_insert(struct osd_thread_info *oti, struct osd_oi *oi,
@@ -568,11 +569,13 @@ int osd_oi_insert(struct osd_thread_info *info, struct osd_device *osd,
        if (fid_is_igif(fid) || unlikely(fid_seq(fid) == FID_SEQ_DOT_LUSTRE))
                return 0;
 
-       if (fid_is_idif(fid) || fid_seq(fid) == FID_SEQ_LLOG)
+       if ((fid_is_idif(fid) && !fid_is_last_id(fid)) ||
+            fid_is_llog(fid))
                return osd_obj_map_insert(info, osd, fid, id, th);
 
        /* Server mount should not depends on OI files */
-       if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE))
+       if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE) ||
+           fid_is_last_id(fid))
                return osd_obj_spec_insert(info, osd, fid, id, th);
 
        fid_cpu_to_be(oi_fid, fid);
@@ -616,12 +619,12 @@ int osd_oi_delete(struct osd_thread_info *info,
 {
        struct lu_fid *oi_fid = &info->oti_fid2;
 
-       if (fid_is_igif(fid))
+       if (fid_is_igif(fid) || fid_is_last_id(fid))
                return 0;
 
        LASSERT(fid_seq(fid) != FID_SEQ_LOCAL_FILE);
 
-       if (fid_is_idif(fid) || fid_seq(fid) == FID_SEQ_LLOG)
+       if (fid_is_idif(fid) || fid_is_llog(fid))
                return osd_obj_map_delete(info, osd, fid, th);
 
        fid_cpu_to_be(oi_fid, fid);
index 6f2ab97..e629821 100644 (file)
@@ -100,7 +100,6 @@ static const struct named_oid oids[] = {
        { MDD_LOV_OBJ_OID,              LOV_OBJID },
        { MDT_LAST_RECV_OID,            LAST_RCVD },
        { OFD_HEALTH_CHECK_OID,         HEALTH_CHECK },
-       { OFD_GROUP0_LAST_OID,          "LAST_ID" },
        { ACCT_USER_OID,                "acct_usr_inode" },
        { ACCT_GROUP_OID,               "acct_grp_inode" },
        { MDD_ROOT_INDEX_OID,           NULL },
@@ -177,6 +176,8 @@ uint64_t osd_get_name_n_idx(const struct lu_env *env, struct osd_device *osd,
 
        if (fid_is_idif(fid)) {
                zapid = osd_get_idx_for_ost_obj(env, osd, fid, buf);
+       } else if (fid_is_last_id(fid)) {
+               zapid = osd->od_ost_compat_grp0;
        } else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) {
                /* special objects with fixed known fids get their name */
                char *name = oid2name(fid_oid(fid));
@@ -184,9 +185,7 @@ uint64_t osd_get_name_n_idx(const struct lu_env *env, struct osd_device *osd,
                if (name) {
                        zapid = osd->od_root;
                        strcpy(buf, name);
-                       if (fid_oid(fid) == OFD_GROUP0_LAST_OID)
-                               zapid = osd->od_ost_compat_grp0;
-                       else if (fid_is_acct(fid))
+                       if (fid_is_acct(fid))
                                zapid = MASTER_NODE_OBJ;
                } else {
                        zapid = osd_get_idx_for_fid(osd, fid, buf);