Whamcloud - gitweb
b=21527 Portability fixes
authorBrian J. Murrell <brian@sun.com>
Tue, 23 Mar 2010 18:37:02 +0000 (11:37 -0700)
committerRobert Read <rread@sun.com>
Tue, 23 Mar 2010 18:37:02 +0000 (11:37 -0700)
Various portability fixes so that we can build without warnings on 64-bit
architectures.

i=fanyong
i=rread

28 files changed:
libcfs/include/libcfs/linux/kp30.h
libcfs/include/libcfs/posix/posix-wordsize.h
lnet/utils/lst.c
lnet/utils/lstclient.c
lustre/fld/fld_index.c
lustre/include/lustre/lustre_user.h
lustre/lclient/lcommon_cl.c
lustre/liblustre/llite_cl.c
lustre/liblustre/rw.c
lustre/liblustre/tests/sanity.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_io.c
lustre/lov/lov_merge.c
lustre/lov/lov_pack.c
lustre/mdd/mdd_device.c
lustre/mdd/mdd_object.c
lustre/mdd/mdd_orphans.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_lib.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_recovery.c
lustre/mdt/mdt_xattr.c
lustre/obdecho/echo_client.c
lustre/osc/osc_page.c
lustre/ptlrpc/llog_net.c
lustre/utils/lustre_rsync.c
lustre/utils/mkfs_lustre.c
lustre/utils/obd.c

index ba566f7..3b4c44b 100644 (file)
@@ -350,11 +350,13 @@ extern int  lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size,
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
+# define LPX64i "%Lx"
 # define LPF64 "L"
 #else
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
+# define LPX64i "%lx"
 # define LPF64 "l"
 #endif
 
@@ -372,8 +374,10 @@ extern int  lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size,
 
 #ifdef HAVE_SIZE_T_LONG
 # define LPSZ  "%lu"
+# define LPSZX "%lx"
 #else
 # define LPSZ  "%u"
+# define LPSZX "%x"
 #endif
 
 #ifdef HAVE_SSIZE_T_LONG
index f70c3ed..64500a5 100644 (file)
@@ -118,23 +118,28 @@ typedef struct {
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
+# define LPX64i "%Lx"
 # define LPF64 "L"
 #elif (BITS_PER_LONG == 32)
 # define LPU64 "%Lu"
 # define LPD64 "%Ld"
 # define LPX64 "%#Lx"
+# define LPX64i "%Lx"
 # define LPF64 "L"
 #elif (BITS_PER_LONG == 64)
 # define LPU64 "%lu"
 # define LPD64 "%ld"
 # define LPX64 "%#lx"
+# define LPX64i "%lx"
 # define LPF64 "l"
 #endif
 
 #ifdef HAVE_SIZE_T_LONG
 # define LPSZ  "%lu"
+# define LPSZX "%lx"
 #else
 # define LPSZ  "%u"
+# define LPSZX "%x"
 #endif
 
 #ifdef HAVE_SSIZE_T_LONG
index 37a7580..776b041 100644 (file)
@@ -645,7 +645,7 @@ jt_lst_show_session(int argc, char **argv)
                 return -1;
         }
 
-        fprintf(stdout, "%s ID: %Lu@%s, KEY: %d NODES: %d\n",
+        fprintf(stdout, "%s ID: "LPU64"@%s, KEY: %d NODES: %d\n",
                 name, sid.ses_stamp, libcfs_nid2str(sid.ses_nid),
                 key, ndinfo.nle_nnode);
 
index 26a05c9..6f46549 100644 (file)
@@ -146,7 +146,7 @@ lstjn_join_session(char *ses, char *grp)
                 return -1;
         }
 
-        fprintf(stdout, "Session %s, ID: %s, %Lu\n",
+        fprintf(stdout, "Session %s, ID: %s, "LPU64"\n",
                 ses, libcfs_nid2str(rep->join_sid.ses_nid),
                 rep->join_sid.ses_stamp);
 
index 03da47e..1dfb481 100644 (file)
@@ -244,7 +244,7 @@ int fld_index_lookup(struct lu_server_fld *fld,
                         rc = -ENOENT;
         }
 
-        CDEBUG(D_INFO, "%s: lookup seq = %llx range : "DRANGE" rc = %d\n",
+        CDEBUG(D_INFO, "%s: lookup seq = "LPX64" range : "DRANGE" rc = %d\n",
                fld->lsf_name, seq, PRANGE(range), rc);
 
         RETURN(rc);
index f56f4b4..18dce74 100644 (file)
@@ -324,7 +324,11 @@ typedef struct lu_fid lustre_fid;
 
 /* scanf input parse format -- strip '[' first.
    e.g. sscanf(fidstr, SFID, RFID(&fid)); */
-#define SFID "0x%llx:0x%x:0x%x"
+/* #define SFID "0x"LPX64i":0x"LPSZX":0x"LPSZX""
+liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', but argument 4 has type 'unsigned int *'
+liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', but argument 5 has type 'unsigned int *'
+*/
+#define SFID "0x"LPX64i":0x%x:0x%x"
 #define RFID(fid)     \
         &((fid)->f_seq), \
         &((fid)->f_oid), \
index 99b6790..a8322e1 100644 (file)
@@ -683,7 +683,7 @@ void ccc_lock_state(const struct lu_env *env,
                         if (lock->cll_descr.cld_start == 0 &&
                             lock->cll_descr.cld_end == CL_PAGE_EOF) {
                                 cl_isize_write_nolock(inode, attr->cat_kms);
-                                CDEBUG(D_INODE, DFID" updating i_size %llu\n",
+                                CDEBUG(D_INODE, DFID" updating i_size "LPU64"\n",
                                        PFID(lu_object_fid(&obj->co_lu)),
                                        (__u64)cl_isize_read(inode));
                         }
index 4d6e8b1..12723d4 100644 (file)
@@ -661,7 +661,7 @@ static int slp_io_start(const struct lu_env *env, const struct cl_io_slice *ios)
                 GOTO(out, err);
 
         CDEBUG(D_INODE,
-               "%s ino %lu, %lu bytes, offset %lld, i_size %llu\n",
+               "%s ino %lu, %lu bytes, offset "LPU64", i_size "LPU64"\n",
                write ? "Write" : "Read", (unsigned long)st->st_ino,
                cnt, (__u64)pos, (__u64)st->st_size);
 
index 6c848de..2b9581e 100644 (file)
@@ -189,7 +189,7 @@ static int llu_glimpse_callback(struct ldlm_lock *lock, void *reqp)
         lvb = req_capsule_server_get(&req->rq_pill, &RMF_DLM_LVB);
         lvb->lvb_size = lli->lli_smd->lsm_oinfo[stripe]->loi_kms;
 
-        LDLM_DEBUG(lock, "i_size: %llu -> stripe number %u -> kms "LPU64,
+        LDLM_DEBUG(lock, "i_size: "LPU64" -> stripe number %u -> kms "LPU64,
                    (__u64)llu_i2stat(inode)->st_size, stripe,lvb->lvb_size);
  iput:
         I_RELE(inode);
@@ -247,7 +247,7 @@ int llu_extent_lock(struct ll_file_data *fd, struct inode *inode,
             (sbi->ll_flags & LL_SBI_NOLCK) || mode == LCK_NL)
                 RETURN(0);
 
-        CDEBUG(D_DLMTRACE, "Locking inode %llu, start "LPU64" end "LPU64"\n",
+        CDEBUG(D_DLMTRACE, "Locking inode "LPU64", start "LPU64" end "LPU64"\n",
                (__u64)st->st_ino, policy->l_extent.start,
                policy->l_extent.end);
 
index c0c3c05..e652cbb 100644 (file)
@@ -793,8 +793,8 @@ int t23(char *name)
 {
         char path[MAX_PATH_LENGTH];
         int fd;
-        off_t ret;
-        off_t off;
+        long long ret;
+        loff_t off;
 
         ENTER("handle seek > 2GB");
         snprintf(path, MAX_PATH_LENGTH, "%s/f%s", lustre_path, name);
@@ -843,7 +843,7 @@ int t23(char *name)
         ret = lseek(fd, -buf_size + 2, SEEK_CUR);
         if (ret != off) {
                 printf("relative seek error for %d %llu != %llu\n",
-                       -buf_size + 2, ret, off);
+                       -buf_size + 2, ret, (unsigned long long) off);
                 if (ret == -1)
                         perror("relative seek");
                 return -1;
@@ -869,7 +869,7 @@ int t23(char *name)
         off = 2048ULL * 1024 * 1024, SEEK_SET;
         ret = lseek(fd, off, SEEK_SET);
         if (ret != off) {
-                printf("seek 2GB error for %llu != %llu\n", ret, off);
+                printf("seek 2GB error for %llu != %llu\n", ret, (unsigned long long) off);
                 if (ret == -1)
                         perror("seek 2GB");
                 return -1;
index def20ca..e4af062 100644 (file)
@@ -2414,7 +2414,7 @@ static int lmv_readpage(struct obd_export *exp, const struct lu_fid *fid,
                                 CDEBUG(D_INODE,
                                        ""DFID" reset end "LPX64" tgt %d\n",
                                        PFID(&rid),
-                                       le64_to_cpu(dp->ldp_hash_end), tgt_idx);
+                                       (__u64)le64_to_cpu(dp->ldp_hash_end), tgt_idx);
                         }
                 }
                 cfs_kunmap(page);
index b21fd94..bf7a958 100644 (file)
@@ -396,7 +396,7 @@ static int lov_io_iter_init(const struct lu_env *env,
                                            start, end);
                         rc = cl_io_iter_init(sub->sub_env, sub->sub_io);
                         lov_sub_put(sub);
-                        CDEBUG(D_VFSTRACE, "shrink: %i [%llu, %llu)\n",
+                        CDEBUG(D_VFSTRACE, "shrink: %i ["LPU64", "LPU64")\n",
                                stripe, start, end);
                 } else
                         rc = PTR_ERR(sub);
@@ -435,7 +435,7 @@ static int lov_io_rw_iter_init(const struct lu_env *env,
                                               next) - io->u.ci_rw.crw_pos;
                 lio->lis_pos    = io->u.ci_rw.crw_pos;
                 lio->lis_endpos = io->u.ci_rw.crw_pos + io->u.ci_rw.crw_count;
-                CDEBUG(D_VFSTRACE, "stripe: %llu chunk: [%llu, %llu) %llu\n",
+                CDEBUG(D_VFSTRACE, "stripe: "LPU64" chunk: ["LPU64", "LPU64") "LPU64"\n",
                        (__u64)start, lio->lis_pos, lio->lis_endpos,
                        (__u64)lio->lis_io_endpos);
         }
index 091e435..272d5ef 100644 (file)
@@ -135,7 +135,7 @@ int lov_merge_lvb(struct obd_export *exp,
         rc = lov_merge_lvb_kms(lsm, lvb, &kms);
         if (kms_only)
                 lvb->lvb_size = kms;
-        CDEBUG(D_INODE, "merged: %llu %llu %llu %llu %llu\n",
+        CDEBUG(D_INODE, "merged: "LPU64" "LPU64" "LPU64" "LPU64" "LPU64"\n",
                lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime,
                lvb->lvb_ctime, lvb->lvb_blocks);
         RETURN(rc);
index ca92e35..2972086 100644 (file)
@@ -59,7 +59,7 @@ static void lov_dump_lmm_common(int level, void *lmmp)
         struct lov_mds_md *lmm = lmmp;
 
         CDEBUG(level, "objid "LPX64", magic 0x%08x, pattern %#x\n",
-               le64_to_cpu(lmm->lmm_object_id),
+               (__u64)le64_to_cpu(lmm->lmm_object_id),
                le32_to_cpu(lmm->lmm_magic),
                le32_to_cpu(lmm->lmm_pattern));
         CDEBUG(level,"stripe_size %u, stripe_count %u\n",
@@ -80,8 +80,8 @@ static void lov_dump_lmm_objects(int level, struct lov_ost_data *lod,
         for (i = 0; i < stripe_count; ++i, ++lod) {
                 CDEBUG(level, "stripe %u idx %u subobj "LPX64"/"LPX64"\n", i,
                        le32_to_cpu(lod->l_ost_idx),
-                       le64_to_cpu(lod->l_object_gr),
-                       le64_to_cpu(lod->l_object_id));
+                       (__u64)le64_to_cpu(lod->l_object_gr),
+                       (__u64)le64_to_cpu(lod->l_object_id));
         }
 }
 
index 1bf62ba..95408d8 100644 (file)
@@ -1410,7 +1410,7 @@ static int mdd_changelog_user_purge(struct mdd_device *mdd, int id,
         int rc;
         ENTRY;
 
-        CDEBUG(D_IOCTL, "Purge request: id=%d, endrec="LPD64"\n", id, endrec);
+        CDEBUG(D_IOCTL, "Purge request: id=%d, endrec=%lld\n", id, endrec);
 
         data.mcud_id = id;
         data.mcud_minid = 0;
index 99ed100..aa9a5cd 100644 (file)
@@ -315,7 +315,7 @@ static int mdd_object_print(const struct lu_env *env, void *cookie,
 {
         struct mdd_object *mdd = lu2mdd_obj((struct lu_object *)o);
         return (*p)(env, cookie, LUSTRE_MDD_NAME"-object@%p(open_count=%d, "
-                    "valid=%x, cltime=%llu, flags=%lx)",
+                    "valid=%x, cltime="LPU64", flags=%lx)",
                     mdd, mdd->mod_count, mdd->mod_valid,
                     mdd->mod_cltime, mdd->mod_flags);
 }
index c9dff6d..c64327c 100644 (file)
@@ -70,7 +70,8 @@ static struct dt_key* orph_key_fill(const struct lu_env *env,
         int rc;
 
         LASSERT(key);
-        rc = snprintf(key, NAME_MAX + 1, ORPHAN_FILE_NAME_FORMAT, fid_seq(lf),
+        rc = snprintf(key, NAME_MAX + 1, ORPHAN_FILE_NAME_FORMAT,
+                      (long long unsigned int)fid_seq(lf),
                       fid_oid(lf), fid_ver(lf), op);
         if (rc > 0)
                 return (struct dt_key*) key;
@@ -98,14 +99,15 @@ static int orphan_key_to_fid(char *key, struct lu_fid *lf)
         int rc = 0;
         unsigned int op;
 
-        rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT, &lf->f_seq, &lf->f_oid,
+        rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT,
+                    (long long unsigned int *)&lf->f_seq, &lf->f_oid,
                     &lf->f_ver, &op);
         if (rc == 4)
                 return 0;
 
         /* build igif */
         rc = sscanf(key, ORPHAN_FILE_NAME_FORMAT_18,
-                    &lf->f_seq, &lf->f_oid);
+                    (long long unsigned int *)&lf->f_seq, &lf->f_oid);
         if (rc == 2) {
                 lf->f_ver = 0;
                 return 0;
index a38edde..1faf7e5 100644 (file)
@@ -4840,8 +4840,8 @@ static int mdt_object_print(const struct lu_env *env, void *cookie,
                             lu_printer_t p, const struct lu_object *o)
 {
         struct mdt_object *mdto = mdt_obj((struct lu_object *)o);
-        return (*p)(env, cookie, LUSTRE_MDT_NAME"-object@%p(ioepoch=%llu "
-                    "flags=%llx, epochcount=%d, writecount=%d)",
+        return (*p)(env, cookie, LUSTRE_MDT_NAME"-object@%p(ioepoch="LPU64" "
+                    "flags="LPX64", epochcount=%d, writecount=%d)",
                     mdto, mdto->mot_ioepoch, mdto->mot_flags,
                     mdto->mot_ioepoch_count, mdto->mot_writecount);
 }
index 0d3307a..de23917 100644 (file)
@@ -755,7 +755,7 @@ static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr,
                 ATTR_ATTR_FLAG|ATTR_RAW|MDS_OPEN_OWNEROVERRIDE|
                 ATTR_FORCE|ATTR_KILL_SUID|ATTR_KILL_SGID);
         if (in != 0)
-                CERROR("Unknown attr bits: %#llx\n", in);
+                CERROR("Unknown attr bits: "LPX64"\n", in);
         return out;
 }
 /* unpacking */
index b8e098a..e48fb7e 100644 (file)
@@ -567,7 +567,7 @@ static void mdt_empty_transno(struct mdt_thread_info* info)
         }
         cfs_spin_unlock(&mdt->mdt_transno_lock);
 
-        CDEBUG(D_INODE, "transno = %llu, last_committed = %llu\n",
+        CDEBUG(D_INODE, "transno = "LPU64", last_committed = "LPU64"\n",
                         info->mti_transno,
                         req->rq_export->exp_obd->obd_last_committed);
 
index 8f18207..4a9440a 100644 (file)
@@ -864,7 +864,7 @@ static int mdt_txn_stop_cb(const struct lu_env *env,
                 mdt_versions_set(mti);
 
         /* filling reply data */
-        CDEBUG(D_INODE, "transno = %llu, last_committed = %llu\n",
+        CDEBUG(D_INODE, "transno = "LPU64", last_committed = "LPU64"\n",
                mti->mti_transno, req->rq_export->exp_obd->obd_last_committed);
 
         req->rq_transno = mti->mti_transno;
index ae04caf..c268b14 100644 (file)
@@ -359,7 +359,7 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
 
         if (unlikely(!(valid & OBD_MD_FLCTIME))) {
                 CWARN("client miss to set OBD_MD_FLCTIME when "
-                      "setxattr: [object "DFID"] [valid %llu]\n",
+                      "setxattr: [object "DFID"] [valid "LPU64"]\n",
                       PFID(rr->rr_fid1), valid);
                 attr->la_ctime = cfs_time_current_sec();
         }
index 7659c88..0cb20d9 100644 (file)
@@ -1067,7 +1067,7 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed,
         cfs_spin_lock (&ec->ec_lock);
         cfs_list_for_each (el, &ec->ec_locks) {
                 ecl = cfs_list_entry (el, struct echo_lock, el_chain);
-                CDEBUG(D_INFO, "ecl: %p, cookie: %llx\n", ecl, ecl->el_cookie);
+                CDEBUG(D_INFO, "ecl: %p, cookie: "LPX64"\n", ecl, ecl->el_cookie);
                 found = (ecl->el_cookie == cookie);
                 if (found) {
                         if (cfs_atomic_dec_and_test(&ecl->el_refcount))
@@ -1757,7 +1757,7 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa,
         rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie);
         if (rc == 0) {
                 oa->o_valid |= OBD_MD_FLHANDLE;
-                CDEBUG(D_INFO, "Cookie is %llx\n", ulh->cookie);
+                CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie);
         }
         echo_put_object(eco);
         RETURN(rc);
@@ -1772,7 +1772,7 @@ echo_client_cancel(struct obd_export *exp, struct obdo *oa)
         if ((oa->o_valid & OBD_MD_FLHANDLE) == 0)
                 return -EINVAL;
 
-        CDEBUG(D_INFO, "Cookie is %llx\n", cookie);
+        CDEBUG(D_INFO, "Cookie is "LPX64"\n", cookie);
         return cl_echo_cancel(ed, cookie);
 }
 
index 56c3106..cc8df43 100644 (file)
@@ -301,7 +301,7 @@ static int osc_page_print(const struct lu_env *env,
 
         return (*printer)(env, cookie, LUSTRE_OSC_NAME"-page@%p: "
                           "1< %#x %d %u %s %s %s > "
-                          "2< %llu %u %#x %#x | %p %p %p %p %p > "
+                          "2< "LPU64" %u %#x %#x | %p %p %p %p %p > "
                           "3< %s %p %d %lu %d > "
                           "4< %d %d %d %lu %s | %s %s %s %s > "
                           "5< %s %s %s %s | %d %s %s | %d %s %s>\n",
index 8be6eed..2818696 100644 (file)
@@ -116,7 +116,7 @@ int llog_origin_connect(struct llog_ctxt *ctxt,
         if (req == NULL)
                 RETURN(-ENOMEM);
 
-        CDEBUG(D_OTHER, "%s mount_count %llu, connection count %llu\n",
+        CDEBUG(D_OTHER, "%s mount_count "LPU64", connection count "LPU64"\n",
                ctxt->loc_exp->exp_obd->obd_type->typ_name,
                ctxt->loc_gen.mnt_cnt, ctxt->loc_gen.conn_cnt);
 
index 5ef3297..0f3d6de 100644 (file)
@@ -1319,7 +1319,7 @@ void lr_print_status(struct lr_info *info)
         if (statuslog != NULL)
                 printf("Statuslog: %s\n", statuslog);
         printf("Changelog registration: %s\n", status->ls_registration);
-        printf("Starting changelog record: %lld\n", status->ls_last_recno);
+        printf("Starting changelog record: "LPD64"\n", status->ls_last_recno);
         if (noxattr)
                 printf("Replicate xattrs: no\n");
         if (noclear)
index cbc33db..6024c74 100644 (file)
@@ -709,7 +709,7 @@ int make_lustre_backfs(struct mkfs_opts *mop)
         vprint("formatting backing filesystem %s on %s\n",
                MT_STR(&mop->mo_ldd), dev);
         vprint("\ttarget name  %s\n", mop->mo_ldd.ldd_svname);
-        vprint("\t4k blocks     %llu\n", block_count);
+        vprint("\t4k blocks     "LPU64"\n", block_count);
         vprint("\toptions       %s\n", mop->mo_mkfsopts);
 
         /* mkfs_cmd's trailing space is important! */
@@ -717,7 +717,7 @@ int make_lustre_backfs(struct mkfs_opts *mop)
         strscat(mkfs_cmd, " ", sizeof(mkfs_cmd));
         strscat(mkfs_cmd, dev, sizeof(mkfs_cmd));
         if (block_count != 0) {
-                sprintf(buf, " %llu", block_count);
+                sprintf(buf, " "LPU64, block_count);
                 strscat(mkfs_cmd, buf, sizeof(mkfs_cmd));
         }
 
index 77e16a4..aca2531 100644 (file)
@@ -3091,7 +3091,7 @@ int jt_get_obj_version(int argc, char **argv)
         }
 
         obd_ioctl_unpack(&data, buf, sizeof rawbuf);
-        printf("0x%llx\n", version);
+        printf("0x"LPX64"\n", version);
         return 0;
 }