Whamcloud - gitweb
LU-2446 build: Update Whamcloud copyright messages for Intel
[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, 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
33 #include <dt_object.h>
34 #include <obd.h>
35 #include <lustre_fid.h>
36 #include <lustre_disk.h>
37
38 struct ls_device {
39         struct dt_device         ls_top_dev;
40         /* all initialized ls_devices on this node linked by this */
41         cfs_list_t               ls_linkage;
42         /* how many handle's reference this local storage */
43         cfs_atomic_t             ls_refcount;
44         /* underlaying OSD device */
45         struct dt_device        *ls_osd;
46         /* list of all local OID storages */
47         cfs_list_t               ls_los_list;
48         struct mutex             ls_los_mutex;
49 };
50
51 static inline struct ls_device *dt2ls_dev(struct dt_device *d)
52 {
53         return container_of0(d, struct ls_device, ls_top_dev);
54 }
55
56 struct ls_object {
57         struct lu_object_header  ls_header;
58         struct dt_object         ls_obj;
59 };
60
61 static inline struct ls_object *lu2ls_obj(struct lu_object *o)
62 {
63         return container_of0(o, struct ls_object, ls_obj.do_lu);
64 }
65
66 static inline struct dt_object *ls_locate(const struct lu_env *env,
67                                           struct ls_device *ls,
68                                           const struct lu_fid *fid)
69 {
70         return dt_locate_at(env, ls->ls_osd, fid, &ls->ls_top_dev.dd_lu_dev);
71 }
72
73 struct ls_device *ls_device_get(struct dt_device *dev);
74 void ls_device_put(const struct lu_env *env, struct ls_device *ls);
75 struct local_oid_storage *dt_los_find(struct ls_device *ls, __u64 seq);
76 void dt_los_put(struct local_oid_storage *los);