Whamcloud - gitweb
- added fid_store.c which contains methods working with backing store what is needed...
authoryury <yury>
Tue, 27 Jun 2006 10:39:01 +0000 (10:39 +0000)
committeryury <yury>
Tue, 27 Jun 2006 10:39:01 +0000 (10:39 +0000)
lustre/fid/Makefile.in
lustre/fid/autoMakefile.am
lustre/fid/fid_handler.c
lustre/fid/fid_internal.h
lustre/fid/fid_store.c [new file with mode: 0644]
lustre/fld/fld_handler.c
lustre/fld/fld_index.c
lustre/fld/fld_internal.h
lustre/include/lustre_fid.h

index d81e598..e4908e5 100644 (file)
@@ -1,4 +1,4 @@
 MODULES := fid
-fid-objs := fid_handler.o fid_request.o lproc_fid.o fid_lib.o
+fid-objs := fid_handler.o fid_store.o fid_request.o lproc_fid.o fid_lib.o
 
 @INCLUDE_RULES@
index b2819c8..c007f43 100644 (file)
@@ -5,7 +5,7 @@
 
 if LIBLUSTRE
 noinst_LIBRARIES = libfid.a
-libfid_a_SOURCES = fid_handler.c fid_request.c lproc_fid.c fid_lib.c fid_internal.h
+libfid_a_SOURCES = fid_handler.c fid_store.c fid_request.c lproc_fid.c fid_lib.c fid_internal.h
 libfid_a_CPPFLAGS = $(LLCPPFLAGS)
 libfid_a_CFLAGS = $(LLCFLAGS)
 endif
index 7c1e89d..3bf67e5 100644 (file)
@@ -63,32 +63,6 @@ const struct lu_range LUSTRE_SEQ_ZERO_RANGE = {
 };
 EXPORT_SYMBOL(LUSTRE_SEQ_ZERO_RANGE);
 
-static int
-seq_server_write_state(struct lu_server_seq *seq,
-                       const struct lu_context *ctx)
-{
-       int rc = 0;
-       ENTRY;
-
-       /* XXX: here should be calling struct dt_device methods to write
-        * sequence state to backing store. */
-
-       RETURN(rc);
-}
-
-static int
-seq_server_read_state(struct lu_server_seq *seq,
-                      const struct lu_context *ctx)
-{
-       int rc = -ENODATA;
-       ENTRY;
-       
-       /* XXX: here should be calling struct dt_device methods to read the
-        * sequence state from backing store. */
-
-       RETURN(rc);
-}
-
 /* assigns client to sequence controller node */
 int
 seq_server_set_ctlr(struct lu_server_seq *seq,
@@ -136,7 +110,7 @@ seq_server_set_ctlr(struct lu_server_seq *seq,
                 seq->seq_super = cli->seq_range;
 
                 /* save init seq to backing store. */
-                rc = seq_server_write_state(seq, ctx);
+                rc = seq_store_write(seq, ctx);
                 if (rc) {
                         CERROR("can't write sequence state, "
                                "rc = %d\n", rc);
@@ -175,7 +149,7 @@ __seq_server_alloc_super(struct lu_server_seq *seq,
                 rc = 0;
         }
 
-        rc = seq_server_write_state(seq, ctx);
+        rc = seq_store_write(seq, ctx);
         if (rc) {
                 CERROR("can't save state, rc = %d\n",
                       rc);
@@ -249,7 +223,7 @@ __seq_server_alloc_meta(struct lu_server_seq *seq,
         }
         range_alloc(range, super, seq->seq_meta_width);
 
-        rc = seq_server_write_state(seq, ctx);
+        rc = seq_store_write(seq, ctx);
         if (rc) {
                 CERROR("can't save state, rc = %d\n",
                       rc);
@@ -478,7 +452,7 @@ seq_server_init(struct lu_server_seq *seq,
         lu_device_get(&seq->seq_dev->dd_lu_dev);
 
         /* request backing store for saved sequence info */
-        rc = seq_server_read_state(seq, ctx);
+        rc = seq_store_read(seq, ctx);
         if (rc == -ENODATA) {
                 CDEBUG(D_INFO|D_WARNING, "SEQ-MGR(srv): no data on "
                        "disk found, waiting for controller assign\n");
@@ -488,6 +462,10 @@ seq_server_init(struct lu_server_seq *seq,
                GOTO(out, rc);
        }
         
+        rc = seq_store_init(seq, ctx);
+        if (rc)
+                GOTO(out, rc);
+        
 #ifdef LPROCFS
         rc  = seq_server_proc_init(seq);
         if (rc)
@@ -532,6 +510,8 @@ seq_server_fini(struct lu_server_seq *seq,
         seq_server_proc_fini(seq);
 #endif
 
+        seq_store_fini(seq, ctx);
+
         if (seq->seq_dev != NULL) {
                 lu_device_put(&seq->seq_dev->dd_lu_dev);
                 seq->seq_dev = NULL;
index 91e85f1..dae22a8 100644 (file)
@@ -33,4 +33,18 @@ extern struct lprocfs_vars seq_server_proc_list[];
 extern struct lprocfs_vars seq_client_proc_list[];
 #endif
 
+#ifdef __KERNEL__
+int seq_store_init(struct lu_server_seq *seq,
+                   const struct lu_context *ctx);
+
+void seq_store_fini(struct lu_server_seq *seq,
+                    const struct lu_context *ctx);
+
+int seq_store_write(struct lu_server_seq *seq,
+                    const struct lu_context *ctx);
+
+int seq_store_read(struct lu_server_seq *seq,
+                   const struct lu_context *ctx);
+#endif
+
 #endif
diff --git a/lustre/fid/fid_store.c b/lustre/fid/fid_store.c
new file mode 100644 (file)
index 0000000..ad40838
--- /dev/null
@@ -0,0 +1,106 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  lustre/fid/fid_store.c
+ *  Lustre Sequence Manager
+ *
+ *  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.
+ */
+
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+#define DEBUG_SUBSYSTEM S_FID
+
+#ifdef __KERNEL__
+# include <libcfs/libcfs.h>
+# include <linux/module.h>
+#else /* __KERNEL__ */
+# include <liblustre.h>
+#endif
+
+#include <obd.h>
+#include <obd_class.h>
+#include <dt_object.h>
+#include <md_object.h>
+#include <obd_support.h>
+#include <lustre_req_layout.h>
+#include <lustre_fid.h>
+#include "fid_internal.h"
+
+#ifdef __KERNEL__
+int
+seq_store_write(struct lu_server_seq *seq,
+               const struct lu_context *ctx)
+{
+       int rc = 0;
+       ENTRY;
+
+       RETURN(rc);
+}
+
+int
+seq_store_read(struct lu_server_seq *seq,
+              const struct lu_context *ctx)
+{
+       int rc = -ENODATA;
+       ENTRY;
+       
+       RETURN(rc);
+}
+
+int
+seq_store_init(struct lu_server_seq *seq,
+              const struct lu_context *ctx)
+{
+        struct dt_device *dt = seq->seq_dev;
+        struct dt_object *dt_obj;
+        int rc;
+        ENTRY;
+
+        LASSERT(seq->seq_service == NULL);
+
+        dt_obj = dt_store_open(ctx, dt, "seq", &seq->seq_fid);
+        if (!IS_ERR(dt_obj)) {
+                seq->seq_obj = dt_obj;
+               rc = 0;
+        } else {
+                CERROR("cannot find \"seq\" obj %d\n",
+                      (int)PTR_ERR(dt_obj));
+                rc = PTR_ERR(dt_obj);
+        }
+
+        RETURN(rc);
+}
+
+void
+seq_store_fini(struct lu_server_seq *seq,
+              const struct lu_context *ctx)
+{
+        ENTRY;
+        if (seq->seq_obj != NULL) {
+                lu_object_put(ctx, &seq->seq_obj->do_lu);
+                seq->seq_obj = NULL;
+        }
+        EXIT;
+}
+#endif
index 39be7e9..2c6aa3d 100644 (file)
@@ -118,15 +118,15 @@ fld_server_handle(struct lu_server_fld *fld,
 
         switch (opc) {
         case FLD_CREATE:
-                rc = fld_index_handle_insert(fld, ctx,
-                                             mf->mf_seq, mf->mf_mds);
+                rc = fld_index_insert(fld, ctx,
+                                      mf->mf_seq, mf->mf_mds);
                 break;
         case FLD_DELETE:
-                rc = fld_index_handle_delete(fld, ctx, mf->mf_seq);
+                rc = fld_index_delete(fld, ctx, mf->mf_seq);
                 break;
         case FLD_LOOKUP:
-                rc = fld_index_handle_lookup(fld, ctx,
-                                             mf->mf_seq, &mf->mf_mds);
+                rc = fld_index_lookup(fld, ctx,
+                                      mf->mf_seq, &mf->mf_mds);
                 break;
         default:
                 rc = -EINVAL;
index 6ed09f7..28b3b64 100644 (file)
@@ -127,9 +127,9 @@ static struct dt_rec *fld_rec(const struct lu_context *ctx,
         RETURN((void *)&info->fti_rec);
 }
 
-int fld_index_handle_insert(struct lu_server_fld *fld,
-                            const struct lu_context *ctx,
-                            fidseq_t seq, mdsno_t mds)
+int fld_index_insert(struct lu_server_fld *fld,
+                     const struct lu_context *ctx,
+                     fidseq_t seq, mdsno_t mds)
 {
         struct dt_device *dt = fld->fld_dt;
         struct dt_object *dt_obj = fld->fld_obj;
@@ -154,9 +154,9 @@ int fld_index_handle_insert(struct lu_server_fld *fld,
         RETURN(rc);
 }
 
-int fld_index_handle_delete(struct lu_server_fld *fld,
-                            const struct lu_context *ctx,
-                            fidseq_t seq)
+int fld_index_delete(struct lu_server_fld *fld,
+                     const struct lu_context *ctx,
+                     fidseq_t seq)
 {
         struct dt_device *dt = fld->fld_dt;
         struct dt_object *dt_obj = fld->fld_obj;
@@ -178,9 +178,9 @@ int fld_index_handle_delete(struct lu_server_fld *fld,
         RETURN(rc);
 }
 
-int fld_index_handle_lookup(struct lu_server_fld *fld,
-                            const struct lu_context *ctx,
-                            fidseq_t seq, mdsno_t *mds)
+int fld_index_lookup(struct lu_server_fld *fld,
+                     const struct lu_context *ctx,
+                     fidseq_t seq, mdsno_t *mds)
 {
         struct dt_object *dt_obj = fld->fld_obj;
         struct dt_rec    *rec = fld_rec(ctx, 0);
@@ -208,7 +208,7 @@ int fld_index_init(struct lu_server_fld *fld,
         if (fld_key_registered == 0) {
                 rc = lu_context_key_register(&fld_thread_key);
                 if (rc != 0)
-                        return rc;
+                        RETURN(rc);
         }
         fld_key_registered++;
 
@@ -226,9 +226,10 @@ int fld_index_init(struct lu_server_fld *fld,
                 if (rc == 0)
                         LASSERT(dt_obj->do_index_ops != NULL);
                 else
-                        CERROR("fld is not an index!\n");
+                        CERROR("\"fld\" is not an index!\n");
         } else {
-                CERROR("Cannot find fld obj %lu \n", PTR_ERR(dt_obj));
+                CERROR("cannot find \"fld\" obj %d\n",
+                       (int)PTR_ERR(dt_obj));
                 rc = PTR_ERR(dt_obj);
         }
 
index 0c4d628..60882aa 100644 (file)
@@ -57,19 +57,20 @@ enum {
 extern struct lu_fld_hash fld_hash[3];
 extern struct fld_cache_info *fld_cache;
 
+#ifdef __KERNEL__
 #define FLD_SERVICE_WATCHDOG_TIMEOUT (obd_timeout * 1000)
 
-int fld_index_handle_insert(struct lu_server_fld *fld,
-                            const struct lu_context *ctx,
-                            fidseq_t seq, mdsno_t mds);
+int fld_index_insert(struct lu_server_fld *fld,
+                     const struct lu_context *ctx,
+                     fidseq_t seq, mdsno_t mds);
 
-int fld_index_handle_delete(struct lu_server_fld *fld,
-                            const struct lu_context *ctx,
-                            fidseq_t seq);
+int fld_index_delete(struct lu_server_fld *fld,
+                     const struct lu_context *ctx,
+                     fidseq_t seq);
 
-int fld_index_handle_lookup(struct lu_server_fld *fld,
-                            const struct lu_context *ctx,
-                            fidseq_t seq, mdsno_t *mds);
+int fld_index_lookup(struct lu_server_fld *fld,
+                     const struct lu_context *ctx,
+                     fidseq_t seq, mdsno_t *mds);
 
 int fld_index_init(struct lu_server_fld *fld,
                    const struct lu_context *ctx);
@@ -77,6 +78,8 @@ int fld_index_init(struct lu_server_fld *fld,
 void fld_index_fini(struct lu_server_fld *fld,
                     const struct lu_context *ctx);
 
+#endif
+
 #ifdef LPROCFS
 extern struct lprocfs_vars fld_server_proc_list[];
 extern struct lprocfs_vars fld_client_proc_list[];
index 835aa39..631ce24 100644 (file)
@@ -89,6 +89,12 @@ struct lu_server_seq {
          * store). */
         struct dt_device       *seq_dev;
 
+        /* /seq file object device */
+        struct dt_object       *seq_obj;
+
+        /* /seq file fid */
+        struct lu_fid           seq_fid;
+
         /* seq related proc */
         cfs_proc_dir_entry_t   *seq_proc_entry;
         cfs_proc_dir_entry_t   *seq_proc_dir;