.ldo_object_init = cmm_object_init,
.ldo_object_free = cmm_object_free,
.ldo_object_release = cmm_object_release,
- .ldo_object_print = cmm_object_print,
.ldo_process_config = cmm_process_config
};
void cmm_object_release(struct lu_context *ctxt, struct lu_object *o);
//int cmm_getattr(struct lu_object *o, struct lu_attr *a);
//int cmm_setattr(struct lu_object *o, struct lu_attr *a);
-int cmm_object_print(struct lu_context *ctx,
- struct seq_file *f, const struct lu_object *o);
/* cmm md operations */
int cmm_config(struct lu_context *ctx, struct md_device *md, const char *name,
#include "cmm_internal.h"
static struct md_object_operations cmm_mo_ops;
+static struct lu_object_operations cmm_obj_ops;
struct lu_object *cmm_object_alloc(struct lu_context *ctx,
struct lu_device *d)
o = &mo->cmo_obj.mo_lu;
lu_object_init(o, NULL, d);
mo->cmo_obj.mo_ops = &cmm_mo_ops;
+ o->lo_ops = &cmm_obj_ops;
RETURN(o);
} else
RETURN(NULL);
//struct lu_fid *fid = &o->lo_header->loh_fid;
//int mds_index;
ENTRY;
-
+
/* under device can be MDD or MDC */
#if 0
mds = cmm_fld_lookup(fid);
if (mds_index != d->local_index)
under = &d->cmm_lmv->md_lu_dev;
- else
+ else
#endif
under = &d->cmm_child->md_lu_dev;
-
-
+
+
below = under->ld_ops->ldo_object_alloc(ctxt, under);
if (below != NULL) {
lu_object_add(o, below);
return;
}
-int cmm_object_print(struct lu_context *ctx,
- struct seq_file *f, const struct lu_object *o)
+static int cmm_object_exists(struct lu_context *ctx, struct lu_object *o)
+{
+ struct lu_object *next = lu_object_next(o);
+
+ return next->lo_ops->loo_object_exists(ctx, next);
+}
+
+static int cmm_object_print(struct lu_context *ctx,
+ struct seq_file *f, const struct lu_object *o)
{
return seq_printf(f, LUSTRE_CMM0_NAME"-object@%p", o);
}
// .moo_link = cmm_link,
// .moo_xattr_get = cmm_xattr_get,
// .moo_xattr_set = cmm_xattr_set,
-// .moo_index_insert = cmm_index_insert,
-// .moo_index_delete = cmm_index_delete,
-// .moo_object_create = cmm_object_create,
};
+static struct lu_object_operations cmm_obj_ops = {
+ .loo_object_print = cmm_object_print,
+ .loo_object_exists = cmm_object_exists
+};
#include <linux/obd_support.h>
#include <linux/lprocfs_status.h>
+#include <linux/dt_object.h>
#include <linux/md_object.h>
#include <linux/lustre_mdc.h>
+#include <linux/lustre_fid.h>
#include "fld_internal.h"
static int fld_handle(struct lu_context *ctx,
lustre_export.h lustre_log.h obd_echo.h \
lustre_compat25.h lustre_fsfilt.h lustre_import.h lustre_mds.h lustre_mdc.h \
lustre_acl.h obd.h lvfs.h lvfs_linux.h lustre_cfg.h lustre_lite.h lustre_idl.h \
- lustre_quota.h lustre_ucache.h lustre_ver.h.in lustre_param.h lu_object.h lustre_fid.h
+ lustre_quota.h lustre_ucache.h lustre_ver.h.in lustre_param.h lu_object.h lustre_fid.h md_object.h
--- /dev/null
+/* -*- 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 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.
+ *
+ * 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 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.
+ *
+ */
+
+#ifndef __LINUX_DT_OBJECT_H
+#define __LINUX_DT_OBJECT_H
+
+/*
+ * Sub-class of lu_object with methods common for "data" objects in OST stack.
+ *
+ * Data objects behave like regular files: you can read/write them, get and
+ * set their attributes. Implementation of dt interface is supposed to
+ * implement some form of garbage collection, normally reference counting
+ * (nlink) based one.
+ *
+ * Examples: osd (lustre/osd) is am implementation of dt interface.
+ */
+
+
+/*
+ * super-class definitions.
+ */
+#include <linux/lu_object.h>
+
+#include <libcfs/list.h>
+#include <libcfs/kp30.h>
+
+struct seq_file;
+struct proc_dir_entry;
+struct lustre_cfg;
+
+struct md_params;
+struct thandle;
+struct txn_param;
+struct dt_device;
+struct dt_object;
+
+/*
+ * Lock mode for DT objects.
+ */
+enum dt_lock_mode {
+ DT_WRITE_LOCK = 1,
+ DT_READ_LOCK = 2,
+};
+
+/*
+ * Operations on dt device.
+ */
+struct dt_device_operations {
+ /*
+ * Method for getting/setting device wide back stored config data,
+ * like last used meta-sequence, etc.
+ */
+ int (*dt_config) (struct lu_context *ctx,
+ struct dt_device *dev, const char *name,
+ void *buf, int size, int mode);
+ /*
+ * Return device-wide statistics.
+ */
+ int (*dt_statfs)(struct lu_context *ctx,
+ struct dt_device *dev, struct kstatfs *sfs);
+ /*
+ * Start transaction, described by @param.
+ */
+ struct thandle *(*dt_trans_start)(struct lu_context *ctx,
+ struct dt_device *dev,
+ struct txn_param *param);
+ /*
+ * Finish previously started transaction.
+ */
+ void (*dt_trans_stop)(struct lu_context *ctx, struct thandle *th);
+ /*
+ * Return fid of root index object.
+ */
+ int (*dt_root_get)(struct lu_context *ctx,
+ struct dt_device *dev, struct lu_fid *f);
+
+ int (*dt_object_create)(struct lu_context *ctxt, struct dt_object *dt,
+ struct md_params *arg, struct thandle *th);
+
+ int (*dt_object_destroy)(struct lu_context *ctxt,
+ struct dt_object *dt, struct thandle *th);
+
+};
+
+struct dt_object_operations {
+ void (*do_object_lock)(struct lu_context *ctx,
+ struct dt_object *dt, enum dt_lock_mode mode);
+ void (*do_object_unlock)(struct lu_context *ctx,
+ struct dt_object *dt, enum dt_lock_mode mode);
+
+ int (*do_attr_get)(struct lu_context *ctxt, struct dt_object *dt,
+ struct lu_attr *attr);
+ int (*do_attr_set)(struct lu_context *ctxt, struct dt_object *dt,
+ struct lu_attr *attr, struct thandle *handle);
+
+ int (*do_xattr_get)(struct lu_context *ctxt, struct dt_object *dt,
+ void *buf, int buf_len, const char *name,
+ struct md_params *arg);
+
+ int (*do_xattr_set)(struct lu_context *ctxt, struct dt_object *dt,
+ void *buf, int buf_len, const char *name,
+ struct md_params *arg, struct thandle *handle);
+
+};
+
+struct dt_body_operations {
+ int (*dbo_read)(struct lu_context *ctxt, struct dt_object *dt, ...);
+ int (*dbo_write)(struct lu_context *ctxt, struct dt_object *dt, ...);
+ int (*dbo_truncate)(struct lu_context *ctxt, struct dt_object *dt, ...);
+ int (*dbo_seek)(struct lu_context *ctxt, struct dt_object *dt, ...);
+};
+
+struct dt_index_operations {
+ int (*dio_index_insert)(struct lu_context *ctxt,
+ struct dt_object *dt,
+ struct lu_fid *fid, const char *name,
+ struct md_params *arg,
+ struct thandle *handle);
+
+ int (*dio_index_delete)(struct lu_context *ctxt,
+ struct dt_object *dt,
+ struct lu_fid *fid, const char *name,
+ struct md_params *arg,
+ struct thandle *handle);
+};
+
+struct dt_device {
+ struct lu_device dd_lu_dev;
+ struct dt_device_operations *dd_ops;
+};
+
+static inline int lu_device_is_dt(const struct lu_device *d)
+{
+ return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_DT);
+}
+
+static inline struct dt_device * lu2dt_dev(struct lu_device *l)
+{
+ LASSERT(lu_device_is_dt(l));
+ return container_of0(l, struct dt_device, dd_lu_dev);
+}
+
+struct dt_object {
+ struct lu_object do_lu;
+ struct dt_object_operations *do_ops;
+ struct dt_body_operations *do_body_ops;
+ struct dt_index_operations *do_index_ops;
+};
+
+struct txn_param {
+ unsigned int tp_credits;
+};
+
+#define TXN_PARAM_INIT(credits) { \
+ .tp_credits = (credits) \
+}
+
+#define TXN_PARAM(...) ((struct txn_param)TXN_PARAM_INIT(__VA_ARGS__))
+
+#endif /* __LINUX_DT_OBJECT_H */
* 3. avoiding recursion.
*
* Generic code tries to replace recursion through layers by iterations
- * where possible.
+ * where possible. Additionally to the end of reducing stack consumption,
+ * data, when practically possible, are allocated through lu_context_key
+ * interface rather than on stack.
*
*/
*/
void (*ldo_object_release)(struct lu_context *ctx, struct lu_object *o);
+ /* process config specific for device */
+ int (*ldo_process_config)(struct lu_device *, struct lustre_cfg *);
+
+};
+
+struct lu_object_operations {
+ int (*loo_object_exists)(struct lu_context *ctx, struct lu_object *o);
/*
* Debugging helper. Print given object.
*/
- int (*ldo_object_print)(struct lu_context *ctx,
+ int (*loo_object_print)(struct lu_context *ctx,
struct seq_file *f, const struct lu_object *o);
-
- /* process config specific for device */
- int (*ldo_process_config)(struct lu_device *, struct lustre_cfg *);
-
};
/*
/*
* Header for this object.
*/
- struct lu_object_header *lo_header;
+ struct lu_object_header *lo_header;
/*
* Device for this layer.
*/
- struct lu_device *lo_dev;
+ struct lu_device *lo_dev;
+ /*
+ * Operations for this object.
+ */
+ struct lu_object_operations *lo_ops;
/*
* Linkage into list of all layers.
*/
- struct list_head lo_linkage;
+ struct list_head lo_linkage;
/*
* Depth. Top level layer depth is 0.
*/
- int lo_depth;
+ int lo_depth;
/*
* Flags from enum lu_object_flags.
*/
- unsigned long lo_flags;
+ unsigned long lo_flags;
};
enum lu_object_header_flags {
/*
* "Compound" object, consisting of multiple layers.
+ *
+ * Compound object with given fid is unique with given lu_site.
+ *
+ * Note, that object does *not* necessary correspond to the real object in the
+ * persistent storage: object is an anchor for locking and method calling, so
+ * it is created for things like not-yet-existing child created by mkdir or
+ * create calls. ->loo_exists() can be used to check whether object is backed
+ * by persistent storage entity.
*/
struct lu_object_header {
/*
spin_unlock(&o->lo_dev->ld_site->ls_guard);
}
+/*
+ * Return true of object will not be cached after last reference to it is
+ * released.
+ */
static inline int lu_object_is_dying(struct lu_object_header *h)
{
return test_bit(LU_OBJECT_HEARD_BANSHEE, &h->loh_flags);
/*
* lu_context. Execution context for lu_object methods. Currently associated
* with thread.
+ *
+ * All lu_object methods, except device and device type methods (called during
+ * system initialization and shutdown) are executed "within" some
+ * lu_context. This means, that pointer to some "current" lu_context is passed
+ * as an argument to all methods.
+ *
+ * All service ptlrpc threads create lu_context as part of their
+ * initialization. It is possible to create "stand-alone" context for other
+ * execution environments (like system calls).
+ *
+ * lu_object methods mainly use lu_context through lu_context_key interface
+ * that allows each layer to associate arbitrary pieces of data with each
+ * context (see pthread_key_create(3) for similar interface).
+ *
*/
struct lu_context {
+ /*
+ * Theoretically we'd want to use lu_objects and lu_contexts on the
+ * client side too. On the other hand, we don't want to allocate
+ * values of server-side keys for the client contexts and vice versa.
+ *
+ * To achieve this, set of tags in introduced. Contexts and keys are
+ * marked with tags. Key value are created only for context whose set
+ * of tags has non-empty intersection with one for key. NOT YET
+ * IMPLEMENTED.
+ */
__u32 lc_tags;
+ /*
+ * Object attribute. This is stuffed directly into context, because we
+ * know it advance it will be needed. As an alternative, it can be
+ * allocated through special key.
+ */
struct lu_attr lc_attr;
+ /*
+ * Pointer to the home service thread. NULL for other execution
+ * contexts.
+ */
struct ptlrpc_thread *lc_thread;
+ /*
+ * Pointer to an array with key values. Internal implementation
+ * detail.
+ */
void **lc_value;
};
+/*
+ * lu_context_key interface. Similar to pthread_key.
+ */
+
+/*
+ * Key. Represents per-context value slot.
+ */
struct lu_context_key {
+ /*
+ * Value constructor. This is called when new value is created for a
+ * context. Returns pointer to new value of error pointer.
+ */
void *(*lct_init)(struct lu_context *ctx);
+ /*
+ * Value destructor. Called when context with previously allocated
+ * value of this slot is destroyed. @data is a value that was returned
+ * by matching call to ->lct_init().
+ */
void (*lct_fini)(struct lu_context *ctx, void *data);
+ /*
+ * Internal implementation detail: index within ->lc_value[] reserved
+ * for this key.
+ */
int lct_index;
+ /*
+ * Internal implementation detail: number of values created for this
+ * key.
+ */
unsigned lct_used;
};
void lu_context_enter(struct lu_context *ctx);
void lu_context_exit(struct lu_context *ctx);
-/*
- * DT device interface. XXX Probably should go elsewhere.
- */
-struct md_params;
-struct thandle;
-struct txn_param;
-struct dt_device;
-struct dt_object;
-
-enum dt_lock_mode {
- DT_WRITE_LOCK = 1,
- DT_READ_LOCK = 2,
-};
-
-struct dt_device_operations {
- /* method for getting/setting device wide back stored config data, like
- * last used meta-sequence, etc. */
- int (*dt_config) (struct lu_context *ctx,
- struct dt_device *dev, const char *name,
- void *buf, int size, int mode);
- int (*dt_statfs)(struct lu_context *ctx,
- struct dt_device *dev, struct kstatfs *sfs);
- struct thandle *(*dt_trans_start)(struct lu_context *ctx,
- struct dt_device *dev,
- struct txn_param *param);
- void (*dt_trans_stop)(struct lu_context *ctx, struct thandle *th);
- int (*dt_root_get)(struct lu_context *ctx,
- struct dt_device *dev, struct lu_fid *f);
-};
-
-struct dt_object_operations {
- void (*do_object_lock)(struct lu_context *ctx,
- struct dt_object *dt, enum dt_lock_mode mode);
- void (*do_object_unlock)(struct lu_context *ctx,
- struct dt_object *dt, enum dt_lock_mode mode);
-
- int (*do_object_create)(struct lu_context *ctxt,
- struct dt_object *dt,
- struct dt_object *child,
- struct md_params *arg, struct thandle *th);
-
- int (*do_object_destroy)(struct lu_context *ctxt,
- struct dt_object *dt,
- struct thandle *th);
-
- int (*do_attr_get)(struct lu_context *ctxt, struct dt_object *dt,
- struct lu_attr *attr);
- int (*do_attr_set)(struct lu_context *ctxt, struct dt_object *dt,
- struct lu_attr *attr, struct thandle *handle);
-
- int (*do_xattr_get)(struct lu_context *ctxt, struct dt_object *dt,
- void *buf, int buf_len, const char *name,
- struct md_params *arg);
-
- int (*do_xattr_set)(struct lu_context *ctxt, struct dt_object *dt,
- void *buf, int buf_len, const char *name,
- struct md_params *arg, struct thandle *handle);
-
- int (*do_index_insert)(struct lu_context *ctxt,
- struct dt_object *dt,
- struct lu_fid *fid, const char *name,
- struct md_params *arg,
- struct thandle *handle);
-
- int (*do_index_delete)(struct lu_context *ctxt,
- struct dt_object *dt,
- struct lu_fid *fid, const char *name,
- struct md_params *arg,
- struct thandle *handle);
-};
-
-struct dt_device {
- struct lu_device dd_lu_dev;
- struct dt_device_operations *dd_ops;
-};
-
-static inline int lu_device_is_dt(const struct lu_device *d)
-{
- return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_DT);
-}
-
-static inline struct dt_device * lu2dt_dev(struct lu_device *l)
-{
- LASSERT(lu_device_is_dt(l));
- return container_of0(l, struct dt_device, dd_lu_dev);
-}
-
-struct dt_object {
- struct lu_object do_lu;
- struct dt_object_operations *do_ops;
-};
-
-struct txn_param {
- unsigned int tp_credits;
-};
-
-#define TXN_PARAM_INIT(credits) { \
- .tp_credits = (credits) \
-}
-
-#define TXN_PARAM(...) ((struct txn_param)TXN_PARAM_INIT(__VA_ARGS__))
-
-struct fld {
- struct proc_dir_entry *fld_proc_entry;
- struct ptlrpc_service *fld_service;
- struct dt_device *fld_dt;
-};
-
-int fld_server_init(struct fld *fld, struct dt_device *dt);
-void fld_server_fini(struct fld *fld);
-
-#endif /* __LINUX_OBD_CLASS_H */
+#endif /* __LINUX_LU_OBJECT_H */
void fid_to_le(struct lu_fid *dst, const struct lu_fid *src);
+/*
+ * fld (fid location database) interface.
+ */
+struct fld {
+ struct proc_dir_entry *fld_proc_entry;
+ struct ptlrpc_service *fld_service;
+ struct dt_device *fld_dt;
+};
+
+int fld_server_init(struct fld *fld, struct dt_device *dt);
+void fld_server_fini(struct fld *fld);
+
+
#endif /* __LINUX_OBD_CLASS_H */
int (*moo_xattr_set)(struct lu_context *ctxt, struct md_object *obj,
void *buf, int buf_len, const char *name,
struct md_params *arg);
-
- /* FLD maintanence related handlers */
- int (*moo_index_insert)(struct lu_context *ctxt,
- struct md_object *pobj, struct md_object *obj,
- const char *name, struct md_params *arg);
-
- int (*moo_index_delete)(struct lu_context *ctxt,
- struct md_object *pobj, struct md_object *obj,
- const char *name, struct md_params *arg);
-
- int (*moo_object_create)(struct lu_context *, struct md_object *,
- struct md_object *, struct md_params *);
};
struct md_device_operations {
LASSERT(dentry != NULL);
sbi = ll_i2sbi(dentry->d_inode);
-
+
if (it->d.lustre.it_lock_mode && dentry->d_inode != NULL) {
struct inode *inode = dentry->d_inode;
CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
LASSERT(it);
parent = de->d_parent->d_inode;
-
+
ll_prepare_md_op_data(&op_data, parent, NULL, de->d_name.name,
de->d_name.len, 0);
unlock_kernel();
handle = (flag) ? &ldd->lld_mnt_och : &ldd->lld_cwd_och;
- rc = obd_pin(sbi->ll_md_exp, &ll_i2info(inode)->lli_fid,
+ rc = obd_pin(sbi->ll_md_exp, &ll_i2info(inode)->lli_fid,
handle, flag);
if (rc) {
#include <linux/lu_object.h>
#include <linux/md_object.h>
+#include <linux/dt_object.h>
#include "mdd_internal.h"
struct mdd_object *obj, enum dt_lock_mode mode);
static struct md_object_operations mdd_obj_ops;
+static struct lu_object_operations mdd_lu_obj_ops;
static int lu_device_is_mdd(struct lu_device *d)
{
o = &mdo->mod_obj.mo_lu;
lu_object_init(o, NULL, d);
mdo->mod_obj.mo_ops = &mdd_obj_ops;
- return (&mdo->mod_obj.mo_lu);
+ o->lo_ops = &mdd_lu_obj_ops;
+ return &mdo->mod_obj.mo_lu;
} else
- return(NULL);
+ return NULL;
}
static int mdd_object_init(struct lu_context *ctxt, struct lu_object *o)
}
static int
-__mdd_object_destroy(struct lu_context *ctxt, struct mdd_device *mdd,
- struct mdd_object *obj,
+__mdd_object_destroy(struct lu_context *ctxt, struct mdd_object *obj,
struct thandle *handle)
{
- int rc = 0;
- struct dt_object *next = mdd_object_child(obj);
-
- rc = next->do_ops->do_object_destroy(ctxt, next, handle);
+ struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
+ int rc;
+ rc = mdd_child_ops(mdd)->dt_object_destroy(ctxt, mdd_object_child(obj),
+ handle);
RETURN(rc);
}
if (open_orphan(mdd_obj))
rc = mdd_add_orphan(mdd, mdd_obj, handle);
else {
- rc = __mdd_object_destroy(ctxt, mdd,
- mdd_obj, handle);
+ rc = __mdd_object_destroy(ctxt, mdd_obj, handle);
if (rc == 0)
rc = mdd_add_unlink_log(mdd, mdd_obj, handle);
}
{
}
+static int mdd_object_exists(struct lu_context *ctx, struct lu_object *o)
+{
+ struct lu_object *next = lu_object_next(o);
+
+ return next->lo_ops->loo_object_exists(ctx, next);
+}
+
static int mdd_object_print(struct lu_context *ctxt,
struct seq_file *f, const struct lu_object *o)
{
.ldo_object_init = mdd_object_init,
.ldo_object_free = mdd_object_free,
.ldo_object_release = mdd_object_release,
- .ldo_object_print = mdd_object_print,
.ldo_process_config = mdd_process_config
};
+static struct lu_object_operations mdd_lu_obj_ops = {
+ .loo_object_print = mdd_object_print,
+ .loo_object_exists = mdd_object_exists
+};
+
static struct dt_object* mdd_object_child(struct mdd_object *o)
{
return container_of0(lu_object_next(&o->mod_obj.mo_lu),
}
static int
-__mdd_object_create(struct lu_context *ctxt, struct mdd_device *mdd,
- struct mdd_object *pobj,
- struct mdd_object *child, struct md_params *arg,
- struct thandle *handle)
+__mdd_object_create(struct lu_context *ctxt, struct mdd_object *obj,
+ struct md_params *arg, struct thandle *handle)
{
+ struct mdd_device *mdd = mdo2mdd(&obj->mod_obj);
int rc;
- struct dt_object *next = mdd_object_child(pobj);
ENTRY;
- rc = next->do_ops->do_object_create(ctxt, next, mdd_object_child(child),
- arg, handle);
+ rc = mdd_child_ops(mdd)->dt_object_create(ctxt, mdd_object_child(obj),
+ arg, handle);
/*XXX increase the refcount of the object or not?*/
RETURN(rc);
}
-static int
-mdd_object_create(struct lu_context *ctxt, struct md_object *pobj,
- struct md_object *child, struct md_params *arg)
+static int mdd_object_create(struct lu_context *ctxt, struct mdd_device *mdd,
+ struct mdd_object *child, struct md_params *arg)
{
- struct mdd_device *mdd = mdo2mdd(pobj);
- struct mdd_object *mdd_pobj = mdo2mddo(pobj);
- struct mdd_object *mdd_child = mdo2mddo(child);
struct thandle *handle;
int rc;
ENTRY;
if (IS_ERR(handle))
RETURN(PTR_ERR(handle));
- rc = __mdd_object_create(ctxt, mdd, mdd_pobj, mdd_child, arg, handle);
+ rc = __mdd_object_create(ctxt, child, arg, handle);
mdd_trans_stop(ctxt, mdd, handle);
mdd_lock2(ctxt, pobj, obj);
- rc = next->do_ops->do_index_insert(ctxt, next, mdd_object_getfid(obj),
- name, arg, handle);
+ rc = next->do_index_ops->dio_index_insert(ctxt, next,
+ mdd_object_getfid(obj),
+ name, arg, handle);
mdd_unlock2(ctxt, pobj, obj);
RETURN(rc);
mdd_lock2(ctxt, pobj, obj);
- rc = next->do_ops->do_index_delete(ctxt, next, mdd_object_getfid(obj),
- name, arg, handle);
+ rc = next->do_index_ops->dio_index_delete(ctxt, next,
+ mdd_object_getfid(obj),
+ name, arg, handle);
mdd_unlock2(ctxt, pobj, obj);
RETURN(rc);
if (rc)
GOTO(cleanup, rc);
- rc = __mdd_object_destroy(ctxt, mdd, mdd_sobj, handle);
+ /*
+ * XXX nikita: huh? What is this?
+ */
+ rc = __mdd_object_destroy(ctxt, mdd_sobj, handle);
if (rc)
GOTO(cleanup, rc);
cleanup:
mdd_lock(ctxt, mdo2mddo(pobj), DT_WRITE_LOCK);
- rc = __mdd_object_create(ctxt, mdd, mdo2mddo(pobj), mdo2mddo(child),
- NULL, handle);
+ rc = __mdd_object_create(ctxt, mdo2mddo(child), NULL, handle);
if (rc)
GOTO(cleanup, rc);
};
static struct md_object_operations mdd_obj_ops = {
- .moo_mkdir = mdd_mkdir,
- .moo_rename = mdd_rename,
- .moo_link = mdd_link,
- .moo_attr_get = mdd_attr_get,
- .moo_attr_set = mdd_attr_set,
- .moo_xattr_get = mdd_xattr_get,
- .moo_xattr_set = mdd_xattr_set,
- .moo_index_insert = mdd_index_insert,
- .moo_index_delete = mdd_index_delete,
- .moo_object_create = mdd_object_create,
+ .moo_mkdir = mdd_mkdir,
+ .moo_rename = mdd_rename,
+ .moo_link = mdd_link,
+ .moo_attr_get = mdd_attr_get,
+ .moo_attr_set = mdd_attr_set,
+ .moo_xattr_get = mdd_xattr_get,
+ .moo_xattr_set = mdd_xattr_set,
};
static struct obd_ops mdd_obd_device_ops = {
#ifndef _MDD_INTERNAL_H
#define _MDD_INTERNAL_H
+#include <linux/md_object.h>
+
+#include <asm/semaphore.h>
+
+struct dt_device;
+struct file;
+struct lr_server_data;
+struct dentry;
+struct llog_handle;
+
struct mdd_device {
struct md_device mdd_md_dev;
struct dt_device *mdd_child;
struct md_object mod_obj;
};
-int mdd_object_put(struct mdd_device *mdd, struct mdd_object *obj);
-void mdd_object_get(struct mdd_device *mdd, struct mdd_object *obj);
#endif
#include <linux/lustre_export.h>
/* struct obd_device */
#include <linux/obd.h>
+/* lu2dt_dev() */
+#include <linux/dt_object.h>
+
/* struct mds_client_data */
#include "../mds/mds_internal.h"
static struct mdt_device *mdt_dev (struct lu_device *d);
static struct lu_fid *mdt_object_fid(struct mdt_object *o);
-static struct lu_context_key mdt_thread_key;
+static struct lu_context_key mdt_thread_key;
+static struct lu_object_operations mdt_obj_ops;
/* object operations */
static int mdt_md_mkdir(struct mdt_thread_info *info, struct mdt_device *d,
lu_object_header_init(h);
lu_object_init(o, h, d);
lu_object_add_top(h, o);
+ o->lo_ops = &mdt_obj_ops;
return o;
} else
return NULL;
{
}
+static int mdt_object_exists(struct lu_context *ctx, struct lu_object *o)
+{
+ struct lu_object *next = lu_object_next(o);
+
+ return next->lo_ops->loo_object_exists(ctx, next);
+}
+
static int mdt_object_print(struct lu_context *ctxt,
struct seq_file *f, const struct lu_object *o)
{
.ldo_object_init = mdt_object_init,
.ldo_object_free = mdt_object_free,
.ldo_object_release = mdt_object_release,
- .ldo_object_print = mdt_object_print,
.ldo_process_config = mdt_process_config
};
+static struct lu_object_operations mdt_obj_ops = {
+ .loo_object_print = mdt_object_print,
+ .loo_object_exists = mdt_object_exists
+};
+
/* mds_connect_internal */
static int mdt_connect0(struct mdt_device *mdt,
struct obd_export *exp, struct obd_connect_data *data)
/********************** Class fns ********************/
static int class_dentry_readdir(struct obd_device *obd, struct dentry *dir,
- struct vfsmount *inmnt,
+ struct vfsmount *inmnt,
struct list_head *dentry_list){
/* see mds_cleanup_pending */
struct lvfs_run_ctxt saved;
struct vfsmount *mnt;
int rc = 0;
ENTRY;
-
+
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
dentry = dget(dir);
if (IS_ERR(dentry))
if (IS_ERR(file))
/* dentry_open_it() drops the dentry, mnt refs */
GOTO(out_pop, rc = PTR_ERR(file));
-
+
INIT_LIST_HEAD(dentry_list);
rc = l_readdir(file, dentry_list);
filp_close(file, 0);
/* filp_close->fput() drops the dentry, mnt refs */
-
+
out_pop:
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
RETURN(rc);
*/
/* FIXME is it better to have a separate db file, instead of parsing the info
out of the client log? */
-static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
+static int mgs_fsdb_handler(struct llog_handle *llh, struct llog_rec_hdr *rec,
void *data)
{
struct fs_db *fsdb = (struct fs_db *)data;
lcfg = (struct lustre_cfg *)cfg_buf;
- CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command,
+ CDEBUG(D_INFO, "cmd %x %s %s\n", lcfg->lcfg_command,
lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1));
- /* Figure out ost indicies */
+ /* Figure out ost indicies */
/* lov_modify_tgts add 0:lov1 1:ost1_UUID 2(index):0 3(gen):1 */
if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD ||
lcfg->lcfg_command == LCFG_LOV_DEL_OBD) {
index = simple_strtoul(lustre_cfg_string(lcfg, 2),
NULL, 10);
CDEBUG(D_MGS, "OST index for %s is %u (%s)\n",
- lustre_cfg_string(lcfg, 1), index,
+ lustre_cfg_string(lcfg, 1), index,
lustre_cfg_string(lcfg, 2));
set_bit(index, fsdb->fsdb_ost_index_map);
}
-
+
/* Figure out mdt indicies */
/* attach 0:MDC_uml1_mdsA_MNT_client 1:mdc 2:1d834_MNT_client_03f */
if ((lcfg->lcfg_command == LCFG_ATTACH) &&
ENTRY;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
+
rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT),
&loghandle, NULL, logname);
if (rc)
struct mgs_obd *mgs = &obd->u.mgs;
struct fs_db *fsdb;
ENTRY;
-
+
OBD_ALLOC_PTR(fsdb);
- if (!fsdb)
+ if (!fsdb)
RETURN(NULL);
OBD_ALLOC(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
CERROR("No memory for index maps\n");
GOTO(err, 0);
}
-
+
strncpy(fsdb->fsdb_name, fsname, sizeof(fsdb->fsdb_name));
sema_init(&fsdb->fsdb_sem, 1);
list_add(&fsdb->fsdb_list, &mgs->mgs_fs_db_list);
RETURN(fsdb);
err:
- if (fsdb->fsdb_ost_index_map)
+ if (fsdb->fsdb_ost_index_map)
OBD_FREE(fsdb->fsdb_ost_index_map, INDEX_MAP_SIZE);
- if (fsdb->fsdb_mdt_index_map)
+ if (fsdb->fsdb_mdt_index_map)
OBD_FREE(fsdb->fsdb_mdt_index_map, INDEX_MAP_SIZE);
OBD_FREE_PTR(fsdb);
RETURN(NULL);
{
LASSERT(newname);
OBD_ALLOC(*newname, strlen(prefix) + strlen(suffix) + 1);
- if (!*newname)
+ if (!*newname)
return -ENOMEM;
sprintf(*newname, "%s%s", prefix, suffix);
return 0;
}
static inline void name_destroy(char *name)
-{
+{
if (name)
OBD_FREE(name, strlen(name) + 1);
}
-static int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
+static int mgs_find_or_make_fsdb(struct obd_device *obd, char *name,
struct fs_db **dbh)
{
struct mgs_obd *mgs = &obd->u.mgs;
CDEBUG(D_MGS, "Creating new db\n");
fsdb = mgs_new_fsdb(obd, name);
up(&mgs->mgs_sem);
- if (!fsdb)
+ if (!fsdb)
return -ENOMEM;
/* populate the db from the client llog */
}
*dbh = fsdb;
-
+
return 0;
}
/* 1 = index in use
- 0 = index unused
+ 0 = index unused
-1= empty client log */
int mgs_check_index(struct obd_device *obd, struct mgs_target_info *mti)
{
LASSERT(!(mti->mti_flags & LDD_F_NEED_INDEX));
- rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+ rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
if (rc) {
CERROR("Can't get db for %s\n", mti->mti_fsname);
RETURN(rc);
}
- if (fsdb->fsdb_flags & FSDB_EMPTY)
+ if (fsdb->fsdb_flags & FSDB_EMPTY)
RETURN(-1);
- if (mti->mti_flags & LDD_F_SV_TYPE_OST)
+ if (mti->mti_flags & LDD_F_SV_TYPE_OST)
imap = fsdb->fsdb_ost_index_map;
- else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
+ else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
imap = fsdb->fsdb_mdt_index_map;
else
RETURN(-EINVAL);
- if (test_bit(mti->mti_stripe_index, imap))
+ if (test_bit(mti->mti_stripe_index, imap))
RETURN(1);
RETURN(0);
}
int rc = 0;
ENTRY;
- rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
+ rc = mgs_find_or_make_fsdb(obd, mti->mti_fsname, &fsdb);
if (rc) {
CERROR("Can't get db for %s\n", mti->mti_fsname);
RETURN(rc);
}
- if (mti->mti_flags & LDD_F_SV_TYPE_OST)
+ if (mti->mti_flags & LDD_F_SV_TYPE_OST)
imap = fsdb->fsdb_ost_index_map;
- else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
+ else if (mti->mti_flags & LDD_F_SV_TYPE_MDT)
imap = fsdb->fsdb_mdt_index_map;
else
RETURN(-EINVAL);
/* Remove after CMD */
/* Now it removed finally!
- if ((mti->mti_flags & LDD_F_SV_TYPE_MDT) &&
+ if ((mti->mti_flags & LDD_F_SV_TYPE_MDT) &&
(mti->mti_stripe_index > 0)) {
LCONSOLE_ERROR("MDT index must = 0 (until Clustered MetaData "
"feature is ready.)\n");
if (mti->mti_stripe_index >= INDEX_MAP_SIZE * 8) {
LCONSOLE_ERROR("Server %s requested index %d, but the"
- "max index is %d.\n",
+ "max index is %d.\n",
mti->mti_svname, mti->mti_stripe_index,
INDEX_MAP_SIZE * 8);
RETURN(-ERANGE);
}
-
+
if (test_bit(mti->mti_stripe_index, imap)) {
if (mti->mti_flags & LDD_F_VIRGIN) {
LCONSOLE_ERROR("Server %s requested index %d, but that "
server_make_name(mti->mti_flags, mti->mti_stripe_index,
mti->mti_fsname, mti->mti_svname);
- CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname,
+ CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname,
mti->mti_stripe_index);
RETURN(0);
}
-
+
/******************** config log recording functions *********************/
static int record_lcfg(struct obd_device *obd, struct llog_handle *llh,
int buflen, rc;
LASSERT(llh);
- LASSERT(llh->lgh_ctxt);
+ LASSERT(llh->lgh_ctxt);
buflen = lustre_cfg_len(lcfg->lcfg_bufcount,
lcfg->lcfg_buflens);
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
int rc;
-
+
CDEBUG(D_MGS, "lcfg %s %#x %s %s %s %s\n", cfgname,
- cmd, s1, s2, s3, s4);
+ cmd, s1, s2, s3, s4);
lustre_cfg_bufs_reset(&bufs, cfgname);
- if (s1)
+ if (s1)
lustre_cfg_bufs_set_string(&bufs, 1, s1);
- if (s2)
+ if (s2)
lustre_cfg_bufs_set_string(&bufs, 2, s2);
- if (s3)
+ if (s3)
lustre_cfg_bufs_set_string(&bufs, 3, s3);
- if (s4)
+ if (s4)
lustre_cfg_bufs_set_string(&bufs, 4, s4);
lcfg = lustre_cfg_new(cmd, &bufs);
lcfg->lcfg_nid = nid;
rc = record_lcfg(obd, llh, lcfg);
-
+
lustre_cfg_free(lcfg);
-
+
if (rc) {
CERROR("error %d: lcfg %s %#x %s %s %s %s\n", rc, cfgname,
- cmd, s1, s2, s3, s4);
+ cmd, s1, s2, s3, s4);
}
return(rc);
}
-static inline int record_add_uuid(struct obd_device *obd,
- struct llog_handle *llh,
+static inline int record_add_uuid(struct obd_device *obd,
+ struct llog_handle *llh,
uint64_t nid, char *uuid)
{
return record_base(obd,llh,NULL,nid,LCFG_ADD_UUID,uuid,0,0,0);
}
-static inline int record_add_conn(struct obd_device *obd,
+static inline int record_add_conn(struct obd_device *obd,
struct llog_handle *llh,
char *devname,
char *uuid)
}
static inline int record_setup(struct obd_device *obd, struct llog_handle *llh,
- char *devname,
+ char *devname,
char *s1, char *s2, char *s3, char *s4)
{
return record_base(obd,llh,devname,0,LCFG_SETUP,s1,s2,s3,s4);
{
return record_base(obd,llh,lmv_name,0,LCFG_ADD_MDC,
mdt_uuid,index,gen,0);
-}
+}
static inline int record_cmm_add(struct obd_device *obd,
struct llog_handle *llh,
{
return record_base(obd,llh,cmm_name,0,LCFG_ADD_MDC,
mdt_uuid,index,gen,0);
-}
+}
{
return record_base(obd,llh,lov_name,0,LCFG_LOV_ADD_OBD,
ost_uuid,index,gen,0);
-}
+}
-static inline int record_mount_opt(struct obd_device *obd,
+static inline int record_mount_opt(struct obd_device *obd,
struct llog_handle *llh,
char *profile, char *lov_name,
char *mdc_name)
{
return record_base(obd,llh,NULL,0,LCFG_MOUNTOPT,
profile,lov_name,mdc_name,0);
-}
+}
static int record_marker(struct obd_device *obd, struct llog_handle *llh,
struct fs_db *fsdb, __u32 flags,
struct lustre_cfg *lcfg;
int rc;
- if (flags & CM_START)
+ if (flags & CM_START)
fsdb->fsdb_gen++;
marker.cm_step = fsdb->fsdb_gen;
marker.cm_flags = flags;
- strncpy(marker.cm_svname, svname, sizeof(marker.cm_svname));
- strncpy(marker.cm_comment, comment, sizeof(marker.cm_comment));
+ strncpy(marker.cm_svname, svname, sizeof(marker.cm_svname));
+ strncpy(marker.cm_comment, comment, sizeof(marker.cm_comment));
do_gettimeofday(&tv);
marker.cm_createtime = tv.tv_sec;
marker.cm_canceltime = 0;
return rc;
}
-static int record_start_log(struct obd_device *obd,
+static int record_start_log(struct obd_device *obd,
struct llog_handle **llh, char *name)
{
static struct obd_uuid cfg_uuid = { .uuid = "config_uuid" };
struct lvfs_run_ctxt saved;
int rc = 0;
-
+
if (*llh) {
GOTO(out, rc = -EBUSY);
}
int rc = 0;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
+
rc = llog_close(*llh);
*llh = NULL;
-
+
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
RETURN(rc);
}
/* write an lcfg directly into a log (with markers) */
static int mgs_write_log_direct(struct obd_device *obd, struct fs_db *fsdb,
- char *logname, char *obdname,
+ char *logname, char *obdname,
struct lustre_cfg *lcfg)
{
struct llog_handle *llh = NULL;
ENTRY;
rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, obdname, "param");
-
+ rc = record_marker(obd, llh, fsdb, CM_START, obdname, "param");
+
rc = record_lcfg(obd, llh, lcfg);
- rc = record_marker(obd, llh, fsdb, CM_END, obdname, "param");
+ rc = record_marker(obd, llh, fsdb, CM_END, obdname, "param");
rc = record_end_log(obd, &llh);
-
+
RETURN(rc);
}
char *logname;
int rc, len = strlen(fsname);
ENTRY;
-
- /* We need to set params for any future logs
+
+ /* We need to set params for any future logs
as well. FIXME Append this file to every new log. */
name_create(fsname, "-params", &logname);
if (mgs_log_is_empty(obd, logname)) {
CERROR("Can't read %s dir\n", MOUNT_CONFIGS_DIR);
RETURN(rc);
}
-
+
/* Could use fsdb index maps instead of directory listing */
list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
list_del(&dirent->lld_list);
}
OBD_FREE(dirent, sizeof(*dirent));
}
-
+
RETURN(rc);
}
struct temp_comp
};
static int mgs_steal_llog_handler(struct llog_handle *llh,
- struct llog_rec_hdr *rec,
+ struct llog_rec_hdr *rec,
void *data)
{
struct obd_device * obd;
char *uuid;
char *index;
char *gen;
- char *dash;
-
+ char *dash;
+
LASSERT(got_an_osc_or_mdc == 1);
name_create(lustre_cfg_string(lcfg, 0),"",&name);
uuid = lustre_cfg_string(lcfg, 1);
*(++dash)='m';
*(++dash)='d';
*(++dash)='t';
-
+
rc = record_start_log(obd, &mdt_llh, mti->mti_svname);
rc = record_lov_add(obd,mdt_llh,name,uuid,index,gen);
rc = record_end_log(obd, &mdt_llh);
char *uuid;
char *index;
char *gen;
- char *dash;
-
+ char *dash;
+
LASSERT(got_an_osc_or_mdc == 2);
name_create(lustre_cfg_string(lcfg, 0),"",&name);
uuid = lustre_cfg_string(lcfg, 1);
*(++dash)='c';
*(++dash)='m';
*(++dash)='m';
-
+
rc = record_start_log(obd, &mdt_llh, mti->mti_svname);
rc = record_cmm_add(obd,mdt_llh,name,uuid,index,gen);
rc = record_end_log(obd, &mdt_llh);
ENTRY;
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
-
+
rc = llog_create(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT),
&loghandle, NULL, client_name);
if (rc)
#if 0
/* lmv is the second thing for client logs */
/* copied from mgs_write_log_lov. Please refer to that. */
-static int mgs_write_log_lmv(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_lmv(struct obd_device *obd, struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *lmvname)
{
uuid = (char *)lmvdesc->ld_uuid.uuid;
rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, lmvname, "lmv setup");
+ rc = record_marker(obd, llh, fsdb, CM_START, lmvname, "lmv setup");
rc = record_attach(obd, llh, lmvname, "lmv", uuid);
rc = record_lmv_setup(obd, llh, lmvname, lmvdesc);
- rc = record_marker(obd, llh, fsdb, CM_END, lmvname, "lmv setup");
+ rc = record_marker(obd, llh, fsdb, CM_END, lmvname, "lmv setup");
rc = record_end_log(obd, &llh);
-
+
OBD_FREE(lmvdesc, sizeof(*lmvdesc));
RETURN(rc);
}
#endif
/* lov is the first thing in the mdt and client logs */
-static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
+static int mgs_write_log_lov(struct obd_device *obd, struct fs_db *fsdb,
struct mgs_target_info *mti,
char *logname, char *lovname)
{
RETURN(-ENOMEM);
lovdesc->ld_magic = LOV_DESC_MAGIC;
lovdesc->ld_tgt_count = 0;
- /* Defaults. Can be changed later by lcfg config_param */
+ /* Defaults. Can be changed later by lcfg config_param */
lovdesc->ld_default_stripe_count = 1;
lovdesc->ld_pattern = LOV_PATTERN_RAID0;
lovdesc->ld_default_stripe_size = 1024 * 1024;
/* This should always be the first entry in a log.
rc = mgs_clear_log(obd, logname); */
rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, lovname, "lov setup");
+ rc = record_marker(obd, llh, fsdb, CM_START, lovname, "lov setup");
rc = record_attach(obd, llh, lovname, "lov", uuid);
rc = record_lov_setup(obd, llh, lovname, lovdesc);
- rc = record_marker(obd, llh, fsdb, CM_END, lovname, "lov setup");
+ rc = record_marker(obd, llh, fsdb, CM_END, lovname, "lov setup");
rc = record_end_log(obd, &llh);
-
+
OBD_FREE(lovdesc, sizeof(*lovdesc));
RETURN(rc);
}
while (class_find_param(ptr, PARAM_FAILNODE, &ptr) == 0) {
while (class_parse_nid(ptr, &nid, &ptr) == 0) {
if (failnodeuuid == NULL) {
- /* We don't know the failover node name,
+ /* We don't know the failover node name,
so just use the first nid as the uuid */
rc = name_create(libcfs_nid2str(nid), "",
&failnodeuuid);
- if (rc)
+ if (rc)
return rc;
}
CDEBUG(D_MGS, "add nid %s for failover uuid %s, "
//This should not happen!
RETURN (-EINVAL);
}
-
+
CDEBUG(D_MGS, "adding mdc for %s to log %s:lmv(%s)\n",
mti->mti_svname, logname, lmvname);
name_create(lmvname, "_UUID", &lmvuuid);
rc = record_start_log(obd, &llh, logname);
- rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,
+ rc = record_marker(obd, llh, fsdb, CM_START, mti->mti_svname,
"add mdc to lmv");
for (i = 0; i < mti->mti_nid_count; i++) {
CDEBUG(D_MGS, "add nid %s for mdt\n", libcfs_nid2str(mti->mti_nids[i]));
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
rc = record_lmv_add(obd, llh, lmvname, mti->mti_uuid, index, "1");
rc = record_marker(obd, llh, fsdb, CM_END, mti->mti_svname,
- "add mdc to lmv");
+ "add mdc to lmv");
rc = record_end_log(obd, &llh);
-
+
name_destroy(lmvuuid);
name_destroy(mdcuuid);
name_destroy(mdcname);
//This should not happen!
RETURN (-EINVAL);
}
-
+
CDEBUG(D_MGS, "adding mdc for %s to %s\n", mti->mti_svname, tgtname);
name_create(libcfs_nid2str(mti->mti_nids[0]), "", &nodeuuid);
snprintf(index, sizeof(index), "%d", mti->mti_stripe_index);
rc = record_base(obd, llh, tgtname, 0, LCFG_ADD_MDC, mdcuuid,
index, "1", 0);
- rc = record_marker(obd, llh, fsdb, CM_END, tgtname, "add mdc to cmm");
+ rc = record_marker(obd, llh, fsdb, CM_END, tgtname, "add mdc to cmm");
rc = record_end_log(obd, &llh);
-
+
name_destroy(mdcuuid);
name_destroy(mdcname);
name_destroy(nodeuuid);
OBD_ALLOC(uuid, sizeof(struct obd_uuid));
if (uuid == NULL)
RETURN(-ENOMEM);
-
+
sprintf((char *)uuid, "%s_UUID", dev);
/* add MDT itself */
rc = record_start_log(obd, &llh, log);
- rc = record_marker(obd, llh, fsdb, CM_START, dev, "add mdt");
+ rc = record_marker(obd, llh, fsdb, CM_START, dev, "add mdt");
rc = record_attach(obd, llh, dev, LUSTRE_MDT0_NAME, uuid);
rc = record_setup(obd, llh, dev, uuid, 0, 0, 0);
- rc = record_marker(obd, llh, fsdb, CM_END, dev, "add mdt");
+ rc = record_marker(obd, llh, fsdb, CM_END, dev, "add mdt");
rc = record_end_log(obd, &llh);
-
+
OBD_FREE(uuid, sizeof(*uuid));
RETURN(rc);
}
CDEBUG(D_MGS, "writing new mds %s\n", mti->mti_svname);
/* Make up our own uuid */
- snprintf(mti->mti_uuid, sizeof(mti->mti_uuid), "%s_UUID", mti->mti_svname);
+ snprintf(mti->mti_uuid, sizeof(mti->mti_uuid), "%s_UUID", mti->mti_svname);
name_create(mti->mti_fsname, "-mdtmdt", &mdtname);
name_create(mti->mti_fsname, "-mdtlov", &lovname);
depth = scan->lo_depth;
if (depth <= o->lo_depth && scan != o)
break;
- LASSERT(lu_object_ops(scan)->ldo_object_print != NULL);
+ LASSERT(scan->lo_ops->loo_object_print != NULL);
nob += seq_printf(f, "%*.*s", depth, depth, ruler);
- nob += lu_object_ops(scan)->ldo_object_print(ctx, f, scan);
+ nob += scan->lo_ops->loo_object_print(ctx, f, scan);
nob += seq_printf(f, "\n");
}
return nob;
static void osd_type_fini (struct lu_device_type *t);
static int osd_object_init (struct lu_context *ctxt, struct lu_object *l);
static void osd_object_release(struct lu_context *ctxt, struct lu_object *l);
+static int osd_object_exists (struct lu_context *ctx, struct lu_object *o);
static int osd_object_print (struct lu_context *ctx,
struct seq_file *f, const struct lu_object *o);
static void osd_device_free (struct lu_device *m);
static struct lu_device_type_operations osd_device_type_ops;
static struct lu_device_type osd_device_type;
+static struct lu_object_operations osd_lu_obj_ops;
static struct obd_ops osd_obd_device_ops;
static struct lprocfs_vars lprocfs_osd_module_vars[];
static struct lprocfs_vars lprocfs_osd_obd_vars[];
static struct lu_device_operations osd_lu_ops;
static struct lu_context_key osd_key;
static struct dt_object_operations osd_obj_ops;
+static struct dt_body_operations osd_body_ops;
+static struct dt_index_operations osd_index_ops;
/*
* DT methods.
l = &mo->oo_dt.do_lu;
lu_object_init(l, NULL, d);
mo->oo_dt.do_ops = &osd_obj_ops;
+ l->lo_ops = &osd_lu_obj_ops;
return l;
} else
return NULL;
static int osd_object_init(struct lu_context *ctxt, struct lu_object *l)
{
- return osd_fid_lookup(ctxt, osd_obj(l), lu_object_fid(l));
+ struct osd_object *obj = osd_obj(l);
+ int result;
+
+ result = osd_fid_lookup(ctxt, obj, lu_object_fid(l));
+ if (result == 0) {
+ if (obj->oo_inode != NULL) {
+ if (S_ISDIR(obj->oo_inode->i_mode))
+ obj->oo_dt.do_index_ops = &osd_index_ops;
+ else
+ obj->oo_dt.do_body_ops = &osd_body_ops;
+ }
+ }
+ return result;
}
static void osd_object_free(struct lu_context *ctx, struct lu_object *l)
set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
}
+static int osd_object_exists(struct lu_context *ctx, struct lu_object *o)
+{
+ return osd_obj(o)->oo_inode != NULL;
+}
+
static int osd_object_print(struct lu_context *ctx,
struct seq_file *f, const struct lu_object *l)
{
.do_attr_get = osd_attr_get
};
+static struct dt_body_operations osd_body_ops = {
+};
+
+static struct dt_index_operations osd_index_ops = {
+};
+
static struct dt_device_operations osd_dt_ops = {
.dt_root_get = osd_root_get,
.dt_config = osd_config,
return dev->od_mount->lmi_mnt->mnt_sb;
}
+static struct lu_object_operations osd_lu_obj_ops = {
+ .loo_object_print = osd_object_print,
+ .loo_object_exists = osd_object_exists
+};
+
static struct lu_device_operations osd_lu_ops = {
.ldo_object_alloc = osd_object_alloc,
.ldo_object_init = osd_object_init,
.ldo_object_free = osd_object_free,
.ldo_object_release = osd_object_release,
.ldo_object_delete = osd_object_delete,
- .ldo_object_print = osd_object_print,
.ldo_process_config = osd_process_config
};
/* struct rw_semaphore */
#include <linux/rwsem.h>
-#include <linux/lu_object.h>
+#include <linux/dt_object.h>
#include "osd_oi.h"