Commit 32c8728d authored by Liang Zhen's avatar Liang Zhen Committed by Greg Kroah-Hartman

staging/lustre/ptlrpc: reorganize ptlrpc_request

ptlrpc_request has some structure members are only for client side,
and some others are only for server side, this patch moved these
members to different structure then putting into an union.

By doing this, size of ptlrpc_request is decreased about 300 bytes,
besides saving memory, it also can reduce memory footprint while
processing.
Signed-off-by: default avatarLiang Zhen <liang.zhen@intel.com>
Reviewed-on: http://review.whamcloud.com/8806
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-181Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarBobi Jam <bobijam@gmail.com>
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fbe04564
......@@ -611,7 +611,6 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request,
lustre_msg_add_version(request->rq_reqmsg, version);
request->rq_send_state = LUSTRE_IMP_FULL;
request->rq_type = PTL_RPC_MSG_REQUEST;
request->rq_export = NULL;
request->rq_req_cbid.cbid_fn = request_out_callback;
request->rq_req_cbid.cbid_arg = request;
......@@ -628,19 +627,7 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request,
ptlrpc_at_set_req_timeout(request);
spin_lock_init(&request->rq_lock);
INIT_LIST_HEAD(&request->rq_list);
INIT_LIST_HEAD(&request->rq_timed_list);
INIT_LIST_HEAD(&request->rq_replay_list);
INIT_LIST_HEAD(&request->rq_ctx_chain);
INIT_LIST_HEAD(&request->rq_set_chain);
INIT_LIST_HEAD(&request->rq_history_list);
INIT_LIST_HEAD(&request->rq_exp_list);
init_waitqueue_head(&request->rq_reply_waitq);
init_waitqueue_head(&request->rq_set_waitq);
request->rq_xid = ptlrpc_next_xid();
atomic_set(&request->rq_refcount, 1);
lustre_msg_set_opc(request->rq_reqmsg, opcode);
return 0;
......@@ -718,7 +705,9 @@ struct ptlrpc_request *__ptlrpc_request_alloc(struct obd_import *imp,
request = ptlrpc_prep_req_from_pool(pool);
if (request) {
LASSERTF((unsigned long)imp > 0x1000, "%p\n", imp);
ptlrpc_cli_req_init(request);
LASSERTF((unsigned long)imp > 0x1000, "%p", imp);
LASSERT(imp != LP_POISON);
LASSERTF((unsigned long)imp->imp_client > 0x1000, "%p\n",
imp->imp_client);
......@@ -1235,8 +1224,9 @@ static int after_reply(struct ptlrpc_request *req)
}
ktime_get_real_ts64(&work_start);
timediff = (work_start.tv_sec - req->rq_arrival_time.tv_sec) * USEC_PER_SEC +
(work_start.tv_nsec - req->rq_arrival_time.tv_nsec) / NSEC_PER_USEC;
timediff = (work_start.tv_sec - req->rq_sent_tv.tv_sec) * USEC_PER_SEC +
(work_start.tv_nsec - req->rq_sent_tv.tv_nsec) /
NSEC_PER_USEC;
if (obd->obd_svc_stats) {
lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR,
timediff);
......@@ -2191,11 +2181,11 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
{
if (!request)
return;
LASSERT(!request->rq_srv_req);
LASSERT(!request->rq_export);
LASSERTF(!request->rq_receiving_reply, "req %p\n", request);
LASSERTF(!request->rq_rqbd, "req %p\n", request);/* client-side */
LASSERTF(list_empty(&request->rq_list), "req %p\n", request);
LASSERTF(list_empty(&request->rq_set_chain), "req %p\n", request);
LASSERTF(list_empty(&request->rq_exp_list), "req %p\n", request);
LASSERTF(!request->rq_replay, "req %p\n", request);
req_capsule_fini(&request->rq_pill);
......@@ -2221,10 +2211,7 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
if (request->rq_repbuf)
sptlrpc_cli_free_repbuf(request);
if (request->rq_export) {
class_export_put(request->rq_export);
request->rq_export = NULL;
}
if (request->rq_import) {
class_import_put(request->rq_import);
request->rq_import = NULL;
......@@ -2614,11 +2601,6 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req)
}
EXPORT_SYMBOL(ptlrpc_queue_wait);
struct ptlrpc_replay_async_args {
int praa_old_state;
int praa_old_status;
};
/**
* Callback used for replayed requests reply processing.
* In case of successful reply calls registered request replay callback.
......@@ -3013,10 +2995,11 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
return ERR_PTR(-ENOMEM);
}
ptlrpc_cli_req_init(req);
req->rq_send_state = LUSTRE_IMP_FULL;
req->rq_type = PTL_RPC_MSG_REQUEST;
req->rq_import = class_import_get(imp);
req->rq_export = NULL;
req->rq_interpret_reply = work_interpreter;
/* don't want reply */
req->rq_receiving_reply = 0;
......@@ -3026,16 +3009,6 @@ void *ptlrpcd_alloc_work(struct obd_import *imp,
req->rq_no_resend = 1;
req->rq_pill.rc_fmt = (void *)&worker_format;
spin_lock_init(&req->rq_lock);
INIT_LIST_HEAD(&req->rq_list);
INIT_LIST_HEAD(&req->rq_replay_list);
INIT_LIST_HEAD(&req->rq_set_chain);
INIT_LIST_HEAD(&req->rq_history_list);
INIT_LIST_HEAD(&req->rq_exp_list);
init_waitqueue_head(&req->rq_reply_waitq);
init_waitqueue_head(&req->rq_set_waitq);
atomic_set(&req->rq_refcount, 1);
CLASSERT(sizeof(*args) <= sizeof(req->rq_async_args));
args = ptlrpc_req_async_args(req);
args->cb = cb;
......
......@@ -324,6 +324,7 @@ void request_in_callback(lnet_event_t *ev)
}
}
ptlrpc_srv_req_init(req);
/* NB we ABSOLUTELY RELY on req being zeroed, so pointers are NULL,
* flags are reset and scalars are zero. We only set the message
* size to non-zero if this was a successful receive.
......@@ -337,10 +338,6 @@ void request_in_callback(lnet_event_t *ev)
req->rq_self = ev->target.nid;
req->rq_rqbd = rqbd;
req->rq_phase = RQ_PHASE_NEW;
spin_lock_init(&req->rq_lock);
INIT_LIST_HEAD(&req->rq_timed_list);
INIT_LIST_HEAD(&req->rq_exp_list);
atomic_set(&req->rq_refcount, 1);
if (ev->type == LNET_EVENT_PUT)
CDEBUG(D_INFO, "incoming req@%p x%llu msgsize %u\n",
req, req->rq_xid, ev->mlength);
......
......@@ -633,7 +633,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5);
ktime_get_real_ts64(&request->rq_arrival_time);
ktime_get_real_ts64(&request->rq_sent_tv);
request->rq_sent = ktime_get_real_seconds();
/* We give the server rq_timeout secs to process the req, and
* add the network latency for our local timeout.
......
......@@ -288,4 +288,38 @@ static inline void ptlrpc_reqset_put(struct ptlrpc_request_set *set)
if (atomic_dec_and_test(&set->set_refcount))
kfree(set);
}
/** initialise ptlrpc common fields */
static inline void ptlrpc_req_comm_init(struct ptlrpc_request *req)
{
spin_lock_init(&req->rq_lock);
atomic_set(&req->rq_refcount, 1);
INIT_LIST_HEAD(&req->rq_list);
INIT_LIST_HEAD(&req->rq_replay_list);
}
/** initialise client side ptlrpc request */
static inline void ptlrpc_cli_req_init(struct ptlrpc_request *req)
{
struct ptlrpc_cli_req *cr = &req->rq_cli;
ptlrpc_req_comm_init(req);
INIT_LIST_HEAD(&cr->cr_set_chain);
INIT_LIST_HEAD(&cr->cr_ctx_chain);
init_waitqueue_head(&cr->cr_reply_waitq);
init_waitqueue_head(&cr->cr_set_waitq);
}
/** initialise server side ptlrpc request */
static inline void ptlrpc_srv_req_init(struct ptlrpc_request *req)
{
struct ptlrpc_srv_req *sr = &req->rq_srv;
ptlrpc_req_comm_init(req);
req->rq_srv_req = 1;
INIT_LIST_HEAD(&sr->sr_exp_list);
INIT_LIST_HEAD(&sr->sr_timed_list);
INIT_LIST_HEAD(&sr->sr_hist_list);
}
#endif /* PTLRPC_INTERNAL_H */
......@@ -157,9 +157,9 @@ static int ptlrpcd_users;
void ptlrpcd_wake(struct ptlrpc_request *req)
{
struct ptlrpc_request_set *rq_set = req->rq_set;
struct ptlrpc_request_set *set = req->rq_set;
wake_up(&rq_set->set_waitq);
wake_up(&set->set_waitq);
}
EXPORT_SYMBOL(ptlrpcd_wake);
......
......@@ -863,11 +863,9 @@ int sptlrpc_import_check_ctx(struct obd_import *imp)
if (!req)
return -ENOMEM;
spin_lock_init(&req->rq_lock);
ptlrpc_cli_req_init(req);
atomic_set(&req->rq_refcount, 10000);
INIT_LIST_HEAD(&req->rq_ctx_chain);
init_waitqueue_head(&req->rq_reply_waitq);
init_waitqueue_head(&req->rq_set_waitq);
req->rq_import = imp;
req->rq_flvr = sec->ps_flvr;
req->rq_cli_ctx = ctx;
......@@ -1047,6 +1045,8 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
if (!early_req)
return -ENOMEM;
ptlrpc_cli_req_init(early_req);
early_size = req->rq_nob_received;
early_bufsz = size_roundup_power2(early_size);
early_buf = libcfs_kvzalloc(early_bufsz, GFP_NOFS);
......@@ -1095,7 +1095,6 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req,
memcpy(early_buf, req->rq_repbuf, early_size);
spin_unlock(&req->rq_lock);
spin_lock_init(&early_req->rq_lock);
early_req->rq_cli_ctx = sptlrpc_cli_ctx_get(req->rq_cli_ctx);
early_req->rq_flvr = req->rq_flvr;
early_req->rq_repbuf = early_buf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment