Whamcloud - gitweb
Add lu_env parameter to ->rq_interpreter call-back. NULL is passed
authornikita <nikita>
Sat, 18 Oct 2008 17:33:11 +0000 (17:33 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 17:33:11 +0000 (17:33 +0000)
there. Actual usage will be in CLIO.
b=16450

15 files changed:
lustre/ChangeLog
lustre/include/lustre_net.h
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_request.c
lustre/mds/lproc_mds.c
lustre/osc/osc_create.c
lustre/osc/osc_request.c
lustre/ptlrpc/client.c
lustre/ptlrpc/import.c
lustre/ptlrpc/pinger.c
lustre/ptlrpc/ptlrpcd.c
lustre/ptlrpc/recov_thread.c
lustre/quota/quota_context.c

index dd69bee..2c9431a 100644 (file)
@@ -1680,6 +1680,12 @@ Bugzilla   : 16450
 Description: Kill obd_set_fail_loc().
 Details    : Remove unused code.
 
 Description: Kill obd_set_fail_loc().
 Details    : Remove unused code.
 
+Severity   : normal
+Bugzilla   : 16450
+Description: Add special type for ptlrpc_request interpret functions.
+Details    : Add lu_env parameter to ->rq_interpreter call-back. NULL is passed 
+        there. Actual usage will be in CLIO.
+
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
index a1bd77a..7ff653c 100644 (file)
@@ -296,6 +296,11 @@ enum rq_phase {
         RQ_PHASE_COMPLETE    = 0xebc0de04,
 };
 
         RQ_PHASE_COMPLETE    = 0xebc0de04,
 };
 
+/** Type of request interpreter call-back */
+typedef int (*ptlrpc_interpterer_t)(const struct lu_env *env,
+                                    struct ptlrpc_request *req,
+                                    void *arg, int rc);
+
 struct ptlrpc_request_pool {
         spinlock_t prp_lock;
         struct list_head prp_req_list;    /* list of ptlrpc_request structs */
 struct ptlrpc_request_pool {
         spinlock_t prp_lock;
         struct list_head prp_req_list;    /* list of ptlrpc_request structs */
@@ -742,6 +747,10 @@ struct ptlrpcd_ctl {
          * Thread name used in cfs_daemonize()
          */
         char                        pc_name[16];
          * Thread name used in cfs_daemonize()
          */
         char                        pc_name[16];
+        /**
+         * Environment for request interpreters to run in.
+         */
+        struct lu_env               pc_env;
 #ifndef __KERNEL__
         /**
          * Async rpcs flag to make sure that ptlrpcd_check() is called only
 #ifndef __KERNEL__
         /**
          * Async rpcs flag to make sure that ptlrpcd_check() is called only
@@ -865,7 +874,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void);
 int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
                       set_interpreter_func fn, void *data);
 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
 int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
                       set_interpreter_func fn, void *data);
 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *);
-int ptlrpc_check_set(struct ptlrpc_request_set *set);
+int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set);
 int ptlrpc_set_wait(struct ptlrpc_request_set *);
 int ptlrpc_expired_set(void *data);
 void ptlrpc_interrupted_set(void *data);
 int ptlrpc_set_wait(struct ptlrpc_request_set *);
 int ptlrpc_expired_set(void *data);
 void ptlrpc_interrupted_set(void *data);
index 7edf62f..c12c3c6 100644 (file)
@@ -543,7 +543,8 @@ static int ldlm_handle_ast_error(struct ldlm_lock *lock,
         return rc;
 }
 
         return rc;
 }
 
-static int ldlm_cb_interpret(struct ptlrpc_request *req, void *data, int rc)
+static int ldlm_cb_interpret(const struct lu_env *env,
+                             struct ptlrpc_request *req, void *data, int rc)
 {
         struct ldlm_cb_set_arg *arg;
         struct ldlm_lock *lock;
 {
         struct ldlm_cb_set_arg *arg;
         struct ldlm_lock *lock;
index 045b779..44f5fb2 100644 (file)
@@ -2022,7 +2022,8 @@ static int ldlm_chain_lock_for_replay(struct ldlm_lock *lock, void *closure)
         return LDLM_ITER_CONTINUE;
 }
 
         return LDLM_ITER_CONTINUE;
 }
 
-static int replay_lock_interpret(struct ptlrpc_request *req,
+static int replay_lock_interpret(const struct lu_env *env,
+                                 struct ptlrpc_request *req,
                                  struct ldlm_async_args *aa, int rc)
 {
         struct lustre_handle  old_hash_key;
                                  struct ldlm_async_args *aa, int rc)
 {
         struct lustre_handle  old_hash_key;
@@ -2147,7 +2148,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock)
         CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         aa->lock_handle = body->lock_handle[0];
         CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         aa->lock_handle = body->lock_handle[0];
-        req->rq_interpret_reply = replay_lock_interpret;
+        req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret;
         ptlrpcd_add_req(req);
 
         RETURN(0);
         ptlrpcd_add_req(req);
 
         RETURN(0);
index a21992c..da91c7e 100644 (file)
@@ -942,7 +942,8 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int mdc_intent_getattr_async_interpret(struct ptlrpc_request *req,
+static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
+                                              struct ptlrpc_request *req,
                                               void *unused, int rc)
 {
         struct obd_export        *exp = req->rq_async_args.pointer_arg[0];
                                               void *unused, int rc)
 {
         struct obd_export        *exp = req->rq_async_args.pointer_arg[0];
index 981b782..e5b01f0 100644 (file)
@@ -1127,7 +1127,7 @@ static int do_set_info_async(struct obd_export *exp,
 
         if (set) {
                 ptlrpc_set_add_req(set, req);
 
         if (set) {
                 ptlrpc_set_add_req(set, req);
-                ptlrpc_check_set(set);
+                ptlrpc_check_set(NULL, set);
         } else {
                 rc = ptlrpc_queue_wait(req);
                 ptlrpc_req_finished(req);
         } else {
                 rc = ptlrpc_queue_wait(req);
                 ptlrpc_req_finished(req);
@@ -1735,7 +1735,8 @@ int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int mdc_interpret_renew_capa(struct ptlrpc_request *req, void *unused,
+static int mdc_interpret_renew_capa(const struct lu_env *env,
+                                    struct ptlrpc_request *req, void *unused,
                                     int status)
 {
         struct obd_capa *oc = req->rq_async_args.pointer_arg[0];
                                     int status)
 {
         struct obd_capa *oc = req->rq_async_args.pointer_arg[0];
index cebd82e..138eafa 100644 (file)
@@ -107,7 +107,7 @@ static int lprocfs_mds_wr_evict_client(struct file *file, const char *buffer,
                         CERROR("Failed to evict nid %s from OSTs: rc %d\n",
                                tmpbuf + 4, rc);
 
                         CERROR("Failed to evict nid %s from OSTs: rc %d\n",
                                tmpbuf + 4, rc);
 
-                ptlrpc_check_set(set);
+                ptlrpc_check_set(NULL, set);
         }
 
         /* See the comments in function lprocfs_wr_evict_client() 
         }
 
         /* See the comments in function lprocfs_wr_evict_client() 
index f3eb6bc..f6b669e 100644 (file)
@@ -61,7 +61,8 @@
 #include <obd_class.h>
 #include "osc_internal.h"
 
 #include <obd_class.h>
 #include "osc_internal.h"
 
-static int osc_interpret_create(struct ptlrpc_request *req, void *data, int rc)
+static int osc_interpret_create(const struct lu_env *env,
+                                struct ptlrpc_request *req, void *data, int rc)
 {
         struct osc_creator *oscc;
         struct ost_body *body = NULL;
 {
         struct osc_creator *oscc;
         struct ost_body *body = NULL;
@@ -97,7 +98,7 @@ static int osc_interpret_create(struct ptlrpc_request *req, void *data, int rc)
         case -EAGAIN:
                 /* valid race delorphan vs create, or somthing after resend */
                 spin_unlock(&oscc->oscc_lock);
         case -EAGAIN:
                 /* valid race delorphan vs create, or somthing after resend */
                 spin_unlock(&oscc->oscc_lock);
-                DEBUG_REQ(D_INODE, req, "Got EGAIN - resend \n");
+                DEBUG_REQ(D_INODE, req, "Got EAGAIN - resend \n");
                 break;
         case -ENOSPC:
         case -EROFS: 
                 break;
         case -ENOSPC:
         case -EROFS: 
index 9e8bcae..cbebdbb 100644 (file)
@@ -68,7 +68,8 @@ static quota_interface_t *quota_interface = NULL;
 extern quota_interface_t osc_quota_interface;
 
 static void osc_release_ppga(struct brw_page **ppga, obd_count count);
 extern quota_interface_t osc_quota_interface;
 
 static void osc_release_ppga(struct brw_page **ppga, obd_count count);
-static int brw_interpret(struct ptlrpc_request *request, void *data, int rc);
+static int brw_interpret(const struct lu_env *env,
+                         struct ptlrpc_request *req, void *data, int rc);
 int osc_cleanup(struct obd_device *obd);
 
 /* Pack OSC object metadata for disk storage (LE byte order). */
 int osc_cleanup(struct obd_device *obd);
 
 /* Pack OSC object metadata for disk storage (LE byte order). */
@@ -200,7 +201,8 @@ static inline void osc_set_capa_size(struct ptlrpc_request *req,
                 ;
 }
 
                 ;
 }
 
-static int osc_getattr_interpret(struct ptlrpc_request *req,
+static int osc_getattr_interpret(const struct lu_env *env,
+                                 struct ptlrpc_request *req,
                                  struct osc_async_args *aa, int rc)
 {
         struct ost_body *body;
                                  struct osc_async_args *aa, int rc)
 {
         struct ost_body *body;
@@ -250,7 +252,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo,
         osc_pack_req_body(req, oinfo);
 
         ptlrpc_request_set_replen(req);
         osc_pack_req_body(req, oinfo);
 
         ptlrpc_request_set_replen(req);
-        req->rq_interpret_reply = osc_getattr_interpret;
+        req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_getattr_interpret;
 
         CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
 
         CLASSERT(sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
@@ -345,7 +347,8 @@ out:
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int osc_setattr_interpret(struct ptlrpc_request *req,
+static int osc_setattr_interpret(const struct lu_env *env,
+                                 struct ptlrpc_request *req,
                                  struct osc_async_args *aa, int rc)
 {
         struct ost_body *body;
                                  struct osc_async_args *aa, int rc)
 {
         struct ost_body *body;
@@ -393,12 +396,13 @@ static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
                 oinfo->oi_oa->o_lcookie = *oti->oti_logcookies;
         }
 
                 oinfo->oi_oa->o_lcookie = *oti->oti_logcookies;
         }
 
-        /* do mds to ost setattr asynchronouly */
+        /* do mds to ost setattr asynchronously */
         if (!rqset) {
                 /* Do not wait for response. */
                 ptlrpcd_add_req(req);
         } else {
         if (!rqset) {
                 /* Do not wait for response. */
                 ptlrpcd_add_req(req);
         } else {
-                req->rq_interpret_reply = osc_setattr_interpret;
+                req->rq_interpret_reply =
+                        (ptlrpc_interpterer_t)osc_setattr_interpret;
 
                 CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
                 aa = ptlrpc_req_async_args(req);
 
                 CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
                 aa = ptlrpc_req_async_args(req);
@@ -495,7 +499,8 @@ out:
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int osc_punch_interpret(struct ptlrpc_request *req,
+static int osc_punch_interpret(const struct lu_env *env,
+                               struct ptlrpc_request *req,
                                struct osc_async_args *aa, int rc)
 {
         struct ost_body *body;
                                struct osc_async_args *aa, int rc)
 {
         struct ost_body *body;
@@ -552,7 +557,7 @@ static int osc_punch(struct obd_export *exp, struct obd_info *oinfo,
         ptlrpc_request_set_replen(req);
 
 
         ptlrpc_request_set_replen(req);
 
 
-        req->rq_interpret_reply = osc_punch_interpret;
+        req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_punch_interpret;
         CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         aa->aa_oi = oinfo;
         CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         aa->aa_oi = oinfo;
@@ -639,7 +644,8 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
         RETURN(count);
 }
 
         RETURN(count);
 }
 
-static int osc_destroy_interpret(struct ptlrpc_request *req, void *data,
+static int osc_destroy_interpret(const struct lu_env *env,
+                                 struct ptlrpc_request *req, void *data,
                                  int rc)
 {
         struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
                                  int rc)
 {
         struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
@@ -2038,7 +2044,8 @@ static void osc_ap_completion(struct client_obd *cli, struct obdo *oa,
         EXIT;
 }
 
         EXIT;
 }
 
-static int brw_interpret(struct ptlrpc_request *req, void *data, int rc)
+static int brw_interpret(const struct lu_env *env,
+                         struct ptlrpc_request *req, void *data, int rc)
 {
         struct osc_brw_async_args *aa = data;
         struct client_obd *cli;
 {
         struct osc_brw_async_args *aa = data;
         struct client_obd *cli;
@@ -3094,7 +3101,8 @@ static int osc_enqueue_fini(struct obd_device *obd, struct ptlrpc_request *req,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int osc_enqueue_interpret(struct ptlrpc_request *req,
+static int osc_enqueue_interpret(const struct lu_env *env,
+                                 struct ptlrpc_request *req,
                                  struct osc_enqueue_args *aa, int rc)
 {
         int intent = aa->oa_oi->oi_flags & LDLM_FL_HAS_INTENT;
                                  struct osc_enqueue_args *aa, int rc)
 {
         int intent = aa->oa_oi->oi_flags & LDLM_FL_HAS_INTENT;
@@ -3237,7 +3245,8 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
                         aa->oa_ei = einfo;
                         aa->oa_exp = exp;
 
                         aa->oa_ei = einfo;
                         aa->oa_exp = exp;
 
-                        req->rq_interpret_reply = osc_enqueue_interpret;
+                        req->rq_interpret_reply =
+                                (ptlrpc_interpterer_t)osc_enqueue_interpret;
                         ptlrpc_set_add_req(rqset, req);
                 } else if (intent) {
                         ptlrpc_req_finished(req);
                         ptlrpc_set_add_req(rqset, req);
                 } else if (intent) {
                         ptlrpc_req_finished(req);
@@ -3374,7 +3383,7 @@ static int osc_statfs_async(struct obd_device *obd, struct obd_info *oinfo,
                 req->rq_no_delay = 1;
         }
 
                 req->rq_no_delay = 1;
         }
 
-        req->rq_interpret_reply = osc_statfs_interpret;
+        req->rq_interpret_reply = (ptlrpc_interpterer_t)osc_statfs_interpret;
         CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         aa->aa_oi = oinfo;
         CLASSERT (sizeof(*aa) <= sizeof(req->rq_async_args));
         aa = ptlrpc_req_async_args(req);
         aa->aa_oi = oinfo;
@@ -3690,7 +3699,8 @@ static int osc_get_info(struct obd_export *exp, obd_count keylen,
         RETURN(-EINVAL);
 }
 
         RETURN(-EINVAL);
 }
 
-static int osc_setinfo_mds_conn_interpret(struct ptlrpc_request *req,
+static int osc_setinfo_mds_conn_interpret(const struct lu_env *env,
+                                          struct ptlrpc_request *req,
                                           void *aa, int rc)
 {
         struct llog_ctxt *ctxt;
                                           void *aa, int rc)
 {
         struct llog_ctxt *ctxt;
@@ -3818,7 +3828,7 @@ static int osc_set_info_async(struct obd_export *exp, obd_count keylen,
 
         ptlrpc_request_set_replen(req);
         ptlrpc_set_add_req(set, req);
 
         ptlrpc_request_set_replen(req);
         ptlrpc_set_add_req(set, req);
-        ptlrpc_check_set(set);
+        ptlrpc_check_set(NULL, set);
 
         RETURN(0);
 }
 
         RETURN(0);
 }
index 5171086..79755d7 100644 (file)
@@ -723,14 +723,13 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set)
                 if (req->rq_phase == RQ_PHASE_NEW) {
 
                         if (req->rq_interpret_reply != NULL) {
                 if (req->rq_phase == RQ_PHASE_NEW) {
 
                         if (req->rq_interpret_reply != NULL) {
-                                int (*interpreter)(struct ptlrpc_request *,
-                                                   void *, int) =
+                                ptlrpc_interpterer_t interpreter =
                                         req->rq_interpret_reply;
 
                                 /* higher level (i.e. LOV) failed;
                                  * let the sub reqs clean up */
                                 req->rq_status = -EBADR;
                                         req->rq_interpret_reply;
 
                                 /* higher level (i.e. LOV) failed;
                                  * let the sub reqs clean up */
                                 req->rq_status = -EBADR;
-                                interpreter(req, &req->rq_async_args,
+                                interpreter(NULL, req, &req->rq_async_args,
                                             req->rq_status);
                         }
                         set->set_remaining--;
                                             req->rq_status);
                         }
                         set->set_remaining--;
@@ -1126,7 +1125,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req)
 }
 
 /* this sends any unsent RPCs in @set and returns TRUE if all are sent */
 }
 
 /* this sends any unsent RPCs in @set and returns TRUE if all are sent */
-int ptlrpc_check_set(struct ptlrpc_request_set *set)
+int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
 {
         struct list_head *tmp;
         int force_timer_recalc = 0;
 {
         struct list_head *tmp;
         int force_timer_recalc = 0;
@@ -1352,9 +1351,10 @@ int ptlrpc_check_set(struct ptlrpc_request_set *set)
                         ptlrpc_unregister_bulk (req);
 
                 if (req->rq_interpret_reply != NULL) {
                         ptlrpc_unregister_bulk (req);
 
                 if (req->rq_interpret_reply != NULL) {
-                        int (*interpreter)(struct ptlrpc_request *,void *,int) =
+                        ptlrpc_interpterer_t interpreter =
                                 req->rq_interpret_reply;
                                 req->rq_interpret_reply;
-                        req->rq_status = interpreter(req, &req->rq_async_args,
+                        req->rq_status = interpreter(NULL, req,
+                                                     &req->rq_async_args,
                                                      req->rq_status);
                 }
                 req->rq_phase = RQ_PHASE_COMPLETE;
                                                      req->rq_status);
                 }
                 req->rq_phase = RQ_PHASE_COMPLETE;
@@ -1577,7 +1577,8 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
                 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout ? timeout : 1),
                                        ptlrpc_expired_set,
                                        ptlrpc_interrupted_set, set);
                 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout ? timeout : 1),
                                        ptlrpc_expired_set,
                                        ptlrpc_interrupted_set, set);
-                rc = l_wait_event(set->set_waitq, ptlrpc_check_set(set), &lwi);
+                rc = l_wait_event(set->set_waitq,
+                                  ptlrpc_check_set(NULL, set), &lwi);
 
                 LASSERT(rc == 0 || rc == -EINTR || rc == -ETIMEDOUT);
 
 
                 LASSERT(rc == 0 || rc == -EINTR || rc == -ETIMEDOUT);
 
@@ -2186,7 +2187,8 @@ struct ptlrpc_replay_async_args {
         int praa_old_status;
 };
 
         int praa_old_status;
 };
 
-static int ptlrpc_replay_interpret(struct ptlrpc_request *req,
+static int ptlrpc_replay_interpret(const struct lu_env *env,
+                                   struct ptlrpc_request *req,
                                     void * data, int rc)
 {
         struct ptlrpc_replay_async_args *aa = data;
                                     void * data, int rc)
 {
         struct ptlrpc_replay_async_args *aa = data;
index cae29ec..cd1d56b 100644 (file)
@@ -79,7 +79,8 @@ do {                                            \
 } while(0)
 
 
 } while(0)
 
 
-static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
+static int ptlrpc_connect_interpret(const struct lu_env *env,
+                                    struct ptlrpc_request *request,
                                     void * data, int rc);
 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
 
                                     void * data, int rc);
 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
 
@@ -656,7 +657,8 @@ static void ptlrpc_maybe_ping_import_soon(struct obd_import *imp)
         EXIT;
 }
 
         EXIT;
 }
 
-static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
+static int ptlrpc_connect_interpret(const struct lu_env *env,
+                                    struct ptlrpc_request *request,
                                     void * data, int rc)
 {
         struct ptlrpc_connect_async_args *aa = data;
                                     void * data, int rc)
 {
         struct ptlrpc_connect_async_args *aa = data;
@@ -1039,7 +1041,8 @@ out:
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-static int completed_replay_interpret(struct ptlrpc_request *req,
+static int completed_replay_interpret(const struct lu_env *env,
+                                      struct ptlrpc_request *req,
                                     void * data, int rc)
 {
         ENTRY;
                                     void * data, int rc)
 {
         ENTRY;
index 9a51022..0da3caa 100644 (file)
@@ -642,7 +642,7 @@ static int pinger_check_rpcs(void *arg)
         }
 
 do_check_set:
         }
 
 do_check_set:
-        rc = ptlrpc_check_set(set);
+        rc = ptlrpc_check_set(NULL, set);
 
         /* not finished, and we are not expired, simply return */
         if (!rc && cfs_time_before(curtime, cfs_time_add(pd->pd_this_ping,
 
         /* not finished, and we are not expired, simply return */
         if (!rc && cfs_time_before(curtime, cfs_time_add(pd->pd_this_ping,
index b87dde6..934e1e7 100644 (file)
@@ -84,8 +84,7 @@ void ptlrpcd_add_req(struct ptlrpc_request *req)
 
         rc = ptlrpc_set_add_new_req(pc, req);
         if (rc) {
 
         rc = ptlrpc_set_add_new_req(pc, req);
         if (rc) {
-                int (*interpreter)(struct ptlrpc_request *,
-                                   void *, int);
+                ptlrpc_interpterer_t interpreter;
                                    
                 interpreter = req->rq_interpret_reply;
 
                                    
                 interpreter = req->rq_interpret_reply;
 
@@ -97,14 +96,14 @@ void ptlrpcd_add_req(struct ptlrpc_request *req)
                  * resources.
                  */
                 req->rq_status = -EBADR;
                  * resources.
                  */
                 req->rq_status = -EBADR;
-                interpreter(req, &req->rq_async_args,
+                interpreter(NULL, req, &req->rq_async_args,
                             req->rq_status);
                 req->rq_set = NULL;
                 ptlrpc_req_finished(req);
         }
 }
 
                             req->rq_status);
                 req->rq_set = NULL;
                 ptlrpc_req_finished(req);
         }
 }
 
-static int ptlrpcd_check(struct ptlrpcd_ctl *pc)
+static int ptlrpcd_check(const struct lu_env *env, struct ptlrpcd_ctl *pc)
 {
         struct list_head *tmp, *pos;
         struct ptlrpc_request *req;
 {
         struct list_head *tmp, *pos;
         struct ptlrpc_request *req;
@@ -127,7 +126,7 @@ static int ptlrpcd_check(struct ptlrpcd_ctl *pc)
         spin_unlock(&pc->pc_set->set_new_req_lock);
 
         if (pc->pc_set->set_remaining) {
         spin_unlock(&pc->pc_set->set_new_req_lock);
 
         if (pc->pc_set->set_remaining) {
-                rc = rc | ptlrpc_check_set(pc->pc_set);
+                rc = rc | ptlrpc_check_set(env, pc->pc_set);
 
                 /* 
                  * XXX: our set never completes, so we prune the completed
 
                 /* 
                  * XXX: our set never completes, so we prune the completed
@@ -189,7 +188,10 @@ static int ptlrpcd(void *arg)
                 timeout = cfs_time_seconds(ptlrpc_set_next_timeout(pc->pc_set));
                 lwi = LWI_TIMEOUT(timeout, ptlrpc_expired_set, pc->pc_set);
 
                 timeout = cfs_time_seconds(ptlrpc_set_next_timeout(pc->pc_set));
                 lwi = LWI_TIMEOUT(timeout, ptlrpc_expired_set, pc->pc_set);
 
-                l_wait_event(pc->pc_set->set_waitq, ptlrpcd_check(pc), &lwi);
+                lu_context_enter(&pc->pc_env.le_ctx);
+                l_wait_event(pc->pc_set->set_waitq,
+                             ptlrpcd_check(&pc->pc_env, pc), &lwi);
+                lu_context_exit(&pc->pc_env.le_ctx);
 
                 /*
                  * Abort inflight rpcs for forced stop case.
 
                 /*
                  * Abort inflight rpcs for forced stop case.
@@ -214,7 +216,7 @@ out:
         return 0;
 }
 
         return 0;
 }
 
-#else
+#else /* !__KERNEL__ */
 
 int ptlrpcd_check_async_rpcs(void *arg)
 {
 
 int ptlrpcd_check_async_rpcs(void *arg)
 {
@@ -227,14 +229,16 @@ int ptlrpcd_check_async_rpcs(void *arg)
         pc->pc_recurred++;
 
         if (pc->pc_recurred == 1) {
         pc->pc_recurred++;
 
         if (pc->pc_recurred == 1) {
-                rc = ptlrpcd_check(pc);
+                lu_context_enter(&pc->pc_env.le_ctx);
+                rc = ptlrpcd_check(&pc->pc_env, pc);
+                lu_context_exit(&pc->pc_env.le_ctx);
                 if (!rc)
                         ptlrpc_expired_set(pc->pc_set);
                 /* 
                  * XXX: send replay requests. 
                  */
                 if (pc == &ptlrpcd_recovery_pc)
                 if (!rc)
                         ptlrpc_expired_set(pc->pc_set);
                 /* 
                  * XXX: send replay requests. 
                  */
                 if (pc == &ptlrpcd_recovery_pc)
-                        rc = ptlrpcd_check(pc);
+                        rc = ptlrpcd_check(&pc->pc_env, pc);
         }
 
         pc->pc_recurred--;
         }
 
         pc->pc_recurred--;
@@ -253,7 +257,7 @@ int ptlrpcd_idle(void *arg)
 
 int ptlrpcd_start(char *name, struct ptlrpcd_ctl *pc)
 {
 
 int ptlrpcd_start(char *name, struct ptlrpcd_ctl *pc)
 {
-        int rc = 0;
+        int rc;
         ENTRY;
  
         /* 
         ENTRY;
  
         /* 
@@ -269,14 +273,24 @@ int ptlrpcd_start(char *name, struct ptlrpcd_ctl *pc)
         init_completion(&pc->pc_finishing);
         spin_lock_init(&pc->pc_lock);
         snprintf (pc->pc_name, sizeof (pc->pc_name), name);
         init_completion(&pc->pc_finishing);
         spin_lock_init(&pc->pc_lock);
         snprintf (pc->pc_name, sizeof (pc->pc_name), name);
-
         pc->pc_set = ptlrpc_prep_set();
         if (pc->pc_set == NULL)
                 GOTO(out, rc = -ENOMEM);
         pc->pc_set = ptlrpc_prep_set();
         if (pc->pc_set == NULL)
                 GOTO(out, rc = -ENOMEM);
+        /*
+         * So far only "client" ptlrpcd uses an environment. In the future,
+         * ptlrpcd thread (or a thread-set) has to be given an argument,
+         * describing its "scope".
+         */
+        rc = lu_context_init(&pc->pc_env.le_ctx, LCT_CL_THREAD|LCT_REMEMBER);
+        if (rc != 0) {
+                ptlrpc_set_destroy(pc->pc_set);
+                GOTO(out, rc);
+        }
 
 #ifdef __KERNEL__
         rc = cfs_kernel_thread(ptlrpcd, pc, 0);
         if (rc < 0)  {
 
 #ifdef __KERNEL__
         rc = cfs_kernel_thread(ptlrpcd, pc, 0);
         if (rc < 0)  {
+                lu_context_fini(&pc->pc_env.le_ctx);
                 ptlrpc_set_destroy(pc->pc_set);
                 GOTO(out, rc);
         }
                 ptlrpc_set_destroy(pc->pc_set);
                 GOTO(out, rc);
         }
@@ -313,6 +327,7 @@ void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force)
         liblustre_deregister_wait_callback(pc->pc_wait_callback);
         liblustre_deregister_idle_callback(pc->pc_idle_callback);
 #endif
         liblustre_deregister_wait_callback(pc->pc_wait_callback);
         liblustre_deregister_idle_callback(pc->pc_idle_callback);
 #endif
+        lu_context_fini(&pc->pc_env.le_ctx);
         ptlrpc_set_destroy(pc->pc_set);
 }
 
         ptlrpc_set_destroy(pc->pc_set);
 }
 
index 60e8a13..716866c 100644 (file)
@@ -149,7 +149,8 @@ static void llcd_print(struct llog_canceld_ctxt *llcd,
  * in cleanup time when all inflight rpcs aborted.
  */
 static int 
  * in cleanup time when all inflight rpcs aborted.
  */
 static int 
-llcd_interpret(struct ptlrpc_request *req, void *noused, int rc)
+llcd_interpret(const struct lu_env *env,
+               struct ptlrpc_request *req, void *noused, int rc)
 {
         struct llog_canceld_ctxt *llcd = req->rq_async_args.pointer_arg[0];
         CDEBUG(D_RPCTRACE, "Sent llcd %p (%d)\n", llcd, rc);
 {
         struct llog_canceld_ctxt *llcd = req->rq_async_args.pointer_arg[0];
         CDEBUG(D_RPCTRACE, "Sent llcd %p (%d)\n", llcd, rc);
@@ -231,7 +232,7 @@ static int llcd_send(struct llog_canceld_ctxt *llcd)
         /* bug 5515 */
         req->rq_request_portal = LDLM_CANCEL_REQUEST_PORTAL;
         req->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
         /* bug 5515 */
         req->rq_request_portal = LDLM_CANCEL_REQUEST_PORTAL;
         req->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
-        req->rq_interpret_reply = llcd_interpret;
+        req->rq_interpret_reply = (ptlrpc_interpterer_t)llcd_interpret;
         req->rq_async_args.pointer_arg[0] = llcd;
         rc = ptlrpc_set_add_new_req(&lcm->lcm_pc, req);
         if (rc) {
         req->rq_async_args.pointer_arg[0] = llcd;
         rc = ptlrpc_set_add_new_req(&lcm->lcm_pc, req);
         if (rc) {
index 0e8d63f..2b7635f 100644 (file)
@@ -559,7 +559,8 @@ struct dqacq_async_args {
         struct lustre_qunit *aa_qunit;
 };
 
         struct lustre_qunit *aa_qunit;
 };
 
-static int dqacq_interpret(struct ptlrpc_request *req, void *data, int rc)
+static int dqacq_interpret(const struct lu_env *env,
+                           struct ptlrpc_request *req, void *data, int rc)
 {
         struct dqacq_async_args *aa = (struct dqacq_async_args *)data;
         struct lustre_quota_ctxt *qctxt = aa->aa_ctxt;
 {
         struct dqacq_async_args *aa = (struct dqacq_async_args *)data;
         struct lustre_quota_ctxt *qctxt = aa->aa_ctxt;