Whamcloud - gitweb
- added fid.ko module. Simple seq management moved to it from mdt. Mdt uses it as...
authoryury <yury>
Wed, 12 Apr 2006 14:40:42 +0000 (14:40 +0000)
committeryury <yury>
Wed, 12 Apr 2006 14:40:42 +0000 (14:40 +0000)
- renamed ll_fid2ino() to ll_fid_build_ino()

13 files changed:
lustre/Makefile.in
lustre/autoMakefile.am
lustre/autoconf/lustre-core.m4
lustre/fid/Makefile.in [new file with mode: 0644]
lustre/fid/autoMakefile.am [new file with mode: 0644]
lustre/fid/fid_seq.c [new file with mode: 0644]
lustre/include/linux/lustre_fid.h [new file with mode: 0644]
lustre/llite/llite_fid.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h

index 82b5d71..486ffd8 100644 (file)
@@ -1,5 +1,6 @@
 @LDISKFS_TRUE@subdir-m += ldiskfs
 
+subdir-m += fid
 subdir-m += lvfs
 subdir-m += obdclass
 subdir-m += lov
index ab001bb..af8ba3c 100644 (file)
@@ -5,7 +5,7 @@
 
 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
index 1b30314..4e98936 100644 (file)
@@ -629,6 +629,8 @@ lustre/kernel_patches/targets/sles-2.4.target
 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
diff --git a/lustre/fid/Makefile.in b/lustre/fid/Makefile.in
new file mode 100644 (file)
index 0000000..b41f627
--- /dev/null
@@ -0,0 +1,4 @@
+MODULES := fid
+fid-objs := fid_seq.o
+
+@INCLUDE_RULES@
diff --git a/lustre/fid/autoMakefile.am b/lustre/fid/autoMakefile.am
new file mode 100644 (file)
index 0000000..f736429
--- /dev/null
@@ -0,0 +1,11 @@
+# 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)
diff --git a/lustre/fid/fid_seq.c b/lustre/fid/fid_seq.c
new file mode 100644 (file)
index 0000000..a54c468
--- /dev/null
@@ -0,0 +1,162 @@
+/* -*- 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);
diff --git a/lustre/include/linux/lustre_fid.h b/lustre/include/linux/lustre_fid.h
new file mode 100644 (file)
index 0000000..8612234
--- /dev/null
@@ -0,0 +1,59 @@
+/* -*- 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 */
index 43cebb9..158c70b 100644 (file)
@@ -55,7 +55,7 @@ int ll_fid_alloc(struct ll_sb_info *sbi, struct lu_fid *fid)
 }
 
 /* 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;
index d0d24be..847d30b 100644 (file)
@@ -575,6 +575,6 @@ int ll_removexattr(struct dentry *dentry, const char *name);
 
 /* 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 */
index 7041833..353a142 100644 (file)
@@ -307,7 +307,7 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc)
         }
 
         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)) {
@@ -1541,7 +1541,7 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode,
                 /* 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;
index 0d8244f..ac6b5f0 100644 (file)
@@ -67,7 +67,7 @@ static struct inode *search_inode_for_lustre(struct super_block *sb,
         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;
index 477af0f..deec8af 100644 (file)
@@ -947,84 +947,36 @@ static int mdt_config(struct mdt_device *m, const char *name,
         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;
@@ -1048,6 +1000,11 @@ static void mdt_fini(struct mdt_device *m)
                 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);
 }
@@ -1084,8 +1041,6 @@ static int mdt_init0(struct mdt_device *m,
         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;
@@ -1126,17 +1081,26 @@ static int mdt_init0(struct mdt_device *m,
                 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:
@@ -1217,6 +1181,7 @@ static int mdt_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
 {
         struct obd_export *exp;
         int rc, abort_recovery;
+        struct mdt_device *mdt;
         struct mds_export_data *med;
         struct mds_client_data *mcd = NULL;
 
@@ -1225,6 +1190,8 @@ static int mdt_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
         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;
@@ -1256,8 +1223,7 @@ static int mdt_obd_connect(struct lustre_handle *conn, struct obd_device *obd,
         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:
index 421aca8..4f0c71f 100644 (file)
@@ -45,8 +45,8 @@
  * 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;
@@ -77,8 +77,7 @@ struct mdt_device {
         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)
@@ -168,8 +167,6 @@ struct mdt_thread_info {
 
 };
 
-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 *);