Whamcloud - gitweb
LU-7345 obdclass: annotate locks in __local_file_create
[fs/lustre-release.git] / lustre / obdclass / local_storage.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,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License version 2 for more details.  A copy is
14  * included in the COPYING file that accompanied this code.
15
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2012, 2014, Intel Corporation.
24  */
25 /*
26  * lustre/obdclass/local_storage.c
27  *
28  * Local storage for file/objects with fid generation. Works on top of OSD.
29  *
30  * Author: Mikhail Pershin <mike.pershin@intel.com>
31  */
32 #ifndef __LOCAL_STORAGE_H
33 #define __LOCAL_STORAGE_H
34
35 #include <dt_object.h>
36 #include <obd.h>
37 #include <lustre_fid.h>
38 #include <lustre_disk.h>
39
40 struct ls_device {
41         struct dt_device         ls_top_dev;
42         /* all initialized ls_devices on this node linked by this */
43         struct list_head         ls_linkage;
44         /* how many handle's reference this local storage */
45         atomic_t                 ls_refcount;
46         /* underlaying OSD device */
47         struct dt_device        *ls_osd;
48         /* list of all local OID storages */
49         struct list_head         ls_los_list;
50         struct mutex             ls_los_mutex;
51 };
52
53 static inline struct ls_device *dt2ls_dev(struct dt_device *d)
54 {
55         return container_of0(d, struct ls_device, ls_top_dev);
56 }
57
58 struct ls_object {
59         struct lu_object_header  ls_header;
60         struct dt_object         ls_obj;
61 };
62
63 static inline struct ls_object *lu2ls_obj(struct lu_object *o)
64 {
65         return container_of0(o, struct ls_object, ls_obj.do_lu);
66 }
67
68 static inline struct dt_object *ls_locate(const struct lu_env *env,
69                                           struct ls_device *ls,
70                                           const struct lu_fid *fid,
71                                           const struct lu_object_conf *conf)
72 {
73         return dt_locate_at(env, ls->ls_osd, fid,
74                             &ls->ls_top_dev.dd_lu_dev, conf);
75 }
76
77 struct ls_device *ls_device_get(struct dt_device *dev);
78 void ls_device_put(const struct lu_env *env, struct ls_device *ls);
79 struct local_oid_storage *dt_los_find(struct ls_device *ls, __u64 seq);
80 void dt_los_put(struct local_oid_storage *los);
81
82 /* Lustre 2.3 on-disk structure describing local object OIDs storage
83  * the structure to be used with any sequence managed by
84  * local object library.
85  * Obsoleted since 2.4 but is kept for compatibility reasons,
86  * see lastid_compat_check() in obdclass/local_storage.c */
87 struct los_ondisk {
88         __u32 lso_magic;
89         __u32 lso_next_oid;
90 };
91
92 #define LOS_MAGIC       0xdecafbee
93
94 /**
95  * Used in __local_file_create() for object lock role
96  **/
97 enum los_object_role {
98         LOS_PARENT,
99         LOS_CHILD,
100 };
101
102 #endif