Whamcloud - gitweb
LU-10602 utils: fix file heat support 57/34757/3
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 25 Apr 2019 13:23:56 +0000 (15:23 +0200)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 May 2019 06:05:20 +0000 (06:05 +0000)
Change the LL_IOC_HEAT_SET ioctl number assignment to reduce the
number of different values used, since we are running out.  Use
a __u64 as the IOC struct argument instead of a "long" since that
is what is actually passed, and it avoids being CPU-dependent.

Move the LU_HEAT_FLAG_* values into an enum to avoid a generic
"flags" argument in the code.  This makes it clear what is passed.

Clean up code style for lfs_heat_get() and lfs_heat_set().

Fixes: ae723cf8161f ("LU-10602 llite: add file heat support")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: If06212d2d62d085a2104cf54ae9a10e512eb2efd
Reviewed-on: https://review.whamcloud.com/34757
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/llite/file.c
lustre/utils/lfs.c

index 29e5260..31a6d4e 100644 (file)
@@ -479,7 +479,7 @@ struct ll_ioc_lease_id {
 #define LL_IOC_GETPARENT               _IOWR('f', 249, struct getparent)
 #define LL_IOC_LADVISE                 _IOR('f', 250, struct llapi_lu_ladvise)
 #define LL_IOC_HEAT_GET                        _IOWR('f', 251, struct lu_heat)
 #define LL_IOC_GETPARENT               _IOWR('f', 249, struct getparent)
 #define LL_IOC_LADVISE                 _IOR('f', 250, struct llapi_lu_ladvise)
 #define LL_IOC_HEAT_GET                        _IOWR('f', 251, struct lu_heat)
-#define LL_IOC_HEAT_SET                        _IOW('f', 252, long)
+#define LL_IOC_HEAT_SET                        _IOW('f', 251, __u64)
 
 #ifndef        FS_IOC_FSGETXATTR
 /*
 
 #ifndef        FS_IOC_FSGETXATTR
 /*
@@ -2240,8 +2240,10 @@ enum lu_heat_flag_bit {
        LU_HEAT_FLAG_BIT_CLEAR,
 };
 
        LU_HEAT_FLAG_BIT_CLEAR,
 };
 
-#define LU_HEAT_FLAG_CLEAR     (1 << LU_HEAT_FLAG_BIT_CLEAR)
-#define LU_HEAT_FLAG_OFF       (1 << LU_HEAT_FLAG_BIT_OFF)
+enum lu_heat_flag {
+       LU_HEAT_FLAG_OFF        = 1ULL << LU_HEAT_FLAG_BIT_OFF,
+       LU_HEAT_FLAG_CLEAR      = 1ULL << LU_HEAT_FLAG_BIT_CLEAR,
+};
 
 enum obd_heat_type {
        OBD_HEAT_READSAMPLE     = 0,
 
 enum obd_heat_type {
        OBD_HEAT_READSAMPLE     = 0,
index 89c354d..4617bc7 100644 (file)
@@ -3301,7 +3301,7 @@ static void ll_heat_get(struct inode *inode, struct lu_heat *heat)
        spin_unlock(&lli->lli_heat_lock);
 }
 
        spin_unlock(&lli->lli_heat_lock);
 }
 
-static int ll_heat_set(struct inode *inode, __u64 flags)
+static int ll_heat_set(struct inode *inode, enum lu_heat_flag flags)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        int rc = 0;
 {
        struct ll_inode_info *lli = ll_i2info(inode);
        int rc = 0;
index 4550b62..30617b6 100644 (file)
@@ -8209,16 +8209,15 @@ next:
        return rc;
 }
 
        return rc;
 }
 
-
 static const char *const heat_names[] = LU_HEAT_NAMES;
 
 static int lfs_heat_get(int argc, char **argv)
 {
 static const char *const heat_names[] = LU_HEAT_NAMES;
 
 static int lfs_heat_get(int argc, char **argv)
 {
-       struct lu_heat  *heat;
-       int              rc = 0, rc2;
-       char            *path;
-       int              fd;
-       int              i;
+       struct lu_heat *heat;
+       int rc = 0, rc2;
+       char *path;
+       int fd;
+       int i;
 
        if (argc <= 1)
                return CMD_HELP;
 
        if (argc <= 1)
                return CMD_HELP;
@@ -8264,25 +8263,22 @@ next:
 
 static int lfs_heat_set(int argc, char **argv)
 {
 
 static int lfs_heat_set(int argc, char **argv)
 {
-       struct option    long_opts[] = {
-               {"clear", no_argument, 0, 'c'},
-               {"off", no_argument, 0, 'o'},
-               {"on", no_argument, 0, 'O'},
-               {0, 0, 0, 0}
-       };
-       char             short_opts[] = "coO";
-       int              rc = 0, rc2;
-       char            *path;
-       int              fd;
-       __u64            flags = 0;
-       int              c;
+       struct option long_opts[] = {
+       { .val = 'c',   .name = "clear",        .has_arg = no_argument },
+       { .val = 'o',   .name = "off",          .has_arg = no_argument },
+       { .val = 'O',   .name = "on",           .has_arg = no_argument },
+       { .name = NULL } };
+       enum lu_heat_flag flags = 0;
+       int rc = 0, rc2;
+       char *path;
+       int fd;
+       int c;
 
        if (argc <= 1)
                return CMD_HELP;
 
        optind = 0;
 
        if (argc <= 1)
                return CMD_HELP;
 
        optind = 0;
-       while ((c = getopt_long(argc, argv, short_opts,
-                               long_opts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "coO", long_opts, NULL)) != -1) {
                switch (c) {
                case 'c':
                        flags |= LU_HEAT_FLAG_CLEAR;
                switch (c) {
                case 'c':
                        flags |= LU_HEAT_FLAG_CLEAR;