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 struct cmm_object *cmm_object_find(struct cmm_device *d, struct lu_fid *f)
41 o = lu_object_find(d->cmm_md_dev.md_lu_dev.ld_site, f);
43 return (struct cmm_object *)o;
45 return container_of(o, struct cmm_object, cmo_obj.mo_lu);
48 void cmm_object_put(struct cmm_object *o)
50 lu_object_put(&o->cmo_obj.mo_lu);
53 struct lu_object *cmm_object_alloc(struct lu_device *d)
55 struct cmm_object *mo;
60 o = &mo->cmo_obj.mo_lu;
66 int cmm_object_init(struct lu_object *o)
68 struct cmm_device *d = lu2cmm_dev(o->lo_dev);
69 struct lu_device *under;
70 struct lu_object *below;
72 under = &d->cmm_child->md_lu_dev;
73 below = under->ld_ops->ldo_object_alloc(under);
75 lu_object_add(o, below);
81 void cmm_object_free(struct lu_object *o)
86 void cmm_object_release(struct lu_object *o)
91 int cmm_object_print(struct seq_file *f, const struct lu_object *o)
93 return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", o);
98 static void cmm_lock(struct md_object *obj, __u32 mode)
100 struct cmm_object *cmm_obj = md2cmm_obj(obj);
101 struct cmm_device *cmm_dev = cmm_obj2dev(cmm_obj);
103 CMM_DO_CHILD(cmm_dev)->ldo_lock_obj(cmm2child_obj(cmm_obj), mode);
107 static void cmm_unlock(struct md_object *obj, __u32 mode)
109 struct cmm_object *cmm_obj = md2cmm_obj(obj);
110 struct cmm_device *cmm_dev = cmm_obj2dev(cmm_obj);
112 CMM_DO_CHILD(cmm_dev)->ldo_unlock_obj(cmm2child_obj(cmm_obj), mode);
119 int cmm_root_get(struct md_device *md, struct lu_fid *fid) {
123 int cmm_mkdir(struct md_object *md_parent, const char *name,
124 struct md_object *md_child)
126 struct cmm_object *cmm_parent = md2cmm_obj(md_parent);
127 struct cmm_device *cmm_dev = cmm_obj2dev(cmm_parent);
128 int result = -EOPNOTSUPP;
130 if (CMM_CHILD_OPS(cmm_dev) && CMM_CHILD_OPS(cmm_dev)->mdo_mkdir) {
131 result = CMM_CHILD_OPS(cmm_dev)->mdo_mkdir(
132 cmm2child_obj(cmm_parent),