X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnodemap_internal.h;h=f447eefdc10d0874f512ad098af12ee5856b068a;hb=3be9beb00e7cca9d758b364a85537b0631dddc12;hp=01a812ef2b080750de03f2af9659cb9e54bad85b;hpb=2b294992edce5af7b79d4300ed3aa1ea6a8db850;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nodemap_internal.h b/lustre/ptlrpc/nodemap_internal.h index 01a812e..f447eef 100644 --- a/lustre/ptlrpc/nodemap_internal.h +++ b/lustre/ptlrpc/nodemap_internal.h @@ -33,7 +33,13 @@ #include #include -#define MODULE_STRING "nodemap" +#define DEFAULT_NODEMAP "default" + +/* Turn on proc debug interface to allow OSS and + * MDS nodes to configure nodemap independently of + * MGS (since the nodemap distribution is not written + * yet */ +#define NODEMAP_PROC_DEBUG 1 /* Default nobody uid and gid values */ @@ -46,11 +52,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,16 +78,65 @@ 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); @@ -94,17 +150,26 @@ 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_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); #define nm_rbtree_postorder_for_each_entry_safe(pos, n, \ root, field) \ @@ -119,4 +184,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 */