diff options
-rw-r--r-- | include/net/9p/9p.h | 2 | ||||
-rw-r--r-- | net/9p/client.c | 23 |
2 files changed, 18 insertions, 7 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 7aefa6d975ac..eaa45f932970 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h | |||
@@ -688,7 +688,7 @@ struct p9_rwstat { | |||
688 | * @id: protocol operating identifier of type &p9_msg_t | 688 | * @id: protocol operating identifier of type &p9_msg_t |
689 | * @tag: transaction id of the request | 689 | * @tag: transaction id of the request |
690 | * @offset: used by marshalling routines to track currentposition in buffer | 690 | * @offset: used by marshalling routines to track currentposition in buffer |
691 | * @capacity: used by marshalling routines to track total capacity | 691 | * @capacity: used by marshalling routines to track total malloc'd capacity |
692 | * @pubuf: Payload user buffer given by the caller | 692 | * @pubuf: Payload user buffer given by the caller |
693 | * @pubuf: Payload kernel buffer given by the caller | 693 | * @pubuf: Payload kernel buffer given by the caller |
694 | * @pbuf_size: pubuf/pkbuf(only one will be !NULL) size to be read/write. | 694 | * @pbuf_size: pubuf/pkbuf(only one will be !NULL) size to be read/write. |
diff --git a/net/9p/client.c b/net/9p/client.c index 251abb1699c4..43ec78af4547 100644 --- a/net/9p/client.c +++ b/net/9p/client.c | |||
@@ -229,10 +229,23 @@ static struct p9_req_t *p9_tag_alloc(struct p9_client *c, u16 tag) | |||
229 | return ERR_PTR(-ENOMEM); | 229 | return ERR_PTR(-ENOMEM); |
230 | } | 230 | } |
231 | init_waitqueue_head(req->wq); | 231 | init_waitqueue_head(req->wq); |
232 | req->tc = kmalloc(sizeof(struct p9_fcall)+c->msize, | 232 | if ((c->trans_mod->pref & P9_TRANS_PREF_PAYLOAD_MASK) == |
233 | GFP_KERNEL); | 233 | P9_TRANS_PREF_PAYLOAD_SEP) { |
234 | req->rc = kmalloc(sizeof(struct p9_fcall)+c->msize, | 234 | int alloc_msize = min(c->msize, 4096); |
235 | GFP_KERNEL); | 235 | req->tc = kmalloc(sizeof(struct p9_fcall)+alloc_msize, |
236 | GFP_KERNEL); | ||
237 | req->tc->capacity = alloc_msize; | ||
238 | req->rc = kmalloc(sizeof(struct p9_fcall)+alloc_msize, | ||
239 | GFP_KERNEL); | ||
240 | req->rc->capacity = alloc_msize; | ||
241 | } else { | ||
242 | req->tc = kmalloc(sizeof(struct p9_fcall)+c->msize, | ||
243 | GFP_KERNEL); | ||
244 | req->tc->capacity = c->msize; | ||
245 | req->rc = kmalloc(sizeof(struct p9_fcall)+c->msize, | ||
246 | GFP_KERNEL); | ||
247 | req->rc->capacity = c->msize; | ||
248 | } | ||
236 | if ((!req->tc) || (!req->rc)) { | 249 | if ((!req->tc) || (!req->rc)) { |
237 | printk(KERN_ERR "Couldn't grow tag array\n"); | 250 | printk(KERN_ERR "Couldn't grow tag array\n"); |
238 | kfree(req->tc); | 251 | kfree(req->tc); |
@@ -243,9 +256,7 @@ static struct p9_req_t *p9_tag_alloc(struct p9_client *c, u16 tag) | |||
243 | return ERR_PTR(-ENOMEM); | 256 | return ERR_PTR(-ENOMEM); |
244 | } | 257 | } |
245 | req->tc->sdata = (char *) req->tc + sizeof(struct p9_fcall); | 258 | req->tc->sdata = (char *) req->tc + sizeof(struct p9_fcall); |
246 | req->tc->capacity = c->msize; | ||
247 | req->rc->sdata = (char *) req->rc + sizeof(struct p9_fcall); | 259 | req->rc->sdata = (char *) req->rc + sizeof(struct p9_fcall); |
248 | req->rc->capacity = c->msize; | ||
249 | } | 260 | } |
250 | 261 | ||
251 | p9pdu_reset(req->tc); | 262 | p9pdu_reset(req->tc); |