Whamcloud - gitweb
LU-3467 seq: unified SEQ handler 65/6765/11
authorMikhail Pershin <mike.pershin@intel.com>
Mon, 24 Jun 2013 04:23:37 +0000 (08:23 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 1 Aug 2013 01:05:23 +0000 (01:05 +0000)
move SEQ handler from MDT to the FID module so it can
be used from any target.

Signed-off-by: Mikhail Pershin <mike.pershin@intel.com>
Change-Id: I1777eddd748486aab275e4440f96685bed0b104a
Reviewed-on: http://review.whamcloud.com/6765
Tested-by: Hudson
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
13 files changed:
lustre/fid/fid_handler.c
lustre/fld/fld_handler.c
lustre/include/Makefile.am
lustre/include/lu_target.h
lustre/include/lustre_fid.h
lustre/include/lustre_mdt.h [deleted file]
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lproc.c
lustre/mdt/mdt_mds.c
lustre/ofd/ofd_dev.c
lustre/ost/ost_handler.c
lustre/quota/qmt_internal.h

index efdd33c..9dff6eb 100644 (file)
@@ -51,7 +51,6 @@
 #include <obd_support.h>
 #include <lustre_req_layout.h>
 #include <lustre_fid.h>
-#include <lustre_mdt.h> /* 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
index 6613817..53694ef 100644 (file)
@@ -51,7 +51,7 @@
 #include <obd_support.h>
 #include <lustre_fid.h>
 #include <lustre_fld.h>
-#include <lustre_mdt.h> /* err_serious() */
+#include <md_object.h>
 #include <lustre_req_layout.h>
 #include <lprocfs_status.h>
 #include "fld_internal.h"
index 97202f9..c3eafd7 100644 (file)
@@ -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 \
index 31f2e81..2dab5cb 100644 (file)
@@ -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);
index 26bc9c3..2ce75b2 100644 (file)
@@ -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 (file)
index a5f3352..0000000
+++ /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 <lustre/lustre_idl.h>
-#include <lustre_req_layout.h>
-#include <md_object.h>
-#include <libcfs/libcfs.h>
-
-/*
- * Common thread info for mdt, seq and fld
- */
-struct com_thread_info {
-        /*
-         * for req-layout interface.
-         */
-        struct req_capsule *cti_pill;
-};
-
-/** @} mdt */
-
-#endif
index 0a4277e..d997413 100644 (file)
@@ -62,7 +62,6 @@
 /* lu2dt_dev() */
 #include <dt_object.h>
 #include <lustre_mds.h>
-#include <lustre_mdt.h>
 #include <lustre_log.h>
 #include "mdt_internal.h"
 #include <lustre_acl.h>
@@ -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
        }
 };
index 2283d99..42ff0b6 100644 (file)
@@ -50,7 +50,6 @@
 
 #if defined(__KERNEL__)
 
-#include <obd_class.h>
 #include <lustre_net.h>
 #include <lustre/lustre_idl.h>
 #include <obd_class.h>
@@ -59,7 +58,6 @@
 #include <md_object.h>
 #include <lustre_fid.h>
 #include <lustre_fld.h>
-#include <lustre_mdt.h>
 #include <lustre_req_layout.h>
 #include <lustre_sec.h>
 #include <lustre_idmap.h>
index d0baefe..17aa9e0 100644 (file)
@@ -59,7 +59,6 @@
 #include <obd.h>
 #include <obd_class.h>
 #include <lustre_mds.h>
-#include <lustre_mdt.h>
 #include <lprocfs_status.h>
 #include "mdt_internal.h"
 #include <lnet/lib-lnet.h>
index 2805fec..7c7d95e 100644 (file)
@@ -49,7 +49,6 @@
 /* lu2dt_dev() */
 #include <dt_object.h>
 #include <lustre_mds.h>
-#include <lustre_mdt.h>
 #include "mdt_internal.h"
 #include <lustre_quota.h>
 #include <lustre_acl.h>
@@ -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,
                },
index 6d7fd09..a9ce020 100644 (file)
@@ -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
        }
 };
index acc1a1d..7880341 100644 (file)
@@ -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,
                },
index 277f4c9..8938f6e 100644 (file)
@@ -28,7 +28,6 @@
 #ifndef _QMT_INTERNAL_H
 #define _QMT_INTERNAL_H
 
-#include <lustre_mdt.h> /* err_serious() */
 #include "lquota_internal.h"
 
 /*