Whamcloud - gitweb
b=13872
[fs/lustre-release.git] / lustre / include / lustre_mdt.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2006 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #ifndef __LINUX_MDT_H
24 #define __LINUX_MDT_H
25
26 #include <lustre/lustre_idl.h>
27 #include <lustre_req_layout.h>
28 #include <md_object.h>
29 #include <dt_object.h>
30 #include <libcfs/list.h>
31 #include <libcfs/kp30.h>
32
33 /*
34  * Common thread info for mdt, seq and fld
35  */
36 struct com_thread_info {
37         /*
38          * for req-layout interface.
39          */
40         struct req_capsule cti_pill;
41 };
42
43 /* id map */
44 #define MDT_IDMAP_HASHSIZE      (32)
45 #define MDT_IDMAP_HASHFUNC(id)  ((id) & (MDT_IDMAP_HASHSIZE - 1))
46
47 enum mdt_idmap_idx {
48         RMT_UIDMAP_IDX,
49         LCL_UIDMAP_IDX,
50         RMT_GIDMAP_IDX,
51         LCL_GIDMAP_IDX,
52         MDT_IDMAP_N_HASHES
53 };
54
55 struct mdt_idmap_table {
56         spinlock_t       mit_lock;
57         struct list_head mit_idmaps[MDT_IDMAP_N_HASHES]
58                                    [MDT_IDMAP_HASHSIZE];
59 };
60
61 enum {
62         ESERIOUS = 0x0001000
63 };
64
65 static inline int err_serious(int rc)
66 {
67         LASSERT(rc < 0);
68         LASSERT(-rc < ESERIOUS);
69         return -(-rc | ESERIOUS);
70 }
71
72 static inline int clear_serious(int rc)
73 {
74         if (rc < 0)
75                 rc = -(-rc & ~ESERIOUS);
76         return rc;
77 }
78
79 static inline int is_serious(int rc)
80 {
81         return (rc < 0 && -rc & ESERIOUS);
82 }
83
84
85 #endif