From 04831bba6e2ee8d3c61c3dbc30d7eba043a453b1 Mon Sep 17 00:00:00 2001 From: Mikhail Pershin Date: Mon, 24 Jun 2013 08:23:37 +0400 Subject: [PATCH] LU-3467 seq: unified SEQ handler move SEQ handler from MDT to the FID module so it can be used from any target. Signed-off-by: Mikhail Pershin Change-Id: I1777eddd748486aab275e4440f96685bed0b104a Reviewed-on: http://review.whamcloud.com/6765 Tested-by: Hudson Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: wangdi Reviewed-by: Oleg Drokin --- lustre/fid/fid_handler.c | 104 ++++++++++++-------------------------------- lustre/fld/fld_handler.c | 2 +- lustre/include/Makefile.am | 1 - lustre/include/lu_target.h | 1 + lustre/include/lustre_fid.h | 6 --- lustre/include/lustre_mdt.h | 60 ------------------------- lustre/mdt/mdt_handler.c | 22 +++++----- lustre/mdt/mdt_internal.h | 2 - lustre/mdt/mdt_lproc.c | 1 - lustre/mdt/mdt_mds.c | 34 +-------------- lustre/ofd/ofd_dev.c | 5 +++ lustre/ost/ost_handler.c | 15 +------ lustre/quota/qmt_internal.h | 1 - 13 files changed, 49 insertions(+), 205 deletions(-) delete mode 100644 lustre/include/lustre_mdt.h diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index efdd33c..9dff6eb 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -51,7 +51,6 @@ #include #include #include -#include /* err_serious() */ #include "fid_internal.h" static void seq_server_proc_fini(struct lu_server_seq *seq); @@ -321,96 +320,51 @@ static int seq_server_handle(struct lu_site *site, RETURN(rc); } -static int seq_req_handle(struct ptlrpc_request *req, - const struct lu_env *env, - struct seq_thread_info *info) +static int seq_handler(struct tgt_session_info *tsi) { - struct lu_seq_range *out, *tmp; - struct lu_site *site; - int rc = -EPROTO; - __u32 *opc; - ENTRY; + struct lu_seq_range *out, *tmp; + struct lu_site *site; + int rc; + __u32 *opc; - LASSERT(!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)); - site = req->rq_export->exp_obd->obd_lu_dev->ld_site; - LASSERT(site != NULL); + ENTRY; - rc = req_capsule_server_pack(info->sti_pill); - if (rc) - RETURN(err_serious(rc)); + LASSERT(!(lustre_msg_get_flags(tgt_ses_req(tsi)->rq_reqmsg) & MSG_REPLAY)); + site = tsi->tsi_exp->exp_obd->obd_lu_dev->ld_site; + LASSERT(site != NULL); - opc = req_capsule_client_get(info->sti_pill, &RMF_SEQ_OPC); - if (opc != NULL) { - out = req_capsule_server_get(info->sti_pill, &RMF_SEQ_RANGE); - if (out == NULL) - RETURN(err_serious(-EPROTO)); + opc = req_capsule_client_get(tsi->tsi_pill, &RMF_SEQ_OPC); + if (opc != NULL) { + out = req_capsule_server_get(tsi->tsi_pill, &RMF_SEQ_RANGE); + if (out == NULL) + RETURN(err_serious(-EPROTO)); - tmp = req_capsule_client_get(info->sti_pill, &RMF_SEQ_RANGE); + tmp = req_capsule_client_get(tsi->tsi_pill, &RMF_SEQ_RANGE); - /* seq client passed mdt id, we need to pass that using out - * range parameter */ + /* seq client passed mdt id, we need to pass that using out + * range parameter */ - out->lsr_index = tmp->lsr_index; - out->lsr_flags = tmp->lsr_flags; - rc = seq_server_handle(site, env, *opc, out); - } else - rc = err_serious(-EPROTO); + out->lsr_index = tmp->lsr_index; + out->lsr_flags = tmp->lsr_flags; + rc = seq_server_handle(site, tsi->tsi_env, *opc, out); + } else { + rc = err_serious(-EPROTO); + } - RETURN(rc); + RETURN(rc); } +struct tgt_handler seq_handlers[] = { +TGT_SEQ_HDL(HABEO_REFERO, SEQ_QUERY, seq_handler), +}; +EXPORT_SYMBOL(seq_handlers); + /* context key constructor/destructor: seq_key_init, seq_key_fini */ LU_KEY_INIT_FINI(seq, struct seq_thread_info); /* context key: seq_thread_key */ LU_CONTEXT_KEY_DEFINE(seq, LCT_MD_THREAD | LCT_DT_THREAD); -static void seq_thread_info_init(struct ptlrpc_request *req, - struct seq_thread_info *info) -{ - info->sti_pill = &req->rq_pill; - /* Init request capsule */ - req_capsule_init(info->sti_pill, req, RCL_SERVER); - req_capsule_set(info->sti_pill, &RQF_SEQ_QUERY); -} - -static void seq_thread_info_fini(struct seq_thread_info *info) -{ - req_capsule_fini(info->sti_pill); -} - -int seq_handle(struct ptlrpc_request *req) -{ - const struct lu_env *env; - struct seq_thread_info *info; - int rc; - - env = req->rq_svc_thread->t_env; - LASSERT(env != NULL); - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - seq_thread_info_init(req, info); - rc = seq_req_handle(req, env, info); - /* XXX: we don't need replay but MDT assign transno in any case, - * remove it manually before reply*/ - lustre_msg_set_transno(req->rq_repmsg, 0); - seq_thread_info_fini(info); - - return rc; -} -EXPORT_SYMBOL(seq_handle); - -/* - * Entry point for handling FLD RPCs called from MDT. - */ -int seq_query(struct com_thread_info *info) -{ - return seq_handle(info->cti_pill->rc_req); -} -EXPORT_SYMBOL(seq_query); - static int seq_server_proc_init(struct lu_server_seq *seq) { #ifdef LPROCFS diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 6613817..53694ef 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -51,7 +51,7 @@ #include #include #include -#include /* err_serious() */ +#include #include #include #include "fld_internal.h" diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index 97202f9..c3eafd7 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -73,7 +73,6 @@ EXTRA_DIST = \ lustre_log.h \ lustre_mdc.h \ lustre_mds.h \ - lustre_mdt.h \ lustre_net.h \ lustre_param.h \ lustre_quota.h \ diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 31f2e81..2dab5cb 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -213,6 +213,7 @@ extern struct tgt_handler tgt_dlm_handlers[]; extern struct tgt_handler tgt_llog_handlers[]; extern struct tgt_handler tgt_out_handlers[]; extern struct tgt_handler fld_handlers[]; +extern struct tgt_handler seq_handlers[]; typedef void (*tgt_cb_t)(struct lu_target *lut, __u64 transno, void *data, int err); diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index 26bc9c3..2ce75b2 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -431,12 +431,6 @@ struct lu_server_seq { struct seq_server_site *lss_site; }; -struct com_thread_info; -int seq_query(struct com_thread_info *info); - -struct ptlrpc_request; -int seq_handle(struct ptlrpc_request *req); - /* Server methods */ int seq_server_init(struct lu_server_seq *seq, diff --git a/lustre/include/lustre_mdt.h b/lustre/include/lustre_mdt.h deleted file mode 100644 index a5f3352..0000000 --- a/lustre/include/lustre_mdt.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LINUX_MDT_H -#define __LINUX_MDT_H - -/** \defgroup mdt mdt - * - * @{ - */ - -#include -#include -#include -#include - -/* - * Common thread info for mdt, seq and fld - */ -struct com_thread_info { - /* - * for req-layout interface. - */ - struct req_capsule *cti_pill; -}; - -/** @} mdt */ - -#endif diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 0a4277e..d997413 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -62,7 +62,6 @@ /* lu2dt_dev() */ #include #include -#include #include #include "mdt_internal.h" #include @@ -3461,19 +3460,13 @@ int mdt_handle_common(struct ptlrpc_request *req, */ int mdt_recovery_handle(struct ptlrpc_request *req) { - int rc; - ENTRY; + int rc; - switch (lustre_msg_get_opc(req->rq_reqmsg)) { - case SEQ_QUERY: - rc = mdt_handle_common(req, mdt_seq_handlers); - break; - default: - rc = mdt_handle_common(req, mdt_regular_handlers); - break; - } + ENTRY; - RETURN(rc); + rc = mdt_handle_common(req, mdt_regular_handlers); + + RETURN(rc); } enum mdt_it_code { @@ -4718,6 +4711,11 @@ static struct tgt_opc_slice mdt_common_slice[] = { .tos_hs = fld_handlers }, { + .tos_opc_start = SEQ_FIRST_OPC, + .tos_opc_end = SEQ_LAST_OPC, + .tos_hs = seq_handlers + }, + { .tos_hs = NULL } }; diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 2283d99..42ff0b6 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -50,7 +50,6 @@ #if defined(__KERNEL__) -#include #include #include #include @@ -59,7 +58,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index d0baefe..17aa9e0 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -59,7 +59,6 @@ #include #include #include -#include #include #include "mdt_internal.h" #include diff --git a/lustre/mdt/mdt_mds.c b/lustre/mdt/mdt_mds.c index 2805fec..7c7d95e 100644 --- a/lustre/mdt/mdt_mds.c +++ b/lustre/mdt/mdt_mds.c @@ -49,7 +49,6 @@ /* lu2dt_dev() */ #include #include -#include #include "mdt_internal.h" #include #include @@ -269,25 +268,6 @@ static struct mdt_opc_slice mdt_readpage_handlers[] = { } }; -/* Sequence service handlers */ -#define DEF_SEQ_HDL(flags, name, fn) \ - DEFINE_RPC_HANDLER(SEQ_QUERY, flags, name, fn, &RQF_ ## name) - -static struct mdt_handler mdt_seq_ops[] = { -DEF_SEQ_HDL(0, SEQ_QUERY, (void *)seq_query), -}; - -struct mdt_opc_slice mdt_seq_handlers[] = { - { - .mos_opc_start = SEQ_QUERY, - .mos_opc_end = SEQ_LAST_OPC, - .mos_hs = mdt_seq_ops - }, - { - .mos_hs = NULL - } -}; - static int mds_regular_handle(struct ptlrpc_request *req) { return mdt_handle_common(req, mdt_regular_handlers); @@ -298,16 +278,6 @@ static int mds_readpage_handle(struct ptlrpc_request *req) return mdt_handle_common(req, mdt_readpage_handlers); } -static int mds_mdsc_handle(struct ptlrpc_request *req) -{ - return mdt_handle_common(req, mdt_seq_handlers); -} - -static int mds_mdss_handle(struct ptlrpc_request *req) -{ - return mdt_handle_common(req, mdt_seq_handlers); -} - /* device init/fini methods */ static void mds_stop_ptlrpc_service(struct mds_device *m) { @@ -552,7 +522,7 @@ static int mds_start_ptlrpc_service(struct mds_device *m) .tc_ctx_tags = LCT_MD_THREAD, }, .psc_ops = { - .so_req_handler = mds_mdsc_handle, + .so_req_handler = tgt_request_handle, .so_req_printer = target_print_req, .so_hpreq_handler = NULL, }, @@ -588,7 +558,7 @@ static int mds_start_ptlrpc_service(struct mds_device *m) .tc_ctx_tags = LCT_MD_THREAD | LCT_DT_THREAD }, .psc_ops = { - .so_req_handler = mds_mdss_handle, + .so_req_handler = tgt_request_handle, .so_req_printer = target_print_req, .so_hpreq_handler = NULL, }, diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 6d7fd09..a9ce020 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -617,6 +617,11 @@ static struct tgt_opc_slice ofd_common_slice[] = { .tos_hs = tgt_out_handlers }, { + .tos_opc_start = SEQ_FIRST_OPC, + .tos_opc_end = SEQ_LAST_OPC, + .tos_hs = seq_handlers + }, + { .tos_hs = NULL } }; diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index acc1a1d..7880341 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1819,15 +1819,6 @@ int ost_msg_check_version(struct lustre_msg *msg) lustre_msg_get_version(msg), LUSTRE_OBD_VERSION); break; - case SEQ_QUERY: - /* Note: client always use MDS_VERSION for FID request */ - rc = lustre_msg_check_version(msg, LUSTRE_MDS_VERSION); - if (rc) - CERROR("bad opc %u version %08x, expecting %08x\n", - lustre_msg_get_opc(msg), - lustre_msg_get_version(msg), - LUSTRE_MDS_VERSION); - break; case OST_CREATE: case OST_DESTROY: case OST_GETATTR: @@ -2463,10 +2454,6 @@ int ost_handle(struct ptlrpc_request *req) req_capsule_set(&req->rq_pill, &RQF_OST_GET_INFO_GENERIC); rc = ost_get_info(req->rq_export, req); break; - case SEQ_QUERY: - CDEBUG(D_INODE, "seq\n"); - rc = seq_handle(req); - break; case OST_QUOTACHECK: CDEBUG(D_INODE, "quotacheck\n"); req_capsule_set(&req->rq_pill, &RQF_OST_QUOTACHECK); @@ -2786,7 +2773,7 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg) .cc_pattern = oss_cpts, }, .psc_ops = { - .so_req_handler = ost_handle, + .so_req_handler = tgt_request_handle, .so_req_printer = target_print_req, .so_hpreq_handler = NULL, }, diff --git a/lustre/quota/qmt_internal.h b/lustre/quota/qmt_internal.h index 277f4c9..8938f6e 100644 --- a/lustre/quota/qmt_internal.h +++ b/lustre/quota/qmt_internal.h @@ -28,7 +28,6 @@ #ifndef _QMT_INTERNAL_H #define _QMT_INTERNAL_H -#include /* err_serious() */ #include "lquota_internal.h" /* -- 1.8.3.1