@LDISKFS_TRUE@subdir-m += ldiskfs
+subdir-m += fid
subdir-m += lvfs
subdir-m += obdclass
subdir-m += lov
AUTOMAKE_OPTIONS = foreign
-ALWAYS_SUBDIRS := include lvfs obdclass ldlm ptlrpc osc lov obdecho \
+ALWAYS_SUBDIRS := include fid lvfs obdclass ldlm ptlrpc osc lov obdecho \
mgc doc utils tests conf scripts autoconf
SERVER_SUBDIRS := ldiskfs obdfilter ost mds mgs mdt cmm mdd osd
lustre/ldiskfs/Makefile
lustre/ldiskfs/autoMakefile
lustre/ldlm/Makefile
+lustre/fid/Makefile
+lustre/fid/autoMakefile
lustre/liblustre/Makefile
lustre/liblustre/tests/Makefile
lustre/llite/Makefile
--- /dev/null
+MODULES := fid
+fid-objs := fid_seq.o
+
+@INCLUDE_RULES@
--- /dev/null
+# Copyright (C) 2001 Cluster File Systems, Inc.
+#
+# This code is issued under the GNU General Public License.
+# See the file COPYING in this distribution
+
+if MODULES
+modulefs_DATA = fid$(KMODEXT)
+endif
+
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
+DIST_SOURCES = $(fid-objs:%.o=%.c)
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * lustre/fid/fid_seq.c
+ * Lustre File Id (fid)
+ *
+ * Copyright (c) 2006 Cluster File Systems, Inc.
+ * Author: Yury Umanets <umka@clusterfs.com>
+ *
+ * This file is part of the Lustre file system, http://www.lustre.org
+ * Lustre is a trademark of Cluster File Systems, Inc.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+
+#include <linux/obd.h>
+#include <linux/lustre_idl.h>
+#include <linux/lustre_fid.h>
+
+/* sequence manager initialization/finalization stuff */
+struct lu_seq_mgr *seq_mgr_init(struct lu_seq_mgr_ops *ops,
+ void *opaque)
+{
+ struct lu_seq_mgr *mgr;
+ ENTRY;
+
+ OBD_ALLOC_PTR(mgr);
+ if (!mgr)
+ RETURN(NULL);
+
+ sema_init(&mgr->m_seq_sem, 1);
+ mgr->m_opaque = opaque;
+ mgr->m_ops = ops;
+
+ RETURN(mgr);
+}
+EXPORT_SYMBOL(seq_mgr_init);
+
+void seq_mgr_fini(struct lu_seq_mgr *mgr)
+{
+ OBD_FREE_PTR(mgr);
+}
+EXPORT_SYMBOL(seq_mgr_fini);
+
+int seq_mgr_write(struct lu_seq_mgr *mgr)
+{
+ int rc = -ENOTSUPP;
+ ENTRY;
+
+ if (mgr->m_ops->smo_write)
+ rc = mgr->m_ops->smo_write(mgr->m_opaque, &mgr->m_seq);
+
+ RETURN(rc);
+}
+EXPORT_SYMBOL(seq_mgr_write);
+
+int seq_mgr_read(struct lu_seq_mgr *mgr)
+{
+ int rc = -ENOTSUPP;
+ ENTRY;
+
+ if (mgr->m_ops->smo_read)
+ rc = mgr->m_ops->smo_read(mgr->m_opaque, &mgr->m_seq);
+
+ RETURN(rc);
+}
+EXPORT_SYMBOL(seq_mgr_read);
+
+/* manager functinality stuff */
+int seq_mgr_alloc(struct lu_seq_mgr *mgr, __u64 *seq)
+{
+ int rc = 0;
+ ENTRY;
+
+ LASSERT(mgr != NULL);
+ LASSERT(seq != NULL);
+
+ down(&mgr->m_seq_sem);
+ mgr->m_seq += 1;
+ *seq = mgr->m_seq;
+
+ rc = seq_mgr_write(mgr);
+ if (rc == -ENOTSUPP) {
+ CERROR("Seq manager ->write() method "
+ "is no defined.\n");
+ rc = 0;
+ }
+
+ up(&mgr->m_seq_sem);
+ RETURN(rc);
+}
+EXPORT_SYMBOL(seq_mgr_alloc);
+
+/* initialize meta-sequence. First of all try to get it from lower layer,
+ * falling down to back store one. In the case this is first run and there is
+ * not meta-sequence initialized yet - store it to backstore. */
+int seq_mgr_setup(struct lu_seq_mgr *mgr)
+{
+ int rc = 0;
+ ENTRY;
+
+ /* allocate next seq after root one */
+ mgr->m_seq = LUSTRE_ROOT_FID_SEQ + 1;
+
+ rc = seq_mgr_read(mgr);
+ if (rc == -EOPNOTSUPP) {
+ /* provide zero error and let continue with default value of
+ * sequence. */
+ GOTO(out, rc = 0);
+ } else if (rc == -ENODATA) {
+ CWARN("initialize sequence by defaut ["LPU64"]\n", mgr->m_seq);
+
+ /* initialize new sequence config as it is not yet created. */
+ rc = seq_mgr_write(mgr);
+ if (rc == -EOPNOTSUPP) {
+ /* provide zero error and let continue with default
+ * value of sequence. */
+ CERROR("can't update save initial sequence. "
+ "No method defined\n");
+ GOTO(out, rc = 0);
+ }
+ }
+
+ EXIT;
+out:
+ if (rc == 0)
+ CWARN("using start sequence: ["LPU64"]\n", mgr->m_seq);
+ return rc;
+}
+EXPORT_SYMBOL(seq_mgr_setup);
+
+static int __init fid_mod_init(void)
+{
+ /* some stuff will be here (cache initializing, etc.) */
+ return 0;
+}
+
+static void __exit fid_mod_exit(void)
+{
+ /* some stuff will be here */
+}
+
+MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_DESCRIPTION("Lustre FID Module");
+MODULE_LICENSE("GPL");
+
+cfs_module(fid, "0.0.1", fid_mod_init, fid_mod_exit);
--- /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_FID_H
+#define __LINUX_FID_H
+
+/*
+ * struct lu_fid
+ */
+#include <linux/lustre_idl.h>
+
+#include <libcfs/list.h>
+#include <libcfs/kp30.h>
+
+struct lu_seq_mgr_ops {
+ int (*smo_read) (void *opaque, __u64 *);
+ int (*smo_write) (void *opaque, __u64 *);
+};
+
+struct lu_seq_mgr {
+ /* seq management fields */
+ struct semaphore m_seq_sem;
+ __u64 m_seq;
+
+ /* ops related stuff */
+ void *m_opaque;
+ struct lu_seq_mgr_ops *m_ops;
+};
+
+/* init/fini methods */
+struct lu_seq_mgr *seq_mgr_init(struct lu_seq_mgr_ops *, void *);
+void seq_mgr_fini(struct lu_seq_mgr *);
+
+/* seq management methods */
+int seq_mgr_setup(struct lu_seq_mgr *);
+int seq_mgr_read(struct lu_seq_mgr *);
+int seq_mgr_write(struct lu_seq_mgr *);
+int seq_mgr_alloc(struct lu_seq_mgr *, __u64 *);
+
+#endif /* __LINUX_OBD_CLASS_H */
}
/* build inode number on passed @fid */
-ino_t ll_fid2ino(struct ll_sb_info *sbi, struct lu_fid *fid)
+ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid)
{
ino_t ino;
ENTRY;
/* llite/llite_fid.c*/
int ll_fid_alloc(struct ll_sb_info *sbi, struct lu_fid *fid);
-ino_t ll_fid2ino(struct ll_sb_info *sbi, struct lu_fid *fid);
+ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid);
#endif /* LLITE_INTERNAL_H */
}
LASSERT(fid_oid(&sbi->ll_root_fid) != 0);
- root = ll_iget(sb, ll_fid2ino(sbi, &sbi->ll_root_fid), &md);
+ root = ll_iget(sb, ll_fid_build_ino(sbi, &sbi->ll_root_fid), &md);
ptlrpc_req_finished(request);
if (root == NULL || is_bad_inode(root)) {
/* at this point server answers to client's RPC with same fid as
* client generated for creating some inode. So using
* md.body.fid1 is okay here. */
- *inode = ll_iget(sb, ll_fid2ino(sbi, &md.body->fid1), &md);
+ *inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md);
if (*inode == NULL || is_bad_inode(*inode)) {
mdc_free_lustre_md(exp, &md);
rc = -ENOMEM;
unsigned long valid = 0;
int eadatalen = 0, rc;
- inode = ILOOKUP(sb, ll_fid2ino(sbi, fid),
+ inode = ILOOKUP(sb, ll_fid_build_ino(sbi, fid),
ll_nfs_test_inode, fid);
if (inode)
return inode;
RETURN(rc);
}
-/* allocate sequence to client */
-int mdt_seq_alloc(struct mdt_device *m, __u64 *seq)
+static int mdt_seq_mgr_hpr(void *opaque, __u64 *seq,
+ int mode)
{
- int rc = 0;
+ struct mdt_device *m = opaque;
+ int rc;
ENTRY;
-
- LASSERT(m != NULL);
- LASSERT(seq != NULL);
-
- down(&m->mdt_seq_sem);
- m->mdt_seq += 1;
- *seq = m->mdt_seq;
-
- /* update new allocated sequence on store */
+
rc = mdt_config(m, LUSTRE_CONFIG_METASEQ,
- &m->mdt_seq, sizeof(m->mdt_seq),
- LUSTRE_CONFIG_SET);
- if (rc) {
- CERROR("can't save new seq, rc %d\n",
- rc);
- }
-
- up(&m->mdt_seq_sem);
-
- RETURN(0);
+ seq, sizeof(*seq),
+ mode);
+ RETURN(rc);
}
-EXPORT_SYMBOL(mdt_seq_alloc);
-/* initialize meta-sequence. First of all try to get it from lower layer down to
- * back store one. In the case this is first run and there is not meta-sequence
- * initialized yet - store it to backstore. */
-static int mdt_seq_init(struct mdt_device *m)
+static int mdt_seq_mgr_read(void *opaque, __u64 *seq)
{
- int rc = 0;
ENTRY;
+ RETURN(mdt_seq_mgr_hpr(opaque, seq, LUSTRE_CONFIG_GET));
+}
- /* allocate next seq after root one */
- m->mdt_seq = LUSTRE_ROOT_FID_SEQ + 1;
-
- rc = mdt_config(m, LUSTRE_CONFIG_METASEQ,
- &m->mdt_seq, sizeof(m->mdt_seq),
- LUSTRE_CONFIG_GET);
-
- if (rc == -EOPNOTSUPP) {
- /* provide zero error and let continue with default value of
- * sequence. */
- GOTO(out, rc = 0);
- } else if (rc == -ENODATA) {
- CWARN("initialize new sequence\n");
-
- /*initialize new sequence config as it is not yet created. */
- rc = mdt_config(m, LUSTRE_CONFIG_METASEQ,
- &m->mdt_seq, sizeof(m->mdt_seq),
- LUSTRE_CONFIG_SET);
- if (rc == -EOPNOTSUPP) {
- /* provide zero error and let continue with default
- * value of sequence. */
- CERROR("can't update save initial sequence. "
- "No method defined\n");
- GOTO(out, rc = 0);
- } else if (rc) {
- CERROR("can't update config %s, rc %d\n",
- LUSTRE_CONFIG_METASEQ, rc);
- GOTO(out, rc);
- }
- } else if (rc) {
- CERROR("can't get config %s, rc %d\n",
- LUSTRE_CONFIG_METASEQ, rc);
- GOTO(out, rc);
- }
-
- EXIT;
-out:
- if (rc == 0)
- CWARN("last used sequence: "LPU64"\n", m->mdt_seq);
- return rc;
+static int mdt_seq_mgr_write(void *opaque, __u64 *seq)
+{
+ ENTRY;
+ RETURN(mdt_seq_mgr_hpr(opaque, seq, LUSTRE_CONFIG_SET));
}
+struct lu_seq_mgr_ops seq_mgr_ops = {
+ .smo_read = mdt_seq_mgr_read,
+ .smo_write = mdt_seq_mgr_write
+};
+
static void mdt_fini(struct mdt_device *m)
{
struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
child->ld_type->ldt_ops->ldto_device_fini(child);
}
+ if (m->mdt_seq_mgr) {
+ seq_mgr_fini(m->mdt_seq_mgr);
+ m->mdt_seq_mgr = NULL;
+ }
+
LASSERT(atomic_read(&d->ld_ref) == 0);
md_device_fini(&m->mdt_md_dev);
}
m->mdt_md_dev.md_lu_dev.ld_ops = &mdt_lu_ops;
lu_site_init(s, &m->mdt_md_dev.md_lu_dev);
- sema_init(&m->mdt_seq_sem, 1);
-
m->mdt_service_conf.psc_nbufs = MDS_NBUFS;
m->mdt_service_conf.psc_bufsize = MDS_BUFSIZE;
m->mdt_service_conf.psc_max_req_size = MDS_MAXREQSIZE;
GOTO(err_free_svc, rc);
}
+ m->mdt_seq_mgr = seq_mgr_init(&seq_mgr_ops, m);
+ if (!m->mdt_seq_mgr) {
+ CERROR("can't initialize sequence manager\n");
+ GOTO(err_fini_child, rc);
+ }
+
/* init sequence info after device stack is initialized. */
- rc = mdt_seq_init(m);
+ rc = seq_mgr_setup(m->mdt_seq_mgr);
if (rc)
- GOTO(err_fini_child, rc);
+ GOTO(err_fini_mgr, rc);
rc = ptlrpc_start_threads(NULL, m->mdt_service, LUSTRE_MDT0_NAME);
if (rc)
- GOTO(err_fini_child, rc);
+ GOTO(err_fini_mgr, rc);
RETURN(0);
+err_fini_mgr:
+ seq_mgr_fini(m->mdt_seq_mgr);
+ m->mdt_seq_mgr = NULL;
err_fini_child:
mdt_child->ld_type->ldt_ops->ldto_device_fini(mdt_child);
err_free_svc:
{
struct obd_export *exp;
int rc, abort_recovery;
+ struct mdt_device *mdt;
struct mds_export_data *med;
struct mds_client_data *mcd = NULL;
if (!conn || !obd || !cluuid)
RETURN(-EINVAL);
+ mdt = mdt_dev(obd->obd_lu_dev);
+
/* Check for aborted recovery. */
spin_lock_bh(&obd->obd_processing_task_lock);
abort_recovery = obd->obd_abort_recovery;
memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid));
med->med_mcd = mcd;
- rc = mdt_seq_alloc(mdt_dev(obd->obd_lu_dev),
- &data->ocd_seq);
+ rc = seq_mgr_alloc(mdt->mdt_seq_mgr, &data->ocd_seq);
if (rc)
GOTO(out, rc);
out:
* struct lustre_handle
*/
#include <linux/lustre_idl.h>
-
#include <linux/md_object.h>
+#include <linux/lustre_fid.h>
struct ptlrpc_service_conf {
int psc_nbufs;
unsigned long mdt_flags;
/* Seq management related stuff */
- struct semaphore mdt_seq_sem;
- __u64 mdt_seq;
+ struct lu_seq_mgr *mdt_seq_mgr;
};
static inline struct md_device_operations *mdt_child_ops(struct mdt_device * m)
};
-int mdt_seq_alloc(struct mdt_device *, __u64 *);
-
int fid_lock(struct ldlm_namespace *, const struct lu_fid *,
struct lustre_handle *, ldlm_mode_t,
ldlm_policy_data_t *);