aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c384
1 files changed, 244 insertions, 140 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 8003c91ccb9a..badd73b7ca12 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -68,13 +68,19 @@ static int nfs4_stat_to_errno(int);
68#endif 68#endif
69 69
70/* lock,open owner id: 70/* lock,open owner id:
71 * we currently use size 1 (u32) out of (NFS4_OPAQUE_LIMIT >> 2) 71 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
72 */ 72 */
73#define owner_id_maxsz (1 + 1) 73#define open_owner_id_maxsz (1 + 4)
74#define lock_owner_id_maxsz (1 + 4)
75#define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
74#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) 76#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
75#define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) 77#define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
76#define op_encode_hdr_maxsz (1) 78#define op_encode_hdr_maxsz (1)
77#define op_decode_hdr_maxsz (2) 79#define op_decode_hdr_maxsz (2)
80#define encode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
81#define decode_stateid_maxsz (XDR_QUADLEN(NFS4_STATEID_SIZE))
82#define encode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
83#define decode_verifier_maxsz (XDR_QUADLEN(NFS4_VERIFIER_SIZE))
78#define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \ 84#define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
79 (NFS4_FHSIZE >> 2)) 85 (NFS4_FHSIZE >> 2))
80#define decode_putfh_maxsz (op_decode_hdr_maxsz) 86#define decode_putfh_maxsz (op_decode_hdr_maxsz)
@@ -87,12 +93,19 @@ static int nfs4_stat_to_errno(int);
87#define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) 93#define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
88#define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) 94#define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
89#define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) 95#define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
96#define nfs4_owner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
97#define nfs4_group_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
90/* This is based on getfattr, which uses the most attributes: */ 98/* This is based on getfattr, which uses the most attributes: */
91#define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \ 99#define nfs4_fattr_value_maxsz (1 + (1 + 2 + 2 + 4 + 2 + 1 + 1 + 2 + 2 + \
92 3 + 3 + 3 + 2 * nfs4_name_maxsz)) 100 3 + 3 + 3 + nfs4_owner_maxsz + nfs4_group_maxsz))
93#define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \ 101#define nfs4_fattr_maxsz (nfs4_fattr_bitmap_maxsz + \
94 nfs4_fattr_value_maxsz) 102 nfs4_fattr_value_maxsz)
95#define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz) 103#define decode_getattr_maxsz (op_decode_hdr_maxsz + nfs4_fattr_maxsz)
104#define encode_attrs_maxsz (nfs4_fattr_bitmap_maxsz + \
105 1 + 2 + 1 + \
106 nfs4_owner_maxsz + \
107 nfs4_group_maxsz + \
108 4 + 4)
96#define encode_savefh_maxsz (op_encode_hdr_maxsz) 109#define encode_savefh_maxsz (op_encode_hdr_maxsz)
97#define decode_savefh_maxsz (op_decode_hdr_maxsz) 110#define decode_savefh_maxsz (op_decode_hdr_maxsz)
98#define encode_restorefh_maxsz (op_encode_hdr_maxsz) 111#define encode_restorefh_maxsz (op_encode_hdr_maxsz)
@@ -116,8 +129,65 @@ static int nfs4_stat_to_errno(int);
116 3 + (NFS4_VERIFIER_SIZE >> 2)) 129 3 + (NFS4_VERIFIER_SIZE >> 2))
117#define decode_setclientid_confirm_maxsz \ 130#define decode_setclientid_confirm_maxsz \
118 (op_decode_hdr_maxsz) 131 (op_decode_hdr_maxsz)
119#define encode_lookup_maxsz (op_encode_hdr_maxsz + \ 132#define encode_lookup_maxsz (op_encode_hdr_maxsz + nfs4_name_maxsz)
120 1 + ((3 + NFS4_FHSIZE) >> 2)) 133#define decode_lookup_maxsz (op_decode_hdr_maxsz)
134#define encode_share_access_maxsz \
135 (2)
136#define encode_createmode_maxsz (1 + encode_attrs_maxsz)
137#define encode_opentype_maxsz (1 + encode_createmode_maxsz)
138#define encode_claim_null_maxsz (1 + nfs4_name_maxsz)
139#define encode_open_maxsz (op_encode_hdr_maxsz + \
140 2 + encode_share_access_maxsz + 2 + \
141 open_owner_id_maxsz + \
142 encode_opentype_maxsz + \
143 encode_claim_null_maxsz)
144#define decode_ace_maxsz (3 + nfs4_owner_maxsz)
145#define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
146 decode_ace_maxsz)
147#define decode_change_info_maxsz (5)
148#define decode_open_maxsz (op_decode_hdr_maxsz + \
149 decode_stateid_maxsz + \
150 decode_change_info_maxsz + 1 + \
151 nfs4_fattr_bitmap_maxsz + \
152 decode_delegation_maxsz)
153#define encode_open_confirm_maxsz \
154 (op_encode_hdr_maxsz + \
155 encode_stateid_maxsz + 1)
156#define decode_open_confirm_maxsz \
157 (op_decode_hdr_maxsz + \
158 decode_stateid_maxsz)
159#define encode_open_downgrade_maxsz \
160 (op_encode_hdr_maxsz + \
161 encode_stateid_maxsz + 1 + \
162 encode_share_access_maxsz)
163#define decode_open_downgrade_maxsz \
164 (op_decode_hdr_maxsz + \
165 decode_stateid_maxsz)
166#define encode_close_maxsz (op_encode_hdr_maxsz + \
167 1 + encode_stateid_maxsz)
168#define decode_close_maxsz (op_decode_hdr_maxsz + \
169 decode_stateid_maxsz)
170#define encode_setattr_maxsz (op_encode_hdr_maxsz + \
171 encode_stateid_maxsz + \
172 encode_attrs_maxsz)
173#define decode_setattr_maxsz (op_decode_hdr_maxsz + \
174 nfs4_fattr_bitmap_maxsz)
175#define encode_read_maxsz (op_encode_hdr_maxsz + \
176 encode_stateid_maxsz + 3)
177#define decode_read_maxsz (op_decode_hdr_maxsz + 2)
178#define encode_readdir_maxsz (op_encode_hdr_maxsz + \
179 2 + encode_verifier_maxsz + 5)
180#define decode_readdir_maxsz (op_decode_hdr_maxsz + \
181 decode_verifier_maxsz)
182#define encode_readlink_maxsz (op_encode_hdr_maxsz)
183#define decode_readlink_maxsz (op_decode_hdr_maxsz + 1)
184#define encode_write_maxsz (op_encode_hdr_maxsz + \
185 encode_stateid_maxsz + 4)
186#define decode_write_maxsz (op_decode_hdr_maxsz + \
187 2 + decode_verifier_maxsz)
188#define encode_commit_maxsz (op_encode_hdr_maxsz + 3)
189#define decode_commit_maxsz (op_decode_hdr_maxsz + \
190 decode_verifier_maxsz)
121#define encode_remove_maxsz (op_encode_hdr_maxsz + \ 191#define encode_remove_maxsz (op_encode_hdr_maxsz + \
122 nfs4_name_maxsz) 192 nfs4_name_maxsz)
123#define encode_rename_maxsz (op_encode_hdr_maxsz + \ 193#define encode_rename_maxsz (op_encode_hdr_maxsz + \
@@ -126,106 +196,142 @@ static int nfs4_stat_to_errno(int);
126#define encode_link_maxsz (op_encode_hdr_maxsz + \ 196#define encode_link_maxsz (op_encode_hdr_maxsz + \
127 nfs4_name_maxsz) 197 nfs4_name_maxsz)
128#define decode_link_maxsz (op_decode_hdr_maxsz + 5) 198#define decode_link_maxsz (op_decode_hdr_maxsz + 5)
199#define encode_lock_maxsz (op_encode_hdr_maxsz + \
200 7 + \
201 1 + encode_stateid_maxsz + 8)
202#define decode_lock_denied_maxsz \
203 (8 + decode_lockowner_maxsz)
204#define decode_lock_maxsz (op_decode_hdr_maxsz + \
205 decode_lock_denied_maxsz)
206#define encode_lockt_maxsz (op_encode_hdr_maxsz + 12)
207#define decode_lockt_maxsz (op_decode_hdr_maxsz + \
208 decode_lock_denied_maxsz)
209#define encode_locku_maxsz (op_encode_hdr_maxsz + 3 + \
210 encode_stateid_maxsz + \
211 4)
212#define decode_locku_maxsz (op_decode_hdr_maxsz + \
213 decode_stateid_maxsz)
214#define encode_access_maxsz (op_encode_hdr_maxsz + 1)
215#define decode_access_maxsz (op_decode_hdr_maxsz + 2)
129#define encode_symlink_maxsz (op_encode_hdr_maxsz + \ 216#define encode_symlink_maxsz (op_encode_hdr_maxsz + \
130 1 + nfs4_name_maxsz + \ 217 1 + nfs4_name_maxsz + \
131 1 + \ 218 1 + \
132 nfs4_fattr_maxsz) 219 nfs4_fattr_maxsz)
133#define decode_symlink_maxsz (op_decode_hdr_maxsz + 8) 220#define decode_symlink_maxsz (op_decode_hdr_maxsz + 8)
134#define encode_create_maxsz (op_encode_hdr_maxsz + \ 221#define encode_create_maxsz (op_encode_hdr_maxsz + \
135 2 + nfs4_name_maxsz + \ 222 1 + 2 + nfs4_name_maxsz + \
136 nfs4_fattr_maxsz) 223 encode_attrs_maxsz)
137#define decode_create_maxsz (op_decode_hdr_maxsz + 8) 224#define decode_create_maxsz (op_decode_hdr_maxsz + \
225 decode_change_info_maxsz + \
226 nfs4_fattr_bitmap_maxsz)
227#define encode_statfs_maxsz (encode_getattr_maxsz)
228#define decode_statfs_maxsz (decode_getattr_maxsz)
138#define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4) 229#define encode_delegreturn_maxsz (op_encode_hdr_maxsz + 4)
139#define decode_delegreturn_maxsz (op_decode_hdr_maxsz) 230#define decode_delegreturn_maxsz (op_decode_hdr_maxsz)
231#define encode_getacl_maxsz (encode_getattr_maxsz)
232#define decode_getacl_maxsz (op_decode_hdr_maxsz + \
233 nfs4_fattr_bitmap_maxsz + 1)
234#define encode_setacl_maxsz (op_encode_hdr_maxsz + \
235 encode_stateid_maxsz + 3)
236#define decode_setacl_maxsz (decode_setattr_maxsz)
237#define encode_fs_locations_maxsz \
238 (encode_getattr_maxsz)
239#define decode_fs_locations_maxsz \
240 (0)
140#define NFS4_enc_compound_sz (1024) /* XXX: large enough? */ 241#define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
141#define NFS4_dec_compound_sz (1024) /* XXX: large enough? */ 242#define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
142#define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \ 243#define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
143 encode_putfh_maxsz + \ 244 encode_putfh_maxsz + \
144 op_encode_hdr_maxsz + 7) 245 encode_read_maxsz)
145#define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \ 246#define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
146 decode_putfh_maxsz + \ 247 decode_putfh_maxsz + \
147 op_decode_hdr_maxsz + 2) 248 decode_read_maxsz)
148#define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \ 249#define NFS4_enc_readlink_sz (compound_encode_hdr_maxsz + \
149 encode_putfh_maxsz + \ 250 encode_putfh_maxsz + \
150 op_encode_hdr_maxsz) 251 encode_readlink_maxsz)
151#define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \ 252#define NFS4_dec_readlink_sz (compound_decode_hdr_maxsz + \
152 decode_putfh_maxsz + \ 253 decode_putfh_maxsz + \
153 op_decode_hdr_maxsz) 254 decode_readlink_maxsz)
154#define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \ 255#define NFS4_enc_readdir_sz (compound_encode_hdr_maxsz + \
155 encode_putfh_maxsz + \ 256 encode_putfh_maxsz + \
156 op_encode_hdr_maxsz + 9) 257 encode_readdir_maxsz)
157#define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \ 258#define NFS4_dec_readdir_sz (compound_decode_hdr_maxsz + \
158 decode_putfh_maxsz + \ 259 decode_putfh_maxsz + \
159 op_decode_hdr_maxsz + 2) 260 decode_readdir_maxsz)
160#define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \ 261#define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
161 encode_putfh_maxsz + \ 262 encode_putfh_maxsz + \
162 op_encode_hdr_maxsz + 8 + \ 263 encode_write_maxsz + \
163 encode_getattr_maxsz) 264 encode_getattr_maxsz)
164#define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \ 265#define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
165 decode_putfh_maxsz + \ 266 decode_putfh_maxsz + \
166 op_decode_hdr_maxsz + 4 + \ 267 decode_write_maxsz + \
167 decode_getattr_maxsz) 268 decode_getattr_maxsz)
168#define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \ 269#define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
169 encode_putfh_maxsz + \ 270 encode_putfh_maxsz + \
170 op_encode_hdr_maxsz + 3 + \ 271 encode_commit_maxsz + \
171 encode_getattr_maxsz) 272 encode_getattr_maxsz)
172#define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \ 273#define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
173 decode_putfh_maxsz + \ 274 decode_putfh_maxsz + \
174 op_decode_hdr_maxsz + 2 + \ 275 decode_commit_maxsz + \
175 decode_getattr_maxsz) 276 decode_getattr_maxsz)
176#define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ 277#define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
177 encode_putfh_maxsz + \ 278 encode_putfh_maxsz + \
178 op_encode_hdr_maxsz + \ 279 encode_savefh_maxsz + \
179 13 + 3 + 2 + 64 + \ 280 encode_open_maxsz + \
180 encode_getattr_maxsz + \ 281 encode_getfh_maxsz + \
181 encode_getfh_maxsz) 282 encode_getattr_maxsz + \
283 encode_restorefh_maxsz + \
284 encode_getattr_maxsz)
182#define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ 285#define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \
183 decode_putfh_maxsz + \ 286 decode_putfh_maxsz + \
184 op_decode_hdr_maxsz + 4 + 5 + 2 + 3 + \ 287 decode_savefh_maxsz + \
185 decode_getattr_maxsz + \ 288 decode_open_maxsz + \
186 decode_getfh_maxsz) 289 decode_getfh_maxsz + \
187#define NFS4_enc_open_confirm_sz \ 290 decode_getattr_maxsz + \
188 (compound_encode_hdr_maxsz + \ 291 decode_restorefh_maxsz + \
189 encode_putfh_maxsz + \ 292 decode_getattr_maxsz)
190 op_encode_hdr_maxsz + 5) 293#define NFS4_enc_open_confirm_sz \
191#define NFS4_dec_open_confirm_sz (compound_decode_hdr_maxsz + \ 294 (compound_encode_hdr_maxsz + \
192 decode_putfh_maxsz + \ 295 encode_putfh_maxsz + \
193 op_decode_hdr_maxsz + 4) 296 encode_open_confirm_maxsz)
297#define NFS4_dec_open_confirm_sz \
298 (compound_decode_hdr_maxsz + \
299 decode_putfh_maxsz + \
300 decode_open_confirm_maxsz)
194#define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \ 301#define NFS4_enc_open_noattr_sz (compound_encode_hdr_maxsz + \
195 encode_putfh_maxsz + \ 302 encode_putfh_maxsz + \
196 op_encode_hdr_maxsz + \ 303 encode_open_maxsz + \
197 11) 304 encode_getattr_maxsz)
198#define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \ 305#define NFS4_dec_open_noattr_sz (compound_decode_hdr_maxsz + \
199 decode_putfh_maxsz + \ 306 decode_putfh_maxsz + \
200 op_decode_hdr_maxsz + \ 307 decode_open_maxsz + \
201 4 + 5 + 2 + 3) 308 decode_getattr_maxsz)
202#define NFS4_enc_open_downgrade_sz \ 309#define NFS4_enc_open_downgrade_sz \
203 (compound_encode_hdr_maxsz + \ 310 (compound_encode_hdr_maxsz + \
204 encode_putfh_maxsz + \ 311 encode_putfh_maxsz + \
205 op_encode_hdr_maxsz + 7 + \ 312 encode_open_downgrade_maxsz + \
206 encode_getattr_maxsz) 313 encode_getattr_maxsz)
207#define NFS4_dec_open_downgrade_sz \ 314#define NFS4_dec_open_downgrade_sz \
208 (compound_decode_hdr_maxsz + \ 315 (compound_decode_hdr_maxsz + \
209 decode_putfh_maxsz + \ 316 decode_putfh_maxsz + \
210 op_decode_hdr_maxsz + 4 + \ 317 decode_open_downgrade_maxsz + \
211 decode_getattr_maxsz) 318 decode_getattr_maxsz)
212#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \ 319#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
213 encode_putfh_maxsz + \ 320 encode_putfh_maxsz + \
214 op_encode_hdr_maxsz + 5 + \ 321 encode_close_maxsz + \
215 encode_getattr_maxsz) 322 encode_getattr_maxsz)
216#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \ 323#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
217 decode_putfh_maxsz + \ 324 decode_putfh_maxsz + \
218 op_decode_hdr_maxsz + 4 + \ 325 decode_close_maxsz + \
219 decode_getattr_maxsz) 326 decode_getattr_maxsz)
220#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \ 327#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
221 encode_putfh_maxsz + \ 328 encode_putfh_maxsz + \
222 op_encode_hdr_maxsz + 4 + \ 329 encode_setattr_maxsz + \
223 nfs4_fattr_maxsz + \ 330 encode_getattr_maxsz)
224 encode_getattr_maxsz) 331#define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
225#define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \ 332 decode_putfh_maxsz + \
226 decode_putfh_maxsz + \ 333 decode_setattr_maxsz + \
227 op_decode_hdr_maxsz + 3 + \ 334 decode_getattr_maxsz)
228 nfs4_fattr_maxsz)
229#define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \ 335#define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
230 encode_putfh_maxsz + \ 336 encode_putfh_maxsz + \
231 encode_fsinfo_maxsz) 337 encode_fsinfo_maxsz)
@@ -252,39 +358,28 @@ static int nfs4_stat_to_errno(int);
252 decode_fsinfo_maxsz) 358 decode_fsinfo_maxsz)
253#define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \ 359#define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
254 encode_putfh_maxsz + \ 360 encode_putfh_maxsz + \
255 encode_getattr_maxsz + \ 361 encode_lock_maxsz)
256 op_encode_hdr_maxsz + \
257 1 + 1 + 2 + 2 + \
258 1 + 4 + 1 + 2 + \
259 owner_id_maxsz)
260#define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \ 362#define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
261 decode_putfh_maxsz + \ 363 decode_putfh_maxsz + \
262 decode_getattr_maxsz + \ 364 decode_lock_maxsz)
263 op_decode_hdr_maxsz + \
264 2 + 2 + 1 + 2 + \
265 owner_id_maxsz)
266#define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \ 365#define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
267 encode_putfh_maxsz + \ 366 encode_putfh_maxsz + \
268 encode_getattr_maxsz + \ 367 encode_lockt_maxsz)
269 op_encode_hdr_maxsz + \ 368#define NFS4_dec_lockt_sz (compound_decode_hdr_maxsz + \
270 1 + 2 + 2 + 2 + \ 369 decode_putfh_maxsz + \
271 owner_id_maxsz) 370 decode_lockt_maxsz)
272#define NFS4_dec_lockt_sz (NFS4_dec_lock_sz)
273#define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \ 371#define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
274 encode_putfh_maxsz + \ 372 encode_putfh_maxsz + \
275 encode_getattr_maxsz + \ 373 encode_locku_maxsz)
276 op_encode_hdr_maxsz + \
277 1 + 1 + 4 + 2 + 2)
278#define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \ 374#define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
279 decode_putfh_maxsz + \ 375 decode_putfh_maxsz + \
280 decode_getattr_maxsz + \ 376 decode_locku_maxsz)
281 op_decode_hdr_maxsz + 4)
282#define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ 377#define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \
283 encode_putfh_maxsz + \ 378 encode_putfh_maxsz + \
284 op_encode_hdr_maxsz + 1) 379 encode_access_maxsz)
285#define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ 380#define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \
286 decode_putfh_maxsz + \ 381 decode_putfh_maxsz + \
287 op_decode_hdr_maxsz + 2) 382 decode_access_maxsz)
288#define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ 383#define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \
289 encode_putfh_maxsz + \ 384 encode_putfh_maxsz + \
290 encode_getattr_maxsz) 385 encode_getattr_maxsz)
@@ -298,7 +393,7 @@ static int nfs4_stat_to_errno(int);
298 encode_getfh_maxsz) 393 encode_getfh_maxsz)
299#define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \ 394#define NFS4_dec_lookup_sz (compound_decode_hdr_maxsz + \
300 decode_putfh_maxsz + \ 395 decode_putfh_maxsz + \
301 op_decode_hdr_maxsz + \ 396 decode_lookup_maxsz + \
302 decode_getattr_maxsz + \ 397 decode_getattr_maxsz + \
303 decode_getfh_maxsz) 398 decode_getfh_maxsz)
304#define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \ 399#define NFS4_enc_lookup_root_sz (compound_encode_hdr_maxsz + \
@@ -383,10 +478,10 @@ static int nfs4_stat_to_errno(int);
383 decode_getattr_maxsz) 478 decode_getattr_maxsz)
384#define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \ 479#define NFS4_enc_statfs_sz (compound_encode_hdr_maxsz + \
385 encode_putfh_maxsz + \ 480 encode_putfh_maxsz + \
386 encode_getattr_maxsz) 481 encode_statfs_maxsz)
387#define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \ 482#define NFS4_dec_statfs_sz (compound_decode_hdr_maxsz + \
388 decode_putfh_maxsz + \ 483 decode_putfh_maxsz + \
389 op_decode_hdr_maxsz + 12) 484 decode_statfs_maxsz)
390#define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \ 485#define NFS4_enc_server_caps_sz (compound_encode_hdr_maxsz + \
391 encode_putfh_maxsz + \ 486 encode_putfh_maxsz + \
392 encode_getattr_maxsz) 487 encode_getattr_maxsz)
@@ -402,27 +497,26 @@ static int nfs4_stat_to_errno(int);
402 decode_getattr_maxsz) 497 decode_getattr_maxsz)
403#define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \ 498#define NFS4_enc_getacl_sz (compound_encode_hdr_maxsz + \
404 encode_putfh_maxsz + \ 499 encode_putfh_maxsz + \
405 encode_getattr_maxsz) 500 encode_getacl_maxsz)
406#define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \ 501#define NFS4_dec_getacl_sz (compound_decode_hdr_maxsz + \
407 decode_putfh_maxsz + \ 502 decode_putfh_maxsz + \
408 op_decode_hdr_maxsz + \ 503 decode_getacl_maxsz)
409 nfs4_fattr_bitmap_maxsz + 1)
410#define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \ 504#define NFS4_enc_setacl_sz (compound_encode_hdr_maxsz + \
411 encode_putfh_maxsz + \ 505 encode_putfh_maxsz + \
412 op_encode_hdr_maxsz + 4 + \ 506 encode_setacl_maxsz)
413 nfs4_fattr_bitmap_maxsz + 1)
414#define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \ 507#define NFS4_dec_setacl_sz (compound_decode_hdr_maxsz + \
415 decode_putfh_maxsz + \ 508 decode_putfh_maxsz + \
416 op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) 509 decode_setacl_maxsz)
417#define NFS4_enc_fs_locations_sz \ 510#define NFS4_enc_fs_locations_sz \
418 (compound_encode_hdr_maxsz + \ 511 (compound_encode_hdr_maxsz + \
419 encode_putfh_maxsz + \ 512 encode_putfh_maxsz + \
420 encode_getattr_maxsz) 513 encode_lookup_maxsz + \
514 encode_fs_locations_maxsz)
421#define NFS4_dec_fs_locations_sz \ 515#define NFS4_dec_fs_locations_sz \
422 (compound_decode_hdr_maxsz + \ 516 (compound_decode_hdr_maxsz + \
423 decode_putfh_maxsz + \ 517 decode_putfh_maxsz + \
424 op_decode_hdr_maxsz + \ 518 decode_lookup_maxsz + \
425 nfs4_fattr_bitmap_maxsz) 519 decode_fs_locations_maxsz)
426 520
427static struct { 521static struct {
428 unsigned int mode; 522 unsigned int mode;
@@ -793,13 +887,14 @@ static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args)
793 WRITE64(nfs4_lock_length(args->fl)); 887 WRITE64(nfs4_lock_length(args->fl));
794 WRITE32(args->new_lock_owner); 888 WRITE32(args->new_lock_owner);
795 if (args->new_lock_owner){ 889 if (args->new_lock_owner){
796 RESERVE_SPACE(4+NFS4_STATEID_SIZE+20); 890 RESERVE_SPACE(4+NFS4_STATEID_SIZE+32);
797 WRITE32(args->open_seqid->sequence->counter); 891 WRITE32(args->open_seqid->sequence->counter);
798 WRITEMEM(args->open_stateid->data, NFS4_STATEID_SIZE); 892 WRITEMEM(args->open_stateid->data, NFS4_STATEID_SIZE);
799 WRITE32(args->lock_seqid->sequence->counter); 893 WRITE32(args->lock_seqid->sequence->counter);
800 WRITE64(args->lock_owner.clientid); 894 WRITE64(args->lock_owner.clientid);
801 WRITE32(4); 895 WRITE32(16);
802 WRITE32(args->lock_owner.id); 896 WRITEMEM("lock id:", 8);
897 WRITE64(args->lock_owner.id);
803 } 898 }
804 else { 899 else {
805 RESERVE_SPACE(NFS4_STATEID_SIZE+4); 900 RESERVE_SPACE(NFS4_STATEID_SIZE+4);
@@ -814,14 +909,15 @@ static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockt_args *arg
814{ 909{
815 __be32 *p; 910 __be32 *p;
816 911
817 RESERVE_SPACE(40); 912 RESERVE_SPACE(52);
818 WRITE32(OP_LOCKT); 913 WRITE32(OP_LOCKT);
819 WRITE32(nfs4_lock_type(args->fl, 0)); 914 WRITE32(nfs4_lock_type(args->fl, 0));
820 WRITE64(args->fl->fl_start); 915 WRITE64(args->fl->fl_start);
821 WRITE64(nfs4_lock_length(args->fl)); 916 WRITE64(nfs4_lock_length(args->fl));
822 WRITE64(args->lock_owner.clientid); 917 WRITE64(args->lock_owner.clientid);
823 WRITE32(4); 918 WRITE32(16);
824 WRITE32(args->lock_owner.id); 919 WRITEMEM("lock id:", 8);
920 WRITE64(args->lock_owner.id);
825 921
826 return 0; 922 return 0;
827} 923}
@@ -886,10 +982,11 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
886 WRITE32(OP_OPEN); 982 WRITE32(OP_OPEN);
887 WRITE32(arg->seqid->sequence->counter); 983 WRITE32(arg->seqid->sequence->counter);
888 encode_share_access(xdr, arg->open_flags); 984 encode_share_access(xdr, arg->open_flags);
889 RESERVE_SPACE(16); 985 RESERVE_SPACE(28);
890 WRITE64(arg->clientid); 986 WRITE64(arg->clientid);
891 WRITE32(4); 987 WRITE32(16);
892 WRITE32(arg->id); 988 WRITEMEM("open id:", 8);
989 WRITE64(arg->id);
893} 990}
894 991
895static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) 992static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
@@ -1071,12 +1168,10 @@ static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args)
1071 1168
1072static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req) 1169static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req)
1073{ 1170{
1074 struct rpc_auth *auth = req->rq_task->tk_auth;
1075 uint32_t attrs[2] = { 1171 uint32_t attrs[2] = {
1076 FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID, 1172 FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID,
1077 FATTR4_WORD1_MOUNTED_ON_FILEID, 1173 FATTR4_WORD1_MOUNTED_ON_FILEID,
1078 }; 1174 };
1079 int replen;
1080 __be32 *p; 1175 __be32 *p;
1081 1176
1082 RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20); 1177 RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20);
@@ -1101,37 +1196,16 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
1101 attrs[0] & readdir->bitmask[0], 1196 attrs[0] & readdir->bitmask[0],
1102 attrs[1] & readdir->bitmask[1]); 1197 attrs[1] & readdir->bitmask[1]);
1103 1198
1104 /* set up reply kvec
1105 * toplevel_status + taglen + rescount + OP_PUTFH + status
1106 * + OP_READDIR + status + verifer(2) = 9
1107 */
1108 replen = (RPC_REPHDRSIZE + auth->au_rslack + 9) << 2;
1109 xdr_inline_pages(&req->rq_rcv_buf, replen, readdir->pages,
1110 readdir->pgbase, readdir->count);
1111 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
1112 __FUNCTION__, replen, readdir->pages,
1113 readdir->pgbase, readdir->count);
1114
1115 return 0; 1199 return 0;
1116} 1200}
1117 1201
1118static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req) 1202static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req)
1119{ 1203{
1120 struct rpc_auth *auth = req->rq_task->tk_auth;
1121 unsigned int replen;
1122 __be32 *p; 1204 __be32 *p;
1123 1205
1124 RESERVE_SPACE(4); 1206 RESERVE_SPACE(4);
1125 WRITE32(OP_READLINK); 1207 WRITE32(OP_READLINK);
1126 1208
1127 /* set up reply kvec
1128 * toplevel_status + taglen + rescount + OP_PUTFH + status
1129 * + OP_READLINK + status + string length = 8
1130 */
1131 replen = (RPC_REPHDRSIZE + auth->au_rslack + 8) << 2;
1132 xdr_inline_pages(&req->rq_rcv_buf, replen, readlink->pages,
1133 readlink->pgbase, readlink->pglen);
1134
1135 return 0; 1209 return 0;
1136} 1210}
1137 1211
@@ -1361,7 +1435,7 @@ out:
1361/* 1435/*
1362 * Encode REMOVE request 1436 * Encode REMOVE request
1363 */ 1437 */
1364static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs4_remove_arg *args) 1438static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
1365{ 1439{
1366 struct xdr_stream xdr; 1440 struct xdr_stream xdr;
1367 struct compound_hdr hdr = { 1441 struct compound_hdr hdr = {
@@ -1373,7 +1447,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs
1373 encode_compound_hdr(&xdr, &hdr); 1447 encode_compound_hdr(&xdr, &hdr);
1374 if ((status = encode_putfh(&xdr, args->fh)) != 0) 1448 if ((status = encode_putfh(&xdr, args->fh)) != 0)
1375 goto out; 1449 goto out;
1376 if ((status = encode_remove(&xdr, args->name)) != 0) 1450 if ((status = encode_remove(&xdr, &args->name)) != 0)
1377 goto out; 1451 goto out;
1378 status = encode_getfattr(&xdr, args->bitmask); 1452 status = encode_getfattr(&xdr, args->bitmask);
1379out: 1453out:
@@ -1697,6 +1771,8 @@ static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct n
1697 struct compound_hdr hdr = { 1771 struct compound_hdr hdr = {
1698 .nops = 2, 1772 .nops = 2,
1699 }; 1773 };
1774 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1775 unsigned int replen;
1700 int status; 1776 int status;
1701 1777
1702 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1778 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
@@ -1705,6 +1781,15 @@ static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct n
1705 if(status) 1781 if(status)
1706 goto out; 1782 goto out;
1707 status = encode_readlink(&xdr, args, req); 1783 status = encode_readlink(&xdr, args, req);
1784
1785 /* set up reply kvec
1786 * toplevel_status + taglen + rescount + OP_PUTFH + status
1787 * + OP_READLINK + status + string length = 8
1788 */
1789 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readlink_sz) << 2;
1790 xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
1791 args->pgbase, args->pglen);
1792
1708out: 1793out:
1709 return status; 1794 return status;
1710} 1795}
@@ -1718,6 +1803,8 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
1718 struct compound_hdr hdr = { 1803 struct compound_hdr hdr = {
1719 .nops = 2, 1804 .nops = 2,
1720 }; 1805 };
1806 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1807 int replen;
1721 int status; 1808 int status;
1722 1809
1723 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1810 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
@@ -1726,6 +1813,18 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
1726 if(status) 1813 if(status)
1727 goto out; 1814 goto out;
1728 status = encode_readdir(&xdr, args, req); 1815 status = encode_readdir(&xdr, args, req);
1816
1817 /* set up reply kvec
1818 * toplevel_status + taglen + rescount + OP_PUTFH + status
1819 * + OP_READDIR + status + verifer(2) = 9
1820 */
1821 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readdir_sz) << 2;
1822 xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
1823 args->pgbase, args->count);
1824 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
1825 __FUNCTION__, replen, args->pages,
1826 args->pgbase, args->count);
1827
1729out: 1828out:
1730 return status; 1829 return status;
1731} 1830}
@@ -1735,7 +1834,7 @@ out:
1735 */ 1834 */
1736static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) 1835static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
1737{ 1836{
1738 struct rpc_auth *auth = req->rq_task->tk_auth; 1837 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1739 struct xdr_stream xdr; 1838 struct xdr_stream xdr;
1740 struct compound_hdr hdr = { 1839 struct compound_hdr hdr = {
1741 .nops = 2, 1840 .nops = 2,
@@ -1795,7 +1894,7 @@ nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p,
1795 struct nfs_getaclargs *args) 1894 struct nfs_getaclargs *args)
1796{ 1895{
1797 struct xdr_stream xdr; 1896 struct xdr_stream xdr;
1798 struct rpc_auth *auth = req->rq_task->tk_auth; 1897 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1799 struct compound_hdr hdr = { 1898 struct compound_hdr hdr = {
1800 .nops = 2, 1899 .nops = 2,
1801 }; 1900 };
@@ -2030,7 +2129,7 @@ static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs
2030 struct compound_hdr hdr = { 2129 struct compound_hdr hdr = {
2031 .nops = 3, 2130 .nops = 3,
2032 }; 2131 };
2033 struct rpc_auth *auth = req->rq_task->tk_auth; 2132 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
2034 int replen; 2133 int replen;
2035 int status; 2134 int status;
2036 2135
@@ -3124,11 +3223,12 @@ static int decode_getfh(struct xdr_stream *xdr, struct nfs_fh *fh)
3124 uint32_t len; 3223 uint32_t len;
3125 int status; 3224 int status;
3126 3225
3226 /* Zero handle first to allow comparisons */
3227 memset(fh, 0, sizeof(*fh));
3228
3127 status = decode_op_hdr(xdr, OP_GETFH); 3229 status = decode_op_hdr(xdr, OP_GETFH);
3128 if (status) 3230 if (status)
3129 return status; 3231 return status;
3130 /* Zero handle first to allow comparisons */
3131 memset(fh, 0, sizeof(*fh));
3132 3232
3133 READ_BUF(4); 3233 READ_BUF(4);
3134 READ32(len); 3234 READ32(len);
@@ -3269,7 +3369,7 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3269static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) 3369static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3270{ 3370{
3271 __be32 *p; 3371 __be32 *p;
3272 uint32_t bmlen; 3372 uint32_t savewords, bmlen, i;
3273 int status; 3373 int status;
3274 3374
3275 status = decode_op_hdr(xdr, OP_OPEN); 3375 status = decode_op_hdr(xdr, OP_OPEN);
@@ -3287,7 +3387,12 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3287 goto xdr_error; 3387 goto xdr_error;
3288 3388
3289 READ_BUF(bmlen << 2); 3389 READ_BUF(bmlen << 2);
3290 p += bmlen; 3390 savewords = min_t(uint32_t, bmlen, NFS4_BITMAP_SIZE);
3391 for (i = 0; i < savewords; ++i)
3392 READ32(res->attrset[i]);
3393 for (; i < NFS4_BITMAP_SIZE; i++)
3394 res->attrset[i] = 0;
3395
3291 return decode_delegation(xdr, res); 3396 return decode_delegation(xdr, res);
3292xdr_error: 3397xdr_error:
3293 dprintk("%s: Bitmap too large! Length = %u\n", __FUNCTION__, bmlen); 3398 dprintk("%s: Bitmap too large! Length = %u\n", __FUNCTION__, bmlen);
@@ -3730,7 +3835,7 @@ out:
3730/* 3835/*
3731 * Decode REMOVE response 3836 * Decode REMOVE response
3732 */ 3837 */
3733static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_remove_res *res) 3838static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res)
3734{ 3839{
3735 struct xdr_stream xdr; 3840 struct xdr_stream xdr;
3736 struct compound_hdr hdr; 3841 struct compound_hdr hdr;
@@ -3743,7 +3848,7 @@ static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_re
3743 goto out; 3848 goto out;
3744 if ((status = decode_remove(&xdr, &res->cinfo)) != 0) 3849 if ((status = decode_remove(&xdr, &res->cinfo)) != 0)
3745 goto out; 3850 goto out;
3746 decode_getfattr(&xdr, res->dir_attr, res->server); 3851 decode_getfattr(&xdr, &res->dir_attr, res->server);
3747out: 3852out:
3748 return status; 3853 return status;
3749} 3854}
@@ -3988,12 +4093,11 @@ static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, __be32 *p, struct nfs_openr
3988 status = decode_open(&xdr, res); 4093 status = decode_open(&xdr, res);
3989 if (status) 4094 if (status)
3990 goto out; 4095 goto out;
3991 status = decode_getfh(&xdr, &res->fh); 4096 if (decode_getfh(&xdr, &res->fh) != 0)
3992 if (status)
3993 goto out; 4097 goto out;
3994 if (decode_getfattr(&xdr, res->f_attr, res->server) != 0) 4098 if (decode_getfattr(&xdr, res->f_attr, res->server) != 0)
3995 goto out; 4099 goto out;
3996 if ((status = decode_restorefh(&xdr)) != 0) 4100 if (decode_restorefh(&xdr) != 0)
3997 goto out; 4101 goto out;
3998 decode_getfattr(&xdr, res->dir_attr, res->server); 4102 decode_getfattr(&xdr, res->dir_attr, res->server);
3999out: 4103out: