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 #define LUSTRE_NODEMAP_NAME "nodemap"
31 #define LUSTRE_NODEMAP_NAME_LENGTH 16
33 #define LUSTRE_NODEMAP_DEFAULT_ID 0
35 /** enums containing the types of ids contained in a nodemap
36 * kept so other modules (mgs, mdt, etc) can define the type
40 enum nodemap_id_type {
45 enum nodemap_tree_type {
50 /** The nodemap id 0 will be the default nodemap. It will have a configuration
51 * set by the MGS, but no ranges will be allowed as all NIDs that do not map
52 * will be added to the default nodemap
56 /* human readable ID */
57 char nm_name[LUSTRE_NODEMAP_NAME_LENGTH + 1];
58 /* flags to govern nodemap behavior */
59 bool nmf_trust_client_ids:1,
60 nmf_allow_root_access:1,
63 nmf_encryption_required:1;
64 /* unique ID set by MGS */
66 /* nodemap ref counter */
68 /* UID to squash unmapped UIDs */
70 /* GID to squash unmapped GIDs */
73 struct list_head nm_ranges;
74 /* UID map keyed by local UID */
75 struct rb_root nm_fs_to_client_uidmap;
76 /* UID map keyed by remote UID */
77 struct rb_root nm_client_to_fs_uidmap;
78 /* GID map keyed by local UID */
79 struct rb_root nm_fs_to_client_gidmap;
80 /* GID map keyed by remote UID */
81 struct rb_root nm_client_to_fs_gidmap;
82 /* proc directory entry */
83 struct proc_dir_entry *nm_proc_entry;
84 /* attached client members of this nodemap */
85 struct list_head nm_exports;
86 /* access by nodemap name */
87 cfs_hlist_node_t nm_hash;
90 void nodemap_activate(const bool value);
91 int nodemap_add(const char *nodemap_name);
92 int nodemap_del(const char *nodemap_name);
93 struct lu_nodemap *nodemap_classify_nid(lnet_nid_t nid);
94 int nodemap_parse_range(const char *range_string, lnet_nid_t range[2]);
95 int nodemap_parse_idmap(const char *idmap_string, __u32 idmap[2]);
96 int nodemap_add_range(const char *name, const lnet_nid_t nid[2]);
97 int nodemap_del_range(const char *name, const lnet_nid_t nid[2]);
98 int nodemap_set_allow_root(const char *name, bool allow_root);
99 int nodemap_set_trust_client_ids(const char *name, bool trust_client_ids);
100 int nodemap_set_squash_uid(const char *name, uid_t uid);
101 int nodemap_set_squash_gid(const char *name, gid_t gid);
102 int nodemap_add_idmap(const char *name, enum nodemap_id_type id_type,
104 int nodemap_del_idmap(const char *name, enum nodemap_id_type id_type,
106 __u32 nodemap_map_id(struct lu_nodemap *nodemap,
107 enum nodemap_id_type id_type,
108 enum nodemap_tree_type tree_type, __u32 id);
109 #endif /* _LUSTRE_NODEMAP_H */