From 3c9e8962403ab9b70323e2fbd7ca1c2789c79f05 Mon Sep 17 00:00:00 2001 From: huanghua Date: Fri, 6 Jun 2008 02:19:20 +0000 Subject: [PATCH] Branch HEAD b=15552 i=nikita.danilov i=adilger - Igif support for the case when of HEAD based server runs on old disk format --- lustre/fid/fid_lib.c | 18 +++++++++++++----- lustre/fld/fld_request.c | 10 ++++++++++ lustre/include/lustre/lustre_idl.h | 36 ++++++++++++++++++++++++++++-------- lustre/llite/llite_fid.c | 5 +++++ lustre/osd/osd_igif.c | 18 +++--------------- lustre/osd/osd_igif.h | 2 -- 6 files changed, 59 insertions(+), 30 deletions(-) diff --git a/lustre/fid/fid_lib.c b/lustre/fid/fid_lib.c index 59bc8d8..137868b 100644 --- a/lustre/fid/fid_lib.c +++ b/lustre/fid/fid_lib.c @@ -43,13 +43,21 @@ #include #include -/* - * Sequence space, starts from 0x100000000ULL to have first 0x100000000ULL - * sequences used for special purposes. - * Those fids are reserved for special purposes (igifs, etc.). +/** + * A cluster-wide range from which fid-sequences are granted to servers and + * then clients. + * + * Fid namespace: + *
+ * Normal FID:        seq:64 [2^32,2^64-1]      oid:32          ver:32
+ * IGIF      :        0:33, ino:31              gen:32          0:32
+ * IDIF      :        0:32, 1:1, ost-index:15,  objd:48         0:32
+ * 
+ * + * The first 0x400 sequences of normal FID are reserved for special purpose. */ const struct lu_range LUSTRE_SEQ_SPACE_RANGE = { - 0x100000400ULL, + FID_SEQ_START + 0x400ULL, (__u64)~0ULL }; EXPORT_SYMBOL(LUSTRE_SEQ_SPACE_RANGE); diff --git a/lustre/fld/fld_request.c b/lustre/fld/fld_request.c index fce247c..23bbcf6 100644 --- a/lustre/fld/fld_request.c +++ b/lustre/fld/fld_request.c @@ -598,6 +598,16 @@ int fld_client_lookup(struct lu_client_fld *fld, #ifdef __KERNEL__ } #endif + if (seq < FID_SEQ_START) { + /* + * The current solution for IGIF is to bind it to mds0. + * In the future, this should be fixed once IGIF can be found + * in FLD. + */ + md_fld.mf_mds = 0; + rc = 0; + } + if (rc == 0) { *mds = md_fld.mf_mds; diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 6ac913c..977ddcd 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -197,8 +197,6 @@ struct lu_fid { * fid constants */ enum { - LUSTRE_ROOT_FID_SEQ = 1ULL, /* XXX: should go into mkfs. */ - /* initial fid id value */ LUSTRE_FID_INIT_OID = 1UL }; @@ -221,19 +219,41 @@ static inline __u32 fid_ver(const struct lu_fid *fid) return fid->f_ver; } -static inline int fid_seq_is_sane(__u64 seq) -{ - return seq != 0; -} +#define FID_SEQ_START 0x100000000ULL static inline void fid_zero(struct lu_fid *fid) { memset(fid, 0, sizeof(*fid)); } +/** + * Check if a fid is igif or not. + * \param fid the fid to be tested. + * \return true if the fid is a igif; otherwise false. + */ static inline int fid_is_igif(const struct lu_fid *fid) { - return fid_seq(fid) == LUSTRE_ROOT_FID_SEQ; + return fid_seq(fid) > 0 && fid_seq(fid) < FID_SEQ_START; +} + +/** + * Get inode number from a igif. + * \param fid a igif to get inode number from. + * \return inode number for the igif. + */ +static inline ino_t lu_igif_ino(const struct lu_fid *fid) +{ + return fid_seq(fid); +} + +/** + * Get inode generation from a igif. + * \param fid a igif to get inode generation from. + * \return inode generation for the igif. + */ +static inline __u32 lu_igif_gen(const struct lu_fid *fid) +{ + return fid_oid(fid); } #define DFID "[0x%16.16"LPF64"x/0x%8.8x:0x%8.8x]" @@ -314,7 +334,7 @@ static inline int fid_is_sane(const struct lu_fid *fid) { return fid != NULL && - ((fid_seq_is_sane(fid_seq(fid)) && fid_oid(fid) != 0 + ((fid_seq(fid) >= FID_SEQ_START && fid_oid(fid) != 0 && fid_ver(fid) == 0) || fid_is_igif(fid)); } diff --git a/lustre/llite/llite_fid.c b/lustre/llite/llite_fid.c index 0fbd7ac..8a4864c 100644 --- a/lustre/llite/llite_fid.c +++ b/lustre/llite/llite_fid.c @@ -43,6 +43,11 @@ ino_t ll_fid_build_ino(struct ll_sb_info *sbi, ino_t ino; ENTRY; + if (fid_is_igif(fid)) { + ino = lu_igif_ino(fid); + RETURN(ino); + } + /* * Very stupid and having many downsides inode allocation algorithm * based on fid. diff --git a/lustre/osd/osd_igif.c b/lustre/osd/osd_igif.c index 9bf9870..441b906 100644 --- a/lustre/osd/osd_igif.c +++ b/lustre/osd/osd_igif.c @@ -49,22 +49,10 @@ void lu_igif_to_id(const struct lu_fid *fid, struct osd_inode_id *id) id->oii_gen = lu_igif_gen(fid); } -__u32 lu_igif_ino(const struct lu_fid *fid) -{ - LASSERT(fid_is_igif(fid)); - return fid_oid(fid); -} - -__u32 lu_igif_gen(const struct lu_fid *fid) -{ - LASSERT(fid_is_igif(fid)); - return fid_ver(fid); -} - void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen) { - fid->f_seq = LUSTRE_ROOT_FID_SEQ; - fid->f_oid = ino; - fid->f_ver = gen; + fid->f_seq = ino; + fid->f_oid = gen; + fid->f_ver = 0; LASSERT(fid_is_igif(fid)); } diff --git a/lustre/osd/osd_igif.h b/lustre/osd/osd_igif.h index 04439d1..cdd87aa 100644 --- a/lustre/osd/osd_igif.h +++ b/lustre/osd/osd_igif.h @@ -35,8 +35,6 @@ struct lu_fid; struct osd_inode_id; void lu_igif_to_id(const struct lu_fid *fid, struct osd_inode_id *id); -__u32 lu_igif_ino(const struct lu_fid *fid); -__u32 lu_igif_gen(const struct lu_fid *fid); void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen); #endif /* __KERNEL__ */ -- 1.8.3.1