aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/internal.h2
-rw-r--r--fs/nfs/nfs3proc.c11
-rw-r--r--fs/nfs/nfs4proc.c22
-rw-r--r--fs/nfs/pagelist.c26
-rw-r--r--fs/nfs/proc.c11
-rw-r--r--fs/nfs/read.c19
-rw-r--r--fs/nfs/write.c19
-rw-r--r--include/linux/nfs_page.h2
-rw-r--r--include/linux/nfs_xdr.h3
9 files changed, 46 insertions, 69 deletions
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 9d6a40eae11c..1959260f8c57 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -241,6 +241,8 @@ struct nfs_rw_header *nfs_rw_header_alloc(const struct nfs_rw_ops *);
241void nfs_rw_header_free(struct nfs_pgio_header *); 241void nfs_rw_header_free(struct nfs_pgio_header *);
242struct nfs_pgio_data *nfs_pgio_data_alloc(struct nfs_pgio_header *, unsigned int); 242struct nfs_pgio_data *nfs_pgio_data_alloc(struct nfs_pgio_header *, unsigned int);
243void nfs_pgio_data_release(struct nfs_pgio_data *); 243void nfs_pgio_data_release(struct nfs_pgio_data *);
244void nfs_pgio_prepare(struct rpc_task *, void *);
245void nfs_pgio_release(void *);
244 246
245static inline void nfs_iocounter_init(struct nfs_io_counter *c) 247static inline void nfs_iocounter_init(struct nfs_io_counter *c)
246{ 248{
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index d235369c3dfb..e7daa42bbc86 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -812,7 +812,7 @@ static void nfs3_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message
812 msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; 812 msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ];
813} 813}
814 814
815static int nfs3_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) 815static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
816{ 816{
817 rpc_call_start(task); 817 rpc_call_start(task);
818 return 0; 818 return 0;
@@ -834,12 +834,6 @@ static void nfs3_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message
834 msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE]; 834 msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
835} 835}
836 836
837static int nfs3_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
838{
839 rpc_call_start(task);
840 return 0;
841}
842
843static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) 837static void nfs3_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
844{ 838{
845 rpc_call_start(task); 839 rpc_call_start(task);
@@ -946,11 +940,10 @@ const struct nfs_rpc_ops nfs_v3_clientops = {
946 .fsinfo = nfs3_proc_fsinfo, 940 .fsinfo = nfs3_proc_fsinfo,
947 .pathconf = nfs3_proc_pathconf, 941 .pathconf = nfs3_proc_pathconf,
948 .decode_dirent = nfs3_decode_dirent, 942 .decode_dirent = nfs3_decode_dirent,
943 .pgio_rpc_prepare = nfs3_proc_pgio_rpc_prepare,
949 .read_setup = nfs3_proc_read_setup, 944 .read_setup = nfs3_proc_read_setup,
950 .read_rpc_prepare = nfs3_proc_read_rpc_prepare,
951 .read_done = nfs3_read_done, 945 .read_done = nfs3_read_done,
952 .write_setup = nfs3_proc_write_setup, 946 .write_setup = nfs3_proc_write_setup,
953 .write_rpc_prepare = nfs3_proc_write_rpc_prepare,
954 .write_done = nfs3_write_done, 947 .write_done = nfs3_write_done,
955 .commit_setup = nfs3_proc_commit_setup, 948 .commit_setup = nfs3_proc_commit_setup,
956 .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare, 949 .commit_rpc_prepare = nfs3_proc_commit_rpc_prepare,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index e793aa91454a..44fb93a66d26 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4089,7 +4089,7 @@ static void nfs4_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message
4089 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); 4089 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0);
4090} 4090}
4091 4091
4092static int nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) 4092static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
4093{ 4093{
4094 if (nfs4_setup_sequence(NFS_SERVER(data->header->inode), 4094 if (nfs4_setup_sequence(NFS_SERVER(data->header->inode),
4095 &data->args.seq_args, 4095 &data->args.seq_args,
@@ -4097,7 +4097,7 @@ static int nfs4_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_dat
4097 task)) 4097 task))
4098 return 0; 4098 return 0;
4099 if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context, 4099 if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context,
4100 data->args.lock_context, FMODE_READ) == -EIO) 4100 data->args.lock_context, data->header->rw_ops->rw_mode) == -EIO)
4101 return -EIO; 4101 return -EIO;
4102 if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags))) 4102 if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags)))
4103 return -EIO; 4103 return -EIO;
@@ -4177,21 +4177,6 @@ static void nfs4_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message
4177 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1); 4177 nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
4178} 4178}
4179 4179
4180static int nfs4_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
4181{
4182 if (nfs4_setup_sequence(NFS_SERVER(data->header->inode),
4183 &data->args.seq_args,
4184 &data->res.seq_res,
4185 task))
4186 return 0;
4187 if (nfs4_set_rw_stateid(&data->args.stateid, data->args.context,
4188 data->args.lock_context, FMODE_WRITE) == -EIO)
4189 return -EIO;
4190 if (unlikely(test_bit(NFS_CONTEXT_BAD, &data->args.context->flags)))
4191 return -EIO;
4192 return 0;
4193}
4194
4195static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) 4180static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
4196{ 4181{
4197 nfs4_setup_sequence(NFS_SERVER(data->inode), 4182 nfs4_setup_sequence(NFS_SERVER(data->inode),
@@ -8432,11 +8417,10 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
8432 .pathconf = nfs4_proc_pathconf, 8417 .pathconf = nfs4_proc_pathconf,
8433 .set_capabilities = nfs4_server_capabilities, 8418 .set_capabilities = nfs4_server_capabilities,
8434 .decode_dirent = nfs4_decode_dirent, 8419 .decode_dirent = nfs4_decode_dirent,
8420 .pgio_rpc_prepare = nfs4_proc_pgio_rpc_prepare,
8435 .read_setup = nfs4_proc_read_setup, 8421 .read_setup = nfs4_proc_read_setup,
8436 .read_rpc_prepare = nfs4_proc_read_rpc_prepare,
8437 .read_done = nfs4_read_done, 8422 .read_done = nfs4_read_done,
8438 .write_setup = nfs4_proc_write_setup, 8423 .write_setup = nfs4_proc_write_setup,
8439 .write_rpc_prepare = nfs4_proc_write_rpc_prepare,
8440 .write_done = nfs4_write_done, 8424 .write_done = nfs4_write_done,
8441 .commit_setup = nfs4_proc_commit_setup, 8425 .commit_setup = nfs4_proc_commit_setup,
8442 .commit_rpc_prepare = nfs4_proc_commit_rpc_prepare, 8426 .commit_rpc_prepare = nfs4_proc_commit_rpc_prepare,
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index ca356fe0836b..0fa211d35e40 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -387,6 +387,32 @@ void nfs_pgio_data_release(struct nfs_pgio_data *data)
387EXPORT_SYMBOL_GPL(nfs_pgio_data_release); 387EXPORT_SYMBOL_GPL(nfs_pgio_data_release);
388 388
389/** 389/**
390 * nfs_pgio_prepare - Prepare pageio data to go over the wire
391 * @task: The current task
392 * @calldata: pageio data to prepare
393 */
394void nfs_pgio_prepare(struct rpc_task *task, void *calldata)
395{
396 struct nfs_pgio_data *data = calldata;
397 int err;
398 err = NFS_PROTO(data->header->inode)->pgio_rpc_prepare(task, data);
399 if (err)
400 rpc_exit(task, err);
401}
402
403/**
404 * nfs_pgio_release - Release pageio data
405 * @calldata: The pageio data to release
406 */
407void nfs_pgio_release(void *calldata)
408{
409 struct nfs_pgio_data *data = calldata;
410 if (data->header->rw_ops->rw_release)
411 data->header->rw_ops->rw_release(data);
412 nfs_pgio_data_release(data);
413}
414
415/**
390 * nfs_pageio_init - initialise a page io descriptor 416 * nfs_pageio_init - initialise a page io descriptor
391 * @desc: pointer to descriptor 417 * @desc: pointer to descriptor
392 * @inode: pointer to inode 418 * @inode: pointer to inode
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index c54829eb2156..c171ce1a8a30 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -599,7 +599,7 @@ static void nfs_proc_read_setup(struct nfs_pgio_data *data, struct rpc_message *
599 msg->rpc_proc = &nfs_procedures[NFSPROC_READ]; 599 msg->rpc_proc = &nfs_procedures[NFSPROC_READ];
600} 600}
601 601
602static int nfs_proc_read_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data) 602static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
603{ 603{
604 rpc_call_start(task); 604 rpc_call_start(task);
605 return 0; 605 return 0;
@@ -621,12 +621,6 @@ static void nfs_proc_write_setup(struct nfs_pgio_data *data, struct rpc_message
621 msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE]; 621 msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE];
622} 622}
623 623
624static int nfs_proc_write_rpc_prepare(struct rpc_task *task, struct nfs_pgio_data *data)
625{
626 rpc_call_start(task);
627 return 0;
628}
629
630static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) 624static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
631{ 625{
632 BUG(); 626 BUG();
@@ -734,11 +728,10 @@ const struct nfs_rpc_ops nfs_v2_clientops = {
734 .fsinfo = nfs_proc_fsinfo, 728 .fsinfo = nfs_proc_fsinfo,
735 .pathconf = nfs_proc_pathconf, 729 .pathconf = nfs_proc_pathconf,
736 .decode_dirent = nfs2_decode_dirent, 730 .decode_dirent = nfs2_decode_dirent,
731 .pgio_rpc_prepare = nfs_proc_pgio_rpc_prepare,
737 .read_setup = nfs_proc_read_setup, 732 .read_setup = nfs_proc_read_setup,
738 .read_rpc_prepare = nfs_proc_read_rpc_prepare,
739 .read_done = nfs_read_done, 733 .read_done = nfs_read_done,
740 .write_setup = nfs_proc_write_setup, 734 .write_setup = nfs_proc_write_setup,
741 .write_rpc_prepare = nfs_proc_write_rpc_prepare,
742 .write_done = nfs_write_done, 735 .write_done = nfs_write_done,
743 .commit_setup = nfs_proc_commit_setup, 736 .commit_setup = nfs_proc_commit_setup,
744 .commit_rpc_prepare = nfs_proc_commit_rpc_prepare, 737 .commit_rpc_prepare = nfs_proc_commit_rpc_prepare,
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 4cf3577bd54e..cfa15e828dd6 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -454,24 +454,10 @@ static void nfs_readpage_result_common(struct rpc_task *task, void *calldata)
454 nfs_readpage_retry(task, data); 454 nfs_readpage_retry(task, data);
455} 455}
456 456
457static void nfs_readpage_release_common(void *calldata)
458{
459 nfs_pgio_data_release(calldata);
460}
461
462void nfs_read_prepare(struct rpc_task *task, void *calldata)
463{
464 struct nfs_pgio_data *data = calldata;
465 int err;
466 err = NFS_PROTO(data->header->inode)->read_rpc_prepare(task, data);
467 if (err)
468 rpc_exit(task, err);
469}
470
471static const struct rpc_call_ops nfs_read_common_ops = { 457static const struct rpc_call_ops nfs_read_common_ops = {
472 .rpc_call_prepare = nfs_read_prepare, 458 .rpc_call_prepare = nfs_pgio_prepare,
473 .rpc_call_done = nfs_readpage_result_common, 459 .rpc_call_done = nfs_readpage_result_common,
474 .rpc_release = nfs_readpage_release_common, 460 .rpc_release = nfs_pgio_release,
475}; 461};
476 462
477/* 463/*
@@ -636,6 +622,7 @@ void nfs_destroy_readpagecache(void)
636} 622}
637 623
638static const struct nfs_rw_ops nfs_rw_read_ops = { 624static const struct nfs_rw_ops nfs_rw_read_ops = {
625 .rw_mode = FMODE_READ,
639 .rw_alloc_header = nfs_readhdr_alloc, 626 .rw_alloc_header = nfs_readhdr_alloc,
640 .rw_free_header = nfs_readhdr_free, 627 .rw_free_header = nfs_readhdr_free,
641}; 628};
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 9c5cde38da45..ae799c96ec2b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1248,15 +1248,6 @@ void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio)
1248EXPORT_SYMBOL_GPL(nfs_pageio_reset_write_mds); 1248EXPORT_SYMBOL_GPL(nfs_pageio_reset_write_mds);
1249 1249
1250 1250
1251void nfs_write_prepare(struct rpc_task *task, void *calldata)
1252{
1253 struct nfs_pgio_data *data = calldata;
1254 int err;
1255 err = NFS_PROTO(data->header->inode)->write_rpc_prepare(task, data);
1256 if (err)
1257 rpc_exit(task, err);
1258}
1259
1260void nfs_commit_prepare(struct rpc_task *task, void *calldata) 1251void nfs_commit_prepare(struct rpc_task *task, void *calldata)
1261{ 1252{
1262 struct nfs_commit_data *data = calldata; 1253 struct nfs_commit_data *data = calldata;
@@ -1278,9 +1269,8 @@ static void nfs_writeback_done_common(struct rpc_task *task, void *calldata)
1278 nfs_writeback_done(task, data); 1269 nfs_writeback_done(task, data);
1279} 1270}
1280 1271
1281static void nfs_writeback_release_common(void *calldata) 1272static void nfs_writeback_release_common(struct nfs_pgio_data *data)
1282{ 1273{
1283 struct nfs_pgio_data *data = calldata;
1284 struct nfs_pgio_header *hdr = data->header; 1274 struct nfs_pgio_header *hdr = data->header;
1285 int status = data->task.tk_status; 1275 int status = data->task.tk_status;
1286 1276
@@ -1294,13 +1284,12 @@ static void nfs_writeback_release_common(void *calldata)
1294 set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags); 1284 set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags);
1295 spin_unlock(&hdr->lock); 1285 spin_unlock(&hdr->lock);
1296 } 1286 }
1297 nfs_pgio_data_release(data);
1298} 1287}
1299 1288
1300static const struct rpc_call_ops nfs_write_common_ops = { 1289static const struct rpc_call_ops nfs_write_common_ops = {
1301 .rpc_call_prepare = nfs_write_prepare, 1290 .rpc_call_prepare = nfs_pgio_prepare,
1302 .rpc_call_done = nfs_writeback_done_common, 1291 .rpc_call_done = nfs_writeback_done_common,
1303 .rpc_release = nfs_writeback_release_common, 1292 .rpc_release = nfs_pgio_release,
1304}; 1293};
1305 1294
1306/* 1295/*
@@ -1918,6 +1907,8 @@ void nfs_destroy_writepagecache(void)
1918} 1907}
1919 1908
1920static const struct nfs_rw_ops nfs_rw_write_ops = { 1909static const struct nfs_rw_ops nfs_rw_write_ops = {
1910 .rw_mode = FMODE_WRITE,
1921 .rw_alloc_header = nfs_writehdr_alloc, 1911 .rw_alloc_header = nfs_writehdr_alloc,
1922 .rw_free_header = nfs_writehdr_free, 1912 .rw_free_header = nfs_writehdr_free,
1913 .rw_release = nfs_writeback_release_common,
1923}; 1914};
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 594812546c25..da00a4d6f470 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -53,8 +53,10 @@ struct nfs_pageio_ops {
53}; 53};
54 54
55struct nfs_rw_ops { 55struct nfs_rw_ops {
56 const fmode_t rw_mode;
56 struct nfs_rw_header *(*rw_alloc_header)(void); 57 struct nfs_rw_header *(*rw_alloc_header)(void);
57 void (*rw_free_header)(struct nfs_rw_header *); 58 void (*rw_free_header)(struct nfs_rw_header *);
59 void (*rw_release)(struct nfs_pgio_data *);
58}; 60};
59 61
60struct nfs_pageio_descriptor { 62struct nfs_pageio_descriptor {
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index a1b91b67145e..adef7bd2d06d 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1429,11 +1429,10 @@ struct nfs_rpc_ops {
1429 struct nfs_pathconf *); 1429 struct nfs_pathconf *);
1430 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); 1430 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1431 int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); 1431 int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int);
1432 int (*pgio_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *);
1432 void (*read_setup) (struct nfs_pgio_data *, struct rpc_message *); 1433 void (*read_setup) (struct nfs_pgio_data *, struct rpc_message *);
1433 int (*read_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *);
1434 int (*read_done) (struct rpc_task *, struct nfs_pgio_data *); 1434 int (*read_done) (struct rpc_task *, struct nfs_pgio_data *);
1435 void (*write_setup) (struct nfs_pgio_data *, struct rpc_message *); 1435 void (*write_setup) (struct nfs_pgio_data *, struct rpc_message *);
1436 int (*write_rpc_prepare)(struct rpc_task *, struct nfs_pgio_data *);
1437 int (*write_done) (struct rpc_task *, struct nfs_pgio_data *); 1436 int (*write_done) (struct rpc_task *, struct nfs_pgio_data *);
1438 void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *); 1437 void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *);
1439 void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *); 1438 void (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *);