Whamcloud - gitweb
LU-17744 ldiskfs: mballoc stats fixes
[fs/lustre-release.git] / lustre / include / obd_target.h
1 /* GPL HEADER START
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 only,
7  * as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License version 2 for more details (a copy is included
13  * in the LICENSE file that accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License
16  * version 2 along with this program; If not, see
17  * http://www.gnu.org/licenses/gpl-2.0.html
18  *
19  * GPL HEADER END
20  */
21 /*
22  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Use is subject to license terms.
24  *
25  * Copyright (c) 2011, 2014, Intel Corporation.
26  */
27 /*
28  * This file is part of Lustre, http://www.lustre.org/
29  */
30
31 #ifndef __OBD_TARGET_H
32 #define __OBD_TARGET_H
33 #include <lprocfs_status.h>
34 #include <obd.h>
35
36 /* server-side individual type definitions */
37
38 #define OBT_MAGIC       0xBDDECEAE
39 /* hold common fields for "target" device */
40 struct obd_device_target {
41         __u32                   obt_magic;
42         __u32                   obt_instance;
43         struct lu_target       *obt_lut;
44         __u64                   obt_mount_count;
45         struct obd_job_stats    obt_jobstats;
46         struct nm_config_file   *obt_nodemap_config_file;
47 };
48
49 #define OBJ_SUBDIR_COUNT 32 /* set to zero for no subdirs */
50
51 struct echo_obd {
52         struct obd_device_target        eo_obt;
53         struct obdo                     eo_oa;
54         spinlock_t                      eo_lock;
55         u64                             eo_lastino;
56         struct lustre_handle            eo_nl_lock;
57         atomic_t                        eo_prep;
58 };
59
60 struct ost_obd {
61         struct ptlrpc_service   *ost_service;
62         struct ptlrpc_service   *ost_create_service;
63         struct ptlrpc_service   *ost_io_service;
64         struct ptlrpc_service   *ost_seq_service;
65         struct ptlrpc_service   *ost_out_service;
66         struct mutex             ost_health_mutex;
67 };
68
69 static inline struct obd_device_target *obd2obt(struct obd_device *obd)
70 {
71         struct obd_device_target *obt;
72
73         BUILD_BUG_ON(sizeof(obd->u) < sizeof(*obt));
74
75         if (!obd)
76                 return NULL;
77         obt = (void *)&obd->u;
78         LASSERT(obt->obt_magic == OBT_MAGIC);
79         return obt;
80 }
81
82 static inline struct obd_device_target *obd_obt_init(struct obd_device *obd)
83 {
84         struct obd_device_target *obt;
85
86         obt = (void *)&obd->u;
87         obt->obt_magic = OBT_MAGIC;
88         obt->obt_instance = 0;
89
90         return obt;
91 }
92
93 static inline struct echo_obd *obd2echo(struct obd_device *obd)
94 {
95         struct echo_obd *echo;
96
97         BUILD_BUG_ON(sizeof(obd->u) < sizeof(*echo));
98
99         if (!obd)
100                 return NULL;
101         echo = (void *)&obd->u;
102
103         return echo;
104 }
105
106 static inline struct ost_obd *obd2ost(struct obd_device *obd)
107 {
108         struct ost_obd *ost;
109
110         BUILD_BUG_ON(sizeof(obd->u) < sizeof(*ost));
111
112         if (!obd)
113                 return NULL;
114         ost = (void *)&obd->u;
115
116         return ost;
117 }
118
119 #endif /* __OBD_TARGET_H */