From 0b54f38a7eb79ece762f12e121bfe26814a2e655 Mon Sep 17 00:00:00 2001 From: Rahul Deshmukh Date: Thu, 7 Oct 2010 17:36:46 +0530 Subject: [PATCH] b=19427 Correct lmm_object_id o=adilger i=wangdi i=tapro i=pravin i=rahul Fix boolean logic for limiting the maximum object ID created within a single group (sequence). For legacy IDIF objects this is 2^48 objects, since we consume 2^16 SEQ numbers for the high bits of the object ID), but for all other groups it is only 2^32 objects that can fit into f_oid. Clean up some duplicate #defines that are no longer needed now that we declare all of the FID_SEQ values in enum fid_seq in lustre_idl.h. --- lustre/fid/fid_lib.c | 6 +++--- lustre/fld/fld_handler.c | 4 ++-- lustre/include/lustre/lustre_idl.h | 4 ++++ lustre/include/lustre_fid.h | 16 +--------------- lustre/obdfilter/filter.c | 13 +++++++++---- lustre/osd-ldiskfs/osd_handler.c | 6 +++--- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/lustre/fid/fid_lib.c b/lustre/fid/fid_lib.c index f98efac..d818b2c 100644 --- a/lustre/fid/fid_lib.c +++ b/lustre/fid/fid_lib.c @@ -73,7 +73,7 @@ * FID_SEQ_START + 2 is for .lustre directory and its objects */ const struct lu_seq_range LUSTRE_SEQ_SPACE_RANGE = { - FID_SEQ_DISTRIBUTED_START, + FID_SEQ_NORMAL, (__u64)~0ULL }; EXPORT_SYMBOL(LUSTRE_SEQ_SPACE_RANGE); @@ -92,13 +92,13 @@ const struct lu_fid LUSTRE_BFL_FID = { .f_seq = 0x0000000000000003, EXPORT_SYMBOL(LUSTRE_BFL_FID); /** Special fid for ".lustre" directory */ -const struct lu_fid LU_DOT_LUSTRE_FID = { .f_seq = LU_DOT_LUSTRE_SEQ, +const struct lu_fid LU_DOT_LUSTRE_FID = { .f_seq = FID_SEQ_DOT_LUSTRE, .f_oid = 0x0000000000000001, .f_ver = 0x0000000000000000 }; EXPORT_SYMBOL(LU_DOT_LUSTRE_FID); /** Special fid for "fid" special object in .lustre */ -const struct lu_fid LU_OBF_FID = { .f_seq = LU_DOT_LUSTRE_SEQ, +const struct lu_fid LU_OBF_FID = { .f_seq = FID_SEQ_DOT_LUSTRE, .f_oid = 0x0000000000000002, .f_ver = 0x0000000000000000 }; EXPORT_SYMBOL(LU_OBF_FID); diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index aa44a97..e9dff56 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -503,8 +503,8 @@ int fld_server_init(struct lu_server_fld *fld, struct dt_device *dt, fld->lsf_control_exp = NULL; /* Insert reserved sequence number of ".lustre" into fld cache. */ - range.lsr_start = LU_DOT_LUSTRE_SEQ; - range.lsr_end = LU_DOT_LUSTRE_SEQ + 1; + range.lsr_start = FID_SEQ_DOT_LUSTRE; + range.lsr_end = FID_SEQ_DOT_LUSTRE + 1; range.lsr_mdt = 0; fld_cache_insert(fld->lsf_cache, &range); diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index dc91a28..6ef74d1 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -389,6 +389,10 @@ static inline obd_id fid_ver_oid(const struct lu_fid *fid) } /** + * Note that reserved SEQ numbers below 12 will conflict with ldiskfs + * inodes in the IGIF namespace, so these reserved SEQ numbers can be + * used for other purposes and not risk collisions with existing inodes. + * * Different FID Format * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs#NEW.0 */ diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index f31c4b5..1f93d4c 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -88,22 +88,8 @@ enum { LUSTRE_SEQ_SUPER_WIDTH = ((1ULL << 30ULL) * LUSTRE_SEQ_META_WIDTH) }; -/** special fid seq: used for local object create. */ -#define FID_SEQ_LOCAL_FILE (FID_SEQ_START + 1) - -/** special fid seq: used for .lustre objects. */ -#define LU_DOT_LUSTRE_SEQ (FID_SEQ_START + 0x02ULL) - -/* Note that reserved SEQ numbers below 12 will conflict with ldiskfs - * inodes in the IGIF namespace, so these reserved SEQ numbers must be - * used sparingly until ldiskfs-based MDT backends and/or IGIF FIDs - * have been completely removed. */ - -/** fid sequence for distributed fs objects */ -#define FID_SEQ_DISTRIBUTED_START (FID_SEQ_START + 0x400ULL) - /** special OID for local objects */ -enum { +enum local_oid { /** \see osd_oi_index_create */ OSD_OI_FID_16_OID = 2UL, /** \see fld_mod_init */ diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index a498a66..3d11179 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3807,10 +3807,15 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, } else next_id = filter_last_id(filter, group) + 1; - /* Temporary solution for oid in CMD before fid-on-OST */ - if ((fid_seq_is_mdt0(oa->o_seq) && next_id >= IDIF_MAX_OID) && - (fid_seq_is_cmd(oa->o_seq) && next_id >= OBIF_MAX_OID)) { - CERROR("%s:"POSTID" hit the max IDIF_MAX_OID(1<<48)!\n", + /* Don't create objects beyond the valid range for this SEQ */ + if (unlikely(fid_seq_is_mdt0(group) && + next_id >= IDIF_MAX_OID)) { + CERROR("%s:"POSTID" hit the IDIF_MAX_OID (1<<48)!\n", + obd->obd_name, next_id, group); + GOTO(cleanup, rc = -ENOSPC); + } else if (unlikely(!fid_seq_is_mdt0(group) && + next_id >= OBIF_MAX_OID)) { + CERROR("%s:"POSTID" hit the OBIF_MAX_OID (1<<32)!\n", obd->obd_name, next_id, group); GOTO(cleanup, rc = -ENOSPC); } diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 78a6778..3bdcaf9 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1944,7 +1944,7 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt, result = __osd_object_create(info, obj, attr, hint, dof, th); /* objects under osd root shld have igif fid, so dont add fid EA */ - if (result == 0 && fid_seq(fid) >= FID_SEQ_DISTRIBUTED_START) + if (result == 0 && fid_seq(fid) >= FID_SEQ_NORMAL) result = osd_ea_fid_set(env, dt, fid); if (result == 0) @@ -2918,7 +2918,7 @@ static int __osd_ea_add_rec(struct osd_thread_info *info, child = osd_child_dentry_get(info->oti_env, pobj, name, strlen(name)); if (fid_is_igif((struct lu_fid *)fid) || - fid_seq((struct lu_fid *)fid) >= FID_SEQ_DISTRIBUTED_START) { + fid_seq((struct lu_fid *)fid) >= FID_SEQ_NORMAL) { ldp = (struct ldiskfs_dentry_param *)info->oti_ldp; osd_get_ldiskfs_dirent_param(ldp, fid); child->d_fsdata = (void*) ldp; @@ -2972,7 +2972,7 @@ static int osd_add_dot_dotdot(struct osd_thread_info *info, if (!dir->oo_compat_dot_created) return -EINVAL; - if (fid_seq((struct lu_fid *) dot_fid) >= FID_SEQ_DISTRIBUTED_START) { + if (fid_seq((struct lu_fid *)dot_fid) >= FID_SEQ_NORMAL) { osd_get_ldiskfs_dirent_param(dot_ldp, dot_fid); osd_get_ldiskfs_dirent_param(dot_dot_ldp, dot_dot_fid); } else { -- 1.8.3.1