Whamcloud - gitweb
LU-3527 nodemap: add nodemap kernel module
[fs/lustre-release.git] / lustre / include / lustre_nodemap.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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).
15  *
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
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (C) 2013, Trustees of Indiana University
24  * Author: Joshua Walgenbach <jjw@iu.edu>
25  */
26
27 #ifndef _LUSTRE_NODEMAP_H
28 #define _LUSTRE_NODEMAP_H
29
30 #define LUSTRE_NODEMAP_NAME "nodemap"
31 #define LUSTRE_NODEMAP_NAME_LENGTH 16
32
33 #define LUSTRE_NODEMAP_DEFAULT_ID 0
34
35 /** The nodemap id 0 will be the default nodemap. It will have a configuration
36  * set by the MGS, but no ranges will be allowed as all NIDs that do not map
37  * will be added to the default nodemap
38  */
39
40 struct lu_nodemap {
41         /* human readable ID */
42         char                    nm_name[LUSTRE_NODEMAP_NAME_LENGTH + 1];
43         /* flags to govern nodemap behavior */
44         bool                    nmf_trust_client_ids:1,
45                                 nmf_allow_root_access:1,
46                                 nmf_block_lookups:1,
47                                 nmf_hmac_required:1,
48                                 nmf_encryption_required:1;
49         /* unique ID set by MGS */
50         int                     nm_id;
51         /* nodemap ref counter */
52         atomic_t                nm_refcount;
53         /* UID to squash unmapped UIDs */
54         uid_t                   nm_squash_uid;
55         /* GID to squash unmapped GIDs */
56         gid_t                   nm_squash_gid;
57         /* NID range list */
58         struct list_head        nm_ranges;
59         /* UID map keyed by local UID */
60         struct rb_root          nm_local_to_remote_uidmap;
61         /* UID map keyed by remote UID */
62         struct rb_root          nm_remote_to_local_uidmap;
63         /* GID map keyed by local UID */
64         struct rb_root          nm_local_to_remote_gidmap;
65         /* GID map keyed by remote UID */
66         struct rb_root          nm_remote_to_local_gidmap;
67         /* proc directory entry */
68         struct proc_dir_entry   *nm_proc_entry;
69         /* attached client members of this nodemap */
70         struct list_head        nm_exports;
71         /* access by nodemap name */
72         cfs_hlist_node_t        nm_hash;
73 };
74
75 int nodemap_add(const char *nodemap_name);
76 int nodemap_del(const char *nodemap_name);
77
78 #endif