Commit f4e49cd2 authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: allocate kvec array for cifs_readdata as a separate allocation

Eventually, we're going to want to append a list of pages to
cifs_readdata instead of a list of kvecs. To prepare for that, turn
the kvec array allocation into a separate one and just keep a
pointer to it in the readdata.
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
parent 67c1f529
...@@ -982,7 +982,7 @@ struct cifs_readdata { ...@@ -982,7 +982,7 @@ struct cifs_readdata {
int (*marshal_iov) (struct cifs_readdata *rdata, int (*marshal_iov) (struct cifs_readdata *rdata,
unsigned int remaining); unsigned int remaining);
unsigned int nr_iov; unsigned int nr_iov;
struct kvec iov[1]; struct kvec *iov;
}; };
struct cifs_writedata; struct cifs_writedata;
......
...@@ -2410,19 +2410,27 @@ ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, ...@@ -2410,19 +2410,27 @@ ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
} }
static struct cifs_readdata * static struct cifs_readdata *
cifs_readdata_alloc(unsigned int nr_vecs, work_func_t complete) cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
{ {
struct cifs_readdata *rdata; struct cifs_readdata *rdata;
struct kvec *iov;
rdata = kzalloc(sizeof(*rdata) + iov = kzalloc(sizeof(*iov) * (nr_pages + 1), GFP_KERNEL);
sizeof(struct kvec) * nr_vecs, GFP_KERNEL); if (!iov)
return (struct cifs_readdata *)iov;
rdata = kzalloc(sizeof(*rdata), GFP_KERNEL);
if (rdata != NULL) { if (rdata != NULL) {
kref_init(&rdata->refcount); kref_init(&rdata->refcount);
INIT_LIST_HEAD(&rdata->list); INIT_LIST_HEAD(&rdata->list);
init_completion(&rdata->done); init_completion(&rdata->done);
INIT_WORK(&rdata->work, complete); INIT_WORK(&rdata->work, complete);
INIT_LIST_HEAD(&rdata->pages); INIT_LIST_HEAD(&rdata->pages);
rdata->iov = iov;
} else {
kfree(iov);
} }
return rdata; return rdata;
} }
...@@ -2435,6 +2443,7 @@ cifs_readdata_release(struct kref *refcount) ...@@ -2435,6 +2443,7 @@ cifs_readdata_release(struct kref *refcount)
if (rdata->cfile) if (rdata->cfile)
cifsFileInfo_put(rdata->cfile); cifsFileInfo_put(rdata->cfile);
kfree(rdata->iov);
kfree(rdata); kfree(rdata);
} }
......
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