Whamcloud - gitweb
LU-5065 utils: uninclude lustre_idl.h from lfs 36/10336/2
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 15 May 2014 12:33:38 +0000 (07:33 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 20 May 2014 05:25:17 +0000 (05:25 +0000)
Move the definition of OBD_OCD_VERSION() and similar macros from
lustre_idl.h to lustre_ver.h (via lustre_ver.h.in). These macros are
primarily used in comparisons to LUSTRE_VERSION_CODE which is defined
in lustre_ver.h and so should be defined there as well. Move a few
definitions (related to FIDs, quota and striping) from lustre_idl.h to
lustre_user.h. Add some preprocessor gunk to the end of lfs.c to
ensure that lustre_idl.h has not been included indirectly or
otherwise.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I0923ff823ddaa1fd6bc5493a434470543d27f273
Reviewed-on: http://review.whamcloud.com/10336
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/lustre_user.h
lustre/include/lustre_ver.h.in
lustre/utils/lfs.c

index 91a3d1d..27481a2 100644 (file)
@@ -99,6 +99,7 @@
 #include <lustre/lustre_user.h>
 
 #include <lustre/lustre_errno.h>
+#include <lustre_ver.h>
 
 /*
  *  GENERAL STUFF
@@ -906,11 +907,6 @@ static inline bool fid_is_sane(const struct lu_fid *fid)
                fid_seq_is_rsvd(fid_seq(fid)));
 }
 
-static inline bool fid_is_zero(const struct lu_fid *fid)
-{
-       return fid_seq(fid) == 0 && fid_oid(fid) == 0;
-}
-
 extern void lustre_swab_lu_fid(struct lu_fid *fid);
 extern void lustre_swab_lu_seq_range(struct lu_seq_range *range);
 
@@ -1424,13 +1420,6 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
 #define CLIENT_CONNECT_MDT_REQD (OBD_CONNECT_IBITS | OBD_CONNECT_FID | \
                                  OBD_CONNECT_FULL20)
 
-#define OBD_OCD_VERSION(major,minor,patch,fix) (((major)<<24) + ((minor)<<16) +\
-                                                ((patch)<<8) + (fix))
-#define OBD_OCD_VERSION_MAJOR(version) ((int)((version)>>24)&255)
-#define OBD_OCD_VERSION_MINOR(version) ((int)((version)>>16)&255)
-#define OBD_OCD_VERSION_PATCH(version) ((int)((version)>>8)&255)
-#define OBD_OCD_VERSION_FIX(version)   ((int)(version)&255)
-
 /* This structure is used for both request and reply.
  *
  * If we eventually have separate connect data for different types, which we
@@ -1609,14 +1598,6 @@ enum obdo_flags {
 #define LOV_MAGIC_V1_DEF  0x0CD10BD0
 #define LOV_MAGIC_V3_DEF  0x0CD30BD0
 
-#define LOV_PATTERN_RAID0      0x001   /* stripes are used round-robin */
-#define LOV_PATTERN_RAID1      0x002   /* stripes are mirrors of each other */
-#define LOV_PATTERN_FIRST      0x100   /* first stripe is not in round-robin */
-#define LOV_PATTERN_CMOBD      0x200
-
-#define LOV_PATTERN_F_MASK     0xffff0000
-#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)
 
@@ -1896,7 +1877,7 @@ extern void lustre_swab_obd_statfs (struct obd_statfs *os);
                                      * space for unstable pages; asking
                                      * it to sync quickly */
 
-#define OBD_OBJECT_EOF 0xffffffffffffffffULL
+#define OBD_OBJECT_EOF LUSTRE_EOF
 
 #define OST_MIN_PRECREATE 32
 #define OST_MAX_PRECREATE 20000
@@ -1967,15 +1948,15 @@ extern void lustre_swab_ost_lvb(struct ost_lvb *lvb);
  */
 
 #ifndef QUOTABLOCK_BITS
-#define QUOTABLOCK_BITS 10
+# define QUOTABLOCK_BITS LUSTRE_QUOTABLOCK_BITS
 #endif
 
 #ifndef QUOTABLOCK_SIZE
-#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
+# define QUOTABLOCK_SIZE LUSTRE_QUOTABLOCK_SIZE
 #endif
 
 #ifndef toqb
-#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
+# define toqb lustre_stoqb
 #endif
 
 /* The lquota_id structure is an union of all the possible identifier types that
@@ -2001,12 +1982,6 @@ struct obd_quotactl {
 
 extern void lustre_swab_obd_quotactl(struct obd_quotactl *q);
 
-#define Q_QUOTACHECK   0x800100 /* deprecated as of 2.4 */
-#define Q_INITQUOTA    0x800101 /* deprecated as of 2.4  */
-#define Q_GETOINFO     0x800102 /* get obd quota info */
-#define Q_GETOQUOTA    0x800103 /* get obd quotas */
-#define Q_FINVALIDATE  0x800104 /* deprecated as of 2.4 */
-
 #define Q_COPY(out, in, member) (out)->member = (in)->member
 
 #define QCTL_COPY(out, in)             \
@@ -2772,19 +2747,11 @@ struct lmv_mds_md_v1 {
  * and the higher part will be the flag to indicate the status of object,
  * for example the object is being migrated. And the hash function
  * might be interpreted differently with different flags. */
-enum lmv_hash_type {
-       LMV_HASH_TYPE_ALL_CHARS = 1,
-       LMV_HASH_TYPE_FNV_1A_64 = 2,
-};
-
 #define LMV_HASH_TYPE_MASK 0x0000ffff
 
 #define LMV_HASH_FLAG_MIGRATION        0x80000000
 #define LMV_HASH_FLAG_DEAD     0x40000000
 
-#define LMV_HASH_NAME_ALL_CHARS        "all_char"
-#define LMV_HASH_NAME_FNV_1A_64        "fnv_1a_64"
-
 /**
  * The FNV-1a hash algorithm is as follows:
  *     hash = FNV_offset_basis
index 412b717..ddcbe0c 100644 (file)
@@ -61,6 +61,8 @@
 #error Unsupported operating system.
 #endif
 
+#define LUSTRE_EOF 0xffffffffffffffffULL
+
 /* for statfs() */
 #define LL_SUPER_MAGIC 0x0BD00BD0
 
@@ -134,6 +136,11 @@ struct lu_fid {
        __u32 f_ver;
 };
 
+static inline bool fid_is_zero(const struct lu_fid *fid)
+{
+       return fid->f_seq == 0 && fid->f_oid == 0;
+}
+
 /* Currently, the filter_fid::ff_parent::f_ver is not the real parent
  * MDT-object's FID::f_ver, instead it is the OST-object index in its
  * parent MDT-object's layout EA. */
@@ -295,9 +302,13 @@ struct ost_id {
 
 #define LMV_USER_MAGIC    0x0CD30CD0    /*default lmv magic*/
 
-#define LOV_PATTERN_RAID0 0x001
-#define LOV_PATTERN_RAID1 0x002
-#define LOV_PATTERN_FIRST 0x100
+#define LOV_PATTERN_RAID0      0x001
+#define LOV_PATTERN_RAID1      0x002
+#define LOV_PATTERN_FIRST      0x100
+#define LOV_PATTERN_CMOBD      0x200
+
+#define LOV_PATTERN_F_MASK     0xffff0000
+#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */
 
 #define LOV_MAXPOOLNAME 16
 #define LOV_POOLNAMEF "%.16s"
@@ -392,6 +403,14 @@ struct lmv_user_mds_data {
        __u32           lum_mds;
 };
 
+enum lmv_hash_type {
+       LMV_HASH_TYPE_ALL_CHARS = 1,
+       LMV_HASH_TYPE_FNV_1A_64 = 2,
+};
+
+#define LMV_HASH_NAME_ALL_CHARS        "all_char"
+#define LMV_HASH_NAME_FNV_1A_64        "fnv_1a_64"
+
 /* Got this according to how get LOV_MAX_STRIPE_COUNT, see above,
  * (max buffer size - lmv+rpc header) / sizeof(struct lmv_user_mds_data) */
 #define LMV_MAX_STRIPE_COUNT 2000  /* ((12 * 4096 - 256) / 24) */
@@ -508,6 +527,20 @@ liblustreapi.c:2893: warning: format '%lx' expects type 'long unsigned int *', b
 
 /********* Quotas **********/
 
+#define LUSTRE_QUOTABLOCK_BITS 10
+#define LUSTRE_QUOTABLOCK_SIZE (1 << LUSTRE_QUOTABLOCK_BITS)
+
+static inline __u64 lustre_stoqb(size_t space)
+{
+       return (space + LUSTRE_QUOTABLOCK_SIZE - 1) >> LUSTRE_QUOTABLOCK_BITS;
+}
+
+#define Q_QUOTACHECK   0x800100 /* deprecated as of 2.4 */
+#define Q_INITQUOTA    0x800101 /* deprecated as of 2.4  */
+#define Q_GETOINFO     0x800102 /* get obd quota info */
+#define Q_GETOQUOTA    0x800103 /* get obd quotas */
+#define Q_FINVALIDATE  0x800104 /* deprecated as of 2.4 */
+
 /* these must be explicitly translated into linux Q_* in ll_dir_ioctl */
 #define LUSTRE_Q_QUOTAON    0x800002     /* turn quotas on */
 #define LUSTRE_Q_QUOTAOFF   0x800003     /* turn quotas off */
index 583447e..b61567c 100644 (file)
 #define LUSTRE_FIX @AC_LUSTRE_FIX@
 #define LUSTRE_VERSION_STRING "@AC_LUSTRE_VERSION_STRING@"
 
-#define LUSTRE_VERSION_CODE OBD_OCD_VERSION(LUSTRE_MAJOR,LUSTRE_MINOR,LUSTRE_PATCH,LUSTRE_FIX)
+#define OBD_OCD_VERSION(major, minor, patch, fix)                      \
+       (((major) << 24) + ((minor) << 16) + ((patch) << 8) + (fix))
+
+#define OBD_OCD_VERSION_MAJOR(version) ((int)((version) >> 24) & 255)
+#define OBD_OCD_VERSION_MINOR(version) ((int)((version) >> 16) & 255)
+#define OBD_OCD_VERSION_PATCH(version) ((int)((version) >>  8) & 255)
+#define OBD_OCD_VERSION_FIX(version)   ((int)((version) >>  0) & 255)
+
+#define LUSTRE_VERSION_CODE                                            \
+       OBD_OCD_VERSION(LUSTRE_MAJOR, LUSTRE_MINOR, LUSTRE_PATCH, LUSTRE_FIX)
 
 /* liblustre clients are only allowed to connect if their LUSTRE_FIX mismatches
  * by this amount (set in lustre/autoconf/lustre-version.ac). */
index 1c0b2fe..3e42beb 100644 (file)
@@ -54,6 +54,7 @@
 #include <err.h>
 #include <pwd.h>
 #include <grp.h>
+#include <sys/quota.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 # include <sys/quota.h>
 #endif
 
-/* For dirname() */
-#include <libgen.h>
-
-#include <lnet/lnetctl.h>
-
 #include <libcfs/libcfs.h>
-#include <lustre/lustre_idl.h>
-#include <lustre/lustreapi.h>
-
 #include <libcfs/libcfsutil.h>
+#include <lnet/lnetctl.h>
+#include <lustre/lustreapi.h>
+#include <lustre_ver.h>
 #include "obdctl.h"
 
 /* all functions */
@@ -2676,7 +2672,7 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type,
                char strbuf[32];
 
                 if (dqb->dqb_bhardlimit &&
-                    toqb(dqb->dqb_curspace) >= dqb->dqb_bhardlimit) {
+                   lustre_stoqb(dqb->dqb_curspace) >= dqb->dqb_bhardlimit) {
                         bover = 1;
                 } else if (dqb->dqb_bsoftlimit && dqb->dqb_btime) {
                         if (dqb->dqb_btime > now) {
@@ -2706,7 +2702,7 @@ static void print_quota(char *mnt, struct if_quotactl *qctl, int type,
                if (bover)
                        diff2str(dqb->dqb_btime, timebuf, now);
 
-               kbytes2str(toqb(dqb->dqb_curspace), strbuf, h);
+               kbytes2str(lustre_stoqb(dqb->dqb_curspace), strbuf, h);
                if (rc == -EREMOTEIO)
                        sprintf(numbuf[0], "%s*", strbuf);
                else
@@ -3172,7 +3168,8 @@ static int lfs_changelog(int argc, char **argv)
                         /* namespace rec includes parent and filename */
                        printf(" p="DFID" %.*s", PFID(&rec->cr_pfid),
                                rec->cr_namelen, rec->cr_name);
-               if (fid_is_sane(&rec->cr_sfid))
+
+               if (!fid_is_zero(&rec->cr_sfid))
                        printf(" s="DFID" sp="DFID" %.*s",
                                PFID(&rec->cr_sfid), PFID(&rec->cr_spfid),
                                changelog_rec_snamelen(rec),
@@ -3546,7 +3543,7 @@ static int lfs_hsm_action(int argc, char **argv)
                if ((hps == HPS_RUNNING) &&
                    (hua == HUA_ARCHIVE || hua == HUA_RESTORE))
                        printf("("LPX64 " bytes moved)\n", he.length);
-               else if ((he.offset + he.length) == OBD_OBJECT_EOF)
+               else if ((he.offset + he.length) == LUSTRE_EOF)
                        printf("(from "LPX64 " to EOF)\n", he.offset);
                else
                        printf("(from "LPX64 " to "LPX64")\n",
@@ -3841,3 +3838,7 @@ int main(int argc, char **argv)
         return rc < 0 ? -rc : rc;
 }
 
+#ifdef _LUSTRE_IDL_H_
+/* Everything we need here should be included by lustreapi.h. */
+# error "lfs should not depend on lustre_idl.h"
+#endif /* _LUSTRE_IDL_H_ */