Whamcloud - gitweb
LU-1445 fid: start ptlrpc service for OST FID
[fs/lustre-release.git] / lustre / ost / ost_handler.c
index f84484e..d8fcccb 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2011, 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -52,6 +52,7 @@
 #include <lprocfs_status.h>
 #include <libcfs/list.h>
 #include "ost_internal.h"
+#include <lustre_fid.h>
 
 static int oss_num_threads;
 CFS_MODULE_PARM(oss_num_threads, "i", int, 0444,
@@ -245,7 +246,8 @@ static int ost_lock_get(struct obd_export *exp, struct obdo *oa,
         RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id,
                                       LDLM_EXTENT, &policy, mode, &flags,
                                       ldlm_blocking_ast, ldlm_completion_ast,
-                                      ldlm_glimpse_ast, NULL, 0, NULL, lh));
+                                     ldlm_glimpse_ast, NULL, 0, LVB_T_NONE,
+                                     NULL, lh));
 }
 
 /* Helper function: release lock, if any. */
@@ -642,7 +644,8 @@ static int ost_brw_lock_get(int mode, struct obd_export *exp,
         RETURN(ldlm_cli_enqueue_local(exp->exp_obd->obd_namespace, &res_id,
                                       LDLM_EXTENT, &policy, mode, &flags,
                                       ldlm_blocking_ast, ldlm_completion_ast,
-                                      ldlm_glimpse_ast, NULL, 0, NULL, lh));
+                                     ldlm_glimpse_ast, NULL, 0, LVB_T_NONE,
+                                     NULL, lh));
 }
 
 static void ost_brw_lock_put(int mode,
@@ -1383,14 +1386,14 @@ static int ost_llog_handle_connect(struct obd_export *exp,
         RETURN(rc);
 }
 
-#define ost_init_sec_none(reply, exp)                                   \
-do {                                                                    \
-        reply->ocd_connect_flags &= ~(OBD_CONNECT_RMT_CLIENT |          \
-                                      OBD_CONNECT_RMT_CLIENT_FORCE |    \
-                                      OBD_CONNECT_OSS_CAPA);            \
-        cfs_spin_lock(&exp->exp_lock);                                  \
-        exp->exp_connect_flags = reply->ocd_connect_flags;              \
-        cfs_spin_unlock(&exp->exp_lock);                                \
+#define ost_init_sec_none(reply, exp)                                  \
+do {                                                                   \
+       reply->ocd_connect_flags &= ~(OBD_CONNECT_RMT_CLIENT |          \
+                                     OBD_CONNECT_RMT_CLIENT_FORCE |    \
+                                     OBD_CONNECT_OSS_CAPA);            \
+       spin_lock(&exp->exp_lock);                                      \
+       exp->exp_connect_flags = reply->ocd_connect_flags;              \
+       spin_unlock(&exp->exp_lock);                                    \
 } while (0)
 
 static int ost_init_sec_level(struct ptlrpc_request *req)
@@ -1487,9 +1490,9 @@ static int ost_init_sec_level(struct ptlrpc_request *req)
                         if (!filter->fo_fl_oss_capa)
                                 reply->ocd_connect_flags &= ~OBD_CONNECT_OSS_CAPA;
 
-                        cfs_spin_lock(&exp->exp_lock);
-                        exp->exp_connect_flags = reply->ocd_connect_flags;
-                        cfs_spin_unlock(&exp->exp_lock);
+                       spin_lock(&exp->exp_lock);
+                       exp->exp_connect_flags = reply->ocd_connect_flags;
+                       spin_unlock(&exp->exp_lock);
                 }
                 break;
         default:
@@ -1522,14 +1525,14 @@ static int ost_connect_check_sptlrpc(struct ptlrpc_request *req)
         }
 
         if (exp->exp_flvr.sf_rpc == SPTLRPC_FLVR_INVALID) {
-                cfs_read_lock(&filter->fo_sptlrpc_lock);
-                sptlrpc_target_choose_flavor(&filter->fo_sptlrpc_rset,
-                                             req->rq_sp_from,
-                                             req->rq_peer.nid,
-                                             &flvr);
-                cfs_read_unlock(&filter->fo_sptlrpc_lock);
+               read_lock(&filter->fo_sptlrpc_lock);
+               sptlrpc_target_choose_flavor(&filter->fo_sptlrpc_rset,
+                                            req->rq_sp_from,
+                                            req->rq_peer.nid,
+                                            &flvr);
+               read_unlock(&filter->fo_sptlrpc_lock);
 
-                cfs_spin_lock(&exp->exp_lock);
+               spin_lock(&exp->exp_lock);
 
                 exp->exp_sp_peer = req->rq_sp_from;
                 exp->exp_flvr = flvr;
@@ -1543,7 +1546,7 @@ static int ost_connect_check_sptlrpc(struct ptlrpc_request *req)
                         rc = -EACCES;
                 }
 
-                cfs_spin_unlock(&exp->exp_lock);
+               spin_unlock(&exp->exp_lock);
         } else {
                 if (exp->exp_sp_peer != req->rq_sp_from) {
                         CERROR("RPC source %s doesn't match %s\n",
@@ -1661,6 +1664,15 @@ 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:
@@ -1792,7 +1804,7 @@ static void ost_prolong_locks(struct ost_prolong_data *data)
         }
 
 
-        cfs_spin_lock_bh(&exp->exp_bl_list_lock);
+       spin_lock_bh(&exp->exp_bl_list_lock);
         cfs_list_for_each_entry(lock, &exp->exp_bl_list, l_exp_list) {
                 LASSERT(lock->l_flags & LDLM_FL_AST_SENT);
                 LASSERT(lock->l_resource->lr_type == LDLM_EXTENT);
@@ -1806,9 +1818,9 @@ static void ost_prolong_locks(struct ost_prolong_data *data)
 
                 ost_prolong_lock_one(data, lock);
         }
-        cfs_spin_unlock_bh(&exp->exp_bl_list_lock);
+       spin_unlock_bh(&exp->exp_bl_list_lock);
 
-        EXIT;
+       EXIT;
 }
 
 /**
@@ -2297,6 +2309,10 @@ 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);
@@ -2456,7 +2472,7 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
         lprocfs_ost_init_vars(&lvars);
         lprocfs_obd_setup(obd, lvars.obd_vars);
 
-        cfs_mutex_init(&ost->ost_health_mutex);
+       mutex_init(&ost->ost_health_mutex);
 
        svc_conf = (typeof(svc_conf)) {
                .psc_name               = LUSTRE_OSS_NAME,
@@ -2603,10 +2619,53 @@ static int ost_setup(struct obd_device *obd, struct lustre_cfg* lcfg)
                GOTO(out_create, rc);
         }
 
+       memset(&svc_conf, 0, sizeof(svc_conf));
+       svc_conf = (typeof(svc_conf)) {
+               .psc_name               = "ost_seq",
+               .psc_watchdog_factor    = OSS_SERVICE_WATCHDOG_FACTOR,
+               .psc_buf                = {
+                       .bc_nbufs               = OST_NBUFS,
+                       .bc_buf_size            = OST_BUFSIZE,
+                       .bc_req_max_size        = OST_MAXREQSIZE,
+                       .bc_rep_max_size        = OST_MAXREPSIZE,
+                       .bc_req_portal          = SEQ_DATA_PORTAL,
+                       .bc_rep_portal          = OSC_REPLY_PORTAL,
+               },
+               .psc_thr                = {
+                       .tc_thr_name            = "ll_ost_seq",
+                       .tc_thr_factor          = OSS_CR_THR_FACTOR,
+                       .tc_nthrs_init          = OSS_CR_NTHRS_INIT,
+                       .tc_nthrs_base          = OSS_CR_NTHRS_BASE,
+                       .tc_nthrs_max           = OSS_CR_NTHRS_MAX,
+                       .tc_nthrs_user          = oss_num_create_threads,
+                       .tc_cpu_affinity        = 1,
+                       .tc_ctx_tags            = LCT_DT_THREAD,
+               },
+
+               .psc_cpt                = {
+                       .cc_pattern          = oss_cpts,
+               },
+               .psc_ops                = {
+                       .so_req_handler         = ost_handle,
+                       .so_req_printer         = target_print_req,
+                       .so_hpreq_handler       = NULL,
+               },
+       };
+       ost->ost_seq_service = ptlrpc_register_service(&svc_conf,
+                                                     obd->obd_proc_entry);
+       if (IS_ERR(ost->ost_seq_service)) {
+               rc = PTR_ERR(ost->ost_seq_service);
+               CERROR("failed to start OST seq service: %d\n", rc);
+               ost->ost_seq_service = NULL;
+               GOTO(out_io, rc);
+       }
+
         ping_evictor_start();
 
         RETURN(0);
-
+out_io:
+       ptlrpc_unregister_service(ost->ost_io_service);
+       ost->ost_io_service = NULL;
 out_create:
         ptlrpc_unregister_service(ost->ost_create_service);
         ost->ost_create_service = NULL;
@@ -2620,24 +2679,26 @@ out_lprocfs:
 
 static int ost_cleanup(struct obd_device *obd)
 {
-        struct ost_obd *ost = &obd->u.ost;
-        int err = 0;
-        ENTRY;
-
-        ping_evictor_stop();
+       struct ost_obd *ost = &obd->u.ost;
+       int err = 0;
+       ENTRY;
 
-        /* there is no recovery for OST OBD, all recovery is controlled by
-         * obdfilter OBD */
-        LASSERT(obd->obd_recovering == 0);
-        cfs_mutex_lock(&ost->ost_health_mutex);
-        ptlrpc_unregister_service(ost->ost_service);
-        ptlrpc_unregister_service(ost->ost_create_service);
-        ptlrpc_unregister_service(ost->ost_io_service);
-        ost->ost_service = NULL;
-        ost->ost_create_service = NULL;
+       ping_evictor_stop();
+
+       /* there is no recovery for OST OBD, all recovery is controlled by
+        * obdfilter OBD */
+       LASSERT(obd->obd_recovering == 0);
+       mutex_lock(&ost->ost_health_mutex);
+       ptlrpc_unregister_service(ost->ost_service);
+       ptlrpc_unregister_service(ost->ost_create_service);
+       ptlrpc_unregister_service(ost->ost_io_service);
+       ptlrpc_unregister_service(ost->ost_seq_service);
+       ost->ost_service = NULL;
+       ost->ost_create_service = NULL;
        ost->ost_io_service = NULL;
+       ost->ost_seq_service = NULL;
 
-       cfs_mutex_unlock(&ost->ost_health_mutex);
+       mutex_unlock(&ost->ost_health_mutex);
 
        lprocfs_obd_cleanup(obd);
 
@@ -2654,11 +2715,11 @@ static int ost_health_check(const struct lu_env *env, struct obd_device *obd)
         struct ost_obd *ost = &obd->u.ost;
         int rc = 0;
 
-        cfs_mutex_lock(&ost->ost_health_mutex);
+       mutex_lock(&ost->ost_health_mutex);
         rc |= ptlrpc_service_health_check(ost->ost_service);
         rc |= ptlrpc_service_health_check(ost->ost_create_service);
         rc |= ptlrpc_service_health_check(ost->ost_io_service);
-        cfs_mutex_unlock(&ost->ost_health_mutex);
+       mutex_unlock(&ost->ost_health_mutex);
 
         /*
          * health_check to return 0 on healthy