From 920c558fa4387d982f78ab40ab90703e493445e1 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sat, 20 Oct 2018 14:42:45 -0400 Subject: [PATCH] LU-6142 llite: move CONFIG_SECURITY handling to llite_internal.h For the linux kernel its recommended to keep CONFIG_* wrapped code in a header file instead of the source files to avoid making the code more difficulty to read. Move CONFIG_SECURITY wrapped code to llite_internal.h in this case. Change-Id: I60eba17181d3b57fb64e99a441163f975dbab03c Test-Parameters: trivial Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/33410 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond --- lustre/llite/llite_internal.h | 17 +++++++++++++++++ lustre/llite/llite_lib.c | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index a97d806..282af57 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -296,6 +296,23 @@ int ll_xattr_cache_get(struct inode *inode, size_t size, __u64 valid); +static inline bool obd_connect_has_secctx(struct obd_connect_data *data) +{ +#if defined(HAVE_SECURITY_DENTRY_INIT_SECURITY) && defined(CONFIG_SECURITY) + return data->ocd_connect_flags & OBD_CONNECT_FLAGS2 && + data->ocd_connect_flags2 & OBD_CONNECT2_FILE_SECCTX; +#else + return false; +#endif /* HAVE_SECURITY_DENTRY_INIT_SECURITY */ +} + +static inline void obd_connect_set_secctx(struct obd_connect_data *data) +{ +#if defined(HAVE_SECURITY_DENTRY_INIT_SECURITY) && defined(CONFIG_SECURITY) + data->ocd_connect_flags2 |= OBD_CONNECT2_FILE_SECCTX; +#endif /* HAVE_SECURITY_DENTRY_INIT_SECURITY */ +} + int ll_dentry_init_security(struct dentry *dentry, int mode, struct qstr *name, const char **secctx_name, void **secctx, __u32 *secctx_size); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 5e8d0ac..9d15bd7 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -159,12 +159,6 @@ static void ll_free_sbi(struct super_block *sb) EXIT; } -static inline int obd_connect_has_secctx(struct obd_connect_data *data) -{ - return data->ocd_connect_flags & OBD_CONNECT_FLAGS2 && - data->ocd_connect_flags2 & OBD_CONNECT2_FILE_SECCTX; -} - static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct vfsmount *mnt) { @@ -271,9 +265,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (sbi->ll_flags & LL_SBI_ALWAYS_PING) data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS; -#if defined(HAVE_SECURITY_DENTRY_INIT_SECURITY) && defined(CONFIG_SECURITY) - data->ocd_connect_flags2 |= OBD_CONNECT2_FILE_SECCTX; -#endif /* HAVE_SECURITY_DENTRY_INIT_SECURITY */ + obd_connect_set_secctx(data); data->ocd_brw_size = MD_MAX_BRW_SIZE; -- 1.8.3.1