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