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 /* lock for idmap red/black trees */
75 rwlock_t nm_idmap_lock;
76 /* UID map keyed by local UID */
77 struct rb_root nm_fs_to_client_uidmap;
78 /* UID map keyed by remote UID */
79 struct rb_root nm_client_to_fs_uidmap;
80 /* GID map keyed by local UID */
81 struct rb_root nm_fs_to_client_gidmap;
82 /* GID map keyed by remote UID */
83 struct rb_root nm_client_to_fs_gidmap;
84 /* proc directory entry */
85 struct proc_dir_entry *nm_proc_entry;
86 /* attached client members of this nodemap */
87 cfs_hash_t *nm_member_hash;
88 /* access by nodemap name */
89 struct hlist_node nm_hash;
92 void nodemap_activate(const bool value);
93 int nodemap_add(const char *nodemap_name);
94 int nodemap_del(const char *nodemap_name);
95 struct lu_nodemap *nodemap_classify_nid(lnet_nid_t nid);
96 int nodemap_add_member(lnet_nid_t nid, struct obd_export *exp);
97 void nodemap_del_member(struct obd_export *exp);
98 int nodemap_parse_range(const char *range_string, lnet_nid_t range[2]);
99 int nodemap_parse_idmap(char *idmap_string, __u32 idmap[2]);
100 int nodemap_add_range(const char *name, const lnet_nid_t nid[2]);
101 int nodemap_del_range(const char *name, const lnet_nid_t nid[2]);
102 int nodemap_set_allow_root(const char *name, bool allow_root);
103 int nodemap_set_trust_client_ids(const char *name, bool trust_client_ids);
104 int nodemap_set_squash_uid(const char *name, uid_t uid);
105 int nodemap_set_squash_gid(const char *name, gid_t gid);
106 bool nodemap_can_setquota(const struct lu_nodemap *nodemap);
107 int nodemap_add_idmap(const char *name, enum nodemap_id_type id_type,
109 int nodemap_del_idmap(const char *name, enum nodemap_id_type id_type,
111 __u32 nodemap_map_id(struct lu_nodemap *nodemap,
112 enum nodemap_id_type id_type,
113 enum nodemap_tree_type tree_type, __u32 id);
114 ssize_t nodemap_map_acl(struct lu_nodemap *nodemap, void *buf, size_t size,
115 enum nodemap_tree_type tree_type);
116 #endif /* _LUSTRE_NODEMAP_H */