4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
23 * Copyright (C) 2013, Trustees of Indiana University
24 * Author: Joshua Walgenbach <jjw@iu.edu>
27 #ifndef _LUSTRE_NODEMAP_H
28 #define _LUSTRE_NODEMAP_H
30 #include <lustre/lustre_idl.h>
32 #define LUSTRE_NODEMAP_NAME "nodemap"
34 #define LUSTRE_NODEMAP_DEFAULT_ID 0
36 /** enums containing the types of ids contained in a nodemap
37 * kept so other modules (mgs, mdt, etc) can define the type
41 enum nodemap_id_type {
46 enum nodemap_tree_type {
52 char npe_name[LUSTRE_NODEMAP_NAME_LENGTH + 1];
53 struct proc_dir_entry *npe_proc_entry;
54 struct list_head npe_list_member;
57 /** The nodemap id 0 will be the default nodemap. It will have a configuration
58 * set by the MGS, but no ranges will be allowed as all NIDs that do not map
59 * will be added to the default nodemap
63 /* human readable ID */
64 char nm_name[LUSTRE_NODEMAP_NAME_LENGTH + 1];
65 /* flags to govern nodemap behavior */
66 bool nmf_trust_client_ids:1,
67 nmf_allow_root_access:1;
68 /* unique ID set by MGS */
70 /* nodemap ref counter */
72 /* UID to squash unmapped UIDs */
74 /* GID to squash unmapped GIDs */
77 struct list_head nm_ranges;
78 /* lock for idmap red/black trees */
79 rwlock_t nm_idmap_lock;
80 /* UID map keyed by local UID */
81 struct rb_root nm_fs_to_client_uidmap;
82 /* UID map keyed by remote UID */
83 struct rb_root nm_client_to_fs_uidmap;
84 /* GID map keyed by local UID */
85 struct rb_root nm_fs_to_client_gidmap;
86 /* GID map keyed by remote UID */
87 struct rb_root nm_client_to_fs_gidmap;
88 /* attached client members of this nodemap */
89 struct mutex nm_member_list_lock;
90 struct list_head nm_member_list;
91 /* access by nodemap name */
92 struct hlist_node nm_hash;
93 struct nodemap_pde *nm_pde_data;
95 /* used when loading/unloading nodemaps */
96 struct list_head nm_list;
99 /* Store handles to local MGC storage to save config locally. In future
100 * versions of nodemap, mgc will receive the config directly and so this might
103 struct nm_config_file {
104 struct dt_object *ncf_obj;
105 struct list_head ncf_list;
108 void nodemap_activate(const bool value);
109 int nodemap_add(const char *nodemap_name);
110 int nodemap_del(const char *nodemap_name);
111 int nodemap_add_member(lnet_nid_t nid, struct obd_export *exp);
112 void nodemap_del_member(struct obd_export *exp);
113 int nodemap_parse_range(const char *range_string, lnet_nid_t range[2]);
114 int nodemap_parse_idmap(char *idmap_string, __u32 idmap[2]);
115 int nodemap_add_range(const char *name, const lnet_nid_t nid[2]);
116 int nodemap_del_range(const char *name, const lnet_nid_t nid[2]);
117 int nodemap_set_allow_root(const char *name, bool allow_root);
118 int nodemap_set_trust_client_ids(const char *name, bool trust_client_ids);
119 int nodemap_set_squash_uid(const char *name, uid_t uid);
120 int nodemap_set_squash_gid(const char *name, gid_t gid);
121 bool nodemap_can_setquota(const struct lu_nodemap *nodemap);
122 int nodemap_add_idmap(const char *name, enum nodemap_id_type id_type,
124 int nodemap_del_idmap(const char *name, enum nodemap_id_type id_type,
126 __u32 nodemap_map_id(struct lu_nodemap *nodemap,
127 enum nodemap_id_type id_type,
128 enum nodemap_tree_type tree_type, __u32 id);
129 ssize_t nodemap_map_acl(struct lu_nodemap *nodemap, void *buf, size_t size,
130 enum nodemap_tree_type tree_type);
131 void nodemap_test_nid(lnet_nid_t nid, char *name_buf, size_t name_len);
132 __u32 nodemap_test_id(lnet_nid_t nid, enum nodemap_id_type idtype,
134 struct nm_config_file *nm_config_file_register(const struct lu_env *env,
135 struct dt_object *obj);
136 void nm_config_file_deregister(const struct lu_env *env,
137 struct nm_config_file *ncf);
138 #endif /* _LUSTRE_NODEMAP_H */