From: Andreas Dilger Date: Thu, 25 Apr 2019 13:23:56 +0000 (+0200) Subject: LU-10602 utils: fix file heat support X-Git-Tag: 2.12.54~91 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=ac1f97a881019b78ce3289885461259d280562b3 LU-10602 utils: fix file heat support 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 Change-Id: If06212d2d62d085a2104cf54ae9a10e512eb2efd Reviewed-on: https://review.whamcloud.com/34757 Reviewed-by: Wang Shilong Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Yingjin Qian Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 29e5260..31a6d4e 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -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_HEAT_SET _IOW('f', 252, long) +#define LL_IOC_HEAT_SET _IOW('f', 251, __u64) #ifndef FS_IOC_FSGETXATTR /* @@ -2240,8 +2240,10 @@ enum lu_heat_flag_bit { 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, diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 89c354d..4617bc7 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3301,7 +3301,7 @@ static void ll_heat_get(struct inode *inode, struct lu_heat *heat) 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; diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 4550b62..30617b6 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -8209,16 +8209,15 @@ next: return rc; } - 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; @@ -8264,25 +8263,22 @@ next: 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; - 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;