aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 13:48:19 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-05-01 15:42:44 -0400
commit778d28172f710184855bcfeadcdd6b46997c4de2 (patch)
treed7aaf6c46d3e408f129a6e514d5684c56d860f9d /fs/nfs
parent7c317fcfbae773e493ecee1c53738db774b1d0ca (diff)
NFSv4: Simplify the NFSv4 REMOVE, LINK and RENAME compounds
Get rid of the post-op GETATTR on the directory in order to reduce the amount of processing done on the server. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4proc.c34
-rw-r--r--fs/nfs/nfs4xdr.c37
2 files changed, 7 insertions, 64 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 619bc1eb157b..c746b0cab499 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2775,7 +2775,6 @@ static int _nfs4_proc_remove(struct inode *dir, struct qstr *name)
2775 .fh = NFS_FH(dir), 2775 .fh = NFS_FH(dir),
2776 .name.len = name->len, 2776 .name.len = name->len,
2777 .name.name = name->name, 2777 .name.name = name->name,
2778 .bitmask = server->attr_bitmask,
2779 }; 2778 };
2780 struct nfs_removeres res = { 2779 struct nfs_removeres res = {
2781 .server = server, 2780 .server = server,
@@ -2785,19 +2784,11 @@ static int _nfs4_proc_remove(struct inode *dir, struct qstr *name)
2785 .rpc_argp = &args, 2784 .rpc_argp = &args,
2786 .rpc_resp = &res, 2785 .rpc_resp = &res,
2787 }; 2786 };
2788 int status = -ENOMEM; 2787 int status;
2789
2790 res.dir_attr = nfs_alloc_fattr();
2791 if (res.dir_attr == NULL)
2792 goto out;
2793 2788
2794 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1); 2789 status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 1);
2795 if (status == 0) { 2790 if (status == 0)
2796 update_changeattr(dir, &res.cinfo); 2791 update_changeattr(dir, &res.cinfo);
2797 nfs_post_op_update_inode(dir, res.dir_attr);
2798 }
2799 nfs_free_fattr(res.dir_attr);
2800out:
2801 return status; 2792 return status;
2802} 2793}
2803 2794
@@ -2819,7 +2810,6 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
2819 struct nfs_removeargs *args = msg->rpc_argp; 2810 struct nfs_removeargs *args = msg->rpc_argp;
2820 struct nfs_removeres *res = msg->rpc_resp; 2811 struct nfs_removeres *res = msg->rpc_resp;
2821 2812
2822 args->bitmask = server->cache_consistency_bitmask;
2823 res->server = server; 2813 res->server = server;
2824 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE]; 2814 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
2825 nfs41_init_sequence(&args->seq_args, &res->seq_res, 1); 2815 nfs41_init_sequence(&args->seq_args, &res->seq_res, 1);
@@ -2844,7 +2834,6 @@ static int nfs4_proc_unlink_done(struct rpc_task *task, struct inode *dir)
2844 if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN) 2834 if (nfs4_async_handle_error(task, res->server, NULL) == -EAGAIN)
2845 return 0; 2835 return 0;
2846 update_changeattr(dir, &res->cinfo); 2836 update_changeattr(dir, &res->cinfo);
2847 nfs_post_op_update_inode(dir, res->dir_attr);
2848 return 1; 2837 return 1;
2849} 2838}
2850 2839
@@ -2855,7 +2844,6 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg, struct inode *dir)
2855 struct nfs_renameres *res = msg->rpc_resp; 2844 struct nfs_renameres *res = msg->rpc_resp;
2856 2845
2857 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME]; 2846 msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME];
2858 arg->bitmask = server->attr_bitmask;
2859 res->server = server; 2847 res->server = server;
2860 nfs41_init_sequence(&arg->seq_args, &res->seq_res, 1); 2848 nfs41_init_sequence(&arg->seq_args, &res->seq_res, 1);
2861} 2849}
@@ -2881,9 +2869,7 @@ static int nfs4_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
2881 return 0; 2869 return 0;
2882 2870
2883 update_changeattr(old_dir, &res->old_cinfo); 2871 update_changeattr(old_dir, &res->old_cinfo);
2884 nfs_post_op_update_inode(old_dir, res->old_fattr);
2885 update_changeattr(new_dir, &res->new_cinfo); 2872 update_changeattr(new_dir, &res->new_cinfo);
2886 nfs_post_op_update_inode(new_dir, res->new_fattr);
2887 return 1; 2873 return 1;
2888} 2874}
2889 2875
@@ -2896,7 +2882,6 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
2896 .new_dir = NFS_FH(new_dir), 2882 .new_dir = NFS_FH(new_dir),
2897 .old_name = old_name, 2883 .old_name = old_name,
2898 .new_name = new_name, 2884 .new_name = new_name,
2899 .bitmask = server->attr_bitmask,
2900 }; 2885 };
2901 struct nfs_renameres res = { 2886 struct nfs_renameres res = {
2902 .server = server, 2887 .server = server,
@@ -2908,21 +2893,11 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
2908 }; 2893 };
2909 int status = -ENOMEM; 2894 int status = -ENOMEM;
2910 2895
2911 res.old_fattr = nfs_alloc_fattr();
2912 res.new_fattr = nfs_alloc_fattr();
2913 if (res.old_fattr == NULL || res.new_fattr == NULL)
2914 goto out;
2915
2916 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); 2896 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
2917 if (!status) { 2897 if (!status) {
2918 update_changeattr(old_dir, &res.old_cinfo); 2898 update_changeattr(old_dir, &res.old_cinfo);
2919 nfs_post_op_update_inode(old_dir, res.old_fattr);
2920 update_changeattr(new_dir, &res.new_cinfo); 2899 update_changeattr(new_dir, &res.new_cinfo);
2921 nfs_post_op_update_inode(new_dir, res.new_fattr);
2922 } 2900 }
2923out:
2924 nfs_free_fattr(res.new_fattr);
2925 nfs_free_fattr(res.old_fattr);
2926 return status; 2901 return status;
2927} 2902}
2928 2903
@@ -2960,18 +2935,15 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *
2960 int status = -ENOMEM; 2935 int status = -ENOMEM;
2961 2936
2962 res.fattr = nfs_alloc_fattr(); 2937 res.fattr = nfs_alloc_fattr();
2963 res.dir_attr = nfs_alloc_fattr(); 2938 if (res.fattr == NULL)
2964 if (res.fattr == NULL || res.dir_attr == NULL)
2965 goto out; 2939 goto out;
2966 2940
2967 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); 2941 status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
2968 if (!status) { 2942 if (!status) {
2969 update_changeattr(dir, &res.cinfo); 2943 update_changeattr(dir, &res.cinfo);
2970 nfs_post_op_update_inode(dir, res.dir_attr);
2971 nfs_post_op_update_inode(inode, res.fattr); 2944 nfs_post_op_update_inode(inode, res.fattr);
2972 } 2945 }
2973out: 2946out:
2974 nfs_free_fattr(res.dir_attr);
2975 nfs_free_fattr(res.fattr); 2947 nfs_free_fattr(res.fattr);
2976 return status; 2948 return status;
2977} 2949}
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 1a70097a8dc7..49483f19c5d3 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -589,38 +589,29 @@ static int nfs4_stat_to_errno(int);
589#define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \ 589#define NFS4_enc_remove_sz (compound_encode_hdr_maxsz + \
590 encode_sequence_maxsz + \ 590 encode_sequence_maxsz + \
591 encode_putfh_maxsz + \ 591 encode_putfh_maxsz + \
592 encode_remove_maxsz + \ 592 encode_remove_maxsz)
593 encode_getattr_maxsz)
594#define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \ 593#define NFS4_dec_remove_sz (compound_decode_hdr_maxsz + \
595 decode_sequence_maxsz + \ 594 decode_sequence_maxsz + \
596 decode_putfh_maxsz + \ 595 decode_putfh_maxsz + \
597 decode_remove_maxsz + \ 596 decode_remove_maxsz)
598 decode_getattr_maxsz)
599#define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \ 597#define NFS4_enc_rename_sz (compound_encode_hdr_maxsz + \
600 encode_sequence_maxsz + \ 598 encode_sequence_maxsz + \
601 encode_putfh_maxsz + \ 599 encode_putfh_maxsz + \
602 encode_savefh_maxsz + \ 600 encode_savefh_maxsz + \
603 encode_putfh_maxsz + \ 601 encode_putfh_maxsz + \
604 encode_rename_maxsz + \ 602 encode_rename_maxsz)
605 encode_getattr_maxsz + \
606 encode_restorefh_maxsz + \
607 encode_getattr_maxsz)
608#define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \ 603#define NFS4_dec_rename_sz (compound_decode_hdr_maxsz + \
609 decode_sequence_maxsz + \ 604 decode_sequence_maxsz + \
610 decode_putfh_maxsz + \ 605 decode_putfh_maxsz + \
611 decode_savefh_maxsz + \ 606 decode_savefh_maxsz + \
612 decode_putfh_maxsz + \ 607 decode_putfh_maxsz + \
613 decode_rename_maxsz + \ 608 decode_rename_maxsz)
614 decode_getattr_maxsz + \
615 decode_restorefh_maxsz + \
616 decode_getattr_maxsz)
617#define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \ 609#define NFS4_enc_link_sz (compound_encode_hdr_maxsz + \
618 encode_sequence_maxsz + \ 610 encode_sequence_maxsz + \
619 encode_putfh_maxsz + \ 611 encode_putfh_maxsz + \
620 encode_savefh_maxsz + \ 612 encode_savefh_maxsz + \
621 encode_putfh_maxsz + \ 613 encode_putfh_maxsz + \
622 encode_link_maxsz + \ 614 encode_link_maxsz + \
623 encode_getattr_maxsz + \
624 encode_restorefh_maxsz + \ 615 encode_restorefh_maxsz + \
625 encode_getattr_maxsz) 616 encode_getattr_maxsz)
626#define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \ 617#define NFS4_dec_link_sz (compound_decode_hdr_maxsz + \
@@ -629,7 +620,6 @@ static int nfs4_stat_to_errno(int);
629 decode_savefh_maxsz + \ 620 decode_savefh_maxsz + \
630 decode_putfh_maxsz + \ 621 decode_putfh_maxsz + \
631 decode_link_maxsz + \ 622 decode_link_maxsz + \
632 decode_getattr_maxsz + \
633 decode_restorefh_maxsz + \ 623 decode_restorefh_maxsz + \
634 decode_getattr_maxsz) 624 decode_getattr_maxsz)
635#define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \ 625#define NFS4_enc_symlink_sz (compound_encode_hdr_maxsz + \
@@ -2052,7 +2042,6 @@ static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr,
2052 encode_sequence(xdr, &args->seq_args, &hdr); 2042 encode_sequence(xdr, &args->seq_args, &hdr);
2053 encode_putfh(xdr, args->fh, &hdr); 2043 encode_putfh(xdr, args->fh, &hdr);
2054 encode_remove(xdr, &args->name, &hdr); 2044 encode_remove(xdr, &args->name, &hdr);
2055 encode_getfattr(xdr, args->bitmask, &hdr);
2056 encode_nops(&hdr); 2045 encode_nops(&hdr);
2057} 2046}
2058 2047
@@ -2072,9 +2061,6 @@ static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr,
2072 encode_savefh(xdr, &hdr); 2061 encode_savefh(xdr, &hdr);
2073 encode_putfh(xdr, args->new_dir, &hdr); 2062 encode_putfh(xdr, args->new_dir, &hdr);
2074 encode_rename(xdr, args->old_name, args->new_name, &hdr); 2063 encode_rename(xdr, args->old_name, args->new_name, &hdr);
2075 encode_getfattr(xdr, args->bitmask, &hdr);
2076 encode_restorefh(xdr, &hdr);
2077 encode_getfattr(xdr, args->bitmask, &hdr);
2078 encode_nops(&hdr); 2064 encode_nops(&hdr);
2079} 2065}
2080 2066
@@ -2094,7 +2080,6 @@ static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr,
2094 encode_savefh(xdr, &hdr); 2080 encode_savefh(xdr, &hdr);
2095 encode_putfh(xdr, args->dir_fh, &hdr); 2081 encode_putfh(xdr, args->dir_fh, &hdr);
2096 encode_link(xdr, args->name, &hdr); 2082 encode_link(xdr, args->name, &hdr);
2097 encode_getfattr(xdr, args->bitmask, &hdr);
2098 encode_restorefh(xdr, &hdr); 2083 encode_restorefh(xdr, &hdr);
2099 encode_getfattr(xdr, args->bitmask, &hdr); 2084 encode_getfattr(xdr, args->bitmask, &hdr);
2100 encode_nops(&hdr); 2085 encode_nops(&hdr);
@@ -5782,9 +5767,6 @@ static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
5782 if (status) 5767 if (status)
5783 goto out; 5768 goto out;
5784 status = decode_remove(xdr, &res->cinfo); 5769 status = decode_remove(xdr, &res->cinfo);
5785 if (status)
5786 goto out;
5787 decode_getfattr(xdr, res->dir_attr, res->server);
5788out: 5770out:
5789 return status; 5771 return status;
5790} 5772}
@@ -5814,15 +5796,6 @@ static int nfs4_xdr_dec_rename(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
5814 if (status) 5796 if (status)
5815 goto out; 5797 goto out;
5816 status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo); 5798 status = decode_rename(xdr, &res->old_cinfo, &res->new_cinfo);
5817 if (status)
5818 goto out;
5819 /* Current FH is target directory */
5820 if (decode_getfattr(xdr, res->new_fattr, res->server))
5821 goto out;
5822 status = decode_restorefh(xdr);
5823 if (status)
5824 goto out;
5825 decode_getfattr(xdr, res->old_fattr, res->server);
5826out: 5799out:
5827 return status; 5800 return status;
5828} 5801}
@@ -5858,8 +5831,6 @@ static int nfs4_xdr_dec_link(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
5858 * Note order: OP_LINK leaves the directory as the current 5831 * Note order: OP_LINK leaves the directory as the current
5859 * filehandle. 5832 * filehandle.
5860 */ 5833 */
5861 if (decode_getfattr(xdr, res->dir_attr, res->server))
5862 goto out;
5863 status = decode_restorefh(xdr); 5834 status = decode_restorefh(xdr);
5864 if (status) 5835 if (status)
5865 goto out; 5836 goto out;