Whamcloud - gitweb
LU-6142 llite: move CONFIG_SECURITY handling to llite_internal.h 10/33410/2
authorJames Simmons <uja.ornl@yahoo.com>
Sat, 20 Oct 2018 18:42:45 +0000 (14:42 -0400)
committerOleg Drokin <green@whamcloud.com>
Mon, 29 Oct 2018 15:58:37 +0000 (15:58 +0000)
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 <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/33410
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c

index a97d806..282af57 100644 (file)
@@ -296,6 +296,23 @@ int ll_xattr_cache_get(struct inode *inode,
                        size_t size,
                        __u64 valid);
 
                        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);
 int ll_dentry_init_security(struct dentry *dentry, int mode, struct qstr *name,
                            const char **secctx_name, void **secctx,
                            __u32 *secctx_size);
index 5e8d0ac..9d15bd7 100644 (file)
@@ -159,12 +159,6 @@ static void ll_free_sbi(struct super_block *sb)
        EXIT;
 }
 
        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)
 {
 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 (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;
 
 
        data->ocd_brw_size = MD_MAX_BRW_SIZE;