}
static int cmm_root_get(const struct lu_context *ctx, struct md_device *md,
- struct lu_fid *fid)
+ struct lu_fid *fid)
{
struct cmm_device *cmm_dev = md2cmm_dev(md);
}
static int cmm_statfs(const struct lu_context *ctxt, struct md_device *md,
- struct kstatfs *sfs) {
+ struct kstatfs *sfs) {
struct cmm_device *cmm_dev = md2cmm_dev(md);
int rc;
{
struct lu_device_type *ldt = &mdc_device_type;
struct lu_device *ld;
- struct mdc_device *mc;
- struct mdc_device *tmp;
+ struct mdc_device *mc, *tmp;
__u32 mdc_num;
int rc;
ENTRY;
spin_lock(&cm->cmm_tgt_guard);
list_for_each_entry_safe(mc, tmp, &cm->cmm_targets,
mc_linkage) {
- if (mc->mc_num == mdc_num)
+ if (mc->mc_num == mdc_num) {
+ spin_unlock(&cm->cmm_tgt_guard);
RETURN(-EEXIST);
+ }
}
spin_unlock(&cm->cmm_tgt_guard);
ld = ldt->ldt_ops->ldto_device_alloc(ctx, ldt, cfg);
ld->ld_site = cmm2lu_dev(cm)->ld_site;
rc = ldt->ldt_ops->ldto_device_init(ctx, ld, NULL);
- if (rc)
+ if (rc) {
ldt->ldt_ops->ldto_device_free(ctx, ld);
-
+ RETURN (rc);
+ }
/* pass config to the just created MDC */
rc = ld->ld_ops->ldo_process_config(ctx, ld, cfg);
if (rc == 0) {
- mc = lu2mdc_dev(ld);
spin_lock(&cm->cmm_tgt_guard);
+ list_for_each_entry_safe(mc, tmp, &cm->cmm_targets,
+ mc_linkage) {
+ if (mc->mc_num == mdc_num) {
+ spin_unlock(&cm->cmm_tgt_guard);
+ ldt->ldt_ops->ldto_device_fini(ctx, ld);
+ ldt->ldt_ops->ldto_device_free(ctx, ld);
+ RETURN(-EEXIST);
+ }
+ }
+ mc = lu2mdc_dev(ld);
list_add_tail(&mc->mc_linkage, &cm->cmm_targets);
cm->cmm_tgt_count++;
spin_unlock(&cm->cmm_tgt_guard);
/* --- lu_device_type operations --- */
static struct lu_device *cmm_device_alloc(const struct lu_context *ctx,
- struct lu_device_type *t,
- struct lustre_cfg *cfg)
+ struct lu_device_type *t,
+ struct lustre_cfg *cfg)
{
struct lu_device *l;
struct cmm_device *m;
l->ld_ops = &cmm_lu_ops;
}
- EXIT;
- return l;
+ RETURN (l);
}
static void cmm_device_free(const struct lu_context *ctx, struct lu_device *d)
LASSERT(atomic_read(&d->ld_ref) == 0);
LASSERT(m->cmm_tgt_count == 0);
+ LASSERT(list_empty(&m->cmm_targets));
md_device_fini(&m->cmm_md_dev);
OBD_FREE_PTR(m);
}
list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) {
struct lu_device *ld_m = mdc2lu_dev(mc);
- list_del(&mc->mc_linkage);
+ list_del_init(&mc->mc_linkage);
lu_device_put(cmm2lu_dev(cm));
ld->ld_type->ldt_ops->ldto_device_fini(ctx, ld_m);
ld->ld_type->ldt_ops->ldto_device_free(ctx, ld_m);
cm->cmm_tgt_count--;
}
- EXIT;
- return md2lu_dev(cm->cmm_child);
+ RETURN (md2lu_dev(cm->cmm_child));
}
static struct lu_device_type_operations cmm_device_type_ops = {
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2006 Cluster File Systems, Inc.
- *
- * This file is part of Lustre, http://www.lustre.org.
+ * lustre/cmm/cmm_internal.h
+ * Lustre Cluster Metadata Manager (cmm)
*
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2006 Cluster File Systems, Inc.
+ * Author: Mike Pershin <tappro@clusterfs.com>
+ *
+ * This file is part of the Lustre file system, http://www.lustre.org
+ * Lustre is a trademark of Cluster File Systems, Inc.
*
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * You may have signed or agreed to another license before downloading
+ * this software. If so, you are bound by the terms and conditions
+ * of that agreement, and the following does not apply to you. See the
+ * LICENSE file included with this distribution for more information.
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * If you did not agree to a different license, then this copy of Lustre
+ * is open source software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
*
+ * In either case, Lustre is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * license text for more details.
*/
#ifndef _CMM_INTERNAL_H
/* device flags, taken from enum cmm_flags */
__u32 cmm_flags;
/* underlaying device in MDS stack, usually MDD */
- struct md_device *cmm_child;
+ struct md_device *cmm_child;
/* other MD servers in cluster */
__u32 cmm_local_num;
__u32 cmm_tgt_count;
static inline struct cmm_device *lu2cmm_dev(struct lu_device *d)
{
- return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
+ return container_of0(d, struct cmm_device, cmm_md_dev.md_lu_dev);
}
static inline struct lu_device *cmm2lu_dev(struct cmm_device *d)
{
- return (&d->cmm_md_dev.md_lu_dev);
+ return (&d->cmm_md_dev.md_lu_dev);
}
struct cmm_object {
- struct md_object cmo_obj;
+ struct md_object cmo_obj;
int cmo_local;
};
-/* local CMM objec */
+/* local CMM object */
struct cml_object {
struct cmm_object cmm_obj;
};
static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
{
- return (md2cmm_dev(md_device_get(&c->cmo_obj)));
+ return (md2cmm_dev(md_obj2dev(&c->cmo_obj)));
}
static inline struct cmm_object *lu2cmm_obj(struct lu_object *o)
{
- //LASSERT(lu_device_is_cmm(o->lo_dev));
- return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
+ //LASSERT(lu_device_is_cmm(o->lo_dev));
+ return container_of0(o, struct cmm_object, cmo_obj.mo_lu);
}
/* get cmm object from md_object */
static inline struct cmm_object *md2cmm_obj(struct md_object *o)
{
- return container_of0(o, struct cmm_object, cmo_obj);
+ return container_of0(o, struct cmm_object, cmo_obj);
}
/* get lower-layer object */
static inline struct md_object *cmm2child_obj(struct cmm_object *o)
#endif /* __KERNEL__ */
#endif /* _CMM_INTERNAL_H */
+
__u64 mds;
int rc;
ENTRY;
- return 0;
+
LASSERT(fid_is_sane(fid));
/* XXX: is this correct? We need this to prevent FLD lookups while CMM
static int cml_object_print(const struct lu_context *ctx,
struct seq_file *f, const struct lu_object *lo)
{
- return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", lo);
+ return seq_printf(f, LUSTRE_CMM0_NAME"-local@%p", lo);
}
static struct lu_object_operations cml_obj_ops = {
return container_of0(co, struct cmr_object, cmm_obj);
}
-/* get local child device */
+/* get proper child device from MDCs */
static struct lu_device *cmr_child_dev(struct cmm_device *d, __u32 num)
{
struct lu_device *next = NULL;
static int cmr_object_print(const struct lu_context *ctx,
struct seq_file *f, const struct lu_object *lo)
{
- return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", lo);
+ return seq_printf(f, LUSTRE_CMM0_NAME"-remote@%p", lo);
}
static struct lu_object_operations cmr_obj_ops = {
* lookup and process this further */
LASSERT(mo_t == NULL);
- rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_pn)), NULL/* mo_t */,
- lf, t_name);
+ rc = mdo_rename_tgt(ctx, cmm2child_obj(md2cmm_obj(mo_pn)),
+ NULL/* mo_t */, lf, t_name);
/* only old name is removed localy */
if (rc == 0)
rc = mdo_name_remove(ctx, cmm2child_obj(md2cmm_obj(mo_po)),
struct mdc_device *mc = lu2mdc_dev(ld);
LASSERT(atomic_read(&ld->ld_ref) == 0);
+ LASSERT(list_empty(&mc->mc_linkage));
md_device_fini(&mc->mc_md_dev);
OBD_FREE_PTR(mc);
}
CLASSERT(CFS_PAGE_SIZE >= sizeof *info);
OBD_ALLOC_PTR(info);
- if (info != NULL)
- info->mci_ctxt = ctx;
- else
+ if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
}
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2006 Cluster File Systems, Inc.
- *
- * This file is part of Lustre, http://www.lustre.org.
+ * lustre/cmm/cmm_internal.h
+ * Lustre Cluster Metadata Manager (cmm),
+ * MDC device
*
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Copyright (C) 2006 Cluster File Systems, Inc.
+ * Author: Mike Pershin <tappro@clusterfs.com>
+ *
+ * This file is part of the Lustre file system, http://www.lustre.org
+ * Lustre is a trademark of Cluster File Systems, Inc.
*
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * You may have signed or agreed to another license before downloading
+ * this software. If so, you are bound by the terms and conditions
+ * of that agreement, and the following does not apply to you. See the
+ * LICENSE file included with this distribution for more information.
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * If you did not agree to a different license, then this copy of Lustre
+ * is open source software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
*
+ * In either case, Lustre is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * license text for more details.
*/
#ifndef _CMM_MDC_INTERNAL_H
};
struct mdc_thread_info {
- const struct lu_context *mci_ctxt;
struct md_op_data mci_opdata;
struct ptlrpc_request *mci_req;
};
static inline struct mdc_device *mdc_obj2dev(struct mdc_object *mco)
{
- return (md2mdc_dev(md_device_get(&mco->mco_obj)));
+ return (md2mdc_dev(md_obj2dev(&mco->mco_obj)));
}
static inline struct mdc_object *lu2mdc_obj(struct lu_object *lo)
RETURN(0);
}
-static int mdc_object_exists(const struct lu_context *ctx, struct lu_object *lo)
+static int mdc_object_exists(const struct lu_context *ctx,
+ struct lu_object *lo)
{
/* we don't know does it exists or not - but suppose that it does*/
return 1;
static int mdc_object_create(const struct lu_context *ctx,
struct md_object *mo, struct lu_attr *attr)
{
- struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
+ struct mdc_device *mc = md2mdc_dev(md_obj2dev(mo));
struct mdc_thread_info *mci;
int rc;
ENTRY;
attr->la_mode, attr->la_uid, attr->la_gid, 0, 0,
&mci->mci_req);
+ ptlrpc_req_finished(mci->mci_req);
+
RETURN(rc);
}
static int mdc_ref_add(const struct lu_context *ctx, struct md_object *mo)
{
- struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
+ struct mdc_device *mc = md2mdc_dev(md_obj2dev(mo));
struct mdc_thread_info *mci;
int rc;
ENTRY;
rc = md_link(mc->mc_desc.cl_exp, &mci->mci_opdata, &mci->mci_req);
+ ptlrpc_req_finished(mci->mci_req);
+
RETURN(rc);
}
static int mdc_ref_del(const struct lu_context *ctx, struct md_object *mo)
{
- struct mdc_device *mc = md2mdc_dev(md_device_get(mo));
+ struct mdc_device *mc = md2mdc_dev(md_obj2dev(mo));
struct mdc_thread_info *mci;
int rc;
ENTRY;
rc = md_unlink(mc->mc_desc.cl_exp, &mci->mci_opdata, &mci->mci_req);
+ ptlrpc_req_finished(mci->mci_req);
+
RETURN(rc);
}
struct md_object *mo_p, struct md_object *mo_t,
const struct lu_fid *lf, const char *name)
{
- struct mdc_device *mc = md2mdc_dev(md_device_get(mo_p));
+ struct mdc_device *mc = md2mdc_dev(md_obj2dev(mo_p));
struct mdc_thread_info *mci;
int rc;
ENTRY;
rc = md_rename(mc->mc_desc.cl_exp, &mci->mci_opdata, NULL, 0,
name, strlen(name), &mci->mci_req);
+ ptlrpc_req_finished(mci->mci_req);
+
RETURN(rc);
}