Whamcloud - gitweb
LU-13004 ptlrpc: Allow BULK_BUF_KIOV to accept a kvec
[fs/lustre-release.git] / lustre / ptlrpc / nodemap_internal.h
index 01a812e..4b8312e 100644 (file)
@@ -22,7 +22,7 @@
 /*
  * Copyright (C) 2013, Trustees of Indiana University
  *
- * Copyright (c) 2013, 2014, Intel Corporation.
+ * Copyright (c) 2013, 2017, Intel Corporation.
  *
  * Author: Joshua Walgenbach <jjw@iu.edu>
  */
@@ -33,7 +33,7 @@
 #include <lustre_nodemap.h>
 #include <interval_tree.h>
 
-#define MODULE_STRING "nodemap"
+#define DEFAULT_NODEMAP "default"
 
 /* Default nobody uid and gid values */
 
@@ -46,11 +46,12 @@ struct lprocfs_static_vars;
 extern struct proc_dir_entry *proc_lustre_nodemap_root;
 /* flag if nodemap is active */
 extern bool nodemap_active;
-/* lock for range interval tree, used in nodemap_lproc.c */
-extern rwlock_t nm_range_tree_lock;
+
+extern struct mutex active_config_lock;
+extern struct nodemap_config *active_config;
 
 struct lu_nid_range {
-       /* unique id set my mgs */
+       /* unique id set by mgs */
        unsigned int             rn_id;
        /* lu_nodemap containing this range */
        struct lu_nodemap       *rn_nodemap;
@@ -71,22 +72,72 @@ struct lu_idmap {
        struct rb_node  id_fs_to_client;
 };
 
+/* first 4 bits of the nodemap_id is the index type */
+struct nodemap_key {
+       __u32 nk_nodemap_id;
+       union {
+               __u32 nk_range_id;
+               __u32 nk_id_client;
+               __u32 nk_unused;
+       };
+};
+
+enum nodemap_idx_type {
+       NODEMAP_EMPTY_IDX = 0,          /* index created with blank record */
+       NODEMAP_CLUSTER_IDX = 1,        /* a nodemap cluster of nodes */
+       NODEMAP_RANGE_IDX = 2,          /* nid range assigned to a nm cluster */
+       NODEMAP_UIDMAP_IDX = 3,         /* uid map assigned to a nm cluster */
+       NODEMAP_GIDMAP_IDX = 4,         /* gid map assigned to a nm cluster */
+       NODEMAP_GLOBAL_IDX = 15,        /* stores nodemap activation status */
+};
+
+#define NM_TYPE_MASK 0x0FFFFFFF
+#define NM_TYPE_SHIFT 28
+
+static inline enum nodemap_idx_type nm_idx_get_type(unsigned int id)
+{
+       return id >> NM_TYPE_SHIFT;
+}
+
+static inline __u32 nm_idx_set_type(unsigned int id, enum nodemap_idx_type t)
+{
+       return (id & NM_TYPE_MASK) | (t << NM_TYPE_SHIFT);
+}
+
+void nodemap_config_set_active(struct nodemap_config *config);
+struct lu_nodemap *nodemap_create(const char *name,
+                                 struct nodemap_config *config,
+                                 bool is_default);
+void nodemap_putref(struct lu_nodemap *nodemap);
+struct lu_nodemap *nodemap_lookup(const char *name);
+
 int nodemap_procfs_init(void);
-int lprocfs_nodemap_register(const char *name, bool is_default_nodemap,
-                            struct lu_nodemap *nodemap);
-struct lu_nid_range *range_create(lnet_nid_t min, lnet_nid_t max,
-                                 struct lu_nodemap *nodemap);
+void nodemap_procfs_exit(void);
+int lprocfs_nodemap_register(struct lu_nodemap *nodemap,
+                            bool is_default_nodemap);
+void lprocfs_nodemap_remove(struct nodemap_pde *nodemap_pde);
+struct lu_nid_range *nodemap_range_find(lnet_nid_t start_nid,
+                                       lnet_nid_t end_nid);
+struct lu_nid_range *range_create(struct nodemap_range_tree *nm_range_tree,
+                                 lnet_nid_t start_nid, lnet_nid_t end_nid,
+                                 struct lu_nodemap *nodemap,
+                                 unsigned int range_id);
 void range_destroy(struct lu_nid_range *range);
-int range_insert(struct lu_nid_range *data);
-void range_delete(struct lu_nid_range *data);
-struct lu_nid_range *range_search(lnet_nid_t nid);
-struct lu_nid_range *range_find(lnet_nid_t start_nid, lnet_nid_t end_nid);
+int range_insert(struct nodemap_range_tree *nm_range_tree,
+                struct lu_nid_range *data);
+void range_delete(struct nodemap_range_tree *nm_range_tree,
+                 struct lu_nid_range *data);
+struct lu_nid_range *range_search(struct nodemap_range_tree *nm_range_tree,
+                                 lnet_nid_t nid);
+struct lu_nid_range *range_find(struct nodemap_range_tree *nm_range_tree,
+                               lnet_nid_t start_nid, lnet_nid_t end_nid);
 int range_parse_nidstring(char *range_string, lnet_nid_t *start_nid,
                          lnet_nid_t *end_nid);
 void range_init_tree(void);
 struct lu_idmap *idmap_create(__u32 client_id, __u32 fs_id);
-void idmap_insert(enum nodemap_id_type id_type, struct lu_idmap *idmap,
-                struct lu_nodemap *nodemap);
+struct lu_idmap *idmap_insert(enum nodemap_id_type id_type,
+                             struct lu_idmap *idmap,
+                             struct lu_nodemap *nodemap);
 void idmap_delete(enum nodemap_id_type id_type,  struct lu_idmap *idmap,
                  struct lu_nodemap *nodemap);
 void idmap_delete_tree(struct lu_nodemap *nodemap);
@@ -94,17 +145,30 @@ struct lu_idmap *idmap_search(struct lu_nodemap *nodemap,
                              enum nodemap_tree_type,
                              enum nodemap_id_type id_type,
                              __u32 id);
-int nodemap_cleanup_nodemaps(void);
-int nm_member_init_hash(struct lu_nodemap *nodemap);
 int nm_member_add(struct lu_nodemap *nodemap, struct obd_export *exp);
 void nm_member_del(struct lu_nodemap *nodemap, struct obd_export *exp);
-void nm_member_delete_hash(struct lu_nodemap *nodemap);
+void nm_member_delete_list(struct lu_nodemap *nodemap);
+struct lu_nodemap *nodemap_classify_nid(lnet_nid_t nid);
 void nm_member_reclassify_nodemap(struct lu_nodemap *nodemap);
 void nm_member_revoke_locks(struct lu_nodemap *nodemap);
+void nm_member_revoke_locks_always(struct lu_nodemap *nodemap);
 void nm_member_revoke_all(void);
 
+int nodemap_add_idmap_helper(struct lu_nodemap *nodemap,
+                            enum nodemap_id_type id_type,
+                            const __u32 map[2]);
+int nodemap_add_range_helper(struct nodemap_config *config,
+                            struct lu_nodemap *nodemap,
+                            const lnet_nid_t nid[2],
+                            unsigned int range_id);
+
 struct rb_node *nm_rb_next_postorder(const struct rb_node *node);
 struct rb_node *nm_rb_first_postorder(const struct rb_root *root);
+void nodemap_getref(struct lu_nodemap *nodemap);
+void nodemap_putref(struct lu_nodemap *nodemap);
+int nm_hash_list_cb(struct cfs_hash *hs, struct cfs_hash_bd *bd,
+                   struct hlist_node *hnode,
+                   void *nodemap_list_head);
 
 #define nm_rbtree_postorder_for_each_entry_safe(pos, n,                        \
                                                root, field)            \
@@ -119,4 +183,18 @@ struct rb_node *nm_rb_first_postorder(const struct rb_root *root);
                n = (pos && nm_rb_next_postorder(&pos->field)) ?        \
                rb_entry(nm_rb_next_postorder(&pos->field),             \
                typeof(*pos), field) : NULL)
+
+int nodemap_idx_nodemap_add(const struct lu_nodemap *nodemap);
+int nodemap_idx_nodemap_update(const struct lu_nodemap *nodemap);
+int nodemap_idx_nodemap_del(const struct lu_nodemap *nodemap);
+int nodemap_idx_idmap_add(const struct lu_nodemap *nodemap,
+                         enum nodemap_id_type id_type,
+                         const __u32 map[2]);
+int nodemap_idx_idmap_del(const struct lu_nodemap *nodemap,
+                         enum nodemap_id_type id_type,
+                         const __u32 map[2]);
+int nodemap_idx_range_add(const struct lu_nid_range *range,
+                         const lnet_nid_t nid[2]);
+int nodemap_idx_range_del(const struct lu_nid_range *range);
+int nodemap_idx_nodemap_activate(bool value);
 #endif  /* _NODEMAP_INTERNAL_H */