Whamcloud - gitweb
LU-12705 build: fix building fail against Power9 little endian 07/36207/4
authorGu Zheng <gzheng@ddn.com>
Fri, 30 Aug 2019 07:27:30 +0000 (03:27 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 23 Sep 2019 08:43:56 +0000 (08:43 +0000)
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.

Lustre-change: https://review.whamcloud.com/36007
Lustre-commit: 4eddf36ac3607c66c172668b30eb5dcf921e3de4

Test-Parameters: trivial
Change-Id: I2e8569f4ac14f7d328a29d153ff57c7834cabc46
Signed-off-by: Gu Zheng <gzheng@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36207
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/utils/lfs.c
lustre/utils/lhsmtool_posix.c
lustre/utils/liblustreapi.c
lustre/utils/ll_decode_filter_fid.c
lustre/utils/ll_decode_linkea.c
lustre/utils/llsom_sync.c
lustre/utils/obd.c

index 55cece2..ab5d0b8 100644 (file)
@@ -630,7 +630,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)
@@ -887,7 +887,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 **********/
 
index a6feac2..bc38e6f 100644 (file)
@@ -2238,13 +2238,13 @@ static int comp_args_to_layout(struct llapi_layout **composite,
                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);
                        return -EINVAL;
                }
                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);
                        return -EINVAL;
                }
                if (lsa->lsa_nr_tgts != 0) {
@@ -2256,7 +2256,7 @@ static int comp_args_to_layout(struct llapi_layout **composite,
                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);
                        return -EINVAL;
                }
                if (lsa->lsa_pool_name != 0) {
@@ -2269,7 +2269,8 @@ static int comp_args_to_layout(struct llapi_layout **composite,
                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 */
@@ -2286,7 +2287,7 @@ static int comp_args_to_layout(struct llapi_layout **composite,
        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;
        }
 
@@ -2319,7 +2320,8 @@ static int comp_args_to_layout(struct llapi_layout **composite,
                    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);
                        return -EINVAL;
                }
                for (i = 0; i < lsa->lsa_nr_tgts; i++) {
@@ -3345,8 +3347,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;
                        }
@@ -3392,9 +3395,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;
@@ -5237,9 +5241,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;
                }
@@ -5911,7 +5916,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':
@@ -5923,7 +5929,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':
@@ -5934,7 +5941,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':
@@ -5945,7 +5953,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:
@@ -6195,7 +6204,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);
@@ -6228,7 +6237,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]",
@@ -6888,14 +6897,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 =
@@ -9835,14 +9846,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);
index 93e72be..22db61a 100644 (file)
@@ -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;
index c972888..50e8a13 100644 (file)
@@ -69,6 +69,7 @@
 #endif
 #include <poll.h>
 #include <time.h>
+#include <inttypes.h>
 
 #include <libcfs/util/ioctl.h>
 #include <libcfs/util/param.h>
@@ -391,7 +392,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);
                return rc;
        }
        if (!llapi_stripe_index_is_valid(stripe_offset)) {
@@ -2569,10 +2570,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) {
@@ -2625,8 +2626,8 @@ static void lov_dump_user_lmm_header(struct lov_user_md *lum, char *path,
                                            "Cannot determine default"
                                            " stripe size.");
                } else {
-                       llapi_printf(LLAPI_MSG_NORMAL, "%u",
-                                    lum->lmm_stripe_size);
+                       llapi_printf(LLAPI_MSG_NORMAL, "%llu",
+                                    (unsigned long long)lum->lmm_stripe_size);
                }
                if (!yaml && is_dir)
                        separator = " ";
@@ -3044,7 +3045,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));
@@ -3062,7 +3063,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";
        }
 
@@ -3075,7 +3076,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";
        }
 
index cc648ff..eb86e1c 100644 (file)
@@ -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,
index 1038df3..c1bc6e8 100644 (file)
@@ -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;
        }
 
index 1c2e5c3..73260ac 100644 (file)
@@ -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));
 
index 50031ca..1c767c2 100644 (file)
@@ -58,7 +58,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <limits.h>
-
 #include "obdctl.h"
 #include "lustreapi_internal.h"
 #include <libcfs/util/list.h>
@@ -1653,7 +1652,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;
                }
 
@@ -1746,7 +1745,7 @@ int jt_obd_destroy(int argc, char **argv)
         for (i = 1, next_count = verbose; i <= count && shmem_running(); 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;
                }
 
@@ -1888,7 +1887,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;
                }
 
@@ -2101,7 +2100,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;
        }