hack version of b11058.
int lustre_msg_size);
void (*free_repbuf) (struct ptlrpc_sec *sec,
struct ptlrpc_request *req);
+ int (*enlarge_reqbuf)
+ (struct ptlrpc_sec *sec,
+ struct ptlrpc_request *req,
+ int segment, int newsize,
+ int move_data);
};
struct ptlrpc_sec_sops {
int sptlrpc_cli_wrap_request(struct ptlrpc_request *req);
int sptlrpc_cli_unwrap_reply(struct ptlrpc_request *req);
int sptlrpc_cli_alloc_reqbuf(struct ptlrpc_request *req, int msgsize);
-int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize);
void sptlrpc_cli_free_reqbuf(struct ptlrpc_request *req);
+int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize);
void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req);
+int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
+ int segment, int newsize, int movedata);
void sptlrpc_request_out_callback(struct ptlrpc_request *req);
/*
static void mdc_realloc_openmsg(struct ptlrpc_request *req,
struct mdt_body *body, int size[9])
{
- int new_size, old_size;
- struct lustre_msg *new_msg;
+ int rc;
- LBUG(); // ericm
- /* save old size */
- old_size = lustre_msg_size(lustre_request_magic(req), 9, size);
-
- size[DLM_INTENT_REC_OFF + 4] = body->eadatasize;
- new_size = lustre_msg_size(lustre_request_magic(req), 9, size);
- OBD_ALLOC(new_msg, new_size);
- if (new_msg != NULL) {
- struct lustre_msg *old_msg = req->rq_reqmsg;
-
- DEBUG_REQ(D_INFO, req, "Replace reqmsg for larger EA %u\n",
- body->eadatasize);
-
- CDEBUG(D_INFO, "Copy old msg of size %d to new allocated msg "
- "of size %d\n", old_size, new_size);
-
- memcpy(new_msg, old_msg, old_size);
- lustre_msg_set_buflen(new_msg, DLM_INTENT_REC_OFF + 4,
- body->eadatasize);
-
- spin_lock(&req->rq_lock);
- req->rq_reqmsg = new_msg;
- req->rq_reqlen = new_size;
- spin_unlock(&req->rq_lock);
-
- OBD_FREE(old_msg, old_size);
- } else {
- CERROR("Can't allocate new msg, size %d\n",
- new_size);
+ rc = sptlrpc_cli_enlarge_reqbuf(req, DLM_INTENT_REC_OFF + 4,
+ body->eadatasize, 0);
+ if (rc) {
+ CERROR("Can't enlarge segment %d size to %d\n",
+ DLM_INTENT_REC_OFF + 4, body->eadatasize);
body->valid &= ~OBD_MD_FLEASIZE;
body->eadatasize = 0;
}
policy->sp_cops->free_reqbuf(ctx->cc_sec, req);
}
+int sptlrpc_cli_enlarge_reqbuf(struct ptlrpc_request *req,
+ int segment, int newsize, int movedata)
+{
+ struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
+ struct ptlrpc_sec_policy *policy;
+ struct lustre_msg *msg = req->rq_reqmsg;
+
+ LASSERT(ctx);
+ LASSERT(msg);
+ LASSERT(msg->lm_bufcount > segment);
+ LASSERT(msg->lm_buflens[segment] <= newsize);
+
+ if (msg->lm_buflens[segment] == newsize)
+ return 0;
+
+ policy = ctx->cc_sec->ps_policy;
+ LASSERT(policy->sp_cops->enlarge_reqbuf);
+ return policy->sp_cops->enlarge_reqbuf(ctx->cc_sec, req,
+ segment, newsize, movedata);
+}
+EXPORT_SYMBOL(sptlrpc_cli_enlarge_reqbuf);
+
int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize)
{
struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx;
}
static
+int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
+ struct ptlrpc_request *req,
+ int segment, int newsize, int move_data)
+{
+ struct lustre_msg *oldmsg = req->rq_reqbuf, *newmsg;
+ int oldsize, new_msgsize;
+
+ LASSERT(req->rq_reqbuf);
+ LASSERT(req->rq_reqbuf == req->rq_reqmsg);
+ LASSERT(!move_data); // XXX
+
+ oldsize = oldmsg->lm_buflens[segment];
+ oldmsg->lm_buflens[segment] = newsize;
+
+ new_msgsize = lustre_msg_size(oldmsg->lm_magic,
+ oldmsg->lm_bufcount, oldmsg->lm_buflens);
+
+ /* FIXME need move data!!! */
+ if (req->rq_pool) {
+ req->rq_reqlen = new_msgsize;
+ } else {
+ OBD_ALLOC(newmsg, new_msgsize);
+ if (newmsg == NULL) {
+ oldmsg->lm_buflens[segment] = oldsize;
+ return -ENOMEM;
+ }
+ memcpy(newmsg, oldmsg, req->rq_reqlen);
+
+ OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ req->rq_reqbuf = req->rq_reqmsg = newmsg;
+ req->rq_reqbuf_len = req->rq_reqlen = new_msgsize;
+ }
+
+ return 0;
+}
+
+static
int null_accept(struct ptlrpc_request *req)
{
LASSERT(SEC_FLAVOR_POLICY(req->rq_sec_flavor) == SPTLRPC_POLICY_NULL);
.alloc_repbuf = null_alloc_repbuf,
.free_reqbuf = null_free_reqbuf,
.free_repbuf = null_free_repbuf,
+ .enlarge_reqbuf = null_enlarge_reqbuf,
};
static struct ptlrpc_sec_sops null_sec_sops = {
}
static
+int plain_enlarge_reqbuf(struct ptlrpc_sec *sec,
+ struct ptlrpc_request *req,
+ int segment, int newsize, int move_data)
+{
+ LBUG();
+ return 0;
+}
+
+static
int plain_accept(struct ptlrpc_request *req)
{
struct lustre_msg *msg = req->rq_reqbuf;
.alloc_repbuf = plain_alloc_repbuf,
.free_reqbuf = plain_free_reqbuf,
.free_repbuf = plain_free_repbuf,
+ .enlarge_reqbuf = plain_enlarge_reqbuf,
};
static struct ptlrpc_sec_sops plain_sec_sops = {