From: Mikhail Pershin Date: Mon, 25 Mar 2013 17:04:51 +0000 (+0400) Subject: LU-2677 obdfilter: add LMA for all OST objects X-Git-Tag: 2.3.64~36 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=fd3dcf04aa169560986a15880d0ced9b07adaad4 LU-2677 obdfilter: add LMA for all OST objects - add LMA to all OST objects so OSD may work with all object uniformly - remove ff_seq and ff_obj from filter_fid because LMA contains lma_self_fid already - change tools to handle these changes Signed-off-by: Mikhail Pershin Change-Id: I699470ef73684aa05d4375da864cda35e4d5541e Reviewed-on: http://review.whamcloud.com/5838 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 821931e..5043f43 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -286,34 +286,6 @@ enum lma_incompat { }; #define LMA_INCOMPAT_SUPP (LMAI_AGENT | LMAI_REMOTE_PARENT) -/** - * Following struct for MDT attributes, that will be kept inode's EA. - * Introduced in 2.0 release (please see b15993, for details) - */ -struct lustre_mdt_attrs { - /** - * Bitfield for supported data in this structure. From enum lma_compat. - * lma_self_fid and lma_flags are always available. - */ - __u32 lma_compat; - /** - * Per-file incompat feature list. Lustre version should support all - * flags set in this field. The supported feature mask is available in - * LMA_INCOMPAT_SUPP. - */ - __u32 lma_incompat; - /** FID of this inode */ - struct lu_fid lma_self_fid; - /** mdt/ost type, others */ - __u64 lma_flags; -}; - -/** - * Prior to 2.4, the LMA structure also included SOM attributes which has since - * been moved to a dedicated xattr - */ -#define LMA_OLD_SIZE (sizeof(struct lustre_mdt_attrs) + 4 * sizeof(__u64)) - extern void lustre_lma_swab(struct lustre_mdt_attrs *lma); extern void lustre_lma_init(struct lustre_mdt_attrs *lma, const struct lu_fid *fid, __u32 incompat); @@ -509,7 +481,8 @@ static inline int fid_seq_is_special(const __u64 seq) static inline int fid_seq_is_local_file(const __u64 seq) { - return seq == FID_SEQ_LOCAL_FILE; + return seq == FID_SEQ_LOCAL_FILE || + seq == FID_SEQ_LOCAL_NAME; }; static inline int fid_seq_is_root(const __u64 seq) diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index 24b899d..60f6d9e 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -145,9 +145,14 @@ struct lu_fid { }; struct filter_fid { - struct lu_fid ff_parent; /* ff_parent.f_ver == file stripe number */ - __u64 ff_objid; - __u64 ff_seq; + struct lu_fid ff_parent; /* ff_parent.f_ver == file stripe number */ +}; + +/* keep this one for compatibility */ +struct filter_fid_old { + struct lu_fid ff_parent; + __u64 ff_objid; + __u64 ff_seq; }; /* Userspace should treat lu_fid as opaque, and only use the following methods @@ -155,6 +160,34 @@ struct filter_fid { * here from lustre_idl.h if needed. */ typedef struct lu_fid lustre_fid; +/** + * Following struct for object attributes, that will be kept inode's EA. + * Introduced in 2.0 release (please see b15993, for details) + * Added to all objects since Lustre 2.4 as contains self FID + */ +struct lustre_mdt_attrs { + /** + * Bitfield for supported data in this structure. From enum lma_compat. + * lma_self_fid and lma_flags are always available. + */ + __u32 lma_compat; + /** + * Per-file incompat feature list. Lustre version should support all + * flags set in this field. The supported feature mask is available in + * LMA_INCOMPAT_SUPP. + */ + __u32 lma_incompat; + /** FID of this inode */ + struct lu_fid lma_self_fid; +}; + +/** + * Prior to 2.4, the LMA structure also included SOM attributes which has since + * been moved to a dedicated xattr + * lma_flags was also removed because of lma_compat/incompat fields. + */ +#define LMA_OLD_SIZE (sizeof(struct lustre_mdt_attrs) + 5 * sizeof(__u64)) + /* * The ioctl naming rules: * LL_* - works on the currently opened filehandle instead of parent dir diff --git a/lustre/obdclass/md_attrs.c b/lustre/obdclass/md_attrs.c index 7d5364a..b71344a 100644 --- a/lustre/obdclass/md_attrs.c +++ b/lustre/obdclass/md_attrs.c @@ -44,13 +44,12 @@ void lustre_lma_init(struct lustre_mdt_attrs *lma, const struct lu_fid *fid, lma->lma_compat = 0; lma->lma_incompat = incompat; lma->lma_self_fid = *fid; - lma->lma_flags = 0; /* If a field is added in struct lustre_mdt_attrs, zero it explicitly * and change the test below. */ LASSERT(sizeof(*lma) == - (offsetof(struct lustre_mdt_attrs, lma_flags) + - sizeof(lma->lma_flags))); + (offsetof(struct lustre_mdt_attrs, lma_self_fid) + + sizeof(lma->lma_self_fid))); }; EXPORT_SYMBOL(lustre_lma_init); @@ -66,7 +65,6 @@ void lustre_lma_swab(struct lustre_mdt_attrs *lma) __swab32s(&lma->lma_compat); __swab32s(&lma->lma_incompat); lustre_swab_lu_fid(&lma->lma_self_fid); - __swab64s(&lma->lma_flags); } }; EXPORT_SYMBOL(lustre_lma_swab); diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index e963ad2..e329154 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -304,7 +304,6 @@ struct ofd_thread_info { struct lu_attr fti_attr2; struct ldlm_res_id fti_resid; struct filter_fid fti_mds_fid; - struct filter_fid fti_mds_fid2; struct ost_id fti_ostid; struct ofd_object *fti_obj; union { @@ -603,8 +602,6 @@ static inline void ofd_prepare_fidea(struct filter_fid *ff, struct obdo *oa) /* XXX: we are ignoring o_parent_ver here, since this should * be the same for all objects in this fileset. */ ff->ff_parent.f_ver = cpu_to_le32(oa->o_stripe_idx); - ff->ff_objid = cpu_to_le64(oa->o_id); - ff->ff_seq = cpu_to_le64(oa->o_seq); } /* niobuf_remote has no rnb_ prefix in master */ diff --git a/lustre/ofd/ofd_objects.c b/lustre/ofd/ofd_objects.c index 32ca902..b05972d 100644 --- a/lustre/ofd/ofd_objects.c +++ b/lustre/ofd/ofd_objects.c @@ -112,8 +112,7 @@ struct ofd_object *ofd_object_find_or_create(const struct lu_env *env, int ofd_object_ff_check(const struct lu_env *env, struct ofd_object *fo) { - struct ofd_thread_info *info = ofd_info(env); - int rc = 0; + int rc = 0; ENTRY; @@ -122,9 +121,7 @@ int ofd_object_ff_check(const struct lu_env *env, struct ofd_object *fo) * This actually means that we don't know whether the object * has the "fid" EA or not. */ - info->fti_buf.lb_buf = &info->fti_mds_fid2; - info->fti_buf.lb_len = sizeof(info->fti_mds_fid2); - rc = dt_xattr_get(env, ofd_object_child(fo), &info->fti_buf, + rc = dt_xattr_get(env, ofd_object_child(fo), &LU_BUF_NULL, XATTR_NAME_FID, BYPASS_CAPA); if (rc >= 0 || rc == -ENODATA) { /* diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 131bb28..9ad62ed 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -2413,17 +2413,11 @@ static int osd_object_ea_create(const struct lu_env *env, struct dt_object *dt, osd_trans_declare_rb(env, th, OSD_OT_REF_ADD); result = __osd_object_create(info, obj, attr, hint, dof, th); - - if (OBD_FAIL_CHECK(OBD_FAIL_FID_IGIF) && !fid_is_internal(fid)) - return result; - - if ((result == 0) && - (fid_is_last_id(fid) || - !fid_is_on_ost(info, osd_dt_dev(th->th_dev), fid))) + if (result == 0) result = osd_ea_fid_set(info, obj->oo_inode, fid, 0); - if (result == 0) - result = __osd_oi_insert(env, obj, fid, th); + if (result == 0) + result = __osd_oi_insert(env, obj, fid, th); LASSERT(ergo(result == 0, dt_object_exists(dt) && !dt_object_remote(dt))); diff --git a/lustre/osd-ldiskfs/osd_oi.c b/lustre/osd-ldiskfs/osd_oi.c index 118359a..d159403 100644 --- a/lustre/osd-ldiskfs/osd_oi.c +++ b/lustre/osd-ldiskfs/osd_oi.c @@ -467,7 +467,8 @@ int fid_is_on_ost(struct osd_thread_info *info, struct osd_device *osd, int rc; ENTRY; - if (unlikely(fid_is_local_file(fid) || fid_is_igif(fid))) + if (unlikely(fid_is_local_file(fid) || fid_is_igif(fid) || + fid_is_llog(fid))) RETURN(0); if (fid_is_idif(fid) || fid_is_last_id(fid)) diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index e65b094..9d43a95 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -54,7 +54,7 @@ void lustre_assert_wire_constants(void) { /* Wire protocol assertions generated by 'wirecheck' * (make -C lustre/utils newwiretest) - * running on Linux testnode 2.6.32-279.5.1.el6_lustre.g53f705f.x86_64 #1 SMP Mon Oct 8 05:12 + * running on Linux node7 2.6.32 #1 SMP Tue Dec 18 04:02:25 MSK 2012 x86_64 x86_64 x86_64 GNU * with gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) */ @@ -417,7 +417,7 @@ void lustre_assert_wire_constants(void) (long long)LU_SEQ_RANGE_OST); /* Checks for struct lustre_mdt_attrs */ - LASSERTF((int)sizeof(struct lustre_mdt_attrs) == 32, "found %lld\n", + LASSERTF((int)sizeof(struct lustre_mdt_attrs) == 24, "found %lld\n", (long long)(int)sizeof(struct lustre_mdt_attrs)); LASSERTF((int)offsetof(struct lustre_mdt_attrs, lma_compat) == 0, "found %lld\n", (long long)(int)offsetof(struct lustre_mdt_attrs, lma_compat)); @@ -431,10 +431,6 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_mdt_attrs, lma_self_fid)); LASSERTF((int)sizeof(((struct lustre_mdt_attrs *)0)->lma_self_fid) == 16, "found %lld\n", (long long)(int)sizeof(((struct lustre_mdt_attrs *)0)->lma_self_fid)); - LASSERTF((int)offsetof(struct lustre_mdt_attrs, lma_flags) == 24, "found %lld\n", - (long long)(int)offsetof(struct lustre_mdt_attrs, lma_flags)); - LASSERTF((int)sizeof(((struct lustre_mdt_attrs *)0)->lma_flags) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lustre_mdt_attrs *)0)->lma_flags)); LASSERTF(LMAI_RELEASED == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)LMAI_RELEASED); LASSERTF(LMAC_HSM == 0x00000001UL, "found 0x%.8xUL\n", diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7685c77..d7e5f3f 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1712,29 +1712,38 @@ check_seq_oid() log "want: stripe:$stripe_nr ost:$obdidx oid:$oid/$hex seq:$seq" #don't unmount/remount the OSTs if we don't need to do that - #local dir=$(facet_mntpt ost$ost) - #stop ost$dev - #do_facet ost$dev mount -t $FSTYPE $dev $dir $OST_MOUNT_OPTS || - # { error "mounting $dev as $FSTYPE failed"; return 3; } - #local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid) - #local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file) - seq=$(echo $seq | sed -e "s/^0x//g") - if [ $seq == 0 ]; then - oid_hex=$(echo $oid) - else - oid_hex=$(echo $hex | sed -e "s/^0x//g") + # LU-2577 changes filter_fid to be smaller, so debugfs needs + # update too, until that use mount/ll_decode_filter_fid/mount + local dir=$(facet_mntpt ost$ost) + local opts=${OST_MOUNT_OPTS} + + if ! do_facet ost$ost test -b ${dev}; then + opts=$(csa_add "$opts" -o loop) fi - local obj_file="O/$seq/d$((oid %32))/$oid_hex" - local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \ - $dev 2>/dev/null" | grep "parent=") + + stop ost$ost + do_facet ost$ost mount -t $(facet_fstype ost$ost) $opts $dev $dir || + { error "mounting $dev as $FSTYPE failed"; return 3; } + local obj_file=$(do_facet ost$ost find $dir/O/$seq -name $oid) + local ff=$(do_facet ost$ost $LL_DECODE_FILTER_FID $obj_file) + do_facet ost$ost umount -d $dir + start ost$ost $dev $OST_MOUNT_OPTS + + # re-enable when debugfs will understand new filter_fid + #seq=$(echo $seq | sed -e "s/^0x//g") + #if [ $seq == 0 ]; then + # oid_hex=$(echo $oid) + #else + # oid_hex=$(echo $hex | sed -e "s/^0x//g") + #fi + #local obj_file="O/$seq/d$((oid %32))/$oid_hex" + #local ff=$(do_facet ost$ost "$DEBUGFS -c -R 'stat $obj_file' \ + # $dev 2>/dev/null" | grep "parent=") [ -z "$ff" ] && error "$obj_file: no filter_fid info" echo "$ff" | sed -e 's#.*objid=#got: objid=#' - #do_facet ost$ost umount -d $dir - #start ost$ost $dev $OST_MOUNT_OPTS - # /mnt/O/0/d23/23: objid=23 seq=0 parent=[0x200000400:0x1e:0x1] # fid: objid=23 seq=0 parent=[0x200000400:0x1e:0x0] stripe=1 local ff_parent=$(echo $ff|sed -e 's/.*parent=.//') diff --git a/lustre/utils/ll_decode_filter_fid.c b/lustre/utils/ll_decode_filter_fid.c index 687ed58..04dadf7 100644 --- a/lustre/utils/ll_decode_filter_fid.c +++ b/lustre/utils/ll_decode_filter_fid.c @@ -59,24 +59,37 @@ int main(int argc, char *argv[]) struct filter_fid *ff = (void *)buf; int size; - size = getxattr(argv[i], "trusted.fid", buf, sizeof(buf)); + size = getxattr(argv[i], "trusted.fid", buf, + sizeof(struct filter_fid_old)); if (size < 0) { fprintf(stderr, "%s: error reading fid: %s\n", argv[i], strerror(errno)); if (rc == 0) rc = size; - continue; - } - if (size > sizeof(*ff)) - fprintf(stderr, "%s: warning: fid larger than expected " - "(%d bytes), recompile?\n", argv[i], size); + continue; + } + if (size > sizeof(struct filter_fid_old)) { + fprintf(stderr, "%s: warning: fid larger than expected" + " (%d bytes), recompile?\n", argv[i], size); + } else if (size > sizeof(*ff)) { + struct filter_fid_old *ffo = (void *)buf; - printf("%s: objid="LPU64" seq="LPU64" parent="DFID"\n", - argv[i], le64_to_cpu(ff->ff_objid), - le64_to_cpu(ff->ff_seq), - le64_to_cpu(ff->ff_parent.f_seq), - le32_to_cpu(ff->ff_parent.f_oid), - le32_to_cpu(ff->ff_parent.f_ver)); + /* old filter_fid */ + printf("%s: objid="LPU64" seq="LPU64" parent="DFID + " stripe=%u\n", argv[i], + le64_to_cpu(ffo->ff_objid), + le64_to_cpu(ffo->ff_seq), + le64_to_cpu(ffo->ff_parent.f_seq), + le32_to_cpu(ffo->ff_parent.f_oid), 0 /* ver */, + /* this is stripe_nr actually */ + le32_to_cpu(ffo->ff_parent.f_ver)); + } else { + printf("%s: parent="DFID" stripe=%u\n", argv[i], + le64_to_cpu(ff->ff_parent.f_seq), + le32_to_cpu(ff->ff_parent.f_oid), 0, /* ver */ + /* this is stripe_nr actually */ + le32_to_cpu(ff->ff_parent.f_ver)); + } } return rc; diff --git a/lustre/utils/ll_recover_lost_found_objs.c b/lustre/utils/ll_recover_lost_found_objs.c index cfe9bd4..9c8d831 100644 --- a/lustre/utils/ll_recover_lost_found_objs.c +++ b/lustre/utils/ll_recover_lost_found_objs.c @@ -248,9 +248,9 @@ static unsigned filetype_dir_table[] = { static int traverse_lost_found(char *src_dir, const char *mount_path) { - DIR *dir_ptr; - struct filter_fid parent_fid; - struct dirent64 *dirent; + DIR *dir_ptr; + struct lustre_mdt_attrs lma; + struct dirent64 *dirent; __u64 ff_seq, ff_objid; char *file_path; char dest_path[PATH_MAX]; @@ -313,27 +313,36 @@ static int traverse_lost_found(char *src_dir, const char *mount_path) case DT_REG: file_path = src_dir; - xattr_len = getxattr(file_path, "trusted.fid", - (void *)&parent_fid, - sizeof(parent_fid)); - - if (xattr_len == -1 || xattr_len < sizeof(parent_fid)) - /* - * Its very much possible that we dont find fid - * on precreated files, LAST_ID - */ - continue; + xattr_len = getxattr(file_path, "trusted.lma", + (void *)&lma, sizeof(lma)); + if (xattr_len == -1 || xattr_len < sizeof(lma)) { + struct filter_fid_old ff; + + /* try old filter_fid EA */ + xattr_len = getxattr(file_path, "trusted.fid", + (void *)&ff, sizeof(ff)); + if (xattr_len == -1 || xattr_len < sizeof(ff)) { + /* + * Its very much possible that we dont find fid + * on precreated files, LAST_ID + */ + continue; + } + ff_seq = le64_to_cpu(ff.ff_seq); + ff_objid = le64_to_cpu(ff.ff_objid); + } else { + ff_seq = le64_to_cpu(lma.lma_self_fid.f_seq); + ff_objid = le64_to_cpu(lma.lma_self_fid.f_oid); + } - ff_seq = le64_to_cpu(parent_fid.ff_seq); sprintf(seq_name, (fid_seq_is_rsvd(ff_seq) || fid_seq_is_mdt0(ff_seq)) ? LPU64 : LPX64i, fid_seq_is_idif(ff_seq) ? 0 : ff_seq); - ff_objid = le64_to_cpu(parent_fid.ff_objid); - sprintf(obj_name, (fid_seq_is_rsvd(parent_fid.ff_seq) || - fid_seq_is_mdt0(parent_fid.ff_seq) || - fid_seq_is_idif(parent_fid.ff_seq)) ? + sprintf(obj_name, (fid_seq_is_rsvd(ff_seq) || + fid_seq_is_mdt0(ff_seq) || + fid_seq_is_idif(ff_seq)) ? LPU64 : LPX64i, ff_objid); grp_info = find_or_create_grp(&grp_info_list, ff_seq, diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 14451fa..2211b0f 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -206,7 +206,6 @@ check_lustre_mdt_attrs(void) CHECK_MEMBER(lustre_mdt_attrs, lma_compat); CHECK_MEMBER(lustre_mdt_attrs, lma_incompat); CHECK_MEMBER(lustre_mdt_attrs, lma_self_fid); - CHECK_MEMBER(lustre_mdt_attrs, lma_flags); CHECK_VALUE_X(LMAI_RELEASED); CHECK_VALUE_X(LMAC_HSM); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 27049c3..3758f30 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -58,12 +58,11 @@ int main() return ret; } - void lustre_assert_wire_constants(void) { /* Wire protocol assertions generated by 'wirecheck' * (make -C lustre/utils newwiretest) - * running on Linux testnode 2.6.32-279.5.1.el6_lustre.g53f705f.x86_64 #1 SMP Mon Oct 8 05:12 + * running on Linux node7 2.6.32 #1 SMP Tue Dec 18 04:02:25 MSK 2012 x86_64 x86_64 x86_64 GNU * with gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) */ @@ -426,7 +425,7 @@ void lustre_assert_wire_constants(void) (long long)LU_SEQ_RANGE_OST); /* Checks for struct lustre_mdt_attrs */ - LASSERTF((int)sizeof(struct lustre_mdt_attrs) == 32, "found %lld\n", + LASSERTF((int)sizeof(struct lustre_mdt_attrs) == 24, "found %lld\n", (long long)(int)sizeof(struct lustre_mdt_attrs)); LASSERTF((int)offsetof(struct lustre_mdt_attrs, lma_compat) == 0, "found %lld\n", (long long)(int)offsetof(struct lustre_mdt_attrs, lma_compat)); @@ -440,10 +439,6 @@ void lustre_assert_wire_constants(void) (long long)(int)offsetof(struct lustre_mdt_attrs, lma_self_fid)); LASSERTF((int)sizeof(((struct lustre_mdt_attrs *)0)->lma_self_fid) == 16, "found %lld\n", (long long)(int)sizeof(((struct lustre_mdt_attrs *)0)->lma_self_fid)); - LASSERTF((int)offsetof(struct lustre_mdt_attrs, lma_flags) == 24, "found %lld\n", - (long long)(int)offsetof(struct lustre_mdt_attrs, lma_flags)); - LASSERTF((int)sizeof(((struct lustre_mdt_attrs *)0)->lma_flags) == 8, "found %lld\n", - (long long)(int)sizeof(((struct lustre_mdt_attrs *)0)->lma_flags)); LASSERTF(LMAI_RELEASED == 0x00000001UL, "found 0x%.8xUL\n", (unsigned)LMAI_RELEASED); LASSERTF(LMAC_HSM == 0x00000001UL, "found 0x%.8xUL\n",