1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/cmm/cmm_object.c
5 * Lustre Cluster Metadata Manager (cmm)
7 * Copyright (c) 2006 Cluster File Systems, Inc.
8 * Author: Mike Pershin <tappro@clusterfs.com>
10 * This file is part of the Lustre file system, http://www.lustre.org
11 * Lustre is a trademark of Cluster File Systems, Inc.
13 * You may have signed or agreed to another license before downloading
14 * this software. If so, you are bound by the terms and conditions
15 * of that agreement, and the following does not apply to you. See the
16 * LICENSE file included with this distribution for more information.
18 * If you did not agree to a different license, then this copy of Lustre
19 * is open source software; you can redistribute it and/or modify it
20 * under the terms of version 2 of the GNU General Public License as
21 * published by the Free Software Foundation.
23 * In either case, Lustre is distributed in the hope that it will be
24 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
25 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * license text for more details.
30 # define EXPORT_SYMTAB
33 #define DEBUG_SUBSYSTEM S_MDS
35 #include "cmm_internal.h"
37 static struct md_object_operations cmm_mo_ops;
39 struct lu_object *cmm_object_alloc(struct lu_context *ctx, struct lu_device *d)
41 struct cmm_object *mo;
48 o = &mo->cmo_obj.mo_lu;
49 lu_object_init(o, NULL, d);
50 mo->cmo_obj.mo_ops = &cmm_mo_ops;
56 int cmm_object_init(struct lu_context *ctxt, struct lu_object *o)
58 struct cmm_device *d = lu2cmm_dev(o->lo_dev);
59 struct lu_device *under;
60 struct lu_object *below;
63 under = &d->cmm_child->md_lu_dev;
64 below = under->ld_ops->ldo_object_alloc(ctxt, under);
66 lu_object_add(o, below);
72 void cmm_object_free(struct lu_context *ctx, struct lu_object *o)
77 void cmm_object_release(struct lu_context *ctxt, struct lu_object *o)
82 int cmm_object_print(struct lu_context *ctx,
83 struct seq_file *f, const struct lu_object *o)
85 return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", o);
90 static void cmm_lock(struct lu_context *ctxt, struct md_object *obj, __u32 mode)
92 struct cmm_object *cmm_obj = md2cmm_obj(obj);
93 struct cmm_device *cmm_dev = cmm_obj2dev(cmm_obj);
94 struct md_object *next = cmm2child_obj(cmm_obj);
96 next->mo_ops->moo_object_lock(ctxt, next, mode);
99 static void cmm_unlock(struct lu_context *ctxt,
100 struct md_object *obj, __u32 mode)
102 struct cmm_object *cmm_obj = md2cmm_obj(obj);
103 struct cmm_device *cmm_dev = cmm_obj2dev(cmm_obj);
104 struct md_object *next = cmm2child_obj(cmm_obj);
106 next->mo_ops->moo_object_unlock(ctxt, next, mode);
112 int cmm_root_get(struct lu_context *ctx,
113 struct md_device *md, struct lu_fid *fid)
115 struct cmm_device *cmm_dev = md2cmm_dev(md);
117 return cmm_child_ops(cmm_dev)->mdo_root_get(ctx,
118 cmm_dev->cmm_child, fid);
121 int cmm_config(struct lu_context *ctxt,
122 struct md_device *md, const char *name,
123 void *buf, int size, int mode)
125 struct cmm_device *cmm_dev = md2cmm_dev(md);
128 result = cmm_child_ops(cmm_dev)->mdo_config(ctxt, cmm_dev->cmm_child,
129 name, buf, size, mode);
133 int cmm_statfs(struct lu_context *ctxt,
134 struct md_device *md, struct kstatfs *sfs) {
135 struct cmm_device *cmm_dev = md2cmm_dev(md);
139 result = cmm_child_ops(cmm_dev)->mdo_statfs(ctxt,
140 cmm_dev->cmm_child, sfs);
144 int cmm_mkdir(struct lu_context *ctxt, struct md_object *md_parent,
145 const char *name, struct md_object *md_child)
147 struct cmm_object *cmm_parent = md2cmm_obj(md_parent);
148 struct md_object *next = cmm2child_obj(cmm_parent);
150 return next->mo_ops->moo_mkdir(ctxt, next, name, md_child);
153 int cmm_attr_get(struct lu_context *ctxt, struct md_object *obj,
154 void *buf, int size, const char *name, struct md_params *arg)
156 struct md_object *next = cmm2child_obj(md2cmm_obj(obj));
158 return next->mo_ops->moo_attr_get(ctxt, next, buf, size, name, arg);
161 static struct md_object_operations cmm_mo_ops = {
162 .moo_mkdir = cmm_mkdir,
163 .moo_attr_get = cmm_attr_get,
164 // .moo_rename = cmm_rename,
165 // .moo_link = cmm_link,
166 // .moo_attr_set = cmm_attr_set,
167 // .moo_index_insert = cmm_index_insert,
168 // .moo_index_delete = cmm_index_delete,
169 // .moo_object_create = cmm_object_create,