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@
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
};
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,
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);
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);
}
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);
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");
GOTO(out, rc);
}
+ rc = seq_store_init(seq, ctx);
+ if (rc)
+ GOTO(out, rc);
+
#ifdef LPROCFS
rc = seq_server_proc_init(seq);
if (rc)
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;
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
--- /dev/null
+/* -*- 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
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;
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;
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;
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);
if (fld_key_registered == 0) {
rc = lu_context_key_register(&fld_thread_key);
if (rc != 0)
- return rc;
+ RETURN(rc);
}
fld_key_registered++;
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);
}
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);
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[];
* 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;