aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-09-18 19:20:36 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:31 -0400
commitf4e49cd2dce2ccac6feae64fbb4e90f7d8baf370 (patch)
tree61f8e5243dd4883d91c80ec60f267d5bed2d1f1a
parent67c1f5295150eb86d065d57b4515a472ecbf008f (diff)
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>
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/file.c15
2 files changed, 13 insertions, 4 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index cc70ac0bac47..737289b50ca5 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -982,7 +982,7 @@ struct cifs_readdata {
982 int (*marshal_iov) (struct cifs_readdata *rdata, 982 int (*marshal_iov) (struct cifs_readdata *rdata,
983 unsigned int remaining); 983 unsigned int remaining);
984 unsigned int nr_iov; 984 unsigned int nr_iov;
985 struct kvec iov[1]; 985 struct kvec *iov;
986}; 986};
987 987
988struct cifs_writedata; 988struct cifs_writedata;
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,
2410} 2410}
2411 2411
2412static struct cifs_readdata * 2412static struct cifs_readdata *
2413cifs_readdata_alloc(unsigned int nr_vecs, work_func_t complete) 2413cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
2414{ 2414{
2415 struct cifs_readdata *rdata; 2415 struct cifs_readdata *rdata;
2416 struct kvec *iov;
2416 2417
2417 rdata = kzalloc(sizeof(*rdata) + 2418 iov = kzalloc(sizeof(*iov) * (nr_pages + 1), GFP_KERNEL);
2418 sizeof(struct kvec) * nr_vecs, GFP_KERNEL); 2419 if (!iov)
2420 return (struct cifs_readdata *)iov;
2421
2422 rdata = kzalloc(sizeof(*rdata), GFP_KERNEL);
2419 if (rdata != NULL) { 2423 if (rdata != NULL) {
2420 kref_init(&rdata->refcount); 2424 kref_init(&rdata->refcount);
2421 INIT_LIST_HEAD(&rdata->list); 2425 INIT_LIST_HEAD(&rdata->list);
2422 init_completion(&rdata->done); 2426 init_completion(&rdata->done);
2423 INIT_WORK(&rdata->work, complete); 2427 INIT_WORK(&rdata->work, complete);
2424 INIT_LIST_HEAD(&rdata->pages); 2428 INIT_LIST_HEAD(&rdata->pages);
2429 rdata->iov = iov;
2430 } else {
2431 kfree(iov);
2425 } 2432 }
2433
2426 return rdata; 2434 return rdata;
2427} 2435}
2428 2436
@@ -2435,6 +2443,7 @@ cifs_readdata_release(struct kref *refcount)
2435 if (rdata->cfile) 2443 if (rdata->cfile)
2436 cifsFileInfo_put(rdata->cfile); 2444 cifsFileInfo_put(rdata->cfile);
2437 2445
2446 kfree(rdata->iov);
2438 kfree(rdata); 2447 kfree(rdata);
2439} 2448}
2440 2449