From fe28c37887feded2ad7e56334434de75cdc4d2dd Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Wed, 15 Sep 2021 11:48:29 -0700 Subject: [PATCH] EX-2240 lipe: remove fake lustre headers The fake lustre headers should be removed and we should include normal lustre headers instead. The two headers are fake_lustre_idl.h and fake_lustre_disk.h. Including the fake headers makes it harder to include other lustre headers due to conflicts. Test-Parameters: testlist=sanity-lipe Change-Id: I95d6b50c9f9fd9f675eceba00464053124b7279c Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/44897 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- lipe/src/Makefile.am | 4 +- lipe/src/debug.h | 11 +- lipe/src/fake_lustre_disk.h | 67 --------- lipe/src/fake_lustre_idl.h | 345 ------------------------------------------- lipe/src/flist.c | 2 +- lipe/src/general_policy.c | 2 +- lipe/src/lamigo.c | 8 +- lipe/src/ldiskfs_read_ldd.h | 4 +- lipe/src/lipe_ldiskfs.c | 2 +- lipe/src/lipe_zfs.c | 6 +- lipe/src/lustre_ea.c | 7 +- lipe/src/lustre_ea.h | 23 ++- lipe/src/lustre_ea_ldiskfs.c | 6 +- lipe/src/lustre_ea_ldiskfs.h | 2 +- lipe/src/policy.c | 2 +- lipe/src/posix_ea.c | 6 +- lipe/src/posix_ea.h | 2 +- lipe/src/zfs_read_ldd.h | 2 +- 18 files changed, 49 insertions(+), 452 deletions(-) delete mode 100644 lipe/src/fake_lustre_disk.h delete mode 100644 lipe/src/fake_lustre_idl.h diff --git a/lipe/src/Makefile.am b/lipe/src/Makefile.am index 20de9e9..a236eb9 100644 --- a/lipe/src/Makefile.am +++ b/lipe/src/Makefile.am @@ -26,8 +26,8 @@ endif ext4_inode2path_SOURCES = debug.c debug.h ext4_inode2path.c -LIPE_SOURCES = cmd.c cmd.h debug.c debug.h fake_lustre_disk.h \ - fake_lustre_idl.h flist.c flist.h misc.c misc.h \ +LIPE_SOURCES = cmd.c cmd.h debug.c debug.h \ + flist.c flist.h misc.c misc.h \ lustre_ea.c lustre_ea.h \ lipe_ldiskfs.c lipe_ldiskfs.h \ lipe_object_attrs.c \ diff --git a/lipe/src/debug.h b/lipe/src/debug.h index d612649..5b9d4bf 100644 --- a/lipe/src/debug.h +++ b/lipe/src/debug.h @@ -15,6 +15,7 @@ #include #include #include +#include #ifdef NEW_USER_HEADER # include @@ -31,18 +32,10 @@ enum debug_level { extern enum debug_level debug_level; extern struct lu_fid debug_watch_fid; -/* FIXME Use lu_fid_eq() when fake_lustre_idl.h is removed. */ -static inline bool lipe_fid_eq(const struct lu_fid *f1, const struct lu_fid *f2) -{ - return f1->f_seq == f2->f_seq && - f1->f_oid == f2->f_oid && - f1->f_ver == f2->f_ver; -} - static inline bool lipe_logging_enabled(enum debug_level level, const struct lu_fid *fid) { return level <= debug_level || - (fid != NULL && lipe_fid_eq(fid, &debug_watch_fid)); + (fid != NULL && lu_fid_eq(fid, &debug_watch_fid)); } /* Keeps this to mask the many format errors which would make build fail. */ diff --git a/lipe/src/fake_lustre_disk.h b/lipe/src/fake_lustre_disk.h deleted file mode 100644 index f63fc5b..0000000 --- a/lipe/src/fake_lustre_disk.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2016, DDN Storage Corporation. - */ -/* - * - * Tool for scanning the MDT and print list of matched files. - * - * Author: Li Xi - */ - -#ifndef _LIPE_FAKE_LUSTRE_DISK_H_ -#define _LIPE_FAKE_LUSTRE_DISK_H_ -#include - -/* On-disk configuration file. In host-endian order. */ -struct lustre_disk_data { - __u32 ldd_magic; - __u32 ldd_feature_compat; /* compatible feature flags */ - __u32 ldd_feature_rocompat;/* read-only compatible feature flags */ - __u32 ldd_feature_incompat;/* incompatible feature flags */ - - __u32 ldd_config_ver; /* config rewrite count - not used */ - __u32 ldd_flags; /* LDD_SV_TYPE */ - __u32 ldd_svindex; /* server index (0001), must match svname */ - __u32 ldd_mount_type; /* target fs type LDD_MT_* */ - char ldd_fsname[64]; /* filesystem this server is part of, MTI_NAME_MAXLEN */ - char ldd_svname[64]; /* this server's name (lustre-mdt0001)*/ - __u8 ldd_uuid[40]; /* server UUID (COMPAT_146) */ - -/*200*/ char ldd_userdata[1024 - 200]; /* arbitrary user string */ -/*1024*/__u8 ldd_padding[4096 - 1024]; -/*4096*/char ldd_mount_opts[4096]; /* target fs mount opts */ -/*8192*/char ldd_params[4096]; /* key=value pairs */ -}; - -#define MOUNT_CONFIGS_DIR "CONFIGS" -#define CONFIGS_FILE "mountdata" -/** Persistent mount data are stored on the disk in this file. */ -#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE - -#define LDD_F_SV_TYPE_MDT 0x0001 -#define LDD_F_SV_TYPE_OST 0x0002 -#define LDD_F_SV_TYPE_MGS 0x0004 -#define LDD_F_SV_TYPE_MASK (LDD_F_SV_TYPE_MDT | \ - LDD_F_SV_TYPE_OST | \ - LDD_F_SV_TYPE_MGS) -#undef IS_MDT -#define IS_MDT(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MDT) -#undef IS_OST -#define IS_OST(data) ((data)->ldd_flags & LDD_F_SV_TYPE_OST) -#undef IS_MGS -#define IS_MGS(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MGS) -#undef IS_SERVER -#define IS_SERVER(data) ((data)->ldd_flags & (LDD_F_SV_TYPE_MGS | \ - LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_OST)) - -enum ldd_mount_type { - LDD_MT_EXT3 = 0, - LDD_MT_LDISKFS, - LDD_MT_SMFS, - LDD_MT_REISERFS, - LDD_MT_LDISKFS2, - LDD_MT_ZFS, - LDD_MT_LAST -}; - -#endif /* _LIPE_FAKE_LUSTRE_DISK_H_ */ diff --git a/lipe/src/fake_lustre_idl.h b/lipe/src/fake_lustre_idl.h deleted file mode 100644 index e6b5572..0000000 --- a/lipe/src/fake_lustre_idl.h +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2016, DDN Storage Corporation. - */ -/* - * - * Tool for scanning the MDT and print list of matched files. - * - * Author: Li Xi - */ - -#ifndef _FAKE_LUSTRE_IDL_H_ -#define _FAKE_LUSTRE_IDL_H_ -#include -#include - -#ifdef NEW_USER_HEADER -#include -#else -#include -#endif - -#include -#include - -#if defined(_ASM_GENERIC_INT_L64_H) -# define LPF64 "l" -#elif defined(_ASM_GENERIC_INT_LL64_H) -# define LPF64 "ll" -#elif !defined(LPF64) -# error "cannot define LPF64" -#endif /* !LPF64 */ - -#define LPU64 "%"LPF64"u" -#define LPD64 "%"LPF64"d" -#define LPX64 "%#"LPF64"x" -#define LPX64i "%"LPF64"x" -#define LPO64 "%#"LPF64"o" - -#define LPLU "%lu" -#define LPLD "%ld" -#define LPLX "%#lx" -#define LPPID "%d" - -/* Defined in */ -/** The link ea holds 1 \a link_ea_entry for each hardlink */ -#define LINK_EA_MAGIC 0x11EAF1DFUL -struct link_ea_header { - __u32 leh_magic; - __u32 leh_reccount; - __u64 leh_len; /* total size */ - /* future use */ - __u32 padding1; - __u32 padding2; -}; - -/** Hardlink data is name and parent fid. - * Stored in this crazy struct for maximum packing and endian-neutrality - */ -struct link_ea_entry { - /** __u16 stored big-endian, unaligned */ - unsigned char lee_reclen[2]; - unsigned char lee_parent_fid[sizeof(struct lu_fid)]; - char lee_name[0]; -} __attribute__((packed)); - -#define XATTR_TRUSTED_PREFIX "trusted." - -#define XATTR_NAME_LMA "trusted.lma" -#define XATTR_NAME_LMV "trusted.lmv" -#define XATTR_NAME_LINK "trusted.link" -#define XATTR_NAME_HSM "trusted.hsm" -#define XATTR_NAME_LOV "trusted.lov" -#define XATTR_NAME_SOM "trusted.som" -#define XATTR_NAME_FID "trusted.fid" - -#ifndef LOV_PATTERN_F_MASK -#define LOV_PATTERN_F_MASK 0xffff0000 -#define LOV_PATTERN_F_HOLE 0x40000000 /* there is hole in LOV EA */ -#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */ -#define lov_pattern(pattern) (pattern & ~LOV_PATTERN_F_MASK) -#define lov_pattern_flags(pattern) (pattern & LOV_PATTERN_F_MASK) -#endif - -/** returns fid object sequence */ -static inline __u64 fid_seq(const struct lu_fid *fid) -{ - return fid->f_seq; -} - -/** returns fid object id */ -static inline __u32 fid_oid(const struct lu_fid *fid) -{ - return fid->f_oid; -} - -/** returns fid object version */ -static inline __u32 fid_ver(const struct lu_fid *fid) -{ - return fid->f_ver; -} - -static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src) -{ - dst->f_seq = __le64_to_cpu(fid_seq(src)); - dst->f_oid = __le32_to_cpu(fid_oid(src)); - dst->f_ver = __le32_to_cpu(fid_ver(src)); -} - -static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src) -{ - dst->f_seq = __be64_to_cpu(fid_seq(src)); - dst->f_oid = __be32_to_cpu(fid_oid(src)); - dst->f_ver = __be32_to_cpu(fid_ver(src)); -} - -/** - * 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 - */ -enum fid_seq { - FID_SEQ_OST_MDT0 = 0, - FID_SEQ_LLOG = 1, /* unnamed llogs */ - FID_SEQ_ECHO = 2, - FID_SEQ_UNUSED_START = 3, - FID_SEQ_UNUSED_END = 9, - FID_SEQ_LLOG_NAME = 10, /* named llogs */ - FID_SEQ_RSVD = 11, - FID_SEQ_IGIF = 12, - FID_SEQ_IGIF_MAX = 0x0ffffffffULL, - FID_SEQ_IDIF = 0x100000000ULL, - FID_SEQ_IDIF_MAX = 0x1ffffffffULL, - /* Normal FID sequence starts from this value, i.e. 1<<33 */ - FID_SEQ_START = 0x200000000ULL, - /* sequence for local pre-defined FIDs listed in local_oid */ - FID_SEQ_LOCAL_FILE = 0x200000001ULL, - FID_SEQ_DOT_LUSTRE = 0x200000002ULL, - /* sequence is used for local named objects FIDs generated - * by local_object_storage library - */ - FID_SEQ_LOCAL_NAME = 0x200000003ULL, - /* Because current FLD will only cache the fid sequence, instead - * of oid on the client side, if the FID needs to be exposed to - * clients sides, it needs to make sure all of fids under one - * sequence will be located in one MDT. - */ - FID_SEQ_SPECIAL = 0x200000004ULL, - FID_SEQ_QUOTA = 0x200000005ULL, - FID_SEQ_QUOTA_GLB = 0x200000006ULL, - FID_SEQ_ROOT = 0x200000007ULL, /* Located on MDT0 */ - FID_SEQ_LAYOUT_RBTREE = 0x200000008ULL, - /* sequence is used for update logs of cross-MDT operation */ - FID_SEQ_UPDATE_LOG = 0x200000009ULL, - /* Sequence is used for the directory under which update logs - * are created. - */ - FID_SEQ_UPDATE_LOG_DIR = 0x20000000aULL, - FID_SEQ_NORMAL = 0x200000400ULL, - FID_SEQ_LOV_DEFAULT = 0xffffffffffffffffULL -}; - -static inline bool fid_seq_is_mdt0(__u64 seq) -{ - return seq == FID_SEQ_OST_MDT0; -} - -/** - * Check if a fid is igif or not. - * \param fid the fid to be tested. - * \return true if the fid is an igif; otherwise false. - */ -static inline bool fid_seq_is_igif(__u64 seq) -{ - return seq >= FID_SEQ_IGIF && seq <= FID_SEQ_IGIF_MAX; -} - -static inline bool fid_is_igif(const struct lu_fid *fid) -{ - return fid_seq_is_igif(fid_seq(fid)); -} - -/** - * Check if a fid is idif or not. - * \param fid the fid to be tested. - * \return true if the fid is an idif; otherwise false. - */ -static inline bool fid_seq_is_idif(__u64 seq) -{ - return seq >= FID_SEQ_IDIF && seq <= FID_SEQ_IDIF_MAX; -} - -static inline bool fid_is_idif(const struct lu_fid *fid) -{ - return fid_seq_is_idif(fid_seq(fid)); -} - - -static inline bool fid_seq_is_rsvd(__u64 seq) -{ - return seq > FID_SEQ_OST_MDT0 && seq <= FID_SEQ_RSVD; -}; - -static inline bool fid_is_sane(const struct lu_fid *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 bool fid_seq_is_norm(__u64 seq) -{ - return (seq >= FID_SEQ_NORMAL); -} - -static inline bool fid_is_norm(const struct lu_fid *fid) -{ - return fid_seq_is_norm(fid_seq(fid)); -} - -static inline int fid_seq_is_default(const __u64 seq) -{ - return seq == FID_SEQ_LOV_DEFAULT; -} - -/* extract OST sequence (group) from a wire ost_id (id/seq) pair */ -static inline __u64 ostid_seq(const struct ost_id *ostid) -{ - if (fid_seq_is_mdt0(ostid->oi.oi_seq)) - return FID_SEQ_OST_MDT0; - - if (fid_seq_is_default(ostid->oi.oi_seq)) - return FID_SEQ_LOV_DEFAULT; - - if (fid_is_idif(&ostid->oi_fid)) - return FID_SEQ_OST_MDT0; - - return fid_seq(&ostid->oi_fid); -} - -#define OBIF_OID_MAX_BITS 32 -#define OBIF_MAX_OID (1ULL << OBIF_OID_MAX_BITS) -#define OBIF_OID_MASK ((1ULL << OBIF_OID_MAX_BITS) - 1) -#define IDIF_OID_MAX_BITS 48 -#define IDIF_MAX_OID (1ULL << IDIF_OID_MAX_BITS) -#define IDIF_OID_MASK ((1ULL << IDIF_OID_MAX_BITS) - 1) - -/* convert a packed IDIF FID into an OST objid */ -static inline __u64 fid_idif_id(__u64 seq, __u32 oid, __u32 ver) -{ - return ((__u64)ver << 48) | ((seq & 0xffff) << 32) | oid; -} - -/* extract OST objid from a wire ost_id (id/seq) pair */ -static inline __u64 ostid_id(const struct ost_id *ostid) -{ - if (fid_seq_is_mdt0(ostid_seq(ostid))) - return ostid->oi.oi_id & IDIF_OID_MASK; - - if (fid_is_idif(&ostid->oi_fid)) - return fid_idif_id(fid_seq(&ostid->oi_fid), - fid_oid(&ostid->oi_fid), 0); - - return fid_oid(&ostid->oi_fid); -} - -static inline bool lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) -{ - return memcmp(f0, f1, sizeof(*f0)) == 0; -} - -/** - * HSM on-disk attributes stored in a separate xattr. - */ -struct hsm_attrs { - /** Bitfield for supported data in this structure. For future use. */ - __u32 hsm_compat; - - /** HSM flags, see hsm_flags enum below */ - __u32 hsm_flags; - /** backend archive id associated with the file */ - __u64 hsm_arch_id; - /** version associated with the last archiving, if any */ - __u64 hsm_arch_ver; -}; - -/** - * Swab, if needed, HSM structure which is stored on-disk in little-endian - * order. - * - * \param attrs - is a pointer to the HSM structure to be swabbed. - */ -static inline void lustre_hsm_swab(struct hsm_attrs *attrs) -{ -#if __BYTE_ORDER == __BIG_ENDIAN - __swab32s(&attrs->hsm_compat); - __swab32s(&attrs->hsm_flags); - __swab64s(&attrs->hsm_arch_id); - __swab64s(&attrs->hsm_arch_ver); -#endif -}; - -/* LMV layout EA, and it will be stored both in master and slave object */ -struct lmv_mds_md_v1 { - __u32 lmv_magic; - __u32 lmv_stripe_count; - __u32 lmv_master_mdt_index; /* On master object, it is master - * MDT index, on slave object, it - * is stripe index of the slave obj */ - __u32 lmv_hash_type; /* dir stripe policy, i.e. indicate - * which hash function to be used, - * Note: only lower 16 bits is being - * used for now. Higher 16 bits will - * be used to mark the object status, - * for example migrating or dead. */ - __u32 lmv_layout_version; /* increased each time layout changed, - * by directory migration, restripe - * and LFSCK. */ - __u32 lmv_migrate_offset; /* once this is set, it means this - * directory is been migrated, stripes - * before this offset belong to target, - * from this to source. */ - __u32 lmv_migrate_hash; /* hash type of source stripes of - * migrating directory */ - __u32 lmv_padding2; - __u64 lmv_padding3; - char lmv_pool_name[LOV_MAXPOOLNAME + 1]; /* pool name */ - struct lu_fid lmv_stripe_fids[0]; /* FIDs for each stripe */ -}; - -#define LMV_MAGIC_V1 0x0CD20CD0 /* normal stripe lmv magic */ -#define LMV_MAGIC LMV_MAGIC_V1 - -/* #define LMV_USER_MAGIC 0x0CD30CD0 */ -#define LMV_MAGIC_STRIPE 0x0CD40CD0 /* magic for dir sub_stripe */ - -union lmv_mds_md { - __u32 lmv_magic; - struct lmv_mds_md_v1 lmv_md_v1; - struct lmv_user_md lmv_user_md; -}; -#endif /* _FAKE_LUSTRE_IDL_H_ */ diff --git a/lipe/src/flist.c b/lipe/src/flist.c index 2a7b9df..f1b68ff 100644 --- a/lipe/src/flist.c +++ b/lipe/src/flist.c @@ -16,10 +16,10 @@ #include #include #include +#include #include "flist.h" #include "debug.h" #include "policy.h" -#include "fake_lustre_idl.h" #include "lipe_object_attrs.h" // This sets up a client UDS diff --git a/lipe/src/general_policy.c b/lipe/src/general_policy.c index e4b21ba..2628a81 100644 --- a/lipe/src/general_policy.c +++ b/lipe/src/general_policy.c @@ -16,7 +16,7 @@ #include #include #include -#include "fake_lustre_idl.h" +#include #include "list.h" #include "policy.h" #include "debug.h" diff --git a/lipe/src/lamigo.c b/lipe/src/lamigo.c index fb77974..4987d46 100644 --- a/lipe/src/lamigo.c +++ b/lipe/src/lamigo.c @@ -1088,9 +1088,9 @@ lamigo_check_user_rules(struct lipe_object_attrs *attrs, return AMIGO_RESYNC_EXTEND; } -int lustre_hsm2user(struct hsm_attrs *disk, struct hsm_user_state *hus); +int lipe_hsm2user(struct hsm_attrs *disk, struct hsm_user_state *hus); -static inline void lustre_som_swab(struct lustre_som_attrs *attrs) +static inline void lipe_som_swab(struct lustre_som_attrs *attrs) { #if __BYTE_ORDER == __BIG_ENDIAN __swab16s(&attrs->lsa_valid); @@ -1187,7 +1187,7 @@ static int lamigo_get_attrs(const struct lu_fid *fid, rc = fgetxattr(fd, XATTR_NAME_HSM, buf, sizeof(buf)); if (rc >= 0) - rc = lustre_hsm2user((struct hsm_attrs *)buf, hus); + rc = lipe_hsm2user((struct hsm_attrs *)buf, hus); if (rc == 0) attrs->loa_attr_bits |= LIPE_OBJECT_ATTR_HSMEA; } @@ -1197,7 +1197,7 @@ static int lamigo_get_attrs(const struct lu_fid *fid, rc = fgetxattr(fd, XATTR_NAME_SOM, som, sizeof(*som)); if (rc >= sizeof(*som)) { - lustre_som_swab(som); + lipe_som_swab(som); attrs->loa_attr_bits |= LIPE_OBJECT_ATTR_SOM; } } diff --git a/lipe/src/ldiskfs_read_ldd.h b/lipe/src/ldiskfs_read_ldd.h index 0818b30..75ed795 100644 --- a/lipe/src/ldiskfs_read_ldd.h +++ b/lipe/src/ldiskfs_read_ldd.h @@ -11,12 +11,14 @@ #ifndef _LIPE_LDISKFS_READ_LDD_H_ #define _LIPE_LDISKFS_READ_LDD_H_ +#include #include #include "debug.h" -#include "fake_lustre_disk.h" struct lustre_disk_data; +#define IS_MDT(data) ((data)->ldd_flags & LDD_F_SV_TYPE_MDT) + #define LDISKFS_OPENFS_FLAGS (EXT2_FLAG_64BITS | EXT2_FLAG_SKIP_MMP | \ EXT2_FLAG_IGNORE_SB_ERRORS | EXT2_FLAG_SUPER_ONLY) int ldiskfs_read_ldd(const char *dev, ext2_filsys fs, diff --git a/lipe/src/lipe_ldiskfs.c b/lipe/src/lipe_ldiskfs.c index 514a118..33d2b5e 100644 --- a/lipe/src/lipe_ldiskfs.c +++ b/lipe/src/lipe_ldiskfs.c @@ -23,10 +23,10 @@ #endif #include +#include #include #include "policy.h" #include "ldiskfs_read_ldd.h" -#include "fake_lustre_idl.h" #include "debug.h" #include "lustre_ea.h" #include "cmd.h" diff --git a/lipe/src/lipe_zfs.c b/lipe/src/lipe_zfs.c index f66a74e..441575c 100644 --- a/lipe/src/lipe_zfs.c +++ b/lipe/src/lipe_zfs.c @@ -12,11 +12,11 @@ #include #include #include +#include #include "lipe_object_attrs.h" #include "lipe_zfs.h" #include "zfs_read_ldd.h" -#include "fake_lustre_idl.h" #include "lustre_ea.h" #include "debug.h" @@ -133,7 +133,7 @@ static int zfs_get_xattr(struct lipe_object *lobject, struct hsm_attrs *hsm; hsm = (struct hsm_attrs *)value; - rc = lustre_hsm2user(hsm, hus); + rc = lipe_hsm2user(hsm, hus); if (rc) { OBJ_ERROR(lobject, "failed to decode HSM xattr, rc = %d\n", @@ -156,7 +156,7 @@ static int zfs_get_xattr(struct lipe_object *lobject, "unexpected size of LSoM xattr, expected [%u] got [%u]\n", sizeof(attrs->loa_som), cnt); } - lustre_som_swab((struct lustre_som_attrs *)value); + lipe_som_swab((struct lustre_som_attrs *)value); memcpy(&attrs->loa_som, value, cnt); } return 0; diff --git a/lipe/src/lustre_ea.c b/lipe/src/lustre_ea.c index e3147e0..31b06d2 100644 --- a/lipe/src/lustre_ea.c +++ b/lipe/src/lustre_ea.c @@ -10,7 +10,7 @@ #include #include #include -#include "fake_lustre_idl.h" +#include #include "lustre_ea.h" #include "debug.h" @@ -254,11 +254,10 @@ int shell_pattern_match_lum_pool(struct lov_user_md *lum, char *pattern) /* * Swab and extract HSM attributes from on-disk xattr. */ -int lustre_hsm2user(struct hsm_attrs *disk, - struct hsm_user_state *hus) +int lipe_hsm2user(struct hsm_attrs *disk, struct hsm_user_state *hus) { /* unpack HSM attributes */ - lustre_hsm_swab(disk); + lipe_hsm_swab(disk); /* fill hsm_user_state structure */ hus->hus_states = disk->hsm_flags; diff --git a/lipe/src/lustre_ea.h b/lipe/src/lustre_ea.h index 986ab76..488ea59 100644 --- a/lipe/src/lustre_ea.h +++ b/lipe/src/lustre_ea.h @@ -10,7 +10,7 @@ #ifndef _LIPE_LUSTRE_EA_H_ #define _LIPE_LUSTRE_EA_H_ -#include "fake_lustre_idl.h" +#include #include "general_policy.h" #include "lipe_object_attrs.h" @@ -18,11 +18,10 @@ int match_lum_ost(struct lov_user_md *lum, int64_t ost_index); int regular_expression_match_lum_pool(struct lov_user_md *lum, regex_t *reg); int shell_pattern_match_lum_pool(struct lov_user_md *lum, char *pattern); int decode_lum(struct lov_user_md *lum, ssize_t size); -int lustre_hsm2user(struct hsm_attrs *disk, - struct hsm_user_state *hus); +int lipe_hsm2user(struct hsm_attrs *disk, struct hsm_user_state *hus); enum lustre_dom_status dom_status_from_lum(struct lov_user_md *lum); -static inline void lustre_som_swab(struct lustre_som_attrs *attrs) +static inline void lipe_som_swab(struct lustre_som_attrs *attrs) { #if __BYTE_ORDER == __BIG_ENDIAN __swab16s(&attrs->lsa_valid); @@ -31,6 +30,22 @@ static inline void lustre_som_swab(struct lustre_som_attrs *attrs) #endif } +/** + * Swab, if needed, HSM structure which is stored on-disk in little-endian + * order. + * + * \param attrs - is a pointer to the HSM structure to be swabbed. + */ +static inline void lipe_hsm_swab(struct hsm_attrs *attrs) +{ +#ifdef __BIG_ENDIAN + __swab32s(&attrs->hsm_compat); + __swab32s(&attrs->hsm_flags); + __swab64s(&attrs->hsm_arch_id); + __swab64s(&attrs->hsm_arch_ver); +#endif +} + int lum_has_pattern_flag(struct lov_user_md *lum, __u32 layout_pattern); int lum_get_stripe(struct lov_user_md *lum, __u32 *stripe_count, __u32 *stripe_size, __u32 *comp_count); diff --git a/lipe/src/lustre_ea_ldiskfs.c b/lipe/src/lustre_ea_ldiskfs.c index 1ab66e0..7baa380 100644 --- a/lipe/src/lustre_ea_ldiskfs.c +++ b/lipe/src/lustre_ea_ldiskfs.c @@ -7,7 +7,7 @@ * * Author: Li Xi */ -#include "fake_lustre_idl.h" +#include #include "lipe_object_attrs.h" #include "lustre_ea.h" #include "lustre_ea_ldiskfs.h" @@ -150,7 +150,7 @@ int get_hsm_ea_ldiskfs(struct lipe_object *object, return -ENODATA; } else { hsm = (struct hsm_attrs *)buf; - rc = lustre_hsm2user(hsm, hus); + rc = lipe_hsm2user(hsm, hus); if (rc) { LERROR("failed to extract [%s] xattr for inode [%d], rc = %d\n", XATTR_NAME_HSM, ino, rc); @@ -249,7 +249,7 @@ int get_som_ea_ldiskfs(struct lipe_object *object, return -ENODATA; } - lustre_som_swab(som); + lipe_som_swab(som); return rc; } diff --git a/lipe/src/lustre_ea_ldiskfs.h b/lipe/src/lustre_ea_ldiskfs.h index bbdf8a8..1ecc356 100644 --- a/lipe/src/lustre_ea_ldiskfs.h +++ b/lipe/src/lustre_ea_ldiskfs.h @@ -12,7 +12,7 @@ #include -#include "fake_lustre_idl.h" +#include #include "general_policy.h" extern struct lipe_backfs_operations ldiskfs_operations; #endif /* _LIPE_LUSTRE_EA_LDISKFS_H_ */ diff --git a/lipe/src/policy.c b/lipe/src/policy.c index 76d69f9..78221fa 100644 --- a/lipe/src/policy.c +++ b/lipe/src/policy.c @@ -13,8 +13,8 @@ #include #include #include +#include #include "debug.h" -#include "fake_lustre_idl.h" #include "general_policy.h" #include "ldiskfs_read_ldd.h" #include "lipe_ldiskfs.h" diff --git a/lipe/src/posix_ea.c b/lipe/src/posix_ea.c index a08f717..35ecbc8 100644 --- a/lipe/src/posix_ea.c +++ b/lipe/src/posix_ea.c @@ -15,7 +15,7 @@ #include #include #include -#include "fake_lustre_idl.h" +#include #include "lipe_object_attrs.h" #include "lustre_ea.h" #include "posix_ea.h" @@ -131,7 +131,7 @@ static int get_hsm_ea_posix(struct lipe_object *object, } } else { hsm = (struct hsm_attrs *)buf; - rc = lustre_hsm2user(hsm, hus); + rc = lipe_hsm2user(hsm, hus); if (rc) { LERROR("failed to extract [%s] xattr for path [%s], rc = %d\n", XATTR_NAME_HSM, path, rc); @@ -200,7 +200,7 @@ static int get_som_ea_posix(struct lipe_object *object, return -ENODATA; } - lustre_som_swab(som); + lipe_som_swab(som); return 0; } diff --git a/lipe/src/posix_ea.h b/lipe/src/posix_ea.h index 47465e2..536c132 100644 --- a/lipe/src/posix_ea.h +++ b/lipe/src/posix_ea.h @@ -10,7 +10,7 @@ #ifndef _LIPE_POSIX_EA_H_ #define _LIPE_POSIX_EA_H_ -#include "fake_lustre_idl.h" +#include #include "general_policy.h" extern struct lipe_backfs_operations posix_operations; #endif /* _LIPE_POSIX_EA_H_ */ diff --git a/lipe/src/zfs_read_ldd.h b/lipe/src/zfs_read_ldd.h index 8af9164..cf2acba 100644 --- a/lipe/src/zfs_read_ldd.h +++ b/lipe/src/zfs_read_ldd.h @@ -12,7 +12,7 @@ #define _LIPE_ZFS_READ_LDD_H_ #include -#include "fake_lustre_disk.h" +#include int zfs_read_ldd(libzfs_handle_t *zfs, char *ds, struct lustre_disk_data *ldd); #endif /* _LIPE_ZFS_READ_LDD_H_ */ -- 1.8.3.1