Whamcloud - gitweb
LU-15010 mdc: add support for grant shrink
[fs/lustre-release.git] / lustre / include / lustre_sec.h
index 47dd3a8..5e53d4e 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #ifndef _LUSTRE_SEC_H_
@@ -51,6 +46,7 @@ struct ptlrpc_request;
 struct ptlrpc_reply_state;
 struct ptlrpc_bulk_desc;
 struct brw_page;
+struct lu_env;
 /* Linux specific */
 struct key;
 struct seq_file;
@@ -66,6 +62,7 @@ struct ptlrpc_sec;
 struct ptlrpc_svc_ctx;
 struct ptlrpc_cli_ctx;
 struct ptlrpc_ctx_ops;
+struct req_msg_field;
 
 /**
  * \addtogroup flavor flavor
@@ -390,8 +387,7 @@ void sptlrpc_conf_log_update_begin(const char *logname);
 void sptlrpc_conf_log_update_end(const char *logname);
 void sptlrpc_conf_client_adapt(struct obd_device *obd);
 int  sptlrpc_conf_target_get_rules(struct obd_device *obd,
-                                   struct sptlrpc_rule_set *rset,
-                                   int initial);
+                                  struct sptlrpc_rule_set *rset);
 void sptlrpc_target_choose_flavor(struct sptlrpc_rule_set *rset,
                                   enum lustre_sec_part from,
                                   lnet_nid_t nid,
@@ -535,12 +531,12 @@ struct ptlrpc_ctx_ops {
 #define PTLRPC_CTX_CACHED_BIT          (8)  /* in ctx cache (hash etc.) */
 #define PTLRPC_CTX_ETERNAL_BIT         (9)  /* always valid */
 
-#define PTLRPC_CTX_NEW                 (1 << PTLRPC_CTX_NEW_BIT)
-#define PTLRPC_CTX_UPTODATE            (1 << PTLRPC_CTX_UPTODATE_BIT)
-#define PTLRPC_CTX_DEAD                (1 << PTLRPC_CTX_DEAD_BIT)
-#define PTLRPC_CTX_ERROR               (1 << PTLRPC_CTX_ERROR_BIT)
-#define PTLRPC_CTX_CACHED              (1 << PTLRPC_CTX_CACHED_BIT)
-#define PTLRPC_CTX_ETERNAL             (1 << PTLRPC_CTX_ETERNAL_BIT)
+#define PTLRPC_CTX_NEW                 BIT(PTLRPC_CTX_NEW_BIT)
+#define PTLRPC_CTX_UPTODATE            BIT(PTLRPC_CTX_UPTODATE_BIT)
+#define PTLRPC_CTX_DEAD                BIT(PTLRPC_CTX_DEAD_BIT)
+#define PTLRPC_CTX_ERROR               BIT(PTLRPC_CTX_ERROR_BIT)
+#define PTLRPC_CTX_CACHED              BIT(PTLRPC_CTX_CACHED_BIT)
+#define PTLRPC_CTX_ETERNAL             BIT(PTLRPC_CTX_ETERNAL_BIT)
 
 #define PTLRPC_CTX_STATUS_MASK         (PTLRPC_CTX_NEW_BIT    |       \
                                         PTLRPC_CTX_UPTODATE   |       \
@@ -552,7 +548,7 @@ struct ptlrpc_cli_ctx {
        atomic_t                cc_refcount;
        struct ptlrpc_sec      *cc_sec;
        struct ptlrpc_ctx_ops  *cc_ops;
-       cfs_time_t              cc_expire;      /* in seconds */
+       time64_t                cc_expire;      /* in seconds */
        unsigned int            cc_early_expire:1;
        unsigned long           cc_flags;
        struct vfs_cred         cc_vcred;
@@ -872,13 +868,24 @@ struct ptlrpc_sec {
         /** owning import */
         struct obd_import              *ps_import;
        spinlock_t                      ps_lock;
+       /** mtime of SELinux policy file */
+       ktime_t                         ps_sepol_mtime;
+       /** next check time of SELinux policy file */
+       ktime_t                         ps_sepol_checknext;
+       /**
+        * SELinux policy info
+        * sepol string format is:
+        * <mode>:<policy name>:<policy version>:<policy hash>
+        */
+       char                            ps_sepol[LUSTRE_NODEMAP_SEPOL_LENGTH
+                                                + 1];
 
        /*
         * garbage collection
         */
        struct list_head                ps_gc_list;
-       cfs_time_t                      ps_gc_interval; /* in seconds */
-       cfs_time_t                      ps_gc_next;     /* in seconds */
+       time64_t                        ps_gc_interval; /* in seconds */
+       time64_t                        ps_gc_next;     /* in seconds */
 };
 
 static inline int flvr_is_rootonly(__u32 flavor)
@@ -957,12 +964,8 @@ struct ptlrpc_bulk_sec_desc {
         __u8            bsd_data[0];    /* policy-specific token */
 };
 
-
-/*
- * lprocfs
- */
-struct proc_dir_entry;
-extern struct proc_dir_entry *sptlrpc_proc_root;
+extern struct dentry *sptlrpc_debugfs_dir;
+extern struct proc_dir_entry *sptlrpc_lprocfs_dir;
 
 /*
  * round size up to next power of 2, for slab allocation.
@@ -1088,12 +1091,14 @@ void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req);
 int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize);
 void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req);
 int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
-                               int segment, int newsize);
+                              const struct req_msg_field *field,
+                              int newsize);
 int  sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
                                     struct ptlrpc_request **req_ret);
 void sptlrpc_cli_finish_early_reply(struct ptlrpc_request *early_req);
 
 void sptlrpc_request_out_callback(struct ptlrpc_request *req);
+int sptlrpc_get_sepol(struct ptlrpc_request *req);
 
 /*
  * exported higher interface of import & request
@@ -1111,6 +1116,7 @@ void sptlrpc_import_flush_all_ctx(struct obd_import *imp);
 int  sptlrpc_req_get_ctx(struct ptlrpc_request *req);
 void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync);
 int  sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout);
+int  sptlrpc_export_update_ctx(struct obd_export *exp);
 int  sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req);
 void sptlrpc_req_set_flavor(struct ptlrpc_request *req, int opcode);
 
@@ -1123,7 +1129,7 @@ void sptlrpc_gc_add_ctx(struct ptlrpc_cli_ctx *ctx);
 
 /* misc */
 const char * sec2target_str(struct ptlrpc_sec *sec);
-int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev);
+int sptlrpc_lprocfs_cliobd_attach(struct obd_device *obd);
 
 /*
  * server side
@@ -1195,10 +1201,6 @@ int sptlrpc_current_user_desc_size(void);
 int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset);
 int sptlrpc_unpack_user_desc(struct lustre_msg *req, int offset, int swabbed);
 
-
-#define CFS_CAP_CHOWN_MASK (1 << CFS_CAP_CHOWN)
-#define CFS_CAP_SYS_RESOURCE_MASK (1 << CFS_CAP_SYS_RESOURCE)
-
 /** @} sptlrpc */
 
 #endif /* _LUSTRE_SEC_H_ */