1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Extention of lu_object.h for metadata objects
6 * Copyright (C) 2006 Cluster File Systems, Inc.
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #ifndef _LINUX_MD_OBJECT_H
26 #define _LINUX_MD_OBJECT_H
28 #include <linux/lu_object.h>
31 struct md_device_operations;
34 /*the context of the mdd ops*/
40 struct md_device_operations {
41 int (*mdo_root_get)(struct md_device *m, struct lu_fid *f);
42 int (*mdo_statfs)(struct md_device *m, struct kstatfs *sfs);
43 int (*mdo_mkdir)(struct md_object *obj, const char *name,
44 struct md_object *child);
46 int (*mdo_rename)(struct md_object *spobj, struct md_object *tpobj,
47 struct md_object *sobj, const char *sname,
48 struct md_object *tobj, const char *tname,
49 struct context *uctxt);
50 int (*mdo_link)(struct md_object *tobj, struct md_object *sobj,
51 const char *name, struct context *uctxt);
52 int (*mdo_attr_get)(struct md_object *obj, void *buf, int buf_len,
53 const char *name, struct context *uctxt);
54 int (*mdo_attr_set)(struct md_object *obj, void *buf, int buf_len,
55 const char *name, struct context *uctxt);
56 int (*mdo_index_insert)(struct md_object *pobj, struct md_object *obj,
57 const char *name, struct context *uctxt);
58 int (*mdo_index_delete)(struct md_object *pobj, struct md_object *obj,
59 const char *name, struct context *uctxt);
60 int (*mdo_object_create)(struct md_object *pobj, struct md_object *child,
61 struct context *uctxt);
65 struct lu_device md_lu_dev;
66 struct md_device_operations *md_ops;
70 struct lu_object mo_lu;
73 static inline int lu_device_is_md(struct lu_device *d)
75 return d->ld_type->ldt_tags & LU_DEVICE_MD;
78 static inline struct md_device *lu2md_dev(struct lu_device *d)
80 LASSERT(lu_device_is_md(d));
81 return container_of(d, struct md_device, md_lu_dev);
84 static inline struct lu_device *md2lu_dev(struct md_device *d)
89 static inline struct md_object *lu2md(struct lu_object *o)
91 LASSERT(lu_device_is_md(o->lo_dev));
92 return container_of(o, struct md_object, mo_lu);
95 static inline struct md_device *md_device_get(struct md_object *o)
97 LASSERT(lu_device_is_md(o->mo_lu.lo_dev));
98 return container_of(o->mo_lu.lo_dev, struct md_device, md_lu_dev);
101 static inline int md_device_init(struct md_device *md, struct lu_device_type *t)
103 return lu_device_init(&md->md_lu_dev, t);
106 static inline void md_device_fini(struct md_device *md)
108 lu_device_fini(&md->md_lu_dev);
110 #endif /* _LINUX_MD_OBJECT_H */