From 4eddf36ac3607c66c172668b30eb5dcf921e3de4 Mon Sep 17 00:00:00 2001 From: Gu Zheng Date: Fri, 30 Aug 2019 03:27:30 -0400 Subject: [PATCH 1/1] LU-12705 build: fix building fail against Power9 little endian We use "%ll[dux]" for __u64 variable as an input/output modifier, this may cause building error on some architectures which use "long" for 64-bit types, for example, Power9 little endian. Here add necessary typecasting (long long/unsigned long long) to make the build correct. Test-Parameters: trivial Change-Id: I2e8569f4ac14f7d328a29d153ff57c7834cabc46 Signed-off-by: Gu Zheng Reviewed-on: https://review.whamcloud.com/36007 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Li Xi --- lustre/include/uapi/linux/lustre/lustre_user.h | 4 +- lustre/utils/lfs.c | 68 ++++++++++++++++---------- lustre/utils/lhsmtool_posix.c | 3 +- lustre/utils/liblustreapi.c | 19 +++---- lustre/utils/ll_decode_filter_fid.c | 3 +- lustre/utils/ll_decode_linkea.c | 13 +++-- lustre/utils/llsom_sync.c | 11 +++-- lustre/utils/obd.c | 9 ++-- 8 files changed, 76 insertions(+), 54 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index edc4395..b799e71 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -684,7 +684,7 @@ struct lu_extent { }; #define DEXT "[%#llx, %#llx)" -#define PEXT(ext) (ext)->e_start, (ext)->e_end +#define PEXT(ext) (unsigned long long)(ext)->e_start, (unsigned long long)(ext)->e_end static inline bool lu_extent_is_overlapped(struct lu_extent *e1, struct lu_extent *e2) @@ -1013,7 +1013,7 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) * Need to strip '[' from DFID format first or use "["SFID"]" at caller. * usage: sscanf(fidstr, SFID, RFID(&fid)); */ #define SFID "0x%llx:0x%x:0x%x" -#define RFID(fid) &((fid)->f_seq), &((fid)->f_oid), &((fid)->f_ver) +#define RFID(fid) (unsigned long long *)&((fid)->f_seq), &((fid)->f_oid), &((fid)->f_ver) /********* Quotas **********/ diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 28e80cd..cf22944 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -2242,14 +2242,14 @@ new_comp: if (lsa->lsa_stripe_count != LLAPI_LAYOUT_DEFAULT) { fprintf(stderr, "Option 'stripe-count' can't be " "specified with Data-on-MDT component: %lld\n", - lsa->lsa_stripe_count); + (long long)lsa->lsa_stripe_count); errno = EINVAL; return -1; } if (lsa->lsa_stripe_size != LLAPI_LAYOUT_DEFAULT) { fprintf(stderr, "Option 'stripe-size' can't be " "specified with Data-on-MDT component: %llu\n", - lsa->lsa_stripe_size); + (unsigned long long)lsa->lsa_stripe_size); errno = EINVAL; return -1; } @@ -2263,7 +2263,7 @@ new_comp: if (lsa->lsa_stripe_off != LLAPI_LAYOUT_DEFAULT) { fprintf(stderr, "Option 'stripe-offset' can't be " "specified with Data-on-MDT component: %lld\n", - lsa->lsa_stripe_off); + (long long)lsa->lsa_stripe_off); errno = EINVAL; return -1; } @@ -2278,7 +2278,8 @@ new_comp: rc = llapi_layout_pattern_set(layout, lsa->lsa_pattern); if (rc) { fprintf(stderr, "Set stripe pattern %#llx failed. %s\n", - lsa->lsa_pattern, strerror(errno)); + (unsigned long long)lsa->lsa_pattern, + strerror(errno)); return rc; } /* Data-on-MDT component has always single stripe up to end */ @@ -2287,7 +2288,8 @@ new_comp: rc = llapi_layout_pattern_set(layout, lsa->lsa_pattern); if (rc) { fprintf(stderr, "Set stripe pattern %#llx failed. %s\n", - lsa->lsa_pattern, strerror(errno)); + (unsigned long long)lsa->lsa_pattern, + strerror(errno)); return rc; } } @@ -2309,7 +2311,7 @@ new_comp: rc = llapi_layout_stripe_count_set(layout, lsa->lsa_stripe_count); if (rc) { fprintf(stderr, "Set stripe count %lld failed: %s\n", - lsa->lsa_stripe_count, strerror(errno)); + (long long)lsa->lsa_stripe_count, strerror(errno)); return rc; } @@ -2335,7 +2337,8 @@ new_comp: lsa->lsa_stripe_count != LLAPI_LAYOUT_WIDE && lsa->lsa_nr_tgts != lsa->lsa_stripe_count) { fprintf(stderr, "stripe_count(%lld) != nr_tgts(%d)\n", - lsa->lsa_stripe_count, lsa->lsa_nr_tgts); + (long long)lsa->lsa_stripe_count, + lsa->lsa_nr_tgts); errno = EINVAL; return -1; } @@ -3577,8 +3580,9 @@ static int lfs_setstripe_internal(int argc, char **argv, lsa.lsa_stripe_count != lsa.lsa_nr_tgts) { fprintf(stderr, "error: %s: stripe count %lld doesn't match the number of MDTs: %d\n", - progname, lsa.lsa_stripe_count, - lsa.lsa_nr_tgts); + progname, + (long long)lsa.lsa_stripe_count, + lsa.lsa_nr_tgts); free(lmu); goto usage_error; } @@ -3632,9 +3636,10 @@ static int lfs_setstripe_internal(int argc, char **argv, lsa.lsa_stripe_count != LLAPI_LAYOUT_DEFAULT && lsa.lsa_stripe_count != LLAPI_LAYOUT_WIDE && lsa.lsa_nr_tgts != lsa.lsa_stripe_count) { - fprintf(stderr, "error: %s: stripe count %lld " - "doesn't match the number of OSTs: %d\n" - , argv[0], lsa.lsa_stripe_count, + fprintf(stderr, + "error: %s: stripe count %lld doesn't match the number of OSTs: %d\n", + argv[0], + (long long)lsa.lsa_stripe_count, lsa.lsa_nr_tgts); free(param); goto usage_error; @@ -5675,9 +5680,10 @@ static int lfs_setdirstripe(int argc, char **argv) if (lsa.lsa_stripe_count > 0 && lsa.lsa_stripe_count != LLAPI_LAYOUT_DEFAULT && lsa.lsa_stripe_count != lsa.lsa_nr_tgts) { - fprintf(stderr, "error: %s: stripe count %lld doesn't " - "match the number of MDTs: %d\n", - argv[0], lsa.lsa_stripe_count, lsa.lsa_nr_tgts); + fprintf(stderr, + "error: %s: stripe count %lld doesn't match the number of MDTs: %d\n", + argv[0], (long long)lsa.lsa_stripe_count, + lsa.lsa_nr_tgts); free(param); return CMD_HELP; } @@ -6437,7 +6443,8 @@ quota_type_def: fprintf(stderr, "%s setquota: warning: block softlimit '%llu' smaller than minimum qunit size\n" "See '%s help setquota' or Lustre manual for details\n", - progname, dqb->dqb_bsoftlimit, + progname, + (unsigned long long)dqb->dqb_bsoftlimit, progname); break; case 'B': @@ -6449,7 +6456,8 @@ quota_type_def: fprintf(stderr, "%s setquota: warning: block hardlimit '%llu' smaller than minimum qunit size\n" "See '%s help setquota' or Lustre manual for details\n", - progname, dqb->dqb_bhardlimit, + progname, + (unsigned long long)dqb->dqb_bhardlimit, progname); break; case 'i': @@ -6460,7 +6468,8 @@ quota_type_def: fprintf(stderr, "%s setquota: warning: inode softlimit '%llu' smaller than minimum qunit size\n" "See '%s help setquota' or Lustre manual for details\n", - progname, dqb->dqb_isoftlimit, + progname, + (unsigned long long)dqb->dqb_isoftlimit, progname); break; case 'I': @@ -6471,7 +6480,8 @@ quota_type_def: fprintf(stderr, "%s setquota: warning: inode hardlimit '%llu' smaller than minimum qunit size\n" "See '%s help setquota' or Lustre manual for details\n", - progname, dqb->dqb_ihardlimit, + progname, + (unsigned long long)dqb->dqb_ihardlimit, progname); break; default: @@ -6721,7 +6731,7 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type, diff2str(dqb->dqb_btime, timebuf, now); else if (show_default) snprintf(timebuf, sizeof(timebuf), "%llu", - dqb->dqb_btime); + (unsigned long long)dqb->dqb_btime); kbytes2str(lustre_stoqb(dqb->dqb_curspace), strbuf, sizeof(strbuf), h); @@ -6754,7 +6764,7 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type, diff2str(dqb->dqb_itime, timebuf, now); else if (show_default) snprintf(timebuf, sizeof(timebuf), "%llu", - dqb->dqb_itime); + (unsigned long long)dqb->dqb_itime); snprintf(numbuf[0], sizeof(numbuf), (dqb->dqb_valid & QIF_INODES) ? "%ju" : "[%ju]", @@ -7416,14 +7426,16 @@ static int lfs_changelog(int argc, char **argv) struct changelog_ext_extra_flags *ef = changelog_rec_extra_flags(rec); - printf(" ef=0x%llx", ef->cr_extra_flags); + printf(" ef=0x%llx", + (unsigned long long)ef->cr_extra_flags); if (ef->cr_extra_flags & CLFE_UIDGID) { struct changelog_ext_uidgid *uidgid = changelog_rec_uidgid(rec); printf(" u=%llu:%llu", - uidgid->cr_uid, uidgid->cr_gid); + (unsigned long long)uidgid->cr_uid, + (unsigned long long)uidgid->cr_gid); } if (ef->cr_extra_flags & CLFE_NID) { struct changelog_ext_nid *nid = @@ -8639,7 +8651,8 @@ static int lfs_heat_get(int argc, char **argv) printf("flags: %x\n", heat->lh_flags); for (i = 0; i < heat->lh_count; i++) - printf("%s: %llu\n", heat_names[i], heat->lh_heat[i]); + printf("%s: %llu\n", heat_names[i], + (unsigned long long)heat->lh_heat[i]); next: if (rc == 0 && rc2 < 0) rc = rc2; @@ -10595,14 +10608,15 @@ static int lfs_getsom(int argc, char **argv) switch (type) { case LFS_SOM_ATTR_ALL: printf("file: %s size: %llu blocks: %llu flags: %x\n", - path, attrs->lsa_size, attrs->lsa_blocks, + path, (unsigned long long)attrs->lsa_size, + (unsigned long long)attrs->lsa_blocks, attrs->lsa_valid); break; case LFS_SOM_SIZE: - printf("%llu\n", attrs->lsa_size); + printf("%llu\n", (unsigned long long)attrs->lsa_size); break; case LFS_SOM_BLOCKS: - printf("%llu\n", attrs->lsa_blocks); + printf("%llu\n", (unsigned long long)attrs->lsa_blocks); break; case LFS_SOM_FLAGS: printf("%x\n", attrs->lsa_valid); diff --git a/lustre/utils/lhsmtool_posix.c b/lustre/utils/lhsmtool_posix.c index a0c8a77..152dc81 100644 --- a/lustre/utils/lhsmtool_posix.c +++ b/lustre/utils/lhsmtool_posix.c @@ -699,7 +699,8 @@ static int ct_copy_data(struct hsm_copyaction_private *hcp, const char *src, CT_TRACE("bandwith control: %lluB/s " "excess=%llu sleep for " "%lld.%09lds", - opt.o_bandwidth, excess, + (unsigned long long)opt.o_bandwidth, + (unsigned long long)excess, (long long)delay.tv_sec, delay.tv_nsec); last_bw_print = now; diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 600e732..59d02de 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -69,6 +69,7 @@ #endif #include #include +#include #include #include @@ -405,7 +406,7 @@ int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset, rc = -EINVAL; llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe_size %llu, " "must be an even multiple of %d bytes", - stripe_size, page_size); + (unsigned long long)stripe_size, page_size); goto out; } if (!llapi_stripe_index_is_valid(stripe_offset)) { @@ -424,7 +425,7 @@ int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset, rc = -EINVAL; llapi_error(LLAPI_MSG_ERROR, rc, "error: stripe size '%llu' over 4GB limit", - stripe_size); + (unsigned long long)stripe_size); goto out; } @@ -2703,10 +2704,10 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path, ver = (__u32)(lmm_oi_id(&lum->lmm_oi) >> 32); if (yaml) llapi_printf(LLAPI_MSG_NORMAL, DFID_NOBRACE"\n", - seq, oid, ver); + (unsigned long long)seq, oid, ver); else llapi_printf(LLAPI_MSG_NORMAL, DFID"\n", - seq, oid, ver); + (unsigned long long)seq, oid, ver); } if (verbose & VERBOSE_STRIPE_COUNT) { @@ -2766,8 +2767,8 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path, /* Extension size is in KiB */ llapi_printf(LLAPI_MSG_NORMAL, "%llu", extension ? - lum->lmm_stripe_size * SEL_UNIT_SIZE : - lum->lmm_stripe_size); + (unsigned long long)(lum->lmm_stripe_size * SEL_UNIT_SIZE) : + (unsigned long long)lum->lmm_stripe_size); } if (!yaml && is_dir) separator = " "; @@ -3185,7 +3186,7 @@ static void lov_dump_comp_v1_entry(struct find_param *param, "%4slcme_timestamp: ", " "); if (yaml) { llapi_printf(LLAPI_MSG_NORMAL, "%llu", - entry->lcme_timestamp); + (unsigned long long)entry->lcme_timestamp); } else { time_t stamp = entry->lcme_timestamp; char *date_str = asctime(localtime(&stamp)); @@ -3203,7 +3204,7 @@ static void lov_dump_comp_v1_entry(struct find_param *param, llapi_printf(LLAPI_MSG_NORMAL, "%4slcme_extent.e_start: ", " "); llapi_printf(LLAPI_MSG_NORMAL, "%llu", - entry->lcme_extent.e_start); + (unsigned long long)entry->lcme_extent.e_start); separator = "\n"; } @@ -3216,7 +3217,7 @@ static void lov_dump_comp_v1_entry(struct find_param *param, llapi_printf(LLAPI_MSG_NORMAL, "%s", "EOF"); else llapi_printf(LLAPI_MSG_NORMAL, "%llu", - entry->lcme_extent.e_end); + (unsigned long long)entry->lcme_extent.e_end); separator = "\n"; } diff --git a/lustre/utils/ll_decode_filter_fid.c b/lustre/utils/ll_decode_filter_fid.c index cc648ff..eb86e1c 100644 --- a/lustre/utils/ll_decode_filter_fid.c +++ b/lustre/utils/ll_decode_filter_fid.c @@ -121,7 +121,8 @@ int main(int argc, char *argv[]) printf("%s: parent="DFID" stripe=%u " "stripe_size=%u stripe_count=%u", - argv[i], loa->loa_parent_fid.f_seq, + argv[i], + (unsigned long long)loa->loa_parent_fid.f_seq, loa->loa_parent_fid.f_oid, 0, /* ver */ loa->loa_parent_fid.f_stripe_idx & PFID_STRIPE_COUNT_MASK, diff --git a/lustre/utils/ll_decode_linkea.c b/lustre/utils/ll_decode_linkea.c index 1038df3..c1bc6e8 100644 --- a/lustre/utils/ll_decode_linkea.c +++ b/lustre/utils/ll_decode_linkea.c @@ -86,7 +86,7 @@ int decode_linkea(const char *fname) if (leh->leh_len > size) { fprintf(stderr, "%s: invalid length %llu, should smaller than %zd\n", - fname, leh->leh_len, size); + fname, (unsigned long long)leh->leh_len, size); return -1; } @@ -98,8 +98,9 @@ int decode_linkea(const char *fname) length += reclen; if (length > leh->leh_len) { fprintf(stderr, - "%s: length exceeded, expected %lld, got %lld\n", - fname, leh->leh_len, length); + "%s: length exceeded, expected %llu, got %llu\n", + fname, (unsigned long long)leh->leh_len, + (unsigned long long)length); return -1; } memcpy(&pfid, &lee->lee_parent_fid, sizeof(pfid)); @@ -112,8 +113,10 @@ int decode_linkea(const char *fname) if (length != leh->leh_len) { fprintf(stderr, - "%s: length mismatch, expected %lld, got %lld\n", - fname, leh->leh_len, length); + "%s: length mismatch, expected %llu, got %llu\n", + fname, + (unsigned long long)leh->leh_len, + (unsigned long long)length); return -1; } diff --git a/lustre/utils/llsom_sync.c b/lustre/utils/llsom_sync.c index 1c2e5c3..73260ac 100644 --- a/lustre/utils/llsom_sync.c +++ b/lustre/utils/llsom_sync.c @@ -272,7 +272,9 @@ static int lsom_update_one(struct fid_rec *f) llapi_printf(LLAPI_MSG_DEBUG, "record %llu:%llu, updated LSOM for fid " DFID - " size:%lu blocks:%lu\n", f->fr_time, f->fr_index, + " size:%lu blocks:%lu\n", + (unsigned long long)f->fr_time, + (unsigned long long)f->fr_index, PFID(&f->fr_fid), st.st_size, st.st_blocks); clean_up: @@ -281,7 +283,7 @@ clean_up: if (rc) llapi_error(LLAPI_MSG_ERROR, rc, "failed to clear changelog record: %s:%llu", - opt.o_chlg_user, f->fr_index); + opt.o_chlg_user, (unsigned long long)f->fr_index); return rc; } @@ -404,8 +406,9 @@ static int process_record(struct changelog_rec *rec) } } - llapi_printf(LLAPI_MSG_DEBUG, "Processed changelog record index:%llu " - "type:%s(0x%x) FID:"DFID"\n", index, + llapi_printf(LLAPI_MSG_DEBUG, + "Processed changelog record index:%llu type:%s(0x%x) FID:"DFID"\n", + (unsigned long long)index, changelog_type2str(__le32_to_cpu(rec->cr_type)), __le32_to_cpu(rec->cr_type), PFID(&rec->cr_tfid)); diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 226852b..e82bdf7 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -58,7 +58,6 @@ #include #include #include - #include "obdctl.h" #include "lustreapi_internal.h" #include @@ -1648,7 +1647,7 @@ int jt_obd_test_setattr(int argc, char **argv) for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) { if (objid >= OBIF_MAX_OID) { fprintf(stderr, "errr: %s: invalid objid '%llu'\n", - jt_cmdname(argv[0]), objid); + jt_cmdname(argv[0]), (unsigned long long)objid); return -E2BIG; } @@ -1741,7 +1740,7 @@ int jt_obd_destroy(int argc, char **argv) i++, id++) { if (id >= OBIF_MAX_OID) { fprintf(stderr, "errr: %s: invalid objid '%llu'\n", - jt_cmdname(argv[0]), id); + jt_cmdname(argv[0]), (unsigned long long)id); return -E2BIG; } @@ -1883,7 +1882,7 @@ int jt_obd_test_getattr(int argc, char **argv) for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) { if (objid >= OBIF_MAX_OID) { fprintf(stderr, "errr: %s: invalid objid '%llu'\n", - jt_cmdname(argv[0]), objid); + jt_cmdname(argv[0]), (unsigned long long)objid); return -E2BIG; } @@ -2095,7 +2094,7 @@ int jt_obd_test_brw(int argc, char **argv) ostid_set_seq_echo(&data.ioc_obdo1.o_oi); if (objid >= OBIF_MAX_OID) { fprintf(stderr, "errr: %s: invalid objid '%llu'\n", - jt_cmdname(argv[0]), objid); + jt_cmdname(argv[0]), (unsigned long long)objid); return -E2BIG; } -- 1.8.3.1