diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-09-18 16:20:36 -0700 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 21:46:31 -0500 |
commit | f4e49cd2dce2ccac6feae64fbb4e90f7d8baf370 (patch) | |
tree | 61f8e5243dd4883d91c80ec60f267d5bed2d1f1a /fs/cifs/file.c | |
parent | 67c1f5295150eb86d065d57b4515a472ecbf008f (diff) | |
download | linux-f4e49cd2dce2ccac6feae64fbb4e90f7d8baf370.tar.bz2 |
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: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r-- | fs/cifs/file.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 8a781226ae33..61b7c834069f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2410,19 +2410,27 @@ ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov, } 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 kvec *iov; - rdata = kzalloc(sizeof(*rdata) + - sizeof(struct kvec) * nr_vecs, GFP_KERNEL); + iov = kzalloc(sizeof(*iov) * (nr_pages + 1), GFP_KERNEL); + if (!iov) + return (struct cifs_readdata *)iov; + + rdata = kzalloc(sizeof(*rdata), GFP_KERNEL); if (rdata != NULL) { kref_init(&rdata->refcount); INIT_LIST_HEAD(&rdata->list); init_completion(&rdata->done); INIT_WORK(&rdata->work, complete); INIT_LIST_HEAD(&rdata->pages); + rdata->iov = iov; + } else { + kfree(iov); } + return rdata; } @@ -2435,6 +2443,7 @@ cifs_readdata_release(struct kref *refcount) if (rdata->cfile) cifsFileInfo_put(rdata->cfile); + kfree(rdata->iov); kfree(rdata); } |