xref: /openbmc/linux/fs/afs/fsclient.c (revision 752beb5e)
1 /* AFS File Server client stubs
2  *
3  * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
4  * Written by David Howells (dhowells@redhat.com)
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11 
12 #include <linux/init.h>
13 #include <linux/slab.h>
14 #include <linux/sched.h>
15 #include <linux/circ_buf.h>
16 #include <linux/iversion.h>
17 #include "internal.h"
18 #include "afs_fs.h"
19 #include "xdr_fs.h"
20 #include "protocol_yfs.h"
21 
22 static const struct afs_fid afs_zero_fid;
23 
24 static inline void afs_use_fs_server(struct afs_call *call, struct afs_cb_interest *cbi)
25 {
26 	call->cbi = afs_get_cb_interest(cbi);
27 }
28 
29 /*
30  * decode an AFSFid block
31  */
32 static void xdr_decode_AFSFid(const __be32 **_bp, struct afs_fid *fid)
33 {
34 	const __be32 *bp = *_bp;
35 
36 	fid->vid		= ntohl(*bp++);
37 	fid->vnode		= ntohl(*bp++);
38 	fid->unique		= ntohl(*bp++);
39 	*_bp = bp;
40 }
41 
42 /*
43  * Dump a bad file status record.
44  */
45 static void xdr_dump_bad(const __be32 *bp)
46 {
47 	__be32 x[4];
48 	int i;
49 
50 	pr_notice("AFS XDR: Bad status record\n");
51 	for (i = 0; i < 5 * 4 * 4; i += 16) {
52 		memcpy(x, bp, 16);
53 		bp += 4;
54 		pr_notice("%03x: %08x %08x %08x %08x\n",
55 			  i, ntohl(x[0]), ntohl(x[1]), ntohl(x[2]), ntohl(x[3]));
56 	}
57 
58 	memcpy(x, bp, 4);
59 	pr_notice("0x50: %08x\n", ntohl(x[0]));
60 }
61 
62 /*
63  * Update the core inode struct from a returned status record.
64  */
65 void afs_update_inode_from_status(struct afs_vnode *vnode,
66 				  struct afs_file_status *status,
67 				  const afs_dataversion_t *expected_version,
68 				  u8 flags)
69 {
70 	struct timespec64 t;
71 	umode_t mode;
72 
73 	t = status->mtime_client;
74 	vnode->vfs_inode.i_ctime = t;
75 	vnode->vfs_inode.i_mtime = t;
76 	vnode->vfs_inode.i_atime = t;
77 
78 	if (flags & (AFS_VNODE_META_CHANGED | AFS_VNODE_NOT_YET_SET)) {
79 		vnode->vfs_inode.i_uid = make_kuid(&init_user_ns, status->owner);
80 		vnode->vfs_inode.i_gid = make_kgid(&init_user_ns, status->group);
81 		set_nlink(&vnode->vfs_inode, status->nlink);
82 
83 		mode = vnode->vfs_inode.i_mode;
84 		mode &= ~S_IALLUGO;
85 		mode |= status->mode;
86 		barrier();
87 		vnode->vfs_inode.i_mode = mode;
88 	}
89 
90 	if (!(flags & AFS_VNODE_NOT_YET_SET)) {
91 		if (expected_version &&
92 		    *expected_version != status->data_version) {
93 			_debug("vnode modified %llx on {%llx:%llu} [exp %llx]",
94 			       (unsigned long long) status->data_version,
95 			       vnode->fid.vid, vnode->fid.vnode,
96 			       (unsigned long long) *expected_version);
97 			vnode->invalid_before = status->data_version;
98 			if (vnode->status.type == AFS_FTYPE_DIR) {
99 				if (test_and_clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
100 					afs_stat_v(vnode, n_inval);
101 			} else {
102 				set_bit(AFS_VNODE_ZAP_DATA, &vnode->flags);
103 			}
104 		} else if (vnode->status.type == AFS_FTYPE_DIR) {
105 			/* Expected directory change is handled elsewhere so
106 			 * that we can locally edit the directory and save on a
107 			 * download.
108 			 */
109 			if (test_bit(AFS_VNODE_DIR_VALID, &vnode->flags))
110 				flags &= ~AFS_VNODE_DATA_CHANGED;
111 		}
112 	}
113 
114 	if (flags & (AFS_VNODE_DATA_CHANGED | AFS_VNODE_NOT_YET_SET)) {
115 		inode_set_iversion_raw(&vnode->vfs_inode, status->data_version);
116 		i_size_write(&vnode->vfs_inode, status->size);
117 	}
118 }
119 
120 /*
121  * decode an AFSFetchStatus block
122  */
123 static int xdr_decode_AFSFetchStatus(struct afs_call *call,
124 				     const __be32 **_bp,
125 				     struct afs_file_status *status,
126 				     struct afs_vnode *vnode,
127 				     const afs_dataversion_t *expected_version,
128 				     struct afs_read *read_req)
129 {
130 	const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
131 	bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
132 	u64 data_version, size;
133 	u32 type, abort_code;
134 	u8 flags = 0;
135 
136 	abort_code = ntohl(xdr->abort_code);
137 
138 	if (xdr->if_version != htonl(AFS_FSTATUS_VERSION)) {
139 		if (xdr->if_version == htonl(0) &&
140 		    abort_code != 0 &&
141 		    inline_error) {
142 			/* The OpenAFS fileserver has a bug in FS.InlineBulkStatus
143 			 * whereby it doesn't set the interface version in the error
144 			 * case.
145 			 */
146 			status->abort_code = abort_code;
147 			return 0;
148 		}
149 
150 		pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
151 		goto bad;
152 	}
153 
154 	if (abort_code != 0 && inline_error) {
155 		status->abort_code = abort_code;
156 		return 0;
157 	}
158 
159 	type = ntohl(xdr->type);
160 	switch (type) {
161 	case AFS_FTYPE_FILE:
162 	case AFS_FTYPE_DIR:
163 	case AFS_FTYPE_SYMLINK:
164 		if (type != status->type &&
165 		    vnode &&
166 		    !test_bit(AFS_VNODE_UNSET, &vnode->flags)) {
167 			pr_warning("Vnode %llx:%llx:%x changed type %u to %u\n",
168 				   vnode->fid.vid,
169 				   vnode->fid.vnode,
170 				   vnode->fid.unique,
171 				   status->type, type);
172 			goto bad;
173 		}
174 		status->type = type;
175 		break;
176 	default:
177 		goto bad;
178 	}
179 
180 #define EXTRACT_M(FIELD)					\
181 	do {							\
182 		u32 x = ntohl(xdr->FIELD);			\
183 		if (status->FIELD != x) {			\
184 			flags |= AFS_VNODE_META_CHANGED;	\
185 			status->FIELD = x;			\
186 		}						\
187 	} while (0)
188 
189 	EXTRACT_M(nlink);
190 	EXTRACT_M(author);
191 	EXTRACT_M(owner);
192 	EXTRACT_M(caller_access); /* call ticket dependent */
193 	EXTRACT_M(anon_access);
194 	EXTRACT_M(mode);
195 	EXTRACT_M(group);
196 
197 	status->mtime_client.tv_sec = ntohl(xdr->mtime_client);
198 	status->mtime_client.tv_nsec = 0;
199 	status->mtime_server.tv_sec = ntohl(xdr->mtime_server);
200 	status->mtime_server.tv_nsec = 0;
201 	status->lock_count   = ntohl(xdr->lock_count);
202 
203 	size  = (u64)ntohl(xdr->size_lo);
204 	size |= (u64)ntohl(xdr->size_hi) << 32;
205 	status->size = size;
206 
207 	data_version  = (u64)ntohl(xdr->data_version_lo);
208 	data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
209 	if (data_version != status->data_version) {
210 		status->data_version = data_version;
211 		flags |= AFS_VNODE_DATA_CHANGED;
212 	}
213 
214 	if (read_req) {
215 		read_req->data_version = data_version;
216 		read_req->file_size = size;
217 	}
218 
219 	*_bp = (const void *)*_bp + sizeof(*xdr);
220 
221 	if (vnode) {
222 		if (test_bit(AFS_VNODE_UNSET, &vnode->flags))
223 			flags |= AFS_VNODE_NOT_YET_SET;
224 		afs_update_inode_from_status(vnode, status, expected_version,
225 					     flags);
226 	}
227 
228 	return 0;
229 
230 bad:
231 	xdr_dump_bad(*_bp);
232 	return afs_protocol_error(call, -EBADMSG, afs_eproto_bad_status);
233 }
234 
235 /*
236  * Decode the file status.  We need to lock the target vnode if we're going to
237  * update its status so that stat() sees the attributes update atomically.
238  */
239 static int afs_decode_status(struct afs_call *call,
240 			     const __be32 **_bp,
241 			     struct afs_file_status *status,
242 			     struct afs_vnode *vnode,
243 			     const afs_dataversion_t *expected_version,
244 			     struct afs_read *read_req)
245 {
246 	int ret;
247 
248 	if (!vnode)
249 		return xdr_decode_AFSFetchStatus(call, _bp, status, vnode,
250 						 expected_version, read_req);
251 
252 	write_seqlock(&vnode->cb_lock);
253 	ret = xdr_decode_AFSFetchStatus(call, _bp, status, vnode,
254 					expected_version, read_req);
255 	write_sequnlock(&vnode->cb_lock);
256 	return ret;
257 }
258 
259 /*
260  * decode an AFSCallBack block
261  */
262 static void xdr_decode_AFSCallBack(struct afs_call *call,
263 				   struct afs_vnode *vnode,
264 				   const __be32 **_bp)
265 {
266 	struct afs_cb_interest *old, *cbi = call->cbi;
267 	const __be32 *bp = *_bp;
268 	u32 cb_expiry;
269 
270 	write_seqlock(&vnode->cb_lock);
271 
272 	if (!afs_cb_is_broken(call->cb_break, vnode, cbi)) {
273 		vnode->cb_version	= ntohl(*bp++);
274 		cb_expiry		= ntohl(*bp++);
275 		vnode->cb_type		= ntohl(*bp++);
276 		vnode->cb_expires_at	= cb_expiry + ktime_get_real_seconds();
277 		old = vnode->cb_interest;
278 		if (old != call->cbi) {
279 			vnode->cb_interest = cbi;
280 			cbi = old;
281 		}
282 		set_bit(AFS_VNODE_CB_PROMISED, &vnode->flags);
283 	} else {
284 		bp += 3;
285 	}
286 
287 	write_sequnlock(&vnode->cb_lock);
288 	call->cbi = cbi;
289 	*_bp = bp;
290 }
291 
292 static ktime_t xdr_decode_expiry(struct afs_call *call, u32 expiry)
293 {
294 	return ktime_add_ns(call->reply_time, expiry * NSEC_PER_SEC);
295 }
296 
297 static void xdr_decode_AFSCallBack_raw(struct afs_call *call,
298 				       const __be32 **_bp,
299 				       struct afs_callback *cb)
300 {
301 	const __be32 *bp = *_bp;
302 
303 	cb->version	= ntohl(*bp++);
304 	cb->expires_at	= xdr_decode_expiry(call, ntohl(*bp++));
305 	cb->type	= ntohl(*bp++);
306 	*_bp = bp;
307 }
308 
309 /*
310  * decode an AFSVolSync block
311  */
312 static void xdr_decode_AFSVolSync(const __be32 **_bp,
313 				  struct afs_volsync *volsync)
314 {
315 	const __be32 *bp = *_bp;
316 	u32 creation;
317 
318 	creation = ntohl(*bp++);
319 	bp++; /* spare2 */
320 	bp++; /* spare3 */
321 	bp++; /* spare4 */
322 	bp++; /* spare5 */
323 	bp++; /* spare6 */
324 	*_bp = bp;
325 
326 	if (volsync)
327 		volsync->creation = creation;
328 }
329 
330 /*
331  * encode the requested attributes into an AFSStoreStatus block
332  */
333 static void xdr_encode_AFS_StoreStatus(__be32 **_bp, struct iattr *attr)
334 {
335 	__be32 *bp = *_bp;
336 	u32 mask = 0, mtime = 0, owner = 0, group = 0, mode = 0;
337 
338 	mask = 0;
339 	if (attr->ia_valid & ATTR_MTIME) {
340 		mask |= AFS_SET_MTIME;
341 		mtime = attr->ia_mtime.tv_sec;
342 	}
343 
344 	if (attr->ia_valid & ATTR_UID) {
345 		mask |= AFS_SET_OWNER;
346 		owner = from_kuid(&init_user_ns, attr->ia_uid);
347 	}
348 
349 	if (attr->ia_valid & ATTR_GID) {
350 		mask |= AFS_SET_GROUP;
351 		group = from_kgid(&init_user_ns, attr->ia_gid);
352 	}
353 
354 	if (attr->ia_valid & ATTR_MODE) {
355 		mask |= AFS_SET_MODE;
356 		mode = attr->ia_mode & S_IALLUGO;
357 	}
358 
359 	*bp++ = htonl(mask);
360 	*bp++ = htonl(mtime);
361 	*bp++ = htonl(owner);
362 	*bp++ = htonl(group);
363 	*bp++ = htonl(mode);
364 	*bp++ = 0;		/* segment size */
365 	*_bp = bp;
366 }
367 
368 /*
369  * decode an AFSFetchVolumeStatus block
370  */
371 static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp,
372 					    struct afs_volume_status *vs)
373 {
374 	const __be32 *bp = *_bp;
375 
376 	vs->vid			= ntohl(*bp++);
377 	vs->parent_id		= ntohl(*bp++);
378 	vs->online		= ntohl(*bp++);
379 	vs->in_service		= ntohl(*bp++);
380 	vs->blessed		= ntohl(*bp++);
381 	vs->needs_salvage	= ntohl(*bp++);
382 	vs->type		= ntohl(*bp++);
383 	vs->min_quota		= ntohl(*bp++);
384 	vs->max_quota		= ntohl(*bp++);
385 	vs->blocks_in_use	= ntohl(*bp++);
386 	vs->part_blocks_avail	= ntohl(*bp++);
387 	vs->part_max_blocks	= ntohl(*bp++);
388 	vs->vol_copy_date	= 0;
389 	vs->vol_backup_date	= 0;
390 	*_bp = bp;
391 }
392 
393 /*
394  * deliver reply data to an FS.FetchStatus
395  */
396 static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
397 {
398 	struct afs_vnode *vnode = call->reply[0];
399 	const __be32 *bp;
400 	int ret;
401 
402 	ret = afs_transfer_reply(call);
403 	if (ret < 0)
404 		return ret;
405 
406 	_enter("{%llx:%llu}", vnode->fid.vid, vnode->fid.vnode);
407 
408 	/* unmarshall the reply once we've received all of it */
409 	bp = call->buffer;
410 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
411 				&call->expected_version, NULL);
412 	if (ret < 0)
413 		return ret;
414 	xdr_decode_AFSCallBack(call, vnode, &bp);
415 	xdr_decode_AFSVolSync(&bp, call->reply[1]);
416 
417 	_leave(" = 0 [done]");
418 	return 0;
419 }
420 
421 /*
422  * FS.FetchStatus operation type
423  */
424 static const struct afs_call_type afs_RXFSFetchStatus_vnode = {
425 	.name		= "FS.FetchStatus(vnode)",
426 	.op		= afs_FS_FetchStatus,
427 	.deliver	= afs_deliver_fs_fetch_status_vnode,
428 	.destructor	= afs_flat_call_destructor,
429 };
430 
431 /*
432  * fetch the status information for a file
433  */
434 int afs_fs_fetch_file_status(struct afs_fs_cursor *fc, struct afs_volsync *volsync,
435 			     bool new_inode)
436 {
437 	struct afs_vnode *vnode = fc->vnode;
438 	struct afs_call *call;
439 	struct afs_net *net = afs_v2net(vnode);
440 	__be32 *bp;
441 
442 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
443 		return yfs_fs_fetch_file_status(fc, volsync, new_inode);
444 
445 	_enter(",%x,{%llx:%llu},,",
446 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
447 
448 	call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus_vnode,
449 				   16, (21 + 3 + 6) * 4);
450 	if (!call) {
451 		fc->ac.error = -ENOMEM;
452 		return -ENOMEM;
453 	}
454 
455 	call->key = fc->key;
456 	call->reply[0] = vnode;
457 	call->reply[1] = volsync;
458 	call->expected_version = new_inode ? 1 : vnode->status.data_version;
459 	call->want_reply_time = true;
460 
461 	/* marshall the parameters */
462 	bp = call->request;
463 	bp[0] = htonl(FSFETCHSTATUS);
464 	bp[1] = htonl(vnode->fid.vid);
465 	bp[2] = htonl(vnode->fid.vnode);
466 	bp[3] = htonl(vnode->fid.unique);
467 
468 	call->cb_break = fc->cb_break;
469 	afs_use_fs_server(call, fc->cbi);
470 	trace_afs_make_fs_call(call, &vnode->fid);
471 
472 	afs_make_call(&fc->ac, call, GFP_NOFS);
473 	return afs_wait_for_call_to_complete(call, &fc->ac);
474 }
475 
476 /*
477  * deliver reply data to an FS.FetchData
478  */
479 static int afs_deliver_fs_fetch_data(struct afs_call *call)
480 {
481 	struct afs_vnode *vnode = call->reply[0];
482 	struct afs_read *req = call->reply[2];
483 	const __be32 *bp;
484 	unsigned int size;
485 	int ret;
486 
487 	_enter("{%u,%zu/%llu}",
488 	       call->unmarshall, iov_iter_count(&call->iter), req->actual_len);
489 
490 	switch (call->unmarshall) {
491 	case 0:
492 		req->actual_len = 0;
493 		req->index = 0;
494 		req->offset = req->pos & (PAGE_SIZE - 1);
495 		call->unmarshall++;
496 		if (call->operation_ID == FSFETCHDATA64) {
497 			afs_extract_to_tmp64(call);
498 		} else {
499 			call->tmp_u = htonl(0);
500 			afs_extract_to_tmp(call);
501 		}
502 
503 		/* Fall through - and extract the returned data length */
504 	case 1:
505 		_debug("extract data length");
506 		ret = afs_extract_data(call, true);
507 		if (ret < 0)
508 			return ret;
509 
510 		req->actual_len = be64_to_cpu(call->tmp64);
511 		_debug("DATA length: %llu", req->actual_len);
512 		req->remain = min(req->len, req->actual_len);
513 		if (req->remain == 0)
514 			goto no_more_data;
515 
516 		call->unmarshall++;
517 
518 	begin_page:
519 		ASSERTCMP(req->index, <, req->nr_pages);
520 		if (req->remain > PAGE_SIZE - req->offset)
521 			size = PAGE_SIZE - req->offset;
522 		else
523 			size = req->remain;
524 		call->bvec[0].bv_len = size;
525 		call->bvec[0].bv_offset = req->offset;
526 		call->bvec[0].bv_page = req->pages[req->index];
527 		iov_iter_bvec(&call->iter, READ, call->bvec, 1, size);
528 		ASSERTCMP(size, <=, PAGE_SIZE);
529 
530 		/* Fall through - and extract the returned data */
531 	case 2:
532 		_debug("extract data %zu/%llu",
533 		       iov_iter_count(&call->iter), req->remain);
534 
535 		ret = afs_extract_data(call, true);
536 		if (ret < 0)
537 			return ret;
538 		req->remain -= call->bvec[0].bv_len;
539 		req->offset += call->bvec[0].bv_len;
540 		ASSERTCMP(req->offset, <=, PAGE_SIZE);
541 		if (req->offset == PAGE_SIZE) {
542 			req->offset = 0;
543 			if (req->page_done)
544 				req->page_done(call, req);
545 			req->index++;
546 			if (req->remain > 0)
547 				goto begin_page;
548 		}
549 
550 		ASSERTCMP(req->remain, ==, 0);
551 		if (req->actual_len <= req->len)
552 			goto no_more_data;
553 
554 		/* Discard any excess data the server gave us */
555 		iov_iter_discard(&call->iter, READ, req->actual_len - req->len);
556 		call->unmarshall = 3;
557 
558 		/* Fall through */
559 	case 3:
560 		_debug("extract discard %zu/%llu",
561 		       iov_iter_count(&call->iter), req->actual_len - req->len);
562 
563 		ret = afs_extract_data(call, true);
564 		if (ret < 0)
565 			return ret;
566 
567 	no_more_data:
568 		call->unmarshall = 4;
569 		afs_extract_to_buf(call, (21 + 3 + 6) * 4);
570 
571 		/* Fall through - and extract the metadata */
572 	case 4:
573 		ret = afs_extract_data(call, false);
574 		if (ret < 0)
575 			return ret;
576 
577 		bp = call->buffer;
578 		ret = afs_decode_status(call, &bp, &vnode->status, vnode,
579 					&vnode->status.data_version, req);
580 		if (ret < 0)
581 			return ret;
582 		xdr_decode_AFSCallBack(call, vnode, &bp);
583 		xdr_decode_AFSVolSync(&bp, call->reply[1]);
584 
585 		call->unmarshall++;
586 
587 	case 5:
588 		break;
589 	}
590 
591 	for (; req->index < req->nr_pages; req->index++) {
592 		if (req->offset < PAGE_SIZE)
593 			zero_user_segment(req->pages[req->index],
594 					  req->offset, PAGE_SIZE);
595 		if (req->page_done)
596 			req->page_done(call, req);
597 		req->offset = 0;
598 	}
599 
600 	_leave(" = 0 [done]");
601 	return 0;
602 }
603 
604 static void afs_fetch_data_destructor(struct afs_call *call)
605 {
606 	struct afs_read *req = call->reply[2];
607 
608 	afs_put_read(req);
609 	afs_flat_call_destructor(call);
610 }
611 
612 /*
613  * FS.FetchData operation type
614  */
615 static const struct afs_call_type afs_RXFSFetchData = {
616 	.name		= "FS.FetchData",
617 	.op		= afs_FS_FetchData,
618 	.deliver	= afs_deliver_fs_fetch_data,
619 	.destructor	= afs_fetch_data_destructor,
620 };
621 
622 static const struct afs_call_type afs_RXFSFetchData64 = {
623 	.name		= "FS.FetchData64",
624 	.op		= afs_FS_FetchData64,
625 	.deliver	= afs_deliver_fs_fetch_data,
626 	.destructor	= afs_fetch_data_destructor,
627 };
628 
629 /*
630  * fetch data from a very large file
631  */
632 static int afs_fs_fetch_data64(struct afs_fs_cursor *fc, struct afs_read *req)
633 {
634 	struct afs_vnode *vnode = fc->vnode;
635 	struct afs_call *call;
636 	struct afs_net *net = afs_v2net(vnode);
637 	__be32 *bp;
638 
639 	_enter("");
640 
641 	call = afs_alloc_flat_call(net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4);
642 	if (!call)
643 		return -ENOMEM;
644 
645 	call->key = fc->key;
646 	call->reply[0] = vnode;
647 	call->reply[1] = NULL; /* volsync */
648 	call->reply[2] = req;
649 	call->expected_version = vnode->status.data_version;
650 	call->want_reply_time = true;
651 
652 	/* marshall the parameters */
653 	bp = call->request;
654 	bp[0] = htonl(FSFETCHDATA64);
655 	bp[1] = htonl(vnode->fid.vid);
656 	bp[2] = htonl(vnode->fid.vnode);
657 	bp[3] = htonl(vnode->fid.unique);
658 	bp[4] = htonl(upper_32_bits(req->pos));
659 	bp[5] = htonl(lower_32_bits(req->pos));
660 	bp[6] = 0;
661 	bp[7] = htonl(lower_32_bits(req->len));
662 
663 	refcount_inc(&req->usage);
664 	call->cb_break = fc->cb_break;
665 	afs_use_fs_server(call, fc->cbi);
666 	trace_afs_make_fs_call(call, &vnode->fid);
667 	afs_make_call(&fc->ac, call, GFP_NOFS);
668 	return afs_wait_for_call_to_complete(call, &fc->ac);
669 }
670 
671 /*
672  * fetch data from a file
673  */
674 int afs_fs_fetch_data(struct afs_fs_cursor *fc, struct afs_read *req)
675 {
676 	struct afs_vnode *vnode = fc->vnode;
677 	struct afs_call *call;
678 	struct afs_net *net = afs_v2net(vnode);
679 	__be32 *bp;
680 
681 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
682 		return yfs_fs_fetch_data(fc, req);
683 
684 	if (upper_32_bits(req->pos) ||
685 	    upper_32_bits(req->len) ||
686 	    upper_32_bits(req->pos + req->len))
687 		return afs_fs_fetch_data64(fc, req);
688 
689 	_enter("");
690 
691 	call = afs_alloc_flat_call(net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4);
692 	if (!call)
693 		return -ENOMEM;
694 
695 	call->key = fc->key;
696 	call->reply[0] = vnode;
697 	call->reply[1] = NULL; /* volsync */
698 	call->reply[2] = req;
699 	call->expected_version = vnode->status.data_version;
700 	call->want_reply_time = true;
701 
702 	/* marshall the parameters */
703 	bp = call->request;
704 	bp[0] = htonl(FSFETCHDATA);
705 	bp[1] = htonl(vnode->fid.vid);
706 	bp[2] = htonl(vnode->fid.vnode);
707 	bp[3] = htonl(vnode->fid.unique);
708 	bp[4] = htonl(lower_32_bits(req->pos));
709 	bp[5] = htonl(lower_32_bits(req->len));
710 
711 	refcount_inc(&req->usage);
712 	call->cb_break = fc->cb_break;
713 	afs_use_fs_server(call, fc->cbi);
714 	trace_afs_make_fs_call(call, &vnode->fid);
715 	afs_make_call(&fc->ac, call, GFP_NOFS);
716 	return afs_wait_for_call_to_complete(call, &fc->ac);
717 }
718 
719 /*
720  * deliver reply data to an FS.CreateFile or an FS.MakeDir
721  */
722 static int afs_deliver_fs_create_vnode(struct afs_call *call)
723 {
724 	struct afs_vnode *vnode = call->reply[0];
725 	const __be32 *bp;
726 	int ret;
727 
728 	_enter("{%u}", call->unmarshall);
729 
730 	ret = afs_transfer_reply(call);
731 	if (ret < 0)
732 		return ret;
733 
734 	/* unmarshall the reply once we've received all of it */
735 	bp = call->buffer;
736 	xdr_decode_AFSFid(&bp, call->reply[1]);
737 	ret = afs_decode_status(call, &bp, call->reply[2], NULL, NULL, NULL);
738 	if (ret < 0)
739 		return ret;
740 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
741 				&call->expected_version, NULL);
742 	if (ret < 0)
743 		return ret;
744 	xdr_decode_AFSCallBack_raw(call, &bp, call->reply[3]);
745 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
746 
747 	_leave(" = 0 [done]");
748 	return 0;
749 }
750 
751 /*
752  * FS.CreateFile and FS.MakeDir operation type
753  */
754 static const struct afs_call_type afs_RXFSCreateFile = {
755 	.name		= "FS.CreateFile",
756 	.op		= afs_FS_CreateFile,
757 	.deliver	= afs_deliver_fs_create_vnode,
758 	.destructor	= afs_flat_call_destructor,
759 };
760 
761 static const struct afs_call_type afs_RXFSMakeDir = {
762 	.name		= "FS.MakeDir",
763 	.op		= afs_FS_MakeDir,
764 	.deliver	= afs_deliver_fs_create_vnode,
765 	.destructor	= afs_flat_call_destructor,
766 };
767 
768 /*
769  * create a file or make a directory
770  */
771 int afs_fs_create(struct afs_fs_cursor *fc,
772 		  const char *name,
773 		  umode_t mode,
774 		  u64 current_data_version,
775 		  struct afs_fid *newfid,
776 		  struct afs_file_status *newstatus,
777 		  struct afs_callback *newcb)
778 {
779 	struct afs_vnode *vnode = fc->vnode;
780 	struct afs_call *call;
781 	struct afs_net *net = afs_v2net(vnode);
782 	size_t namesz, reqsz, padsz;
783 	__be32 *bp;
784 
785 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags)){
786 		if (S_ISDIR(mode))
787 			return yfs_fs_make_dir(fc, name, mode, current_data_version,
788 					       newfid, newstatus, newcb);
789 		else
790 			return yfs_fs_create_file(fc, name, mode, current_data_version,
791 						  newfid, newstatus, newcb);
792 	}
793 
794 	_enter("");
795 
796 	namesz = strlen(name);
797 	padsz = (4 - (namesz & 3)) & 3;
798 	reqsz = (5 * 4) + namesz + padsz + (6 * 4);
799 
800 	call = afs_alloc_flat_call(
801 		net, S_ISDIR(mode) ? &afs_RXFSMakeDir : &afs_RXFSCreateFile,
802 		reqsz, (3 + 21 + 21 + 3 + 6) * 4);
803 	if (!call)
804 		return -ENOMEM;
805 
806 	call->key = fc->key;
807 	call->reply[0] = vnode;
808 	call->reply[1] = newfid;
809 	call->reply[2] = newstatus;
810 	call->reply[3] = newcb;
811 	call->expected_version = current_data_version + 1;
812 	call->want_reply_time = true;
813 
814 	/* marshall the parameters */
815 	bp = call->request;
816 	*bp++ = htonl(S_ISDIR(mode) ? FSMAKEDIR : FSCREATEFILE);
817 	*bp++ = htonl(vnode->fid.vid);
818 	*bp++ = htonl(vnode->fid.vnode);
819 	*bp++ = htonl(vnode->fid.unique);
820 	*bp++ = htonl(namesz);
821 	memcpy(bp, name, namesz);
822 	bp = (void *) bp + namesz;
823 	if (padsz > 0) {
824 		memset(bp, 0, padsz);
825 		bp = (void *) bp + padsz;
826 	}
827 	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
828 	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
829 	*bp++ = 0; /* owner */
830 	*bp++ = 0; /* group */
831 	*bp++ = htonl(mode & S_IALLUGO); /* unix mode */
832 	*bp++ = 0; /* segment size */
833 
834 	afs_use_fs_server(call, fc->cbi);
835 	trace_afs_make_fs_call1(call, &vnode->fid, name);
836 	afs_make_call(&fc->ac, call, GFP_NOFS);
837 	return afs_wait_for_call_to_complete(call, &fc->ac);
838 }
839 
840 /*
841  * Deliver reply data to any operation that returns file status and volume
842  * sync.
843  */
844 static int afs_deliver_fs_status_and_vol(struct afs_call *call)
845 {
846 	struct afs_vnode *vnode = call->reply[0];
847 	const __be32 *bp;
848 	int ret;
849 
850 	_enter("{%u}", call->unmarshall);
851 
852 	ret = afs_transfer_reply(call);
853 	if (ret < 0)
854 		return ret;
855 
856 	/* unmarshall the reply once we've received all of it */
857 	bp = call->buffer;
858 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
859 				&call->expected_version, NULL);
860 	if (ret < 0)
861 		return ret;
862 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
863 
864 	_leave(" = 0 [done]");
865 	return 0;
866 }
867 
868 /*
869  * FS.RemoveDir/FS.RemoveFile operation type
870  */
871 static const struct afs_call_type afs_RXFSRemoveFile = {
872 	.name		= "FS.RemoveFile",
873 	.op		= afs_FS_RemoveFile,
874 	.deliver	= afs_deliver_fs_status_and_vol,
875 	.destructor	= afs_flat_call_destructor,
876 };
877 
878 static const struct afs_call_type afs_RXFSRemoveDir = {
879 	.name		= "FS.RemoveDir",
880 	.op		= afs_FS_RemoveDir,
881 	.deliver	= afs_deliver_fs_status_and_vol,
882 	.destructor	= afs_flat_call_destructor,
883 };
884 
885 /*
886  * remove a file or directory
887  */
888 int afs_fs_remove(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
889 		  const char *name, bool isdir, u64 current_data_version)
890 {
891 	struct afs_vnode *dvnode = fc->vnode;
892 	struct afs_call *call;
893 	struct afs_net *net = afs_v2net(dvnode);
894 	size_t namesz, reqsz, padsz;
895 	__be32 *bp;
896 
897 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
898 		return yfs_fs_remove(fc, vnode, name, isdir, current_data_version);
899 
900 	_enter("");
901 
902 	namesz = strlen(name);
903 	padsz = (4 - (namesz & 3)) & 3;
904 	reqsz = (5 * 4) + namesz + padsz;
905 
906 	call = afs_alloc_flat_call(
907 		net, isdir ? &afs_RXFSRemoveDir : &afs_RXFSRemoveFile,
908 		reqsz, (21 + 6) * 4);
909 	if (!call)
910 		return -ENOMEM;
911 
912 	call->key = fc->key;
913 	call->reply[0] = dvnode;
914 	call->reply[1] = vnode;
915 	call->expected_version = current_data_version + 1;
916 
917 	/* marshall the parameters */
918 	bp = call->request;
919 	*bp++ = htonl(isdir ? FSREMOVEDIR : FSREMOVEFILE);
920 	*bp++ = htonl(dvnode->fid.vid);
921 	*bp++ = htonl(dvnode->fid.vnode);
922 	*bp++ = htonl(dvnode->fid.unique);
923 	*bp++ = htonl(namesz);
924 	memcpy(bp, name, namesz);
925 	bp = (void *) bp + namesz;
926 	if (padsz > 0) {
927 		memset(bp, 0, padsz);
928 		bp = (void *) bp + padsz;
929 	}
930 
931 	afs_use_fs_server(call, fc->cbi);
932 	trace_afs_make_fs_call1(call, &dvnode->fid, name);
933 	afs_make_call(&fc->ac, call, GFP_NOFS);
934 	return afs_wait_for_call_to_complete(call, &fc->ac);
935 }
936 
937 /*
938  * deliver reply data to an FS.Link
939  */
940 static int afs_deliver_fs_link(struct afs_call *call)
941 {
942 	struct afs_vnode *dvnode = call->reply[0], *vnode = call->reply[1];
943 	const __be32 *bp;
944 	int ret;
945 
946 	_enter("{%u}", call->unmarshall);
947 
948 	ret = afs_transfer_reply(call);
949 	if (ret < 0)
950 		return ret;
951 
952 	/* unmarshall the reply once we've received all of it */
953 	bp = call->buffer;
954 	ret = afs_decode_status(call, &bp, &vnode->status, vnode, NULL, NULL);
955 	if (ret < 0)
956 		return ret;
957 	ret = afs_decode_status(call, &bp, &dvnode->status, dvnode,
958 				&call->expected_version, NULL);
959 	if (ret < 0)
960 		return ret;
961 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
962 
963 	_leave(" = 0 [done]");
964 	return 0;
965 }
966 
967 /*
968  * FS.Link operation type
969  */
970 static const struct afs_call_type afs_RXFSLink = {
971 	.name		= "FS.Link",
972 	.op		= afs_FS_Link,
973 	.deliver	= afs_deliver_fs_link,
974 	.destructor	= afs_flat_call_destructor,
975 };
976 
977 /*
978  * make a hard link
979  */
980 int afs_fs_link(struct afs_fs_cursor *fc, struct afs_vnode *vnode,
981 		const char *name, u64 current_data_version)
982 {
983 	struct afs_vnode *dvnode = fc->vnode;
984 	struct afs_call *call;
985 	struct afs_net *net = afs_v2net(vnode);
986 	size_t namesz, reqsz, padsz;
987 	__be32 *bp;
988 
989 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
990 		return yfs_fs_link(fc, vnode, name, current_data_version);
991 
992 	_enter("");
993 
994 	namesz = strlen(name);
995 	padsz = (4 - (namesz & 3)) & 3;
996 	reqsz = (5 * 4) + namesz + padsz + (3 * 4);
997 
998 	call = afs_alloc_flat_call(net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4);
999 	if (!call)
1000 		return -ENOMEM;
1001 
1002 	call->key = fc->key;
1003 	call->reply[0] = dvnode;
1004 	call->reply[1] = vnode;
1005 	call->expected_version = current_data_version + 1;
1006 
1007 	/* marshall the parameters */
1008 	bp = call->request;
1009 	*bp++ = htonl(FSLINK);
1010 	*bp++ = htonl(dvnode->fid.vid);
1011 	*bp++ = htonl(dvnode->fid.vnode);
1012 	*bp++ = htonl(dvnode->fid.unique);
1013 	*bp++ = htonl(namesz);
1014 	memcpy(bp, name, namesz);
1015 	bp = (void *) bp + namesz;
1016 	if (padsz > 0) {
1017 		memset(bp, 0, padsz);
1018 		bp = (void *) bp + padsz;
1019 	}
1020 	*bp++ = htonl(vnode->fid.vid);
1021 	*bp++ = htonl(vnode->fid.vnode);
1022 	*bp++ = htonl(vnode->fid.unique);
1023 
1024 	afs_use_fs_server(call, fc->cbi);
1025 	trace_afs_make_fs_call1(call, &vnode->fid, name);
1026 	afs_make_call(&fc->ac, call, GFP_NOFS);
1027 	return afs_wait_for_call_to_complete(call, &fc->ac);
1028 }
1029 
1030 /*
1031  * deliver reply data to an FS.Symlink
1032  */
1033 static int afs_deliver_fs_symlink(struct afs_call *call)
1034 {
1035 	struct afs_vnode *vnode = call->reply[0];
1036 	const __be32 *bp;
1037 	int ret;
1038 
1039 	_enter("{%u}", call->unmarshall);
1040 
1041 	ret = afs_transfer_reply(call);
1042 	if (ret < 0)
1043 		return ret;
1044 
1045 	/* unmarshall the reply once we've received all of it */
1046 	bp = call->buffer;
1047 	xdr_decode_AFSFid(&bp, call->reply[1]);
1048 	ret = afs_decode_status(call, &bp, call->reply[2], NULL, NULL, NULL);
1049 	if (ret < 0)
1050 		return ret;
1051 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
1052 				&call->expected_version, NULL);
1053 	if (ret < 0)
1054 		return ret;
1055 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1056 
1057 	_leave(" = 0 [done]");
1058 	return 0;
1059 }
1060 
1061 /*
1062  * FS.Symlink operation type
1063  */
1064 static const struct afs_call_type afs_RXFSSymlink = {
1065 	.name		= "FS.Symlink",
1066 	.op		= afs_FS_Symlink,
1067 	.deliver	= afs_deliver_fs_symlink,
1068 	.destructor	= afs_flat_call_destructor,
1069 };
1070 
1071 /*
1072  * create a symbolic link
1073  */
1074 int afs_fs_symlink(struct afs_fs_cursor *fc,
1075 		   const char *name,
1076 		   const char *contents,
1077 		   u64 current_data_version,
1078 		   struct afs_fid *newfid,
1079 		   struct afs_file_status *newstatus)
1080 {
1081 	struct afs_vnode *vnode = fc->vnode;
1082 	struct afs_call *call;
1083 	struct afs_net *net = afs_v2net(vnode);
1084 	size_t namesz, reqsz, padsz, c_namesz, c_padsz;
1085 	__be32 *bp;
1086 
1087 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1088 		return yfs_fs_symlink(fc, name, contents, current_data_version,
1089 				      newfid, newstatus);
1090 
1091 	_enter("");
1092 
1093 	namesz = strlen(name);
1094 	padsz = (4 - (namesz & 3)) & 3;
1095 
1096 	c_namesz = strlen(contents);
1097 	c_padsz = (4 - (c_namesz & 3)) & 3;
1098 
1099 	reqsz = (6 * 4) + namesz + padsz + c_namesz + c_padsz + (6 * 4);
1100 
1101 	call = afs_alloc_flat_call(net, &afs_RXFSSymlink, reqsz,
1102 				   (3 + 21 + 21 + 6) * 4);
1103 	if (!call)
1104 		return -ENOMEM;
1105 
1106 	call->key = fc->key;
1107 	call->reply[0] = vnode;
1108 	call->reply[1] = newfid;
1109 	call->reply[2] = newstatus;
1110 	call->expected_version = current_data_version + 1;
1111 
1112 	/* marshall the parameters */
1113 	bp = call->request;
1114 	*bp++ = htonl(FSSYMLINK);
1115 	*bp++ = htonl(vnode->fid.vid);
1116 	*bp++ = htonl(vnode->fid.vnode);
1117 	*bp++ = htonl(vnode->fid.unique);
1118 	*bp++ = htonl(namesz);
1119 	memcpy(bp, name, namesz);
1120 	bp = (void *) bp + namesz;
1121 	if (padsz > 0) {
1122 		memset(bp, 0, padsz);
1123 		bp = (void *) bp + padsz;
1124 	}
1125 	*bp++ = htonl(c_namesz);
1126 	memcpy(bp, contents, c_namesz);
1127 	bp = (void *) bp + c_namesz;
1128 	if (c_padsz > 0) {
1129 		memset(bp, 0, c_padsz);
1130 		bp = (void *) bp + c_padsz;
1131 	}
1132 	*bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
1133 	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
1134 	*bp++ = 0; /* owner */
1135 	*bp++ = 0; /* group */
1136 	*bp++ = htonl(S_IRWXUGO); /* unix mode */
1137 	*bp++ = 0; /* segment size */
1138 
1139 	afs_use_fs_server(call, fc->cbi);
1140 	trace_afs_make_fs_call1(call, &vnode->fid, name);
1141 	afs_make_call(&fc->ac, call, GFP_NOFS);
1142 	return afs_wait_for_call_to_complete(call, &fc->ac);
1143 }
1144 
1145 /*
1146  * deliver reply data to an FS.Rename
1147  */
1148 static int afs_deliver_fs_rename(struct afs_call *call)
1149 {
1150 	struct afs_vnode *orig_dvnode = call->reply[0], *new_dvnode = call->reply[1];
1151 	const __be32 *bp;
1152 	int ret;
1153 
1154 	_enter("{%u}", call->unmarshall);
1155 
1156 	ret = afs_transfer_reply(call);
1157 	if (ret < 0)
1158 		return ret;
1159 
1160 	/* unmarshall the reply once we've received all of it */
1161 	bp = call->buffer;
1162 	ret = afs_decode_status(call, &bp, &orig_dvnode->status, orig_dvnode,
1163 				&call->expected_version, NULL);
1164 	if (ret < 0)
1165 		return ret;
1166 	if (new_dvnode != orig_dvnode) {
1167 		ret = afs_decode_status(call, &bp, &new_dvnode->status, new_dvnode,
1168 					&call->expected_version_2, NULL);
1169 		if (ret < 0)
1170 			return ret;
1171 	}
1172 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1173 
1174 	_leave(" = 0 [done]");
1175 	return 0;
1176 }
1177 
1178 /*
1179  * FS.Rename operation type
1180  */
1181 static const struct afs_call_type afs_RXFSRename = {
1182 	.name		= "FS.Rename",
1183 	.op		= afs_FS_Rename,
1184 	.deliver	= afs_deliver_fs_rename,
1185 	.destructor	= afs_flat_call_destructor,
1186 };
1187 
1188 /*
1189  * create a symbolic link
1190  */
1191 int afs_fs_rename(struct afs_fs_cursor *fc,
1192 		  const char *orig_name,
1193 		  struct afs_vnode *new_dvnode,
1194 		  const char *new_name,
1195 		  u64 current_orig_data_version,
1196 		  u64 current_new_data_version)
1197 {
1198 	struct afs_vnode *orig_dvnode = fc->vnode;
1199 	struct afs_call *call;
1200 	struct afs_net *net = afs_v2net(orig_dvnode);
1201 	size_t reqsz, o_namesz, o_padsz, n_namesz, n_padsz;
1202 	__be32 *bp;
1203 
1204 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1205 		return yfs_fs_rename(fc, orig_name,
1206 				     new_dvnode, new_name,
1207 				     current_orig_data_version,
1208 				     current_new_data_version);
1209 
1210 	_enter("");
1211 
1212 	o_namesz = strlen(orig_name);
1213 	o_padsz = (4 - (o_namesz & 3)) & 3;
1214 
1215 	n_namesz = strlen(new_name);
1216 	n_padsz = (4 - (n_namesz & 3)) & 3;
1217 
1218 	reqsz = (4 * 4) +
1219 		4 + o_namesz + o_padsz +
1220 		(3 * 4) +
1221 		4 + n_namesz + n_padsz;
1222 
1223 	call = afs_alloc_flat_call(net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4);
1224 	if (!call)
1225 		return -ENOMEM;
1226 
1227 	call->key = fc->key;
1228 	call->reply[0] = orig_dvnode;
1229 	call->reply[1] = new_dvnode;
1230 	call->expected_version = current_orig_data_version + 1;
1231 	call->expected_version_2 = current_new_data_version + 1;
1232 
1233 	/* marshall the parameters */
1234 	bp = call->request;
1235 	*bp++ = htonl(FSRENAME);
1236 	*bp++ = htonl(orig_dvnode->fid.vid);
1237 	*bp++ = htonl(orig_dvnode->fid.vnode);
1238 	*bp++ = htonl(orig_dvnode->fid.unique);
1239 	*bp++ = htonl(o_namesz);
1240 	memcpy(bp, orig_name, o_namesz);
1241 	bp = (void *) bp + o_namesz;
1242 	if (o_padsz > 0) {
1243 		memset(bp, 0, o_padsz);
1244 		bp = (void *) bp + o_padsz;
1245 	}
1246 
1247 	*bp++ = htonl(new_dvnode->fid.vid);
1248 	*bp++ = htonl(new_dvnode->fid.vnode);
1249 	*bp++ = htonl(new_dvnode->fid.unique);
1250 	*bp++ = htonl(n_namesz);
1251 	memcpy(bp, new_name, n_namesz);
1252 	bp = (void *) bp + n_namesz;
1253 	if (n_padsz > 0) {
1254 		memset(bp, 0, n_padsz);
1255 		bp = (void *) bp + n_padsz;
1256 	}
1257 
1258 	afs_use_fs_server(call, fc->cbi);
1259 	trace_afs_make_fs_call2(call, &orig_dvnode->fid, orig_name, new_name);
1260 	afs_make_call(&fc->ac, call, GFP_NOFS);
1261 	return afs_wait_for_call_to_complete(call, &fc->ac);
1262 }
1263 
1264 /*
1265  * deliver reply data to an FS.StoreData
1266  */
1267 static int afs_deliver_fs_store_data(struct afs_call *call)
1268 {
1269 	struct afs_vnode *vnode = call->reply[0];
1270 	const __be32 *bp;
1271 	int ret;
1272 
1273 	_enter("");
1274 
1275 	ret = afs_transfer_reply(call);
1276 	if (ret < 0)
1277 		return ret;
1278 
1279 	/* unmarshall the reply once we've received all of it */
1280 	bp = call->buffer;
1281 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
1282 				&call->expected_version, NULL);
1283 	if (ret < 0)
1284 		return ret;
1285 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1286 
1287 	afs_pages_written_back(vnode, call);
1288 
1289 	_leave(" = 0 [done]");
1290 	return 0;
1291 }
1292 
1293 /*
1294  * FS.StoreData operation type
1295  */
1296 static const struct afs_call_type afs_RXFSStoreData = {
1297 	.name		= "FS.StoreData",
1298 	.op		= afs_FS_StoreData,
1299 	.deliver	= afs_deliver_fs_store_data,
1300 	.destructor	= afs_flat_call_destructor,
1301 };
1302 
1303 static const struct afs_call_type afs_RXFSStoreData64 = {
1304 	.name		= "FS.StoreData64",
1305 	.op		= afs_FS_StoreData64,
1306 	.deliver	= afs_deliver_fs_store_data,
1307 	.destructor	= afs_flat_call_destructor,
1308 };
1309 
1310 /*
1311  * store a set of pages to a very large file
1312  */
1313 static int afs_fs_store_data64(struct afs_fs_cursor *fc,
1314 			       struct address_space *mapping,
1315 			       pgoff_t first, pgoff_t last,
1316 			       unsigned offset, unsigned to,
1317 			       loff_t size, loff_t pos, loff_t i_size)
1318 {
1319 	struct afs_vnode *vnode = fc->vnode;
1320 	struct afs_call *call;
1321 	struct afs_net *net = afs_v2net(vnode);
1322 	__be32 *bp;
1323 
1324 	_enter(",%x,{%llx:%llu},,",
1325 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1326 
1327 	call = afs_alloc_flat_call(net, &afs_RXFSStoreData64,
1328 				   (4 + 6 + 3 * 2) * 4,
1329 				   (21 + 6) * 4);
1330 	if (!call)
1331 		return -ENOMEM;
1332 
1333 	call->key = fc->key;
1334 	call->mapping = mapping;
1335 	call->reply[0] = vnode;
1336 	call->first = first;
1337 	call->last = last;
1338 	call->first_offset = offset;
1339 	call->last_to = to;
1340 	call->send_pages = true;
1341 	call->expected_version = vnode->status.data_version + 1;
1342 
1343 	/* marshall the parameters */
1344 	bp = call->request;
1345 	*bp++ = htonl(FSSTOREDATA64);
1346 	*bp++ = htonl(vnode->fid.vid);
1347 	*bp++ = htonl(vnode->fid.vnode);
1348 	*bp++ = htonl(vnode->fid.unique);
1349 
1350 	*bp++ = htonl(AFS_SET_MTIME); /* mask */
1351 	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
1352 	*bp++ = 0; /* owner */
1353 	*bp++ = 0; /* group */
1354 	*bp++ = 0; /* unix mode */
1355 	*bp++ = 0; /* segment size */
1356 
1357 	*bp++ = htonl(pos >> 32);
1358 	*bp++ = htonl((u32) pos);
1359 	*bp++ = htonl(size >> 32);
1360 	*bp++ = htonl((u32) size);
1361 	*bp++ = htonl(i_size >> 32);
1362 	*bp++ = htonl((u32) i_size);
1363 
1364 	trace_afs_make_fs_call(call, &vnode->fid);
1365 	afs_make_call(&fc->ac, call, GFP_NOFS);
1366 	return afs_wait_for_call_to_complete(call, &fc->ac);
1367 }
1368 
1369 /*
1370  * store a set of pages
1371  */
1372 int afs_fs_store_data(struct afs_fs_cursor *fc, struct address_space *mapping,
1373 		      pgoff_t first, pgoff_t last,
1374 		      unsigned offset, unsigned to)
1375 {
1376 	struct afs_vnode *vnode = fc->vnode;
1377 	struct afs_call *call;
1378 	struct afs_net *net = afs_v2net(vnode);
1379 	loff_t size, pos, i_size;
1380 	__be32 *bp;
1381 
1382 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1383 		return yfs_fs_store_data(fc, mapping, first, last, offset, to);
1384 
1385 	_enter(",%x,{%llx:%llu},,",
1386 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1387 
1388 	size = (loff_t)to - (loff_t)offset;
1389 	if (first != last)
1390 		size += (loff_t)(last - first) << PAGE_SHIFT;
1391 	pos = (loff_t)first << PAGE_SHIFT;
1392 	pos += offset;
1393 
1394 	i_size = i_size_read(&vnode->vfs_inode);
1395 	if (pos + size > i_size)
1396 		i_size = size + pos;
1397 
1398 	_debug("size %llx, at %llx, i_size %llx",
1399 	       (unsigned long long) size, (unsigned long long) pos,
1400 	       (unsigned long long) i_size);
1401 
1402 	if (pos >> 32 || i_size >> 32 || size >> 32 || (pos + size) >> 32)
1403 		return afs_fs_store_data64(fc, mapping, first, last, offset, to,
1404 					   size, pos, i_size);
1405 
1406 	call = afs_alloc_flat_call(net, &afs_RXFSStoreData,
1407 				   (4 + 6 + 3) * 4,
1408 				   (21 + 6) * 4);
1409 	if (!call)
1410 		return -ENOMEM;
1411 
1412 	call->key = fc->key;
1413 	call->mapping = mapping;
1414 	call->reply[0] = vnode;
1415 	call->first = first;
1416 	call->last = last;
1417 	call->first_offset = offset;
1418 	call->last_to = to;
1419 	call->send_pages = true;
1420 	call->expected_version = vnode->status.data_version + 1;
1421 
1422 	/* marshall the parameters */
1423 	bp = call->request;
1424 	*bp++ = htonl(FSSTOREDATA);
1425 	*bp++ = htonl(vnode->fid.vid);
1426 	*bp++ = htonl(vnode->fid.vnode);
1427 	*bp++ = htonl(vnode->fid.unique);
1428 
1429 	*bp++ = htonl(AFS_SET_MTIME); /* mask */
1430 	*bp++ = htonl(vnode->vfs_inode.i_mtime.tv_sec); /* mtime */
1431 	*bp++ = 0; /* owner */
1432 	*bp++ = 0; /* group */
1433 	*bp++ = 0; /* unix mode */
1434 	*bp++ = 0; /* segment size */
1435 
1436 	*bp++ = htonl(pos);
1437 	*bp++ = htonl(size);
1438 	*bp++ = htonl(i_size);
1439 
1440 	afs_use_fs_server(call, fc->cbi);
1441 	trace_afs_make_fs_call(call, &vnode->fid);
1442 	afs_make_call(&fc->ac, call, GFP_NOFS);
1443 	return afs_wait_for_call_to_complete(call, &fc->ac);
1444 }
1445 
1446 /*
1447  * deliver reply data to an FS.StoreStatus
1448  */
1449 static int afs_deliver_fs_store_status(struct afs_call *call)
1450 {
1451 	struct afs_vnode *vnode = call->reply[0];
1452 	const __be32 *bp;
1453 	int ret;
1454 
1455 	_enter("");
1456 
1457 	ret = afs_transfer_reply(call);
1458 	if (ret < 0)
1459 		return ret;
1460 
1461 	/* unmarshall the reply once we've received all of it */
1462 	bp = call->buffer;
1463 	ret = afs_decode_status(call, &bp, &vnode->status, vnode,
1464 				&call->expected_version, NULL);
1465 	if (ret < 0)
1466 		return ret;
1467 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1468 
1469 	_leave(" = 0 [done]");
1470 	return 0;
1471 }
1472 
1473 /*
1474  * FS.StoreStatus operation type
1475  */
1476 static const struct afs_call_type afs_RXFSStoreStatus = {
1477 	.name		= "FS.StoreStatus",
1478 	.op		= afs_FS_StoreStatus,
1479 	.deliver	= afs_deliver_fs_store_status,
1480 	.destructor	= afs_flat_call_destructor,
1481 };
1482 
1483 static const struct afs_call_type afs_RXFSStoreData_as_Status = {
1484 	.name		= "FS.StoreData",
1485 	.op		= afs_FS_StoreData,
1486 	.deliver	= afs_deliver_fs_store_status,
1487 	.destructor	= afs_flat_call_destructor,
1488 };
1489 
1490 static const struct afs_call_type afs_RXFSStoreData64_as_Status = {
1491 	.name		= "FS.StoreData64",
1492 	.op		= afs_FS_StoreData64,
1493 	.deliver	= afs_deliver_fs_store_status,
1494 	.destructor	= afs_flat_call_destructor,
1495 };
1496 
1497 /*
1498  * set the attributes on a very large file, using FS.StoreData rather than
1499  * FS.StoreStatus so as to alter the file size also
1500  */
1501 static int afs_fs_setattr_size64(struct afs_fs_cursor *fc, struct iattr *attr)
1502 {
1503 	struct afs_vnode *vnode = fc->vnode;
1504 	struct afs_call *call;
1505 	struct afs_net *net = afs_v2net(vnode);
1506 	__be32 *bp;
1507 
1508 	_enter(",%x,{%llx:%llu},,",
1509 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1510 
1511 	ASSERT(attr->ia_valid & ATTR_SIZE);
1512 
1513 	call = afs_alloc_flat_call(net, &afs_RXFSStoreData64_as_Status,
1514 				   (4 + 6 + 3 * 2) * 4,
1515 				   (21 + 6) * 4);
1516 	if (!call)
1517 		return -ENOMEM;
1518 
1519 	call->key = fc->key;
1520 	call->reply[0] = vnode;
1521 	call->expected_version = vnode->status.data_version + 1;
1522 
1523 	/* marshall the parameters */
1524 	bp = call->request;
1525 	*bp++ = htonl(FSSTOREDATA64);
1526 	*bp++ = htonl(vnode->fid.vid);
1527 	*bp++ = htonl(vnode->fid.vnode);
1528 	*bp++ = htonl(vnode->fid.unique);
1529 
1530 	xdr_encode_AFS_StoreStatus(&bp, attr);
1531 
1532 	*bp++ = htonl(attr->ia_size >> 32);	/* position of start of write */
1533 	*bp++ = htonl((u32) attr->ia_size);
1534 	*bp++ = 0;				/* size of write */
1535 	*bp++ = 0;
1536 	*bp++ = htonl(attr->ia_size >> 32);	/* new file length */
1537 	*bp++ = htonl((u32) attr->ia_size);
1538 
1539 	afs_use_fs_server(call, fc->cbi);
1540 	trace_afs_make_fs_call(call, &vnode->fid);
1541 	afs_make_call(&fc->ac, call, GFP_NOFS);
1542 	return afs_wait_for_call_to_complete(call, &fc->ac);
1543 }
1544 
1545 /*
1546  * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus
1547  * so as to alter the file size also
1548  */
1549 static int afs_fs_setattr_size(struct afs_fs_cursor *fc, struct iattr *attr)
1550 {
1551 	struct afs_vnode *vnode = fc->vnode;
1552 	struct afs_call *call;
1553 	struct afs_net *net = afs_v2net(vnode);
1554 	__be32 *bp;
1555 
1556 	_enter(",%x,{%llx:%llu},,",
1557 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1558 
1559 	ASSERT(attr->ia_valid & ATTR_SIZE);
1560 	if (attr->ia_size >> 32)
1561 		return afs_fs_setattr_size64(fc, attr);
1562 
1563 	call = afs_alloc_flat_call(net, &afs_RXFSStoreData_as_Status,
1564 				   (4 + 6 + 3) * 4,
1565 				   (21 + 6) * 4);
1566 	if (!call)
1567 		return -ENOMEM;
1568 
1569 	call->key = fc->key;
1570 	call->reply[0] = vnode;
1571 	call->expected_version = vnode->status.data_version + 1;
1572 
1573 	/* marshall the parameters */
1574 	bp = call->request;
1575 	*bp++ = htonl(FSSTOREDATA);
1576 	*bp++ = htonl(vnode->fid.vid);
1577 	*bp++ = htonl(vnode->fid.vnode);
1578 	*bp++ = htonl(vnode->fid.unique);
1579 
1580 	xdr_encode_AFS_StoreStatus(&bp, attr);
1581 
1582 	*bp++ = htonl(attr->ia_size);		/* position of start of write */
1583 	*bp++ = 0;				/* size of write */
1584 	*bp++ = htonl(attr->ia_size);		/* new file length */
1585 
1586 	afs_use_fs_server(call, fc->cbi);
1587 	trace_afs_make_fs_call(call, &vnode->fid);
1588 	afs_make_call(&fc->ac, call, GFP_NOFS);
1589 	return afs_wait_for_call_to_complete(call, &fc->ac);
1590 }
1591 
1592 /*
1593  * set the attributes on a file, using FS.StoreData if there's a change in file
1594  * size, and FS.StoreStatus otherwise
1595  */
1596 int afs_fs_setattr(struct afs_fs_cursor *fc, struct iattr *attr)
1597 {
1598 	struct afs_vnode *vnode = fc->vnode;
1599 	struct afs_call *call;
1600 	struct afs_net *net = afs_v2net(vnode);
1601 	__be32 *bp;
1602 
1603 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1604 		return yfs_fs_setattr(fc, attr);
1605 
1606 	if (attr->ia_valid & ATTR_SIZE)
1607 		return afs_fs_setattr_size(fc, attr);
1608 
1609 	_enter(",%x,{%llx:%llu},,",
1610 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
1611 
1612 	call = afs_alloc_flat_call(net, &afs_RXFSStoreStatus,
1613 				   (4 + 6) * 4,
1614 				   (21 + 6) * 4);
1615 	if (!call)
1616 		return -ENOMEM;
1617 
1618 	call->key = fc->key;
1619 	call->reply[0] = vnode;
1620 	call->expected_version = vnode->status.data_version;
1621 
1622 	/* marshall the parameters */
1623 	bp = call->request;
1624 	*bp++ = htonl(FSSTORESTATUS);
1625 	*bp++ = htonl(vnode->fid.vid);
1626 	*bp++ = htonl(vnode->fid.vnode);
1627 	*bp++ = htonl(vnode->fid.unique);
1628 
1629 	xdr_encode_AFS_StoreStatus(&bp, attr);
1630 
1631 	afs_use_fs_server(call, fc->cbi);
1632 	trace_afs_make_fs_call(call, &vnode->fid);
1633 	afs_make_call(&fc->ac, call, GFP_NOFS);
1634 	return afs_wait_for_call_to_complete(call, &fc->ac);
1635 }
1636 
1637 /*
1638  * deliver reply data to an FS.GetVolumeStatus
1639  */
1640 static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1641 {
1642 	const __be32 *bp;
1643 	char *p;
1644 	u32 size;
1645 	int ret;
1646 
1647 	_enter("{%u}", call->unmarshall);
1648 
1649 	switch (call->unmarshall) {
1650 	case 0:
1651 		call->unmarshall++;
1652 		afs_extract_to_buf(call, 12 * 4);
1653 
1654 		/* Fall through - and extract the returned status record */
1655 	case 1:
1656 		_debug("extract status");
1657 		ret = afs_extract_data(call, true);
1658 		if (ret < 0)
1659 			return ret;
1660 
1661 		bp = call->buffer;
1662 		xdr_decode_AFSFetchVolumeStatus(&bp, call->reply[1]);
1663 		call->unmarshall++;
1664 		afs_extract_to_tmp(call);
1665 
1666 		/* Fall through - and extract the volume name length */
1667 	case 2:
1668 		ret = afs_extract_data(call, true);
1669 		if (ret < 0)
1670 			return ret;
1671 
1672 		call->count = ntohl(call->tmp);
1673 		_debug("volname length: %u", call->count);
1674 		if (call->count >= AFSNAMEMAX)
1675 			return afs_protocol_error(call, -EBADMSG,
1676 						  afs_eproto_volname_len);
1677 		size = (call->count + 3) & ~3; /* It's padded */
1678 		afs_extract_begin(call, call->reply[2], size);
1679 		call->unmarshall++;
1680 
1681 		/* Fall through - and extract the volume name */
1682 	case 3:
1683 		_debug("extract volname");
1684 		ret = afs_extract_data(call, true);
1685 		if (ret < 0)
1686 			return ret;
1687 
1688 		p = call->reply[2];
1689 		p[call->count] = 0;
1690 		_debug("volname '%s'", p);
1691 		afs_extract_to_tmp(call);
1692 		call->unmarshall++;
1693 
1694 		/* Fall through - and extract the offline message length */
1695 	case 4:
1696 		ret = afs_extract_data(call, true);
1697 		if (ret < 0)
1698 			return ret;
1699 
1700 		call->count = ntohl(call->tmp);
1701 		_debug("offline msg length: %u", call->count);
1702 		if (call->count >= AFSNAMEMAX)
1703 			return afs_protocol_error(call, -EBADMSG,
1704 						  afs_eproto_offline_msg_len);
1705 		size = (call->count + 3) & ~3; /* It's padded */
1706 		afs_extract_begin(call, call->reply[2], size);
1707 		call->unmarshall++;
1708 
1709 		/* Fall through - and extract the offline message */
1710 	case 5:
1711 		_debug("extract offline");
1712 		ret = afs_extract_data(call, true);
1713 		if (ret < 0)
1714 			return ret;
1715 
1716 		p = call->reply[2];
1717 		p[call->count] = 0;
1718 		_debug("offline '%s'", p);
1719 
1720 		afs_extract_to_tmp(call);
1721 		call->unmarshall++;
1722 
1723 		/* Fall through - and extract the message of the day length */
1724 	case 6:
1725 		ret = afs_extract_data(call, true);
1726 		if (ret < 0)
1727 			return ret;
1728 
1729 		call->count = ntohl(call->tmp);
1730 		_debug("motd length: %u", call->count);
1731 		if (call->count >= AFSNAMEMAX)
1732 			return afs_protocol_error(call, -EBADMSG,
1733 						  afs_eproto_motd_len);
1734 		size = (call->count + 3) & ~3; /* It's padded */
1735 		afs_extract_begin(call, call->reply[2], size);
1736 		call->unmarshall++;
1737 
1738 		/* Fall through - and extract the message of the day */
1739 	case 7:
1740 		_debug("extract motd");
1741 		ret = afs_extract_data(call, false);
1742 		if (ret < 0)
1743 			return ret;
1744 
1745 		p = call->reply[2];
1746 		p[call->count] = 0;
1747 		_debug("motd '%s'", p);
1748 
1749 		call->unmarshall++;
1750 
1751 	case 8:
1752 		break;
1753 	}
1754 
1755 	_leave(" = 0 [done]");
1756 	return 0;
1757 }
1758 
1759 /*
1760  * destroy an FS.GetVolumeStatus call
1761  */
1762 static void afs_get_volume_status_call_destructor(struct afs_call *call)
1763 {
1764 	kfree(call->reply[2]);
1765 	call->reply[2] = NULL;
1766 	afs_flat_call_destructor(call);
1767 }
1768 
1769 /*
1770  * FS.GetVolumeStatus operation type
1771  */
1772 static const struct afs_call_type afs_RXFSGetVolumeStatus = {
1773 	.name		= "FS.GetVolumeStatus",
1774 	.op		= afs_FS_GetVolumeStatus,
1775 	.deliver	= afs_deliver_fs_get_volume_status,
1776 	.destructor	= afs_get_volume_status_call_destructor,
1777 };
1778 
1779 /*
1780  * fetch the status of a volume
1781  */
1782 int afs_fs_get_volume_status(struct afs_fs_cursor *fc,
1783 			     struct afs_volume_status *vs)
1784 {
1785 	struct afs_vnode *vnode = fc->vnode;
1786 	struct afs_call *call;
1787 	struct afs_net *net = afs_v2net(vnode);
1788 	__be32 *bp;
1789 	void *tmpbuf;
1790 
1791 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1792 		return yfs_fs_get_volume_status(fc, vs);
1793 
1794 	_enter("");
1795 
1796 	tmpbuf = kmalloc(AFSOPAQUEMAX, GFP_KERNEL);
1797 	if (!tmpbuf)
1798 		return -ENOMEM;
1799 
1800 	call = afs_alloc_flat_call(net, &afs_RXFSGetVolumeStatus, 2 * 4, 12 * 4);
1801 	if (!call) {
1802 		kfree(tmpbuf);
1803 		return -ENOMEM;
1804 	}
1805 
1806 	call->key = fc->key;
1807 	call->reply[0] = vnode;
1808 	call->reply[1] = vs;
1809 	call->reply[2] = tmpbuf;
1810 
1811 	/* marshall the parameters */
1812 	bp = call->request;
1813 	bp[0] = htonl(FSGETVOLUMESTATUS);
1814 	bp[1] = htonl(vnode->fid.vid);
1815 
1816 	afs_use_fs_server(call, fc->cbi);
1817 	trace_afs_make_fs_call(call, &vnode->fid);
1818 	afs_make_call(&fc->ac, call, GFP_NOFS);
1819 	return afs_wait_for_call_to_complete(call, &fc->ac);
1820 }
1821 
1822 /*
1823  * deliver reply data to an FS.SetLock, FS.ExtendLock or FS.ReleaseLock
1824  */
1825 static int afs_deliver_fs_xxxx_lock(struct afs_call *call)
1826 {
1827 	const __be32 *bp;
1828 	int ret;
1829 
1830 	_enter("{%u}", call->unmarshall);
1831 
1832 	ret = afs_transfer_reply(call);
1833 	if (ret < 0)
1834 		return ret;
1835 
1836 	/* unmarshall the reply once we've received all of it */
1837 	bp = call->buffer;
1838 	/* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
1839 
1840 	_leave(" = 0 [done]");
1841 	return 0;
1842 }
1843 
1844 /*
1845  * FS.SetLock operation type
1846  */
1847 static const struct afs_call_type afs_RXFSSetLock = {
1848 	.name		= "FS.SetLock",
1849 	.op		= afs_FS_SetLock,
1850 	.deliver	= afs_deliver_fs_xxxx_lock,
1851 	.done		= afs_lock_op_done,
1852 	.destructor	= afs_flat_call_destructor,
1853 };
1854 
1855 /*
1856  * FS.ExtendLock operation type
1857  */
1858 static const struct afs_call_type afs_RXFSExtendLock = {
1859 	.name		= "FS.ExtendLock",
1860 	.op		= afs_FS_ExtendLock,
1861 	.deliver	= afs_deliver_fs_xxxx_lock,
1862 	.done		= afs_lock_op_done,
1863 	.destructor	= afs_flat_call_destructor,
1864 };
1865 
1866 /*
1867  * FS.ReleaseLock operation type
1868  */
1869 static const struct afs_call_type afs_RXFSReleaseLock = {
1870 	.name		= "FS.ReleaseLock",
1871 	.op		= afs_FS_ReleaseLock,
1872 	.deliver	= afs_deliver_fs_xxxx_lock,
1873 	.destructor	= afs_flat_call_destructor,
1874 };
1875 
1876 /*
1877  * Set a lock on a file
1878  */
1879 int afs_fs_set_lock(struct afs_fs_cursor *fc, afs_lock_type_t type)
1880 {
1881 	struct afs_vnode *vnode = fc->vnode;
1882 	struct afs_call *call;
1883 	struct afs_net *net = afs_v2net(vnode);
1884 	__be32 *bp;
1885 
1886 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1887 		return yfs_fs_set_lock(fc, type);
1888 
1889 	_enter("");
1890 
1891 	call = afs_alloc_flat_call(net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
1892 	if (!call)
1893 		return -ENOMEM;
1894 
1895 	call->key = fc->key;
1896 	call->reply[0] = vnode;
1897 	call->want_reply_time = true;
1898 
1899 	/* marshall the parameters */
1900 	bp = call->request;
1901 	*bp++ = htonl(FSSETLOCK);
1902 	*bp++ = htonl(vnode->fid.vid);
1903 	*bp++ = htonl(vnode->fid.vnode);
1904 	*bp++ = htonl(vnode->fid.unique);
1905 	*bp++ = htonl(type);
1906 
1907 	afs_use_fs_server(call, fc->cbi);
1908 	trace_afs_make_fs_calli(call, &vnode->fid, type);
1909 	afs_make_call(&fc->ac, call, GFP_NOFS);
1910 	return afs_wait_for_call_to_complete(call, &fc->ac);
1911 }
1912 
1913 /*
1914  * extend a lock on a file
1915  */
1916 int afs_fs_extend_lock(struct afs_fs_cursor *fc)
1917 {
1918 	struct afs_vnode *vnode = fc->vnode;
1919 	struct afs_call *call;
1920 	struct afs_net *net = afs_v2net(vnode);
1921 	__be32 *bp;
1922 
1923 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1924 		return yfs_fs_extend_lock(fc);
1925 
1926 	_enter("");
1927 
1928 	call = afs_alloc_flat_call(net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
1929 	if (!call)
1930 		return -ENOMEM;
1931 
1932 	call->key = fc->key;
1933 	call->reply[0] = vnode;
1934 	call->want_reply_time = true;
1935 
1936 	/* marshall the parameters */
1937 	bp = call->request;
1938 	*bp++ = htonl(FSEXTENDLOCK);
1939 	*bp++ = htonl(vnode->fid.vid);
1940 	*bp++ = htonl(vnode->fid.vnode);
1941 	*bp++ = htonl(vnode->fid.unique);
1942 
1943 	afs_use_fs_server(call, fc->cbi);
1944 	trace_afs_make_fs_call(call, &vnode->fid);
1945 	afs_make_call(&fc->ac, call, GFP_NOFS);
1946 	return afs_wait_for_call_to_complete(call, &fc->ac);
1947 }
1948 
1949 /*
1950  * release a lock on a file
1951  */
1952 int afs_fs_release_lock(struct afs_fs_cursor *fc)
1953 {
1954 	struct afs_vnode *vnode = fc->vnode;
1955 	struct afs_call *call;
1956 	struct afs_net *net = afs_v2net(vnode);
1957 	__be32 *bp;
1958 
1959 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
1960 		return yfs_fs_release_lock(fc);
1961 
1962 	_enter("");
1963 
1964 	call = afs_alloc_flat_call(net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
1965 	if (!call)
1966 		return -ENOMEM;
1967 
1968 	call->key = fc->key;
1969 	call->reply[0] = vnode;
1970 
1971 	/* marshall the parameters */
1972 	bp = call->request;
1973 	*bp++ = htonl(FSRELEASELOCK);
1974 	*bp++ = htonl(vnode->fid.vid);
1975 	*bp++ = htonl(vnode->fid.vnode);
1976 	*bp++ = htonl(vnode->fid.unique);
1977 
1978 	afs_use_fs_server(call, fc->cbi);
1979 	trace_afs_make_fs_call(call, &vnode->fid);
1980 	afs_make_call(&fc->ac, call, GFP_NOFS);
1981 	return afs_wait_for_call_to_complete(call, &fc->ac);
1982 }
1983 
1984 /*
1985  * Deliver reply data to an FS.GiveUpAllCallBacks operation.
1986  */
1987 static int afs_deliver_fs_give_up_all_callbacks(struct afs_call *call)
1988 {
1989 	return afs_transfer_reply(call);
1990 }
1991 
1992 /*
1993  * FS.GiveUpAllCallBacks operation type
1994  */
1995 static const struct afs_call_type afs_RXFSGiveUpAllCallBacks = {
1996 	.name		= "FS.GiveUpAllCallBacks",
1997 	.op		= afs_FS_GiveUpAllCallBacks,
1998 	.deliver	= afs_deliver_fs_give_up_all_callbacks,
1999 	.destructor	= afs_flat_call_destructor,
2000 };
2001 
2002 /*
2003  * Flush all the callbacks we have on a server.
2004  */
2005 int afs_fs_give_up_all_callbacks(struct afs_net *net,
2006 				 struct afs_server *server,
2007 				 struct afs_addr_cursor *ac,
2008 				 struct key *key)
2009 {
2010 	struct afs_call *call;
2011 	__be32 *bp;
2012 
2013 	_enter("");
2014 
2015 	call = afs_alloc_flat_call(net, &afs_RXFSGiveUpAllCallBacks, 1 * 4, 0);
2016 	if (!call)
2017 		return -ENOMEM;
2018 
2019 	call->key = key;
2020 
2021 	/* marshall the parameters */
2022 	bp = call->request;
2023 	*bp++ = htonl(FSGIVEUPALLCALLBACKS);
2024 
2025 	/* Can't take a ref on server */
2026 	afs_make_call(ac, call, GFP_NOFS);
2027 	return afs_wait_for_call_to_complete(call, ac);
2028 }
2029 
2030 /*
2031  * Deliver reply data to an FS.GetCapabilities operation.
2032  */
2033 static int afs_deliver_fs_get_capabilities(struct afs_call *call)
2034 {
2035 	u32 count;
2036 	int ret;
2037 
2038 	_enter("{%u,%zu}", call->unmarshall, iov_iter_count(&call->iter));
2039 
2040 	switch (call->unmarshall) {
2041 	case 0:
2042 		afs_extract_to_tmp(call);
2043 		call->unmarshall++;
2044 
2045 		/* Fall through - and extract the capabilities word count */
2046 	case 1:
2047 		ret = afs_extract_data(call, true);
2048 		if (ret < 0)
2049 			return ret;
2050 
2051 		count = ntohl(call->tmp);
2052 
2053 		call->count = count;
2054 		call->count2 = count;
2055 		iov_iter_discard(&call->iter, READ, count * sizeof(__be32));
2056 		call->unmarshall++;
2057 
2058 		/* Fall through - and extract capabilities words */
2059 	case 2:
2060 		ret = afs_extract_data(call, false);
2061 		if (ret < 0)
2062 			return ret;
2063 
2064 		/* TODO: Examine capabilities */
2065 
2066 		call->unmarshall++;
2067 		break;
2068 	}
2069 
2070 	_leave(" = 0 [done]");
2071 	return 0;
2072 }
2073 
2074 static void afs_destroy_fs_get_capabilities(struct afs_call *call)
2075 {
2076 	struct afs_server *server = call->reply[0];
2077 
2078 	afs_put_server(call->net, server);
2079 	afs_flat_call_destructor(call);
2080 }
2081 
2082 /*
2083  * FS.GetCapabilities operation type
2084  */
2085 static const struct afs_call_type afs_RXFSGetCapabilities = {
2086 	.name		= "FS.GetCapabilities",
2087 	.op		= afs_FS_GetCapabilities,
2088 	.deliver	= afs_deliver_fs_get_capabilities,
2089 	.done		= afs_fileserver_probe_result,
2090 	.destructor	= afs_destroy_fs_get_capabilities,
2091 };
2092 
2093 /*
2094  * Probe a fileserver for the capabilities that it supports.  This can
2095  * return up to 196 words.
2096  */
2097 struct afs_call *afs_fs_get_capabilities(struct afs_net *net,
2098 					 struct afs_server *server,
2099 					 struct afs_addr_cursor *ac,
2100 					 struct key *key,
2101 					 unsigned int server_index)
2102 {
2103 	struct afs_call *call;
2104 	__be32 *bp;
2105 
2106 	_enter("");
2107 
2108 	call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
2109 	if (!call)
2110 		return ERR_PTR(-ENOMEM);
2111 
2112 	call->key = key;
2113 	call->reply[0] = afs_get_server(server);
2114 	call->reply[1] = (void *)(long)server_index;
2115 	call->upgrade = true;
2116 	call->want_reply_time = true;
2117 	call->async = true;
2118 
2119 	/* marshall the parameters */
2120 	bp = call->request;
2121 	*bp++ = htonl(FSGETCAPABILITIES);
2122 
2123 	/* Can't take a ref on server */
2124 	trace_afs_make_fs_call(call, NULL);
2125 	afs_make_call(ac, call, GFP_NOFS);
2126 	return call;
2127 }
2128 
2129 /*
2130  * Deliver reply data to an FS.FetchStatus with no vnode.
2131  */
2132 static int afs_deliver_fs_fetch_status(struct afs_call *call)
2133 {
2134 	struct afs_file_status *status = call->reply[1];
2135 	struct afs_callback *callback = call->reply[2];
2136 	struct afs_volsync *volsync = call->reply[3];
2137 	struct afs_fid *fid = call->reply[0];
2138 	const __be32 *bp;
2139 	int ret;
2140 
2141 	ret = afs_transfer_reply(call);
2142 	if (ret < 0)
2143 		return ret;
2144 
2145 	_enter("{%llx:%llu}", fid->vid, fid->vnode);
2146 
2147 	/* unmarshall the reply once we've received all of it */
2148 	bp = call->buffer;
2149 	ret = afs_decode_status(call, &bp, status, NULL,
2150 				&call->expected_version, NULL);
2151 	if (ret < 0)
2152 		return ret;
2153 	xdr_decode_AFSCallBack_raw(call, &bp, callback);
2154 	xdr_decode_AFSVolSync(&bp, volsync);
2155 
2156 	_leave(" = 0 [done]");
2157 	return 0;
2158 }
2159 
2160 /*
2161  * FS.FetchStatus operation type
2162  */
2163 static const struct afs_call_type afs_RXFSFetchStatus = {
2164 	.name		= "FS.FetchStatus",
2165 	.op		= afs_FS_FetchStatus,
2166 	.deliver	= afs_deliver_fs_fetch_status,
2167 	.destructor	= afs_flat_call_destructor,
2168 };
2169 
2170 /*
2171  * Fetch the status information for a fid without needing a vnode handle.
2172  */
2173 int afs_fs_fetch_status(struct afs_fs_cursor *fc,
2174 			struct afs_net *net,
2175 			struct afs_fid *fid,
2176 			struct afs_file_status *status,
2177 			struct afs_callback *callback,
2178 			struct afs_volsync *volsync)
2179 {
2180 	struct afs_call *call;
2181 	__be32 *bp;
2182 
2183 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2184 		return yfs_fs_fetch_status(fc, net, fid, status, callback, volsync);
2185 
2186 	_enter(",%x,{%llx:%llu},,",
2187 	       key_serial(fc->key), fid->vid, fid->vnode);
2188 
2189 	call = afs_alloc_flat_call(net, &afs_RXFSFetchStatus, 16, (21 + 3 + 6) * 4);
2190 	if (!call) {
2191 		fc->ac.error = -ENOMEM;
2192 		return -ENOMEM;
2193 	}
2194 
2195 	call->key = fc->key;
2196 	call->reply[0] = fid;
2197 	call->reply[1] = status;
2198 	call->reply[2] = callback;
2199 	call->reply[3] = volsync;
2200 	call->expected_version = 1; /* vnode->status.data_version */
2201 	call->want_reply_time = true;
2202 
2203 	/* marshall the parameters */
2204 	bp = call->request;
2205 	bp[0] = htonl(FSFETCHSTATUS);
2206 	bp[1] = htonl(fid->vid);
2207 	bp[2] = htonl(fid->vnode);
2208 	bp[3] = htonl(fid->unique);
2209 
2210 	call->cb_break = fc->cb_break;
2211 	afs_use_fs_server(call, fc->cbi);
2212 	trace_afs_make_fs_call(call, fid);
2213 	afs_make_call(&fc->ac, call, GFP_NOFS);
2214 	return afs_wait_for_call_to_complete(call, &fc->ac);
2215 }
2216 
2217 /*
2218  * Deliver reply data to an FS.InlineBulkStatus call
2219  */
2220 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
2221 {
2222 	struct afs_file_status *statuses;
2223 	struct afs_callback *callbacks;
2224 	struct afs_vnode *vnode = call->reply[0];
2225 	const __be32 *bp;
2226 	u32 tmp;
2227 	int ret;
2228 
2229 	_enter("{%u}", call->unmarshall);
2230 
2231 	switch (call->unmarshall) {
2232 	case 0:
2233 		afs_extract_to_tmp(call);
2234 		call->unmarshall++;
2235 
2236 		/* Extract the file status count and array in two steps */
2237 		/* Fall through */
2238 	case 1:
2239 		_debug("extract status count");
2240 		ret = afs_extract_data(call, true);
2241 		if (ret < 0)
2242 			return ret;
2243 
2244 		tmp = ntohl(call->tmp);
2245 		_debug("status count: %u/%u", tmp, call->count2);
2246 		if (tmp != call->count2)
2247 			return afs_protocol_error(call, -EBADMSG,
2248 						  afs_eproto_ibulkst_count);
2249 
2250 		call->count = 0;
2251 		call->unmarshall++;
2252 	more_counts:
2253 		afs_extract_to_buf(call, 21 * sizeof(__be32));
2254 
2255 		/* Fall through */
2256 	case 2:
2257 		_debug("extract status array %u", call->count);
2258 		ret = afs_extract_data(call, true);
2259 		if (ret < 0)
2260 			return ret;
2261 
2262 		bp = call->buffer;
2263 		statuses = call->reply[1];
2264 		ret = afs_decode_status(call, &bp, &statuses[call->count],
2265 					call->count == 0 ? vnode : NULL,
2266 					NULL, NULL);
2267 		if (ret < 0)
2268 			return ret;
2269 
2270 		call->count++;
2271 		if (call->count < call->count2)
2272 			goto more_counts;
2273 
2274 		call->count = 0;
2275 		call->unmarshall++;
2276 		afs_extract_to_tmp(call);
2277 
2278 		/* Extract the callback count and array in two steps */
2279 		/* Fall through */
2280 	case 3:
2281 		_debug("extract CB count");
2282 		ret = afs_extract_data(call, true);
2283 		if (ret < 0)
2284 			return ret;
2285 
2286 		tmp = ntohl(call->tmp);
2287 		_debug("CB count: %u", tmp);
2288 		if (tmp != call->count2)
2289 			return afs_protocol_error(call, -EBADMSG,
2290 						  afs_eproto_ibulkst_cb_count);
2291 		call->count = 0;
2292 		call->unmarshall++;
2293 	more_cbs:
2294 		afs_extract_to_buf(call, 3 * sizeof(__be32));
2295 
2296 		/* Fall through */
2297 	case 4:
2298 		_debug("extract CB array");
2299 		ret = afs_extract_data(call, true);
2300 		if (ret < 0)
2301 			return ret;
2302 
2303 		_debug("unmarshall CB array");
2304 		bp = call->buffer;
2305 		callbacks = call->reply[2];
2306 		callbacks[call->count].version	= ntohl(bp[0]);
2307 		callbacks[call->count].expires_at = xdr_decode_expiry(call, ntohl(bp[1]));
2308 		callbacks[call->count].type	= ntohl(bp[2]);
2309 		statuses = call->reply[1];
2310 		if (call->count == 0 && vnode && statuses[0].abort_code == 0)
2311 			xdr_decode_AFSCallBack(call, vnode, &bp);
2312 		call->count++;
2313 		if (call->count < call->count2)
2314 			goto more_cbs;
2315 
2316 		afs_extract_to_buf(call, 6 * sizeof(__be32));
2317 		call->unmarshall++;
2318 
2319 		/* Fall through */
2320 	case 5:
2321 		ret = afs_extract_data(call, false);
2322 		if (ret < 0)
2323 			return ret;
2324 
2325 		bp = call->buffer;
2326 		xdr_decode_AFSVolSync(&bp, call->reply[3]);
2327 
2328 		call->unmarshall++;
2329 
2330 	case 6:
2331 		break;
2332 	}
2333 
2334 	_leave(" = 0 [done]");
2335 	return 0;
2336 }
2337 
2338 /*
2339  * FS.InlineBulkStatus operation type
2340  */
2341 static const struct afs_call_type afs_RXFSInlineBulkStatus = {
2342 	.name		= "FS.InlineBulkStatus",
2343 	.op		= afs_FS_InlineBulkStatus,
2344 	.deliver	= afs_deliver_fs_inline_bulk_status,
2345 	.destructor	= afs_flat_call_destructor,
2346 };
2347 
2348 /*
2349  * Fetch the status information for up to 50 files
2350  */
2351 int afs_fs_inline_bulk_status(struct afs_fs_cursor *fc,
2352 			      struct afs_net *net,
2353 			      struct afs_fid *fids,
2354 			      struct afs_file_status *statuses,
2355 			      struct afs_callback *callbacks,
2356 			      unsigned int nr_fids,
2357 			      struct afs_volsync *volsync)
2358 {
2359 	struct afs_call *call;
2360 	__be32 *bp;
2361 	int i;
2362 
2363 	if (test_bit(AFS_SERVER_FL_IS_YFS, &fc->cbi->server->flags))
2364 		return yfs_fs_inline_bulk_status(fc, net, fids, statuses, callbacks,
2365 						 nr_fids, volsync);
2366 
2367 	_enter(",%x,{%llx:%llu},%u",
2368 	       key_serial(fc->key), fids[0].vid, fids[1].vnode, nr_fids);
2369 
2370 	call = afs_alloc_flat_call(net, &afs_RXFSInlineBulkStatus,
2371 				   (2 + nr_fids * 3) * 4,
2372 				   21 * 4);
2373 	if (!call) {
2374 		fc->ac.error = -ENOMEM;
2375 		return -ENOMEM;
2376 	}
2377 
2378 	call->key = fc->key;
2379 	call->reply[0] = NULL; /* vnode for fid[0] */
2380 	call->reply[1] = statuses;
2381 	call->reply[2] = callbacks;
2382 	call->reply[3] = volsync;
2383 	call->count2 = nr_fids;
2384 	call->want_reply_time = true;
2385 
2386 	/* marshall the parameters */
2387 	bp = call->request;
2388 	*bp++ = htonl(FSINLINEBULKSTATUS);
2389 	*bp++ = htonl(nr_fids);
2390 	for (i = 0; i < nr_fids; i++) {
2391 		*bp++ = htonl(fids[i].vid);
2392 		*bp++ = htonl(fids[i].vnode);
2393 		*bp++ = htonl(fids[i].unique);
2394 	}
2395 
2396 	call->cb_break = fc->cb_break;
2397 	afs_use_fs_server(call, fc->cbi);
2398 	trace_afs_make_fs_call(call, &fids[0]);
2399 	afs_make_call(&fc->ac, call, GFP_NOFS);
2400 	return afs_wait_for_call_to_complete(call, &fc->ac);
2401 }
2402 
2403 /*
2404  * deliver reply data to an FS.FetchACL
2405  */
2406 static int afs_deliver_fs_fetch_acl(struct afs_call *call)
2407 {
2408 	struct afs_vnode *vnode = call->reply[1];
2409 	struct afs_acl *acl;
2410 	const __be32 *bp;
2411 	unsigned int size;
2412 	int ret;
2413 
2414 	_enter("{%u}", call->unmarshall);
2415 
2416 	switch (call->unmarshall) {
2417 	case 0:
2418 		afs_extract_to_tmp(call);
2419 		call->unmarshall++;
2420 
2421 		/* extract the returned data length */
2422 	case 1:
2423 		ret = afs_extract_data(call, true);
2424 		if (ret < 0)
2425 			return ret;
2426 
2427 		size = call->count2 = ntohl(call->tmp);
2428 		size = round_up(size, 4);
2429 
2430 		acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
2431 		if (!acl)
2432 			return -ENOMEM;
2433 		call->reply[0] = acl;
2434 		acl->size = call->count2;
2435 		afs_extract_begin(call, acl->data, size);
2436 		call->unmarshall++;
2437 
2438 		/* extract the returned data */
2439 	case 2:
2440 		ret = afs_extract_data(call, true);
2441 		if (ret < 0)
2442 			return ret;
2443 
2444 		afs_extract_to_buf(call, (21 + 6) * 4);
2445 		call->unmarshall++;
2446 
2447 		/* extract the metadata */
2448 	case 3:
2449 		ret = afs_extract_data(call, false);
2450 		if (ret < 0)
2451 			return ret;
2452 
2453 		bp = call->buffer;
2454 		ret = afs_decode_status(call, &bp, &vnode->status, vnode,
2455 					&vnode->status.data_version, NULL);
2456 		if (ret < 0)
2457 			return ret;
2458 		xdr_decode_AFSVolSync(&bp, call->reply[2]);
2459 
2460 		call->unmarshall++;
2461 
2462 	case 4:
2463 		break;
2464 	}
2465 
2466 	_leave(" = 0 [done]");
2467 	return 0;
2468 }
2469 
2470 static void afs_destroy_fs_fetch_acl(struct afs_call *call)
2471 {
2472 	kfree(call->reply[0]);
2473 	afs_flat_call_destructor(call);
2474 }
2475 
2476 /*
2477  * FS.FetchACL operation type
2478  */
2479 static const struct afs_call_type afs_RXFSFetchACL = {
2480 	.name		= "FS.FetchACL",
2481 	.op		= afs_FS_FetchACL,
2482 	.deliver	= afs_deliver_fs_fetch_acl,
2483 	.destructor	= afs_destroy_fs_fetch_acl,
2484 };
2485 
2486 /*
2487  * Fetch the ACL for a file.
2488  */
2489 struct afs_acl *afs_fs_fetch_acl(struct afs_fs_cursor *fc)
2490 {
2491 	struct afs_vnode *vnode = fc->vnode;
2492 	struct afs_call *call;
2493 	struct afs_net *net = afs_v2net(vnode);
2494 	__be32 *bp;
2495 
2496 	_enter(",%x,{%llx:%llu},,",
2497 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2498 
2499 	call = afs_alloc_flat_call(net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2500 	if (!call) {
2501 		fc->ac.error = -ENOMEM;
2502 		return ERR_PTR(-ENOMEM);
2503 	}
2504 
2505 	call->key = fc->key;
2506 	call->reply[0] = NULL;
2507 	call->reply[1] = vnode;
2508 	call->reply[2] = NULL; /* volsync */
2509 	call->ret_reply0 = true;
2510 
2511 	/* marshall the parameters */
2512 	bp = call->request;
2513 	bp[0] = htonl(FSFETCHACL);
2514 	bp[1] = htonl(vnode->fid.vid);
2515 	bp[2] = htonl(vnode->fid.vnode);
2516 	bp[3] = htonl(vnode->fid.unique);
2517 
2518 	call->cb_break = fc->cb_break;
2519 	afs_use_fs_server(call, fc->cbi);
2520 	trace_afs_make_fs_call(call, &vnode->fid);
2521 	afs_make_call(&fc->ac, call, GFP_KERNEL);
2522 	return (struct afs_acl *)afs_wait_for_call_to_complete(call, &fc->ac);
2523 }
2524 
2525 /*
2526  * FS.StoreACL operation type
2527  */
2528 static const struct afs_call_type afs_RXFSStoreACL = {
2529 	.name		= "FS.StoreACL",
2530 	.op		= afs_FS_StoreACL,
2531 	.deliver	= afs_deliver_fs_status_and_vol,
2532 	.destructor	= afs_flat_call_destructor,
2533 };
2534 
2535 /*
2536  * Fetch the ACL for a file.
2537  */
2538 int afs_fs_store_acl(struct afs_fs_cursor *fc, const struct afs_acl *acl)
2539 {
2540 	struct afs_vnode *vnode = fc->vnode;
2541 	struct afs_call *call;
2542 	struct afs_net *net = afs_v2net(vnode);
2543 	size_t size;
2544 	__be32 *bp;
2545 
2546 	_enter(",%x,{%llx:%llu},,",
2547 	       key_serial(fc->key), vnode->fid.vid, vnode->fid.vnode);
2548 
2549 	size = round_up(acl->size, 4);
2550 	call = afs_alloc_flat_call(net, &afs_RXFSStoreACL,
2551 				   5 * 4 + size, (21 + 6) * 4);
2552 	if (!call) {
2553 		fc->ac.error = -ENOMEM;
2554 		return -ENOMEM;
2555 	}
2556 
2557 	call->key = fc->key;
2558 	call->reply[0] = vnode;
2559 	call->reply[2] = NULL; /* volsync */
2560 
2561 	/* marshall the parameters */
2562 	bp = call->request;
2563 	bp[0] = htonl(FSSTOREACL);
2564 	bp[1] = htonl(vnode->fid.vid);
2565 	bp[2] = htonl(vnode->fid.vnode);
2566 	bp[3] = htonl(vnode->fid.unique);
2567 	bp[4] = htonl(acl->size);
2568 	memcpy(&bp[5], acl->data, acl->size);
2569 	if (acl->size != size)
2570 		memset((void *)&bp[5] + acl->size, 0, size - acl->size);
2571 
2572 	trace_afs_make_fs_call(call, &vnode->fid);
2573 	afs_make_call(&fc->ac, call, GFP_KERNEL);
2574 	return afs_wait_for_call_to_complete(call, &fc->ac);
2575 }
2576