mgc fid fld doc utils tests scripts autoconf contrib conf
SERVER_SUBDIRS = ost mds mgs mdt cmm mdd ofd osd-zfs osd-ldiskfs \
- quota osp lod
+ quota osp lod target
CLIENT_SUBDIRS = mdc lmv llite lclient lov osc
lustre/mgc/autoMakefile
lustre/mgs/Makefile
lustre/mgs/autoMakefile
+lustre/target/Makefile
lustre/ptlrpc/Makefile
lustre/ptlrpc/autoMakefile
lustre/ptlrpc/gss/Makefile
int lut_last_commit_cb_add(struct thandle *th, struct lu_target *lut,
struct obd_export *exp, __u64 transno);
int lut_new_client_cb_add(struct thandle *th, struct obd_export *exp);
-int lut_init(const struct lu_env *env, struct lu_target *lut,
+int tgt_init(const struct lu_env *env, struct lu_target *lut,
struct obd_device *obd, struct dt_device *dt);
-void lut_fini(const struct lu_env *env, struct lu_target *lut);
+void tgt_fini(const struct lu_env *env, struct lu_target *lut);
int lut_client_alloc(struct obd_export *exp);
void lut_client_free(struct obd_export *exp);
int lut_client_del(const struct lu_env *env, struct obd_export *exp);
mdt_procfs_fini(m);
- lut_fini(env, &m->mdt_lut);
+ tgt_fini(env, &m->mdt_lut);
mdt_fs_cleanup(env, m);
upcall_cache_cleanup(m->mdt_identity_cache);
m->mdt_identity_cache = NULL;
}
}
- rc = lut_init(env, &m->mdt_lut, obd, m->mdt_bottom);
+ rc = tgt_init(env, &m->mdt_lut, obd, m->mdt_bottom);
if (rc)
GOTO(err_fini_stack, rc);
err_fini_seq:
mdt_seq_fini(env, m);
mdt_fld_fini(env, m);
- lut_fini(env, &m->mdt_lut);
+ tgt_fini(env, &m->mdt_lut);
err_fini_stack:
mdt_stack_fini(env, m, md2lu_dev(m->mdt_child));
err_lmi:
m->ofd_grant_ratio =
ofd_grant_ratio_conv(m->ofd_dt_conf.ddp_grant_reserved);
- rc = lut_init(env, &m->ofd_lut, obd, m->ofd_osd);
+ rc = tgt_init(env, &m->ofd_lut, obd, m->ofd_osd);
if (rc)
GOTO(err_free_ns, rc);
RETURN(0);
err_fini_lut:
- lut_fini(env, &m->ofd_lut);
+ tgt_fini(env, &m->ofd_lut);
err_free_ns:
ldlm_namespace_free(m->ofd_namespace, 0, obd->obd_force);
obd->obd_namespace = m->ofd_namespace = NULL;
obd_exports_barrier(obd);
obd_zombie_barrier();
- lut_fini(env, &m->ofd_lut);
+ tgt_fini(env, &m->ofd_lut);
ofd_fs_cleanup(env, m);
ofd_free_capa_keys(m);
MODULES := ptlrpc
LDLM := @top_srcdir@/lustre/ldlm/
+TARGET := @top_srcdir@/lustre/target/
-ldlm_objs := $(LDLM)l_lock.o $(LDLM)ldlm_lock.o
+ldlm_objs := $(LDLM)l_lock.o $(LDLM)ldlm_lock.o
ldlm_objs += $(LDLM)ldlm_resource.o $(LDLM)ldlm_lib.o
ldlm_objs += $(LDLM)ldlm_plain.o $(LDLM)ldlm_extent.o
ldlm_objs += $(LDLM)ldlm_request.o $(LDLM)ldlm_lockd.o
ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o
ptlrpc_objs += sec_null.o sec_plain.o
-@SERVER_TRUE@ptlrpc_objs += target.o
+target_objs := $(TARGET)tgt_main.o $(TARGET)tgt_lastrcvd.o
ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs)
+@SERVER_TRUE@ptlrpc-objs += $(target_objs)
@GSS_TRUE@subdir-m += gss
interval_tree.c: @LUSTRE@/ldlm/interval_tree.c
ln -sf $< $@
-EXTRA_DIST = $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
-EXTRA_PRE_CFLAGS := -I@LUSTRE@/ldlm
+tgt_%.c: @LUSTRE@/target/tgt_%.c
+ ln -sf $< $@
+
+EXTRA_DIST := $(ptlrpc_objs:.o=.c) ptlrpc_internal.h
+@SERVER_TRUE@EXTRA_DIST += $(TARGET)tgt_internal.h
+
+EXTRA_PRE_CFLAGS := -I@LUSTRE@/ldlm -I@LUSTRE@/target
@INCLUDE_RULES@
}
#ifdef HAVE_SERVER_SUPPORT
-/* target.c */
-int lut_mod_init(void);
-void lut_mod_exit(void);
+int tgt_mod_init(void);
+void tgt_mod_exit(void);
#else
-static inline int lut_mod_init(void)
+static inline int tgt_mod_init(void)
{
return 0;
}
-static inline void lut_mod_exit(void)
+static inline void tgt_mod_exit(void)
{
return;
}
#ifdef __KERNEL__
cleanup_phase = 7;
- rc = lut_mod_init();
+ rc = tgt_mod_init();
if (rc)
GOTO(cleanup, rc);
#endif
#ifdef __KERNEL__
static void __exit ptlrpc_exit(void)
{
- lut_mod_exit();
+ tgt_mod_exit();
llog_recov_fini();
sptlrpc_fini();
ldlm_exit();
--- /dev/null
+#
+# GPL HEADER START
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 only,
+# as published by the Free Software Foundation.
+#
+# This program 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 version 2 for more details (a copy is included
+# in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU General Public License
+# version 2 along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 021110-1307, USA
+#
+# GPL HEADER END
+#
+
+#
+# Copyright (c) 2011, 2012, Intel Corporation.
+# Use is subject to license terms.
+#
+
+#
+# target is built into ptlrpc
+#
+
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@
+EXTRA_DIST = tgt_main.c tgt_lastrcvd.c tgt_internal.h
--- /dev/null
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2011, 2012, Intel Corporation.
+ */
+/*
+ * lustre/target/tgt_internal.h
+ *
+ * Lustre Unified Target header file
+ *
+ * Author: Mikhail Pershin <mike.pershin@intel.com>
+ */
+
+#ifndef _TG_INTERNAL_H
+#define _TG_INTERNAL_H
+
+#include <lustre_net.h>
+#include <lustre/lustre_idl.h>
+#include <lu_target.h>
+#include <lustre_export.h>
+#include <lustre_fid.h>
+#include <lustre_fld.h>
+#include <lustre_req_layout.h>
+#include <lustre_sec.h>
+
+extern struct lu_context_key tgt_thread_key;
+
+/**
+ * Common data shared by tg-level handlers. This is allocated per-thread to
+ * reduce stack consumption.
+ */
+struct tgt_thread_info {
+ /* server and client data buffers */
+ struct lr_server_data tti_lsd;
+ struct lsd_client_data tti_lcd;
+ struct lu_buf tti_buf;
+ loff_t tti_off;
+};
+
+static inline struct tgt_thread_info *tgt_th_info(const struct lu_env *env)
+{
+ struct tgt_thread_info *tti;
+
+ tti = lu_context_key_get(&env->le_ctx, &tgt_thread_key);
+ LASSERT(tti);
+ return tti;
+}
+
+#endif /* _TG_INTERNAL_H */
* This file is part of Lustre, http://www.lustre.org/
* Lustre is a trademark of Sun Microsystems, Inc.
*
- * Lustre Common Target
- * These are common function for MDT and OST recovery-related functionality
+ * Lustre Unified Target
+ * These are common function to work with last_received file
*
- * Author: Mikhail Pershin <tappro@sun.com>
+ * Author: Mikhail Pershin <mike.pershin@intel.com>
*/
-
#include <obd.h>
-#include <lustre_fsfilt.h>
#include <obd_class.h>
#include <lustre_fid.h>
-/**
- * Common data shared by tg-level handlers. This is allocated per-thread to
- * reduce stack consumption.
- */
-struct tg_thread_info {
- /* server and client data buffers */
- struct lr_server_data tti_lsd;
- struct lsd_client_data tti_lcd;
- struct lu_buf tti_buf;
- loff_t tti_off;
-};
+#include "tgt_internal.h"
-static inline struct lu_buf *tti_buf_lsd(struct tg_thread_info *tti)
+static inline struct lu_buf *tti_buf_lsd(struct tgt_thread_info *tti)
{
tti->tti_buf.lb_buf = &tti->tti_lsd;
tti->tti_buf.lb_len = sizeof(tti->tti_lsd);
return &tti->tti_buf;
}
-static inline struct lu_buf *tti_buf_lcd(struct tg_thread_info *tti)
+static inline struct lu_buf *tti_buf_lcd(struct tgt_thread_info *tti)
{
tti->tti_buf.lb_buf = &tti->tti_lcd;
tti->tti_buf.lb_len = sizeof(tti->tti_lcd);
return &tti->tti_buf;
}
-extern struct lu_context_key tg_thread_key;
-
-static inline struct tg_thread_info *tg_th_info(const struct lu_env *env)
-{
- struct tg_thread_info *tti;
-
- tti = lu_context_key_get(&env->le_ctx, &tg_thread_key);
- LASSERT(tti);
- return tti;
-}
-
-/**
- * Update client data in last_rcvd file. An obd API
- */
-static int obt_client_data_update(struct obd_export *exp)
-{
- struct tg_export_data *ted = &exp->exp_target_data;
- struct obd_device_target *obt = &exp->exp_obd->u.obt;
- struct lu_target *lut = class_exp2tgt(exp);
- loff_t off = ted->ted_lr_off;
- int rc = 0;
-
- rc = fsfilt_write_record(exp->exp_obd, obt->obt_rcvd_filp,
- ted->ted_lcd, sizeof(*ted->ted_lcd), &off, 0);
-
- CDEBUG(D_INFO, "update client idx %u last_epoch %#x (%#x)\n",
- ted->ted_lr_idx, le32_to_cpu(ted->ted_lcd->lcd_last_epoch),
- le32_to_cpu(lut->lut_lsd.lsd_start_epoch));
-
- return rc;
-}
-
-/**
- * Update server data in last_rcvd file. An obd API
- */
-int obt_server_data_update(struct lu_target *lut, int force_sync)
-{
- struct obd_device_target *obt = &lut->lut_obd->u.obt;
- loff_t off = 0;
- int rc;
- ENTRY;
-
- CDEBUG(D_SUPER,
- "%s: mount_count is "LPU64", last_transno is "LPU64"\n",
- lut->lut_lsd.lsd_uuid,
- le64_to_cpu(lut->lut_lsd.lsd_mount_count),
- le64_to_cpu(lut->lut_lsd.lsd_last_transno));
-
- rc = fsfilt_write_record(lut->lut_obd, obt->obt_rcvd_filp,
- &lut->lut_lsd, sizeof(lut->lut_lsd),
- &off, force_sync);
- if (rc)
- CERROR("error writing lr_server_data: rc = %d\n", rc);
-
- RETURN(rc);
-}
-
-/**
- * Update client epoch with server's one
- */
-void obt_client_epoch_update(struct obd_export *exp)
-{
- struct lsd_client_data *lcd = exp->exp_target_data.ted_lcd;
- struct lu_target *lut = class_exp2tgt(exp);
-
- /** VBR: set client last_epoch to current epoch */
- if (le32_to_cpu(lcd->lcd_last_epoch) >=
- le32_to_cpu(lut->lut_lsd.lsd_start_epoch))
- return;
- lcd->lcd_last_epoch = lut->lut_lsd.lsd_start_epoch;
- obt_client_data_update(exp);
-}
-
-/**
- * Increment server epoch. An obd API
- */
-static void obt_boot_epoch_update(struct lu_target *lut)
-{
- struct obd_device *obd = lut->lut_obd;
- __u32 start_epoch;
- struct ptlrpc_request *req;
- cfs_list_t client_list;
-
- cfs_spin_lock(&lut->lut_translock);
- start_epoch = lr_epoch(le64_to_cpu(lut->lut_last_transno)) + 1;
- lut->lut_last_transno = cpu_to_le64((__u64)start_epoch <<
- LR_EPOCH_BITS);
- lut->lut_lsd.lsd_start_epoch = cpu_to_le32(start_epoch);
- cfs_spin_unlock(&lut->lut_translock);
-
- CFS_INIT_LIST_HEAD(&client_list);
- cfs_spin_lock(&obd->obd_recovery_task_lock);
- cfs_list_splice_init(&obd->obd_final_req_queue, &client_list);
- cfs_spin_unlock(&obd->obd_recovery_task_lock);
-
- /**
- * go through list of exports participated in recovery and
- * set new epoch for them
- */
- cfs_list_for_each_entry(req, &client_list, rq_list) {
- LASSERT(!req->rq_export->exp_delayed);
- obt_client_epoch_update(req->rq_export);
- }
- /** return list back at once */
- cfs_spin_lock(&obd->obd_recovery_task_lock);
- cfs_list_splice_init(&client_list, &obd->obd_final_req_queue);
- cfs_spin_unlock(&obd->obd_recovery_task_lock);
- obt_server_data_update(lut, 1);
-}
-
/**
* Allocate in-memory data for client slot related to export.
*/
int lut_client_data_read(const struct lu_env *env, struct lu_target *tg,
struct lsd_client_data *lcd, loff_t *off, int index)
{
- struct tg_thread_info *tti = tg_th_info(env);
+ struct tgt_thread_info *tti = tgt_th_info(env);
int rc;
tti_buf_lcd(tti);
struct lsd_client_data *lcd, loff_t *off,
struct thandle *th)
{
- struct tg_thread_info *tti = tg_th_info(env);
+ struct tgt_thread_info *tti = tgt_th_info(env);
lcd_cpu_to_le(lcd, &tti->tti_lcd);
tti_buf_lcd(tti);
{
struct tg_export_data *ted = &exp->exp_target_data;
struct lu_target *tg = class_exp2tgt(exp);
- struct tg_thread_info *tti = tg_th_info(env);
+ struct tgt_thread_info *tti = tgt_th_info(env);
struct thandle *th;
int rc = 0;
int lut_server_data_read(const struct lu_env *env, struct lu_target *tg)
{
- struct tg_thread_info *tti = tg_th_info(env);
+ struct tgt_thread_info *tti = tgt_th_info(env);
int rc;
tti->tti_off = 0;
int lut_server_data_write(const struct lu_env *env, struct lu_target *tg,
struct thandle *th)
{
- struct tg_thread_info *tti = tg_th_info(env);
+ struct tgt_thread_info *tti = tgt_th_info(env);
int rc;
ENTRY;
int lut_server_data_update(const struct lu_env *env, struct lu_target *tg,
int sync)
{
- struct tg_thread_info *tti = tg_th_info(env);
+ struct tgt_thread_info *tti = tgt_th_info(env);
struct thandle *th;
int rc = 0;
if (lut->lut_obd->obd_stopping)
return;
- /** Increase server epoch after recovery */
- if (lut->lut_bottom == NULL)
- return obt_boot_epoch_update(lut);
rc = lu_env_init(&env, LCT_DT_THREAD);
if (rc) {
RETURN(rc);
}
EXPORT_SYMBOL(lut_client_del);
-
-int lut_init(const struct lu_env *env, struct lu_target *lut,
- struct obd_device *obd, struct dt_device *dt)
-{
- struct dt_object_format dof;
- struct lu_attr attr;
- struct lu_fid fid;
- struct dt_object *o;
- int rc = 0;
- ENTRY;
-
- LASSERT(lut);
- LASSERT(obd);
- lut->lut_obd = obd;
- lut->lut_bottom = dt;
- lut->lut_last_rcvd = NULL;
- obd->u.obt.obt_lut = lut;
-
- cfs_spin_lock_init(&lut->lut_translock);
-
- OBD_ALLOC(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3);
- if (lut->lut_client_bitmap == NULL)
- RETURN(-ENOMEM);
-
- /** obdfilter has no lu_device stack yet */
- if (dt == NULL)
- RETURN(rc);
-
- memset(&attr, 0, sizeof(attr));
- attr.la_valid = LA_MODE;
- attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR;
- dof.dof_type = dt_mode_to_dft(S_IFREG);
-
- lu_local_obj_fid(&fid, MDT_LAST_RECV_OID);
-
- o = dt_find_or_create(env, lut->lut_bottom, &fid, &dof, &attr);
- if (!IS_ERR(o)) {
- lut->lut_last_rcvd = o;
- } else {
- OBD_FREE(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3);
- lut->lut_client_bitmap = NULL;
- rc = PTR_ERR(o);
- CERROR("cannot open %s: rc = %d\n", LAST_RCVD, rc);
- }
-
- RETURN(rc);
-}
-EXPORT_SYMBOL(lut_init);
-
-void lut_fini(const struct lu_env *env, struct lu_target *lut)
-{
- ENTRY;
-
- if (lut->lut_client_bitmap) {
- OBD_FREE(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3);
- lut->lut_client_bitmap = NULL;
- }
- if (lut->lut_last_rcvd) {
- lu_object_put(env, &lut->lut_last_rcvd->do_lu);
- lut->lut_last_rcvd = NULL;
- }
- EXIT;
-}
-EXPORT_SYMBOL(lut_fini);
-
-/* context key constructor/destructor: tg_key_init, tg_key_fini */
-LU_KEY_INIT_FINI(tg, struct tg_thread_info);
-/* context key: tg_thread_key */
-LU_CONTEXT_KEY_DEFINE(tg, LCT_MD_THREAD|LCT_DT_THREAD);
-LU_KEY_INIT_GENERIC(tg);
-EXPORT_SYMBOL(tg_thread_key);
-
-int lut_mod_init(void)
-{
- tg_key_init_generic(&tg_thread_key, NULL);
- lu_context_key_register_many(&tg_thread_key, NULL);
- return 0;
-}
-
-void lut_mod_exit(void)
-{
- lu_context_key_degister_many(&tg_thread_key, NULL);
-}
-
--- /dev/null
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2011, 2012, Intel Corporation.
+ */
+/*
+ * lustre/target/tgt_main.c
+ *
+ * Lustre Unified Target main initialization code
+ *
+ * Author: Mikhail Pershin <mike.pershin@intel.com>
+ */
+
+#define DEBUG_SUBSYSTEM S_CLASS
+
+#include <obd.h>
+
+#include "tgt_internal.h"
+
+int tgt_init(const struct lu_env *env, struct lu_target *lut,
+ struct obd_device *obd, struct dt_device *dt)
+{
+ struct dt_object_format dof;
+ struct lu_attr attr;
+ struct lu_fid fid;
+ struct dt_object *o;
+ int rc = 0;
+
+ ENTRY;
+
+ LASSERT(lut);
+ LASSERT(obd);
+ lut->lut_obd = obd;
+ lut->lut_bottom = dt;
+ lut->lut_last_rcvd = NULL;
+ obd->u.obt.obt_lut = lut;
+ obd->u.obt.obt_magic = OBT_MAGIC;
+
+ cfs_spin_lock_init(&lut->lut_translock);
+
+ OBD_ALLOC(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3);
+ if (lut->lut_client_bitmap == NULL)
+ RETURN(-ENOMEM);
+
+ memset(&attr, 0, sizeof(attr));
+ attr.la_valid = LA_MODE;
+ attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR;
+ dof.dof_type = dt_mode_to_dft(S_IFREG);
+
+ lu_local_obj_fid(&fid, MDT_LAST_RECV_OID);
+
+ o = dt_find_or_create(env, lut->lut_bottom, &fid, &dof, &attr);
+ if (!IS_ERR(o)) {
+ lut->lut_last_rcvd = o;
+ } else {
+ OBD_FREE(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3);
+ lut->lut_client_bitmap = NULL;
+ rc = PTR_ERR(o);
+ CERROR("cannot open %s: rc = %d\n", LAST_RCVD, rc);
+ }
+
+ RETURN(rc);
+}
+EXPORT_SYMBOL(tgt_init);
+
+void tgt_fini(const struct lu_env *env, struct lu_target *lut)
+{
+ ENTRY;
+
+ if (lut->lut_client_bitmap) {
+ OBD_FREE(lut->lut_client_bitmap, LR_MAX_CLIENTS >> 3);
+ lut->lut_client_bitmap = NULL;
+ }
+ if (lut->lut_last_rcvd) {
+ lu_object_put(env, &lut->lut_last_rcvd->do_lu);
+ lut->lut_last_rcvd = NULL;
+ }
+ EXIT;
+}
+EXPORT_SYMBOL(tgt_fini);
+
+/* context key constructor/destructor: tg_key_init, tg_key_fini */
+LU_KEY_INIT_FINI(tgt, struct tgt_thread_info);
+
+/* context key: tg_thread_key */
+LU_CONTEXT_KEY_DEFINE(tgt, LCT_MD_THREAD | LCT_DT_THREAD);
+EXPORT_SYMBOL(tgt_thread_key);
+
+LU_KEY_INIT_GENERIC(tg);
+
+int tgt_mod_init(void)
+{
+ tg_key_init_generic(&tgt_thread_key, NULL);
+ lu_context_key_register_many(&tgt_thread_key, NULL);
+ return 0;
+}
+
+void tgt_mod_exit(void)
+{
+ lu_context_key_degister(&tgt_thread_key);
+}
+