From 980f8741339f2bece106f6955b0b076d35211850 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 4 Jun 2020 22:13:38 -0400 Subject: [PATCH] LU-12511 utils: Move utilies specific values out of Lustre UAPI headers Use FS_IOC_FS[S|G]ETXATTR directly. Move several things in the UAPI header lustre_user.h that is only needed by user land tools to the proper places. Change-Id: Ie7a33742c0aba478c365c5fa44315400b28d8193 Test-Parameters: trivial Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/38790 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Wang Shilong --- lustre/include/lustre/lustreapi.h | 34 ++++++++++++++++++++++++++ lustre/include/uapi/linux/lustre/lustre_user.h | 27 -------------------- lustre/llite/dir.c | 4 +-- lustre/llite/file.c | 4 +-- lustre/tests/statx.c | 5 ++++ lustre/utils/lfs_project.c | 6 ++--- lustre/utils/liblustreapi.c | 2 +- lustre/utils/liblustreapi_layout.c | 4 +++ 8 files changed, 51 insertions(+), 35 deletions(-) diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index c9573db..b959bf1 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -54,6 +54,16 @@ extern "C" { #define LL_MAXQUOTAS 3 #endif +#ifndef SEL_UNIT_SIZE +#define SEL_UNIT_SIZE 1024llu +#endif + +#ifndef LOV_PATTERN_DEFAULT +#define LOV_PATTERN_DEFAULT 0xffffffff +#endif + +typedef struct statx lstatx_t; + #define lustre_fid struct lu_fid /* Currently external applications can access this but in the @@ -553,6 +563,30 @@ int llapi_hsm_request(const char *path, const struct hsm_user_request *request); int llapi_hsm_current_action(const char *path, struct hsm_current_action *hca); /* JSON handling */ +enum llapi_json_types { + LLAPI_JSON_INTEGER = 1, + LLAPI_JSON_BIGNUM, + LLAPI_JSON_REAL, + LLAPI_JSON_STRING +}; + +struct llapi_json_item { + char *lji_key; + __u32 lji_type; + union { + int lji_integer; + __u64 lji_u64; + double lji_real; + char *lji_string; + }; + struct llapi_json_item *lji_next; +}; + +struct llapi_json_item_list { + int ljil_item_count; + struct llapi_json_item *ljil_items; +}; + int llapi_json_init_list(struct llapi_json_item_list **item_list); int llapi_json_destroy_list(struct llapi_json_item_list **item_list); int llapi_json_add_item(struct llapi_json_item_list **item_list, char *key, diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index 25ff63c..15d62b6 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -648,8 +648,6 @@ struct fsxattr { #define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr) #define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr) #endif -#define LL_IOC_FSGETXATTR FS_IOC_FSGETXATTR -#define LL_IOC_FSSETXATTR FS_IOC_FSSETXATTR #ifndef FS_XFLAG_PROJINHERIT #define FS_XFLAG_PROJINHERIT 0x00000200 #endif @@ -2435,31 +2433,6 @@ struct hsm_copy { struct hsm_action_item hc_hai; }; -/* JSON objects */ -enum llapi_json_types { - LLAPI_JSON_INTEGER = 1, - LLAPI_JSON_BIGNUM, - LLAPI_JSON_REAL, - LLAPI_JSON_STRING -}; - -struct llapi_json_item { - char *lji_key; - __u32 lji_type; - union { - int lji_integer; - __u64 lji_u64; - double lji_real; - char *lji_string; - }; - struct llapi_json_item *lji_next; -}; - -struct llapi_json_item_list { - int ljil_item_count; - struct llapi_json_item *ljil_items; -}; - enum lu_ladvise_type { LU_LADVISE_INVALID = 0, LU_LADVISE_WILLREAD = 1, diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 9a83ba4..1501ce0 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -2082,9 +2082,9 @@ migrate_free: RETURN(rc); } - case LL_IOC_FSGETXATTR: + case FS_IOC_FSGETXATTR: RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg)); - case LL_IOC_FSSETXATTR: + case FS_IOC_FSSETXATTR: RETURN(ll_ioctl_fssetxattr(inode, cmd, arg)); case LL_IOC_PCC_DETACH_BY_FID: { struct lu_pcc_detach_fid *detach; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 4085d54..aac8685f 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3899,9 +3899,9 @@ out_ladvise: fd->fd_designated_mirror = (__u32)arg; RETURN(0); } - case LL_IOC_FSGETXATTR: + case FS_IOC_FSGETXATTR: RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg)); - case LL_IOC_FSSETXATTR: + case FS_IOC_FSSETXATTR: RETURN(ll_ioctl_fssetxattr(inode, cmd, arg)); case BLKSSZGET: RETURN(put_user(PAGE_SIZE, (int __user *)arg)); diff --git a/lustre/tests/statx.c b/lustre/tests/statx.c index 80bc295..aa7429b 100644 --- a/lustre/tests/statx.c +++ b/lustre/tests/statx.c @@ -73,6 +73,11 @@ static bool o_quiet; #ifdef __NR_statx #ifndef HAVE_STATX + +#define AT_STATX_SYNC_TYPE 0x6000 +#define AT_STATX_FORCE_SYNC 0x2000 +#define AT_STATX_DONT_SYNC 0x4000 + static __attribute__((unused)) ssize_t statx(int dfd, const char *filename, int flags, unsigned int mask, struct statx *buffer) diff --git a/lustre/utils/lfs_project.c b/lustre/utils/lfs_project.c index f16d825..9f82b74 100644 --- a/lustre/utils/lfs_project.c +++ b/lustre/utils/lfs_project.c @@ -118,7 +118,7 @@ static int project_get_xattr(const char *pathname, struct fsxattr *fsx, return -errno; } - ret = ioctl(fd, LL_IOC_FSGETXATTR, fsx); + ret = ioctl(fd, FS_IOC_FSGETXATTR, fsx); if (ret) { fprintf(stderr, "%s: failed to get xattr for '%s': %s\n", progname, pathname, strerror(errno)); @@ -207,7 +207,7 @@ project_set_one(const char *pathname, struct project_handle_control *phc) if (phc->set_projid) fsx.fsx_projid = phc->projid; - ret = ioctl(fd, LL_IOC_FSSETXATTR, &fsx); + ret = ioctl(fd, FS_IOC_FSSETXATTR, &fsx); if (ret) fprintf(stderr, "%s: failed to set xattr for '%s': %s\n", progname, pathname, strerror(errno)); @@ -235,7 +235,7 @@ project_clear_one(const char *pathname, struct project_handle_control *phc) if (!phc->keep_projid) fsx.fsx_projid = 0; - ret = ioctl(fd, LL_IOC_FSSETXATTR, &fsx); + ret = ioctl(fd, FS_IOC_FSSETXATTR, &fsx); if (ret) fprintf(stderr, "%s: failed to set xattr for '%s': %s\n", progname, pathname, strerror(errno)); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 705b544..f46f72b 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -4597,7 +4597,7 @@ static int fget_projid(int fd, int *projid) struct fsxattr fsx; int rc; - rc = ioctl(fd, LL_IOC_FSGETXATTR, &fsx); + rc = ioctl(fd, FS_IOC_FSGETXATTR, &fsx); if (rc) return -errno; diff --git a/lustre/utils/liblustreapi_layout.c b/lustre/utils/liblustreapi_layout.c index 5dfd6f4..87ed8c8 100644 --- a/lustre/utils/liblustreapi_layout.c +++ b/lustre/utils/liblustreapi_layout.c @@ -3110,6 +3110,10 @@ struct llapi_layout_sanity_args { int lsa_rc; }; +/* The component flags can be set by users at creation/modification time. */ +#define LCME_USER_COMP_FLAGS (LCME_FL_PREF_RW | LCME_FL_NOSYNC | \ + LCME_FL_EXTENSION) + static int llapi_layout_sanity_cb(struct llapi_layout *layout, void *arg) { -- 1.8.3.1