Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /* AFS File Server client stubs
0003  *
0004  * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
0005  * Written by David Howells (dhowells@redhat.com)
0006  */
0007 
0008 #include <linux/init.h>
0009 #include <linux/slab.h>
0010 #include <linux/sched.h>
0011 #include <linux/circ_buf.h>
0012 #include <linux/iversion.h>
0013 #include <linux/netfs.h>
0014 #include "internal.h"
0015 #include "afs_fs.h"
0016 #include "xdr_fs.h"
0017 
0018 /*
0019  * decode an AFSFid block
0020  */
0021 static void xdr_decode_AFSFid(const __be32 **_bp, struct afs_fid *fid)
0022 {
0023     const __be32 *bp = *_bp;
0024 
0025     fid->vid        = ntohl(*bp++);
0026     fid->vnode      = ntohl(*bp++);
0027     fid->unique     = ntohl(*bp++);
0028     *_bp = bp;
0029 }
0030 
0031 /*
0032  * Dump a bad file status record.
0033  */
0034 static void xdr_dump_bad(const __be32 *bp)
0035 {
0036     __be32 x[4];
0037     int i;
0038 
0039     pr_notice("AFS XDR: Bad status record\n");
0040     for (i = 0; i < 5 * 4 * 4; i += 16) {
0041         memcpy(x, bp, 16);
0042         bp += 4;
0043         pr_notice("%03x: %08x %08x %08x %08x\n",
0044               i, ntohl(x[0]), ntohl(x[1]), ntohl(x[2]), ntohl(x[3]));
0045     }
0046 
0047     memcpy(x, bp, 4);
0048     pr_notice("0x50: %08x\n", ntohl(x[0]));
0049 }
0050 
0051 /*
0052  * decode an AFSFetchStatus block
0053  */
0054 static void xdr_decode_AFSFetchStatus(const __be32 **_bp,
0055                       struct afs_call *call,
0056                       struct afs_status_cb *scb)
0057 {
0058     const struct afs_xdr_AFSFetchStatus *xdr = (const void *)*_bp;
0059     struct afs_file_status *status = &scb->status;
0060     bool inline_error = (call->operation_ID == afs_FS_InlineBulkStatus);
0061     u64 data_version, size;
0062     u32 type, abort_code;
0063 
0064     abort_code = ntohl(xdr->abort_code);
0065 
0066     if (xdr->if_version != htonl(AFS_FSTATUS_VERSION)) {
0067         if (xdr->if_version == htonl(0) &&
0068             abort_code != 0 &&
0069             inline_error) {
0070             /* The OpenAFS fileserver has a bug in FS.InlineBulkStatus
0071              * whereby it doesn't set the interface version in the error
0072              * case.
0073              */
0074             status->abort_code = abort_code;
0075             scb->have_error = true;
0076             goto advance;
0077         }
0078 
0079         pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
0080         goto bad;
0081     }
0082 
0083     if (abort_code != 0 && inline_error) {
0084         status->abort_code = abort_code;
0085         scb->have_error = true;
0086         goto advance;
0087     }
0088 
0089     type = ntohl(xdr->type);
0090     switch (type) {
0091     case AFS_FTYPE_FILE:
0092     case AFS_FTYPE_DIR:
0093     case AFS_FTYPE_SYMLINK:
0094         status->type = type;
0095         break;
0096     default:
0097         goto bad;
0098     }
0099 
0100     status->nlink       = ntohl(xdr->nlink);
0101     status->author      = ntohl(xdr->author);
0102     status->owner       = ntohl(xdr->owner);
0103     status->caller_access   = ntohl(xdr->caller_access); /* Ticket dependent */
0104     status->anon_access = ntohl(xdr->anon_access);
0105     status->mode        = ntohl(xdr->mode) & S_IALLUGO;
0106     status->group       = ntohl(xdr->group);
0107     status->lock_count  = ntohl(xdr->lock_count);
0108 
0109     status->mtime_client.tv_sec = ntohl(xdr->mtime_client);
0110     status->mtime_client.tv_nsec = 0;
0111     status->mtime_server.tv_sec = ntohl(xdr->mtime_server);
0112     status->mtime_server.tv_nsec = 0;
0113 
0114     size  = (u64)ntohl(xdr->size_lo);
0115     size |= (u64)ntohl(xdr->size_hi) << 32;
0116     status->size = size;
0117 
0118     data_version  = (u64)ntohl(xdr->data_version_lo);
0119     data_version |= (u64)ntohl(xdr->data_version_hi) << 32;
0120     status->data_version = data_version;
0121     scb->have_status = true;
0122 advance:
0123     *_bp = (const void *)*_bp + sizeof(*xdr);
0124     return;
0125 
0126 bad:
0127     xdr_dump_bad(*_bp);
0128     afs_protocol_error(call, afs_eproto_bad_status);
0129     goto advance;
0130 }
0131 
0132 static time64_t xdr_decode_expiry(struct afs_call *call, u32 expiry)
0133 {
0134     return ktime_divns(call->issue_time, NSEC_PER_SEC) + expiry;
0135 }
0136 
0137 static void xdr_decode_AFSCallBack(const __be32 **_bp,
0138                    struct afs_call *call,
0139                    struct afs_status_cb *scb)
0140 {
0141     struct afs_callback *cb = &scb->callback;
0142     const __be32 *bp = *_bp;
0143 
0144     bp++; /* version */
0145     cb->expires_at  = xdr_decode_expiry(call, ntohl(*bp++));
0146     bp++; /* type */
0147     scb->have_cb    = true;
0148     *_bp = bp;
0149 }
0150 
0151 /*
0152  * decode an AFSVolSync block
0153  */
0154 static void xdr_decode_AFSVolSync(const __be32 **_bp,
0155                   struct afs_volsync *volsync)
0156 {
0157     const __be32 *bp = *_bp;
0158     u32 creation;
0159 
0160     creation = ntohl(*bp++);
0161     bp++; /* spare2 */
0162     bp++; /* spare3 */
0163     bp++; /* spare4 */
0164     bp++; /* spare5 */
0165     bp++; /* spare6 */
0166     *_bp = bp;
0167 
0168     if (volsync)
0169         volsync->creation = creation;
0170 }
0171 
0172 /*
0173  * encode the requested attributes into an AFSStoreStatus block
0174  */
0175 static void xdr_encode_AFS_StoreStatus(__be32 **_bp, struct iattr *attr)
0176 {
0177     __be32 *bp = *_bp;
0178     u32 mask = 0, mtime = 0, owner = 0, group = 0, mode = 0;
0179 
0180     mask = 0;
0181     if (attr->ia_valid & ATTR_MTIME) {
0182         mask |= AFS_SET_MTIME;
0183         mtime = attr->ia_mtime.tv_sec;
0184     }
0185 
0186     if (attr->ia_valid & ATTR_UID) {
0187         mask |= AFS_SET_OWNER;
0188         owner = from_kuid(&init_user_ns, attr->ia_uid);
0189     }
0190 
0191     if (attr->ia_valid & ATTR_GID) {
0192         mask |= AFS_SET_GROUP;
0193         group = from_kgid(&init_user_ns, attr->ia_gid);
0194     }
0195 
0196     if (attr->ia_valid & ATTR_MODE) {
0197         mask |= AFS_SET_MODE;
0198         mode = attr->ia_mode & S_IALLUGO;
0199     }
0200 
0201     *bp++ = htonl(mask);
0202     *bp++ = htonl(mtime);
0203     *bp++ = htonl(owner);
0204     *bp++ = htonl(group);
0205     *bp++ = htonl(mode);
0206     *bp++ = 0;      /* segment size */
0207     *_bp = bp;
0208 }
0209 
0210 /*
0211  * decode an AFSFetchVolumeStatus block
0212  */
0213 static void xdr_decode_AFSFetchVolumeStatus(const __be32 **_bp,
0214                         struct afs_volume_status *vs)
0215 {
0216     const __be32 *bp = *_bp;
0217 
0218     vs->vid         = ntohl(*bp++);
0219     vs->parent_id       = ntohl(*bp++);
0220     vs->online      = ntohl(*bp++);
0221     vs->in_service      = ntohl(*bp++);
0222     vs->blessed     = ntohl(*bp++);
0223     vs->needs_salvage   = ntohl(*bp++);
0224     vs->type        = ntohl(*bp++);
0225     vs->min_quota       = ntohl(*bp++);
0226     vs->max_quota       = ntohl(*bp++);
0227     vs->blocks_in_use   = ntohl(*bp++);
0228     vs->part_blocks_avail   = ntohl(*bp++);
0229     vs->part_max_blocks = ntohl(*bp++);
0230     vs->vol_copy_date   = 0;
0231     vs->vol_backup_date = 0;
0232     *_bp = bp;
0233 }
0234 
0235 /*
0236  * deliver reply data to an FS.FetchStatus
0237  */
0238 static int afs_deliver_fs_fetch_status(struct afs_call *call)
0239 {
0240     struct afs_operation *op = call->op;
0241     struct afs_vnode_param *vp = &op->file[op->fetch_status.which];
0242     const __be32 *bp;
0243     int ret;
0244 
0245     ret = afs_transfer_reply(call);
0246     if (ret < 0)
0247         return ret;
0248 
0249     /* unmarshall the reply once we've received all of it */
0250     bp = call->buffer;
0251     xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
0252     xdr_decode_AFSCallBack(&bp, call, &vp->scb);
0253     xdr_decode_AFSVolSync(&bp, &op->volsync);
0254 
0255     _leave(" = 0 [done]");
0256     return 0;
0257 }
0258 
0259 /*
0260  * FS.FetchStatus operation type
0261  */
0262 static const struct afs_call_type afs_RXFSFetchStatus = {
0263     .name       = "FS.FetchStatus",
0264     .op     = afs_FS_FetchStatus,
0265     .deliver    = afs_deliver_fs_fetch_status,
0266     .destructor = afs_flat_call_destructor,
0267 };
0268 
0269 /*
0270  * fetch the status information for a file
0271  */
0272 void afs_fs_fetch_status(struct afs_operation *op)
0273 {
0274     struct afs_vnode_param *vp = &op->file[op->fetch_status.which];
0275     struct afs_call *call;
0276     __be32 *bp;
0277 
0278     _enter(",%x,{%llx:%llu},,",
0279            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
0280 
0281     call = afs_alloc_flat_call(op->net, &afs_RXFSFetchStatus,
0282                    16, (21 + 3 + 6) * 4);
0283     if (!call)
0284         return afs_op_nomem(op);
0285 
0286     /* marshall the parameters */
0287     bp = call->request;
0288     bp[0] = htonl(FSFETCHSTATUS);
0289     bp[1] = htonl(vp->fid.vid);
0290     bp[2] = htonl(vp->fid.vnode);
0291     bp[3] = htonl(vp->fid.unique);
0292 
0293     trace_afs_make_fs_call(call, &vp->fid);
0294     afs_make_op_call(op, call, GFP_NOFS);
0295 }
0296 
0297 /*
0298  * deliver reply data to an FS.FetchData
0299  */
0300 static int afs_deliver_fs_fetch_data(struct afs_call *call)
0301 {
0302     struct afs_operation *op = call->op;
0303     struct afs_vnode_param *vp = &op->file[0];
0304     struct afs_read *req = op->fetch.req;
0305     const __be32 *bp;
0306     int ret;
0307 
0308     _enter("{%u,%zu,%zu/%llu}",
0309            call->unmarshall, call->iov_len, iov_iter_count(call->iter),
0310            req->actual_len);
0311 
0312     switch (call->unmarshall) {
0313     case 0:
0314         req->actual_len = 0;
0315         call->unmarshall++;
0316         if (call->operation_ID == FSFETCHDATA64) {
0317             afs_extract_to_tmp64(call);
0318         } else {
0319             call->tmp_u = htonl(0);
0320             afs_extract_to_tmp(call);
0321         }
0322         fallthrough;
0323 
0324         /* Extract the returned data length into
0325          * ->actual_len.  This may indicate more or less data than was
0326          * requested will be returned.
0327          */
0328     case 1:
0329         _debug("extract data length");
0330         ret = afs_extract_data(call, true);
0331         if (ret < 0)
0332             return ret;
0333 
0334         req->actual_len = be64_to_cpu(call->tmp64);
0335         _debug("DATA length: %llu", req->actual_len);
0336 
0337         if (req->actual_len == 0)
0338             goto no_more_data;
0339 
0340         call->iter = req->iter;
0341         call->iov_len = min(req->actual_len, req->len);
0342         call->unmarshall++;
0343         fallthrough;
0344 
0345         /* extract the returned data */
0346     case 2:
0347         _debug("extract data %zu/%llu",
0348                iov_iter_count(call->iter), req->actual_len);
0349 
0350         ret = afs_extract_data(call, true);
0351         if (ret < 0)
0352             return ret;
0353 
0354         call->iter = &call->def_iter;
0355         if (req->actual_len <= req->len)
0356             goto no_more_data;
0357 
0358         /* Discard any excess data the server gave us */
0359         afs_extract_discard(call, req->actual_len - req->len);
0360         call->unmarshall = 3;
0361         fallthrough;
0362 
0363     case 3:
0364         _debug("extract discard %zu/%llu",
0365                iov_iter_count(call->iter), req->actual_len - req->len);
0366 
0367         ret = afs_extract_data(call, true);
0368         if (ret < 0)
0369             return ret;
0370 
0371     no_more_data:
0372         call->unmarshall = 4;
0373         afs_extract_to_buf(call, (21 + 3 + 6) * 4);
0374         fallthrough;
0375 
0376         /* extract the metadata */
0377     case 4:
0378         ret = afs_extract_data(call, false);
0379         if (ret < 0)
0380             return ret;
0381 
0382         bp = call->buffer;
0383         xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
0384         xdr_decode_AFSCallBack(&bp, call, &vp->scb);
0385         xdr_decode_AFSVolSync(&bp, &op->volsync);
0386 
0387         req->data_version = vp->scb.status.data_version;
0388         req->file_size = vp->scb.status.size;
0389 
0390         call->unmarshall++;
0391         fallthrough;
0392 
0393     case 5:
0394         break;
0395     }
0396 
0397     _leave(" = 0 [done]");
0398     return 0;
0399 }
0400 
0401 /*
0402  * FS.FetchData operation type
0403  */
0404 static const struct afs_call_type afs_RXFSFetchData = {
0405     .name       = "FS.FetchData",
0406     .op     = afs_FS_FetchData,
0407     .deliver    = afs_deliver_fs_fetch_data,
0408     .destructor = afs_flat_call_destructor,
0409 };
0410 
0411 static const struct afs_call_type afs_RXFSFetchData64 = {
0412     .name       = "FS.FetchData64",
0413     .op     = afs_FS_FetchData64,
0414     .deliver    = afs_deliver_fs_fetch_data,
0415     .destructor = afs_flat_call_destructor,
0416 };
0417 
0418 /*
0419  * fetch data from a very large file
0420  */
0421 static void afs_fs_fetch_data64(struct afs_operation *op)
0422 {
0423     struct afs_vnode_param *vp = &op->file[0];
0424     struct afs_read *req = op->fetch.req;
0425     struct afs_call *call;
0426     __be32 *bp;
0427 
0428     _enter("");
0429 
0430     call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData64, 32, (21 + 3 + 6) * 4);
0431     if (!call)
0432         return afs_op_nomem(op);
0433 
0434     /* marshall the parameters */
0435     bp = call->request;
0436     bp[0] = htonl(FSFETCHDATA64);
0437     bp[1] = htonl(vp->fid.vid);
0438     bp[2] = htonl(vp->fid.vnode);
0439     bp[3] = htonl(vp->fid.unique);
0440     bp[4] = htonl(upper_32_bits(req->pos));
0441     bp[5] = htonl(lower_32_bits(req->pos));
0442     bp[6] = 0;
0443     bp[7] = htonl(lower_32_bits(req->len));
0444 
0445     trace_afs_make_fs_call(call, &vp->fid);
0446     afs_make_op_call(op, call, GFP_NOFS);
0447 }
0448 
0449 /*
0450  * fetch data from a file
0451  */
0452 void afs_fs_fetch_data(struct afs_operation *op)
0453 {
0454     struct afs_vnode_param *vp = &op->file[0];
0455     struct afs_call *call;
0456     struct afs_read *req = op->fetch.req;
0457     __be32 *bp;
0458 
0459     if (test_bit(AFS_SERVER_FL_HAS_FS64, &op->server->flags))
0460         return afs_fs_fetch_data64(op);
0461 
0462     _enter("");
0463 
0464     call = afs_alloc_flat_call(op->net, &afs_RXFSFetchData, 24, (21 + 3 + 6) * 4);
0465     if (!call)
0466         return afs_op_nomem(op);
0467 
0468     req->call_debug_id = call->debug_id;
0469 
0470     /* marshall the parameters */
0471     bp = call->request;
0472     bp[0] = htonl(FSFETCHDATA);
0473     bp[1] = htonl(vp->fid.vid);
0474     bp[2] = htonl(vp->fid.vnode);
0475     bp[3] = htonl(vp->fid.unique);
0476     bp[4] = htonl(lower_32_bits(req->pos));
0477     bp[5] = htonl(lower_32_bits(req->len));
0478 
0479     trace_afs_make_fs_call(call, &vp->fid);
0480     afs_make_op_call(op, call, GFP_NOFS);
0481 }
0482 
0483 /*
0484  * deliver reply data to an FS.CreateFile or an FS.MakeDir
0485  */
0486 static int afs_deliver_fs_create_vnode(struct afs_call *call)
0487 {
0488     struct afs_operation *op = call->op;
0489     struct afs_vnode_param *dvp = &op->file[0];
0490     struct afs_vnode_param *vp = &op->file[1];
0491     const __be32 *bp;
0492     int ret;
0493 
0494     ret = afs_transfer_reply(call);
0495     if (ret < 0)
0496         return ret;
0497 
0498     /* unmarshall the reply once we've received all of it */
0499     bp = call->buffer;
0500     xdr_decode_AFSFid(&bp, &op->file[1].fid);
0501     xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
0502     xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
0503     xdr_decode_AFSCallBack(&bp, call, &vp->scb);
0504     xdr_decode_AFSVolSync(&bp, &op->volsync);
0505 
0506     _leave(" = 0 [done]");
0507     return 0;
0508 }
0509 
0510 /*
0511  * FS.CreateFile and FS.MakeDir operation type
0512  */
0513 static const struct afs_call_type afs_RXFSCreateFile = {
0514     .name       = "FS.CreateFile",
0515     .op     = afs_FS_CreateFile,
0516     .deliver    = afs_deliver_fs_create_vnode,
0517     .destructor = afs_flat_call_destructor,
0518 };
0519 
0520 /*
0521  * Create a file.
0522  */
0523 void afs_fs_create_file(struct afs_operation *op)
0524 {
0525     const struct qstr *name = &op->dentry->d_name;
0526     struct afs_vnode_param *dvp = &op->file[0];
0527     struct afs_call *call;
0528     size_t namesz, reqsz, padsz;
0529     __be32 *bp;
0530 
0531     _enter("");
0532 
0533     namesz = name->len;
0534     padsz = (4 - (namesz & 3)) & 3;
0535     reqsz = (5 * 4) + namesz + padsz + (6 * 4);
0536 
0537     call = afs_alloc_flat_call(op->net, &afs_RXFSCreateFile,
0538                    reqsz, (3 + 21 + 21 + 3 + 6) * 4);
0539     if (!call)
0540         return afs_op_nomem(op);
0541 
0542     /* marshall the parameters */
0543     bp = call->request;
0544     *bp++ = htonl(FSCREATEFILE);
0545     *bp++ = htonl(dvp->fid.vid);
0546     *bp++ = htonl(dvp->fid.vnode);
0547     *bp++ = htonl(dvp->fid.unique);
0548     *bp++ = htonl(namesz);
0549     memcpy(bp, name->name, namesz);
0550     bp = (void *) bp + namesz;
0551     if (padsz > 0) {
0552         memset(bp, 0, padsz);
0553         bp = (void *) bp + padsz;
0554     }
0555     *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
0556     *bp++ = htonl(op->mtime.tv_sec); /* mtime */
0557     *bp++ = 0; /* owner */
0558     *bp++ = 0; /* group */
0559     *bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */
0560     *bp++ = 0; /* segment size */
0561 
0562     trace_afs_make_fs_call1(call, &dvp->fid, name);
0563     afs_make_op_call(op, call, GFP_NOFS);
0564 }
0565 
0566 static const struct afs_call_type afs_RXFSMakeDir = {
0567     .name       = "FS.MakeDir",
0568     .op     = afs_FS_MakeDir,
0569     .deliver    = afs_deliver_fs_create_vnode,
0570     .destructor = afs_flat_call_destructor,
0571 };
0572 
0573 /*
0574  * Create a new directory
0575  */
0576 void afs_fs_make_dir(struct afs_operation *op)
0577 {
0578     const struct qstr *name = &op->dentry->d_name;
0579     struct afs_vnode_param *dvp = &op->file[0];
0580     struct afs_call *call;
0581     size_t namesz, reqsz, padsz;
0582     __be32 *bp;
0583 
0584     _enter("");
0585 
0586     namesz = name->len;
0587     padsz = (4 - (namesz & 3)) & 3;
0588     reqsz = (5 * 4) + namesz + padsz + (6 * 4);
0589 
0590     call = afs_alloc_flat_call(op->net, &afs_RXFSMakeDir,
0591                    reqsz, (3 + 21 + 21 + 3 + 6) * 4);
0592     if (!call)
0593         return afs_op_nomem(op);
0594 
0595     /* marshall the parameters */
0596     bp = call->request;
0597     *bp++ = htonl(FSMAKEDIR);
0598     *bp++ = htonl(dvp->fid.vid);
0599     *bp++ = htonl(dvp->fid.vnode);
0600     *bp++ = htonl(dvp->fid.unique);
0601     *bp++ = htonl(namesz);
0602     memcpy(bp, name->name, namesz);
0603     bp = (void *) bp + namesz;
0604     if (padsz > 0) {
0605         memset(bp, 0, padsz);
0606         bp = (void *) bp + padsz;
0607     }
0608     *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
0609     *bp++ = htonl(op->mtime.tv_sec); /* mtime */
0610     *bp++ = 0; /* owner */
0611     *bp++ = 0; /* group */
0612     *bp++ = htonl(op->create.mode & S_IALLUGO); /* unix mode */
0613     *bp++ = 0; /* segment size */
0614 
0615     trace_afs_make_fs_call1(call, &dvp->fid, name);
0616     afs_make_op_call(op, call, GFP_NOFS);
0617 }
0618 
0619 /*
0620  * Deliver reply data to any operation that returns status and volume sync.
0621  */
0622 static int afs_deliver_fs_file_status_and_vol(struct afs_call *call)
0623 {
0624     struct afs_operation *op = call->op;
0625     struct afs_vnode_param *vp = &op->file[0];
0626     const __be32 *bp;
0627     int ret;
0628 
0629     ret = afs_transfer_reply(call);
0630     if (ret < 0)
0631         return ret;
0632 
0633     /* unmarshall the reply once we've received all of it */
0634     bp = call->buffer;
0635     xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
0636     xdr_decode_AFSVolSync(&bp, &op->volsync);
0637 
0638     _leave(" = 0 [done]");
0639     return 0;
0640 }
0641 
0642 /*
0643  * FS.RemoveFile operation type
0644  */
0645 static const struct afs_call_type afs_RXFSRemoveFile = {
0646     .name       = "FS.RemoveFile",
0647     .op     = afs_FS_RemoveFile,
0648     .deliver    = afs_deliver_fs_file_status_and_vol,
0649     .destructor = afs_flat_call_destructor,
0650 };
0651 
0652 /*
0653  * Remove a file.
0654  */
0655 void afs_fs_remove_file(struct afs_operation *op)
0656 {
0657     const struct qstr *name = &op->dentry->d_name;
0658     struct afs_vnode_param *dvp = &op->file[0];
0659     struct afs_call *call;
0660     size_t namesz, reqsz, padsz;
0661     __be32 *bp;
0662 
0663     _enter("");
0664 
0665     namesz = name->len;
0666     padsz = (4 - (namesz & 3)) & 3;
0667     reqsz = (5 * 4) + namesz + padsz;
0668 
0669     call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveFile,
0670                    reqsz, (21 + 6) * 4);
0671     if (!call)
0672         return afs_op_nomem(op);
0673 
0674     /* marshall the parameters */
0675     bp = call->request;
0676     *bp++ = htonl(FSREMOVEFILE);
0677     *bp++ = htonl(dvp->fid.vid);
0678     *bp++ = htonl(dvp->fid.vnode);
0679     *bp++ = htonl(dvp->fid.unique);
0680     *bp++ = htonl(namesz);
0681     memcpy(bp, name->name, namesz);
0682     bp = (void *) bp + namesz;
0683     if (padsz > 0) {
0684         memset(bp, 0, padsz);
0685         bp = (void *) bp + padsz;
0686     }
0687 
0688     trace_afs_make_fs_call1(call, &dvp->fid, name);
0689     afs_make_op_call(op, call, GFP_NOFS);
0690 }
0691 
0692 static const struct afs_call_type afs_RXFSRemoveDir = {
0693     .name       = "FS.RemoveDir",
0694     .op     = afs_FS_RemoveDir,
0695     .deliver    = afs_deliver_fs_file_status_and_vol,
0696     .destructor = afs_flat_call_destructor,
0697 };
0698 
0699 /*
0700  * Remove a directory.
0701  */
0702 void afs_fs_remove_dir(struct afs_operation *op)
0703 {
0704     const struct qstr *name = &op->dentry->d_name;
0705     struct afs_vnode_param *dvp = &op->file[0];
0706     struct afs_call *call;
0707     size_t namesz, reqsz, padsz;
0708     __be32 *bp;
0709 
0710     _enter("");
0711 
0712     namesz = name->len;
0713     padsz = (4 - (namesz & 3)) & 3;
0714     reqsz = (5 * 4) + namesz + padsz;
0715 
0716     call = afs_alloc_flat_call(op->net, &afs_RXFSRemoveDir,
0717                    reqsz, (21 + 6) * 4);
0718     if (!call)
0719         return afs_op_nomem(op);
0720 
0721     /* marshall the parameters */
0722     bp = call->request;
0723     *bp++ = htonl(FSREMOVEDIR);
0724     *bp++ = htonl(dvp->fid.vid);
0725     *bp++ = htonl(dvp->fid.vnode);
0726     *bp++ = htonl(dvp->fid.unique);
0727     *bp++ = htonl(namesz);
0728     memcpy(bp, name->name, namesz);
0729     bp = (void *) bp + namesz;
0730     if (padsz > 0) {
0731         memset(bp, 0, padsz);
0732         bp = (void *) bp + padsz;
0733     }
0734 
0735     trace_afs_make_fs_call1(call, &dvp->fid, name);
0736     afs_make_op_call(op, call, GFP_NOFS);
0737 }
0738 
0739 /*
0740  * deliver reply data to an FS.Link
0741  */
0742 static int afs_deliver_fs_link(struct afs_call *call)
0743 {
0744     struct afs_operation *op = call->op;
0745     struct afs_vnode_param *dvp = &op->file[0];
0746     struct afs_vnode_param *vp = &op->file[1];
0747     const __be32 *bp;
0748     int ret;
0749 
0750     _enter("{%u}", call->unmarshall);
0751 
0752     ret = afs_transfer_reply(call);
0753     if (ret < 0)
0754         return ret;
0755 
0756     /* unmarshall the reply once we've received all of it */
0757     bp = call->buffer;
0758     xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
0759     xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
0760     xdr_decode_AFSVolSync(&bp, &op->volsync);
0761 
0762     _leave(" = 0 [done]");
0763     return 0;
0764 }
0765 
0766 /*
0767  * FS.Link operation type
0768  */
0769 static const struct afs_call_type afs_RXFSLink = {
0770     .name       = "FS.Link",
0771     .op     = afs_FS_Link,
0772     .deliver    = afs_deliver_fs_link,
0773     .destructor = afs_flat_call_destructor,
0774 };
0775 
0776 /*
0777  * make a hard link
0778  */
0779 void afs_fs_link(struct afs_operation *op)
0780 {
0781     const struct qstr *name = &op->dentry->d_name;
0782     struct afs_vnode_param *dvp = &op->file[0];
0783     struct afs_vnode_param *vp = &op->file[1];
0784     struct afs_call *call;
0785     size_t namesz, reqsz, padsz;
0786     __be32 *bp;
0787 
0788     _enter("");
0789 
0790     namesz = name->len;
0791     padsz = (4 - (namesz & 3)) & 3;
0792     reqsz = (5 * 4) + namesz + padsz + (3 * 4);
0793 
0794     call = afs_alloc_flat_call(op->net, &afs_RXFSLink, reqsz, (21 + 21 + 6) * 4);
0795     if (!call)
0796         return afs_op_nomem(op);
0797 
0798     /* marshall the parameters */
0799     bp = call->request;
0800     *bp++ = htonl(FSLINK);
0801     *bp++ = htonl(dvp->fid.vid);
0802     *bp++ = htonl(dvp->fid.vnode);
0803     *bp++ = htonl(dvp->fid.unique);
0804     *bp++ = htonl(namesz);
0805     memcpy(bp, name->name, namesz);
0806     bp = (void *) bp + namesz;
0807     if (padsz > 0) {
0808         memset(bp, 0, padsz);
0809         bp = (void *) bp + padsz;
0810     }
0811     *bp++ = htonl(vp->fid.vid);
0812     *bp++ = htonl(vp->fid.vnode);
0813     *bp++ = htonl(vp->fid.unique);
0814 
0815     trace_afs_make_fs_call1(call, &vp->fid, name);
0816     afs_make_op_call(op, call, GFP_NOFS);
0817 }
0818 
0819 /*
0820  * deliver reply data to an FS.Symlink
0821  */
0822 static int afs_deliver_fs_symlink(struct afs_call *call)
0823 {
0824     struct afs_operation *op = call->op;
0825     struct afs_vnode_param *dvp = &op->file[0];
0826     struct afs_vnode_param *vp = &op->file[1];
0827     const __be32 *bp;
0828     int ret;
0829 
0830     _enter("{%u}", call->unmarshall);
0831 
0832     ret = afs_transfer_reply(call);
0833     if (ret < 0)
0834         return ret;
0835 
0836     /* unmarshall the reply once we've received all of it */
0837     bp = call->buffer;
0838     xdr_decode_AFSFid(&bp, &vp->fid);
0839     xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
0840     xdr_decode_AFSFetchStatus(&bp, call, &dvp->scb);
0841     xdr_decode_AFSVolSync(&bp, &op->volsync);
0842 
0843     _leave(" = 0 [done]");
0844     return 0;
0845 }
0846 
0847 /*
0848  * FS.Symlink operation type
0849  */
0850 static const struct afs_call_type afs_RXFSSymlink = {
0851     .name       = "FS.Symlink",
0852     .op     = afs_FS_Symlink,
0853     .deliver    = afs_deliver_fs_symlink,
0854     .destructor = afs_flat_call_destructor,
0855 };
0856 
0857 /*
0858  * create a symbolic link
0859  */
0860 void afs_fs_symlink(struct afs_operation *op)
0861 {
0862     const struct qstr *name = &op->dentry->d_name;
0863     struct afs_vnode_param *dvp = &op->file[0];
0864     struct afs_call *call;
0865     size_t namesz, reqsz, padsz, c_namesz, c_padsz;
0866     __be32 *bp;
0867 
0868     _enter("");
0869 
0870     namesz = name->len;
0871     padsz = (4 - (namesz & 3)) & 3;
0872 
0873     c_namesz = strlen(op->create.symlink);
0874     c_padsz = (4 - (c_namesz & 3)) & 3;
0875 
0876     reqsz = (6 * 4) + namesz + padsz + c_namesz + c_padsz + (6 * 4);
0877 
0878     call = afs_alloc_flat_call(op->net, &afs_RXFSSymlink, reqsz,
0879                    (3 + 21 + 21 + 6) * 4);
0880     if (!call)
0881         return afs_op_nomem(op);
0882 
0883     /* marshall the parameters */
0884     bp = call->request;
0885     *bp++ = htonl(FSSYMLINK);
0886     *bp++ = htonl(dvp->fid.vid);
0887     *bp++ = htonl(dvp->fid.vnode);
0888     *bp++ = htonl(dvp->fid.unique);
0889     *bp++ = htonl(namesz);
0890     memcpy(bp, name->name, namesz);
0891     bp = (void *) bp + namesz;
0892     if (padsz > 0) {
0893         memset(bp, 0, padsz);
0894         bp = (void *) bp + padsz;
0895     }
0896     *bp++ = htonl(c_namesz);
0897     memcpy(bp, op->create.symlink, c_namesz);
0898     bp = (void *) bp + c_namesz;
0899     if (c_padsz > 0) {
0900         memset(bp, 0, c_padsz);
0901         bp = (void *) bp + c_padsz;
0902     }
0903     *bp++ = htonl(AFS_SET_MODE | AFS_SET_MTIME);
0904     *bp++ = htonl(op->mtime.tv_sec); /* mtime */
0905     *bp++ = 0; /* owner */
0906     *bp++ = 0; /* group */
0907     *bp++ = htonl(S_IRWXUGO); /* unix mode */
0908     *bp++ = 0; /* segment size */
0909 
0910     trace_afs_make_fs_call1(call, &dvp->fid, name);
0911     afs_make_op_call(op, call, GFP_NOFS);
0912 }
0913 
0914 /*
0915  * deliver reply data to an FS.Rename
0916  */
0917 static int afs_deliver_fs_rename(struct afs_call *call)
0918 {
0919     struct afs_operation *op = call->op;
0920     struct afs_vnode_param *orig_dvp = &op->file[0];
0921     struct afs_vnode_param *new_dvp = &op->file[1];
0922     const __be32 *bp;
0923     int ret;
0924 
0925     ret = afs_transfer_reply(call);
0926     if (ret < 0)
0927         return ret;
0928 
0929     bp = call->buffer;
0930     /* If the two dirs are the same, we have two copies of the same status
0931      * report, so we just decode it twice.
0932      */
0933     xdr_decode_AFSFetchStatus(&bp, call, &orig_dvp->scb);
0934     xdr_decode_AFSFetchStatus(&bp, call, &new_dvp->scb);
0935     xdr_decode_AFSVolSync(&bp, &op->volsync);
0936 
0937     _leave(" = 0 [done]");
0938     return 0;
0939 }
0940 
0941 /*
0942  * FS.Rename operation type
0943  */
0944 static const struct afs_call_type afs_RXFSRename = {
0945     .name       = "FS.Rename",
0946     .op     = afs_FS_Rename,
0947     .deliver    = afs_deliver_fs_rename,
0948     .destructor = afs_flat_call_destructor,
0949 };
0950 
0951 /*
0952  * Rename/move a file or directory.
0953  */
0954 void afs_fs_rename(struct afs_operation *op)
0955 {
0956     struct afs_vnode_param *orig_dvp = &op->file[0];
0957     struct afs_vnode_param *new_dvp = &op->file[1];
0958     const struct qstr *orig_name = &op->dentry->d_name;
0959     const struct qstr *new_name = &op->dentry_2->d_name;
0960     struct afs_call *call;
0961     size_t reqsz, o_namesz, o_padsz, n_namesz, n_padsz;
0962     __be32 *bp;
0963 
0964     _enter("");
0965 
0966     o_namesz = orig_name->len;
0967     o_padsz = (4 - (o_namesz & 3)) & 3;
0968 
0969     n_namesz = new_name->len;
0970     n_padsz = (4 - (n_namesz & 3)) & 3;
0971 
0972     reqsz = (4 * 4) +
0973         4 + o_namesz + o_padsz +
0974         (3 * 4) +
0975         4 + n_namesz + n_padsz;
0976 
0977     call = afs_alloc_flat_call(op->net, &afs_RXFSRename, reqsz, (21 + 21 + 6) * 4);
0978     if (!call)
0979         return afs_op_nomem(op);
0980 
0981     /* marshall the parameters */
0982     bp = call->request;
0983     *bp++ = htonl(FSRENAME);
0984     *bp++ = htonl(orig_dvp->fid.vid);
0985     *bp++ = htonl(orig_dvp->fid.vnode);
0986     *bp++ = htonl(orig_dvp->fid.unique);
0987     *bp++ = htonl(o_namesz);
0988     memcpy(bp, orig_name->name, o_namesz);
0989     bp = (void *) bp + o_namesz;
0990     if (o_padsz > 0) {
0991         memset(bp, 0, o_padsz);
0992         bp = (void *) bp + o_padsz;
0993     }
0994 
0995     *bp++ = htonl(new_dvp->fid.vid);
0996     *bp++ = htonl(new_dvp->fid.vnode);
0997     *bp++ = htonl(new_dvp->fid.unique);
0998     *bp++ = htonl(n_namesz);
0999     memcpy(bp, new_name->name, n_namesz);
1000     bp = (void *) bp + n_namesz;
1001     if (n_padsz > 0) {
1002         memset(bp, 0, n_padsz);
1003         bp = (void *) bp + n_padsz;
1004     }
1005 
1006     trace_afs_make_fs_call2(call, &orig_dvp->fid, orig_name, new_name);
1007     afs_make_op_call(op, call, GFP_NOFS);
1008 }
1009 
1010 /*
1011  * Deliver reply data to FS.StoreData or FS.StoreStatus
1012  */
1013 static int afs_deliver_fs_store_data(struct afs_call *call)
1014 {
1015     struct afs_operation *op = call->op;
1016     struct afs_vnode_param *vp = &op->file[0];
1017     const __be32 *bp;
1018     int ret;
1019 
1020     _enter("");
1021 
1022     ret = afs_transfer_reply(call);
1023     if (ret < 0)
1024         return ret;
1025 
1026     /* unmarshall the reply once we've received all of it */
1027     bp = call->buffer;
1028     xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
1029     xdr_decode_AFSVolSync(&bp, &op->volsync);
1030 
1031     _leave(" = 0 [done]");
1032     return 0;
1033 }
1034 
1035 /*
1036  * FS.StoreData operation type
1037  */
1038 static const struct afs_call_type afs_RXFSStoreData = {
1039     .name       = "FS.StoreData",
1040     .op     = afs_FS_StoreData,
1041     .deliver    = afs_deliver_fs_store_data,
1042     .destructor = afs_flat_call_destructor,
1043 };
1044 
1045 static const struct afs_call_type afs_RXFSStoreData64 = {
1046     .name       = "FS.StoreData64",
1047     .op     = afs_FS_StoreData64,
1048     .deliver    = afs_deliver_fs_store_data,
1049     .destructor = afs_flat_call_destructor,
1050 };
1051 
1052 /*
1053  * store a set of pages to a very large file
1054  */
1055 static void afs_fs_store_data64(struct afs_operation *op)
1056 {
1057     struct afs_vnode_param *vp = &op->file[0];
1058     struct afs_call *call;
1059     __be32 *bp;
1060 
1061     _enter(",%x,{%llx:%llu},,",
1062            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1063 
1064     call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64,
1065                    (4 + 6 + 3 * 2) * 4,
1066                    (21 + 6) * 4);
1067     if (!call)
1068         return afs_op_nomem(op);
1069 
1070     call->write_iter = op->store.write_iter;
1071 
1072     /* marshall the parameters */
1073     bp = call->request;
1074     *bp++ = htonl(FSSTOREDATA64);
1075     *bp++ = htonl(vp->fid.vid);
1076     *bp++ = htonl(vp->fid.vnode);
1077     *bp++ = htonl(vp->fid.unique);
1078 
1079     *bp++ = htonl(AFS_SET_MTIME); /* mask */
1080     *bp++ = htonl(op->mtime.tv_sec); /* mtime */
1081     *bp++ = 0; /* owner */
1082     *bp++ = 0; /* group */
1083     *bp++ = 0; /* unix mode */
1084     *bp++ = 0; /* segment size */
1085 
1086     *bp++ = htonl(upper_32_bits(op->store.pos));
1087     *bp++ = htonl(lower_32_bits(op->store.pos));
1088     *bp++ = htonl(upper_32_bits(op->store.size));
1089     *bp++ = htonl(lower_32_bits(op->store.size));
1090     *bp++ = htonl(upper_32_bits(op->store.i_size));
1091     *bp++ = htonl(lower_32_bits(op->store.i_size));
1092 
1093     trace_afs_make_fs_call(call, &vp->fid);
1094     afs_make_op_call(op, call, GFP_NOFS);
1095 }
1096 
1097 /*
1098  * Write data to a file on the server.
1099  */
1100 void afs_fs_store_data(struct afs_operation *op)
1101 {
1102     struct afs_vnode_param *vp = &op->file[0];
1103     struct afs_call *call;
1104     __be32 *bp;
1105 
1106     _enter(",%x,{%llx:%llu},,",
1107            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1108 
1109     _debug("size %llx, at %llx, i_size %llx",
1110            (unsigned long long)op->store.size,
1111            (unsigned long long)op->store.pos,
1112            (unsigned long long)op->store.i_size);
1113 
1114     if (test_bit(AFS_SERVER_FL_HAS_FS64, &op->server->flags))
1115         return afs_fs_store_data64(op);
1116 
1117     call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData,
1118                    (4 + 6 + 3) * 4,
1119                    (21 + 6) * 4);
1120     if (!call)
1121         return afs_op_nomem(op);
1122 
1123     call->write_iter = op->store.write_iter;
1124 
1125     /* marshall the parameters */
1126     bp = call->request;
1127     *bp++ = htonl(FSSTOREDATA);
1128     *bp++ = htonl(vp->fid.vid);
1129     *bp++ = htonl(vp->fid.vnode);
1130     *bp++ = htonl(vp->fid.unique);
1131 
1132     *bp++ = htonl(AFS_SET_MTIME); /* mask */
1133     *bp++ = htonl(op->mtime.tv_sec); /* mtime */
1134     *bp++ = 0; /* owner */
1135     *bp++ = 0; /* group */
1136     *bp++ = 0; /* unix mode */
1137     *bp++ = 0; /* segment size */
1138 
1139     *bp++ = htonl(lower_32_bits(op->store.pos));
1140     *bp++ = htonl(lower_32_bits(op->store.size));
1141     *bp++ = htonl(lower_32_bits(op->store.i_size));
1142 
1143     trace_afs_make_fs_call(call, &vp->fid);
1144     afs_make_op_call(op, call, GFP_NOFS);
1145 }
1146 
1147 /*
1148  * FS.StoreStatus operation type
1149  */
1150 static const struct afs_call_type afs_RXFSStoreStatus = {
1151     .name       = "FS.StoreStatus",
1152     .op     = afs_FS_StoreStatus,
1153     .deliver    = afs_deliver_fs_store_data,
1154     .destructor = afs_flat_call_destructor,
1155 };
1156 
1157 static const struct afs_call_type afs_RXFSStoreData_as_Status = {
1158     .name       = "FS.StoreData",
1159     .op     = afs_FS_StoreData,
1160     .deliver    = afs_deliver_fs_store_data,
1161     .destructor = afs_flat_call_destructor,
1162 };
1163 
1164 static const struct afs_call_type afs_RXFSStoreData64_as_Status = {
1165     .name       = "FS.StoreData64",
1166     .op     = afs_FS_StoreData64,
1167     .deliver    = afs_deliver_fs_store_data,
1168     .destructor = afs_flat_call_destructor,
1169 };
1170 
1171 /*
1172  * set the attributes on a very large file, using FS.StoreData rather than
1173  * FS.StoreStatus so as to alter the file size also
1174  */
1175 static void afs_fs_setattr_size64(struct afs_operation *op)
1176 {
1177     struct afs_vnode_param *vp = &op->file[0];
1178     struct afs_call *call;
1179     struct iattr *attr = op->setattr.attr;
1180     __be32 *bp;
1181 
1182     _enter(",%x,{%llx:%llu},,",
1183            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1184 
1185     ASSERT(attr->ia_valid & ATTR_SIZE);
1186 
1187     call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData64_as_Status,
1188                    (4 + 6 + 3 * 2) * 4,
1189                    (21 + 6) * 4);
1190     if (!call)
1191         return afs_op_nomem(op);
1192 
1193     /* marshall the parameters */
1194     bp = call->request;
1195     *bp++ = htonl(FSSTOREDATA64);
1196     *bp++ = htonl(vp->fid.vid);
1197     *bp++ = htonl(vp->fid.vnode);
1198     *bp++ = htonl(vp->fid.unique);
1199 
1200     xdr_encode_AFS_StoreStatus(&bp, attr);
1201 
1202     *bp++ = htonl(upper_32_bits(attr->ia_size));    /* position of start of write */
1203     *bp++ = htonl(lower_32_bits(attr->ia_size));
1204     *bp++ = 0;                  /* size of write */
1205     *bp++ = 0;
1206     *bp++ = htonl(upper_32_bits(attr->ia_size));    /* new file length */
1207     *bp++ = htonl(lower_32_bits(attr->ia_size));
1208 
1209     trace_afs_make_fs_call(call, &vp->fid);
1210     afs_make_op_call(op, call, GFP_NOFS);
1211 }
1212 
1213 /*
1214  * set the attributes on a file, using FS.StoreData rather than FS.StoreStatus
1215  * so as to alter the file size also
1216  */
1217 static void afs_fs_setattr_size(struct afs_operation *op)
1218 {
1219     struct afs_vnode_param *vp = &op->file[0];
1220     struct afs_call *call;
1221     struct iattr *attr = op->setattr.attr;
1222     __be32 *bp;
1223 
1224     _enter(",%x,{%llx:%llu},,",
1225            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1226 
1227     ASSERT(attr->ia_valid & ATTR_SIZE);
1228     if (test_bit(AFS_SERVER_FL_HAS_FS64, &op->server->flags))
1229         return afs_fs_setattr_size64(op);
1230 
1231     call = afs_alloc_flat_call(op->net, &afs_RXFSStoreData_as_Status,
1232                    (4 + 6 + 3) * 4,
1233                    (21 + 6) * 4);
1234     if (!call)
1235         return afs_op_nomem(op);
1236 
1237     /* marshall the parameters */
1238     bp = call->request;
1239     *bp++ = htonl(FSSTOREDATA);
1240     *bp++ = htonl(vp->fid.vid);
1241     *bp++ = htonl(vp->fid.vnode);
1242     *bp++ = htonl(vp->fid.unique);
1243 
1244     xdr_encode_AFS_StoreStatus(&bp, attr);
1245 
1246     *bp++ = htonl(attr->ia_size);       /* position of start of write */
1247     *bp++ = 0;              /* size of write */
1248     *bp++ = htonl(attr->ia_size);       /* new file length */
1249 
1250     trace_afs_make_fs_call(call, &vp->fid);
1251     afs_make_op_call(op, call, GFP_NOFS);
1252 }
1253 
1254 /*
1255  * set the attributes on a file, using FS.StoreData if there's a change in file
1256  * size, and FS.StoreStatus otherwise
1257  */
1258 void afs_fs_setattr(struct afs_operation *op)
1259 {
1260     struct afs_vnode_param *vp = &op->file[0];
1261     struct afs_call *call;
1262     struct iattr *attr = op->setattr.attr;
1263     __be32 *bp;
1264 
1265     if (attr->ia_valid & ATTR_SIZE)
1266         return afs_fs_setattr_size(op);
1267 
1268     _enter(",%x,{%llx:%llu},,",
1269            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
1270 
1271     call = afs_alloc_flat_call(op->net, &afs_RXFSStoreStatus,
1272                    (4 + 6) * 4,
1273                    (21 + 6) * 4);
1274     if (!call)
1275         return afs_op_nomem(op);
1276 
1277     /* marshall the parameters */
1278     bp = call->request;
1279     *bp++ = htonl(FSSTORESTATUS);
1280     *bp++ = htonl(vp->fid.vid);
1281     *bp++ = htonl(vp->fid.vnode);
1282     *bp++ = htonl(vp->fid.unique);
1283 
1284     xdr_encode_AFS_StoreStatus(&bp, op->setattr.attr);
1285 
1286     trace_afs_make_fs_call(call, &vp->fid);
1287     afs_make_op_call(op, call, GFP_NOFS);
1288 }
1289 
1290 /*
1291  * deliver reply data to an FS.GetVolumeStatus
1292  */
1293 static int afs_deliver_fs_get_volume_status(struct afs_call *call)
1294 {
1295     struct afs_operation *op = call->op;
1296     const __be32 *bp;
1297     char *p;
1298     u32 size;
1299     int ret;
1300 
1301     _enter("{%u}", call->unmarshall);
1302 
1303     switch (call->unmarshall) {
1304     case 0:
1305         call->unmarshall++;
1306         afs_extract_to_buf(call, 12 * 4);
1307         fallthrough;
1308 
1309         /* extract the returned status record */
1310     case 1:
1311         _debug("extract status");
1312         ret = afs_extract_data(call, true);
1313         if (ret < 0)
1314             return ret;
1315 
1316         bp = call->buffer;
1317         xdr_decode_AFSFetchVolumeStatus(&bp, &op->volstatus.vs);
1318         call->unmarshall++;
1319         afs_extract_to_tmp(call);
1320         fallthrough;
1321 
1322         /* extract the volume name length */
1323     case 2:
1324         ret = afs_extract_data(call, true);
1325         if (ret < 0)
1326             return ret;
1327 
1328         call->count = ntohl(call->tmp);
1329         _debug("volname length: %u", call->count);
1330         if (call->count >= AFSNAMEMAX)
1331             return afs_protocol_error(call, afs_eproto_volname_len);
1332         size = (call->count + 3) & ~3; /* It's padded */
1333         afs_extract_to_buf(call, size);
1334         call->unmarshall++;
1335         fallthrough;
1336 
1337         /* extract the volume name */
1338     case 3:
1339         _debug("extract volname");
1340         ret = afs_extract_data(call, true);
1341         if (ret < 0)
1342             return ret;
1343 
1344         p = call->buffer;
1345         p[call->count] = 0;
1346         _debug("volname '%s'", p);
1347         afs_extract_to_tmp(call);
1348         call->unmarshall++;
1349         fallthrough;
1350 
1351         /* extract the offline message length */
1352     case 4:
1353         ret = afs_extract_data(call, true);
1354         if (ret < 0)
1355             return ret;
1356 
1357         call->count = ntohl(call->tmp);
1358         _debug("offline msg length: %u", call->count);
1359         if (call->count >= AFSNAMEMAX)
1360             return afs_protocol_error(call, afs_eproto_offline_msg_len);
1361         size = (call->count + 3) & ~3; /* It's padded */
1362         afs_extract_to_buf(call, size);
1363         call->unmarshall++;
1364         fallthrough;
1365 
1366         /* extract the offline message */
1367     case 5:
1368         _debug("extract offline");
1369         ret = afs_extract_data(call, true);
1370         if (ret < 0)
1371             return ret;
1372 
1373         p = call->buffer;
1374         p[call->count] = 0;
1375         _debug("offline '%s'", p);
1376 
1377         afs_extract_to_tmp(call);
1378         call->unmarshall++;
1379         fallthrough;
1380 
1381         /* extract the message of the day length */
1382     case 6:
1383         ret = afs_extract_data(call, true);
1384         if (ret < 0)
1385             return ret;
1386 
1387         call->count = ntohl(call->tmp);
1388         _debug("motd length: %u", call->count);
1389         if (call->count >= AFSNAMEMAX)
1390             return afs_protocol_error(call, afs_eproto_motd_len);
1391         size = (call->count + 3) & ~3; /* It's padded */
1392         afs_extract_to_buf(call, size);
1393         call->unmarshall++;
1394         fallthrough;
1395 
1396         /* extract the message of the day */
1397     case 7:
1398         _debug("extract motd");
1399         ret = afs_extract_data(call, false);
1400         if (ret < 0)
1401             return ret;
1402 
1403         p = call->buffer;
1404         p[call->count] = 0;
1405         _debug("motd '%s'", p);
1406 
1407         call->unmarshall++;
1408         fallthrough;
1409 
1410     case 8:
1411         break;
1412     }
1413 
1414     _leave(" = 0 [done]");
1415     return 0;
1416 }
1417 
1418 /*
1419  * FS.GetVolumeStatus operation type
1420  */
1421 static const struct afs_call_type afs_RXFSGetVolumeStatus = {
1422     .name       = "FS.GetVolumeStatus",
1423     .op     = afs_FS_GetVolumeStatus,
1424     .deliver    = afs_deliver_fs_get_volume_status,
1425     .destructor = afs_flat_call_destructor,
1426 };
1427 
1428 /*
1429  * fetch the status of a volume
1430  */
1431 void afs_fs_get_volume_status(struct afs_operation *op)
1432 {
1433     struct afs_vnode_param *vp = &op->file[0];
1434     struct afs_call *call;
1435     __be32 *bp;
1436 
1437     _enter("");
1438 
1439     call = afs_alloc_flat_call(op->net, &afs_RXFSGetVolumeStatus, 2 * 4,
1440                    max(12 * 4, AFSOPAQUEMAX + 1));
1441     if (!call)
1442         return afs_op_nomem(op);
1443 
1444     /* marshall the parameters */
1445     bp = call->request;
1446     bp[0] = htonl(FSGETVOLUMESTATUS);
1447     bp[1] = htonl(vp->fid.vid);
1448 
1449     trace_afs_make_fs_call(call, &vp->fid);
1450     afs_make_op_call(op, call, GFP_NOFS);
1451 }
1452 
1453 /*
1454  * deliver reply data to an FS.SetLock, FS.ExtendLock or FS.ReleaseLock
1455  */
1456 static int afs_deliver_fs_xxxx_lock(struct afs_call *call)
1457 {
1458     struct afs_operation *op = call->op;
1459     const __be32 *bp;
1460     int ret;
1461 
1462     _enter("{%u}", call->unmarshall);
1463 
1464     ret = afs_transfer_reply(call);
1465     if (ret < 0)
1466         return ret;
1467 
1468     /* unmarshall the reply once we've received all of it */
1469     bp = call->buffer;
1470     xdr_decode_AFSVolSync(&bp, &op->volsync);
1471 
1472     _leave(" = 0 [done]");
1473     return 0;
1474 }
1475 
1476 /*
1477  * FS.SetLock operation type
1478  */
1479 static const struct afs_call_type afs_RXFSSetLock = {
1480     .name       = "FS.SetLock",
1481     .op     = afs_FS_SetLock,
1482     .deliver    = afs_deliver_fs_xxxx_lock,
1483     .done       = afs_lock_op_done,
1484     .destructor = afs_flat_call_destructor,
1485 };
1486 
1487 /*
1488  * FS.ExtendLock operation type
1489  */
1490 static const struct afs_call_type afs_RXFSExtendLock = {
1491     .name       = "FS.ExtendLock",
1492     .op     = afs_FS_ExtendLock,
1493     .deliver    = afs_deliver_fs_xxxx_lock,
1494     .done       = afs_lock_op_done,
1495     .destructor = afs_flat_call_destructor,
1496 };
1497 
1498 /*
1499  * FS.ReleaseLock operation type
1500  */
1501 static const struct afs_call_type afs_RXFSReleaseLock = {
1502     .name       = "FS.ReleaseLock",
1503     .op     = afs_FS_ReleaseLock,
1504     .deliver    = afs_deliver_fs_xxxx_lock,
1505     .destructor = afs_flat_call_destructor,
1506 };
1507 
1508 /*
1509  * Set a lock on a file
1510  */
1511 void afs_fs_set_lock(struct afs_operation *op)
1512 {
1513     struct afs_vnode_param *vp = &op->file[0];
1514     struct afs_call *call;
1515     __be32 *bp;
1516 
1517     _enter("");
1518 
1519     call = afs_alloc_flat_call(op->net, &afs_RXFSSetLock, 5 * 4, 6 * 4);
1520     if (!call)
1521         return afs_op_nomem(op);
1522 
1523     /* marshall the parameters */
1524     bp = call->request;
1525     *bp++ = htonl(FSSETLOCK);
1526     *bp++ = htonl(vp->fid.vid);
1527     *bp++ = htonl(vp->fid.vnode);
1528     *bp++ = htonl(vp->fid.unique);
1529     *bp++ = htonl(op->lock.type);
1530 
1531     trace_afs_make_fs_calli(call, &vp->fid, op->lock.type);
1532     afs_make_op_call(op, call, GFP_NOFS);
1533 }
1534 
1535 /*
1536  * extend a lock on a file
1537  */
1538 void afs_fs_extend_lock(struct afs_operation *op)
1539 {
1540     struct afs_vnode_param *vp = &op->file[0];
1541     struct afs_call *call;
1542     __be32 *bp;
1543 
1544     _enter("");
1545 
1546     call = afs_alloc_flat_call(op->net, &afs_RXFSExtendLock, 4 * 4, 6 * 4);
1547     if (!call)
1548         return afs_op_nomem(op);
1549 
1550     /* marshall the parameters */
1551     bp = call->request;
1552     *bp++ = htonl(FSEXTENDLOCK);
1553     *bp++ = htonl(vp->fid.vid);
1554     *bp++ = htonl(vp->fid.vnode);
1555     *bp++ = htonl(vp->fid.unique);
1556 
1557     trace_afs_make_fs_call(call, &vp->fid);
1558     afs_make_op_call(op, call, GFP_NOFS);
1559 }
1560 
1561 /*
1562  * release a lock on a file
1563  */
1564 void afs_fs_release_lock(struct afs_operation *op)
1565 {
1566     struct afs_vnode_param *vp = &op->file[0];
1567     struct afs_call *call;
1568     __be32 *bp;
1569 
1570     _enter("");
1571 
1572     call = afs_alloc_flat_call(op->net, &afs_RXFSReleaseLock, 4 * 4, 6 * 4);
1573     if (!call)
1574         return afs_op_nomem(op);
1575 
1576     /* marshall the parameters */
1577     bp = call->request;
1578     *bp++ = htonl(FSRELEASELOCK);
1579     *bp++ = htonl(vp->fid.vid);
1580     *bp++ = htonl(vp->fid.vnode);
1581     *bp++ = htonl(vp->fid.unique);
1582 
1583     trace_afs_make_fs_call(call, &vp->fid);
1584     afs_make_op_call(op, call, GFP_NOFS);
1585 }
1586 
1587 /*
1588  * Deliver reply data to an FS.GiveUpAllCallBacks operation.
1589  */
1590 static int afs_deliver_fs_give_up_all_callbacks(struct afs_call *call)
1591 {
1592     return afs_transfer_reply(call);
1593 }
1594 
1595 /*
1596  * FS.GiveUpAllCallBacks operation type
1597  */
1598 static const struct afs_call_type afs_RXFSGiveUpAllCallBacks = {
1599     .name       = "FS.GiveUpAllCallBacks",
1600     .op     = afs_FS_GiveUpAllCallBacks,
1601     .deliver    = afs_deliver_fs_give_up_all_callbacks,
1602     .destructor = afs_flat_call_destructor,
1603 };
1604 
1605 /*
1606  * Flush all the callbacks we have on a server.
1607  */
1608 int afs_fs_give_up_all_callbacks(struct afs_net *net,
1609                  struct afs_server *server,
1610                  struct afs_addr_cursor *ac,
1611                  struct key *key)
1612 {
1613     struct afs_call *call;
1614     __be32 *bp;
1615 
1616     _enter("");
1617 
1618     call = afs_alloc_flat_call(net, &afs_RXFSGiveUpAllCallBacks, 1 * 4, 0);
1619     if (!call)
1620         return -ENOMEM;
1621 
1622     call->key = key;
1623 
1624     /* marshall the parameters */
1625     bp = call->request;
1626     *bp++ = htonl(FSGIVEUPALLCALLBACKS);
1627 
1628     call->server = afs_use_server(server, afs_server_trace_give_up_cb);
1629     afs_make_call(ac, call, GFP_NOFS);
1630     return afs_wait_for_call_to_complete(call, ac);
1631 }
1632 
1633 /*
1634  * Deliver reply data to an FS.GetCapabilities operation.
1635  */
1636 static int afs_deliver_fs_get_capabilities(struct afs_call *call)
1637 {
1638     u32 count;
1639     int ret;
1640 
1641     _enter("{%u,%zu}", call->unmarshall, iov_iter_count(call->iter));
1642 
1643     switch (call->unmarshall) {
1644     case 0:
1645         afs_extract_to_tmp(call);
1646         call->unmarshall++;
1647         fallthrough;
1648 
1649         /* Extract the capabilities word count */
1650     case 1:
1651         ret = afs_extract_data(call, true);
1652         if (ret < 0)
1653             return ret;
1654 
1655         count = ntohl(call->tmp);
1656         call->count = count;
1657         call->count2 = count;
1658         if (count == 0) {
1659             call->unmarshall = 4;
1660             call->tmp = 0;
1661             break;
1662         }
1663 
1664         /* Extract the first word of the capabilities to call->tmp */
1665         afs_extract_to_tmp(call);
1666         call->unmarshall++;
1667         fallthrough;
1668 
1669     case 2:
1670         ret = afs_extract_data(call, false);
1671         if (ret < 0)
1672             return ret;
1673 
1674         afs_extract_discard(call, (count - 1) * sizeof(__be32));
1675         call->unmarshall++;
1676         fallthrough;
1677 
1678         /* Extract remaining capabilities words */
1679     case 3:
1680         ret = afs_extract_data(call, false);
1681         if (ret < 0)
1682             return ret;
1683 
1684         call->unmarshall++;
1685         break;
1686     }
1687 
1688     _leave(" = 0 [done]");
1689     return 0;
1690 }
1691 
1692 /*
1693  * FS.GetCapabilities operation type
1694  */
1695 static const struct afs_call_type afs_RXFSGetCapabilities = {
1696     .name       = "FS.GetCapabilities",
1697     .op     = afs_FS_GetCapabilities,
1698     .deliver    = afs_deliver_fs_get_capabilities,
1699     .done       = afs_fileserver_probe_result,
1700     .destructor = afs_flat_call_destructor,
1701 };
1702 
1703 /*
1704  * Probe a fileserver for the capabilities that it supports.  This RPC can
1705  * reply with up to 196 words.  The operation is asynchronous and if we managed
1706  * to allocate a call, true is returned the result is delivered through the
1707  * ->done() - otherwise we return false to indicate we didn't even try.
1708  */
1709 bool afs_fs_get_capabilities(struct afs_net *net, struct afs_server *server,
1710                  struct afs_addr_cursor *ac, struct key *key)
1711 {
1712     struct afs_call *call;
1713     __be32 *bp;
1714 
1715     _enter("");
1716 
1717     call = afs_alloc_flat_call(net, &afs_RXFSGetCapabilities, 1 * 4, 16 * 4);
1718     if (!call)
1719         return false;
1720 
1721     call->key = key;
1722     call->server = afs_use_server(server, afs_server_trace_get_caps);
1723     call->upgrade = true;
1724     call->async = true;
1725     call->max_lifespan = AFS_PROBE_MAX_LIFESPAN;
1726 
1727     /* marshall the parameters */
1728     bp = call->request;
1729     *bp++ = htonl(FSGETCAPABILITIES);
1730 
1731     trace_afs_make_fs_call(call, NULL);
1732     afs_make_call(ac, call, GFP_NOFS);
1733     afs_put_call(call);
1734     return true;
1735 }
1736 
1737 /*
1738  * Deliver reply data to an FS.InlineBulkStatus call
1739  */
1740 static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
1741 {
1742     struct afs_operation *op = call->op;
1743     struct afs_status_cb *scb;
1744     const __be32 *bp;
1745     u32 tmp;
1746     int ret;
1747 
1748     _enter("{%u}", call->unmarshall);
1749 
1750     switch (call->unmarshall) {
1751     case 0:
1752         afs_extract_to_tmp(call);
1753         call->unmarshall++;
1754         fallthrough;
1755 
1756         /* Extract the file status count and array in two steps */
1757     case 1:
1758         _debug("extract status count");
1759         ret = afs_extract_data(call, true);
1760         if (ret < 0)
1761             return ret;
1762 
1763         tmp = ntohl(call->tmp);
1764         _debug("status count: %u/%u", tmp, op->nr_files);
1765         if (tmp != op->nr_files)
1766             return afs_protocol_error(call, afs_eproto_ibulkst_count);
1767 
1768         call->count = 0;
1769         call->unmarshall++;
1770     more_counts:
1771         afs_extract_to_buf(call, 21 * sizeof(__be32));
1772         fallthrough;
1773 
1774     case 2:
1775         _debug("extract status array %u", call->count);
1776         ret = afs_extract_data(call, true);
1777         if (ret < 0)
1778             return ret;
1779 
1780         switch (call->count) {
1781         case 0:
1782             scb = &op->file[0].scb;
1783             break;
1784         case 1:
1785             scb = &op->file[1].scb;
1786             break;
1787         default:
1788             scb = &op->more_files[call->count - 2].scb;
1789             break;
1790         }
1791 
1792         bp = call->buffer;
1793         xdr_decode_AFSFetchStatus(&bp, call, scb);
1794 
1795         call->count++;
1796         if (call->count < op->nr_files)
1797             goto more_counts;
1798 
1799         call->count = 0;
1800         call->unmarshall++;
1801         afs_extract_to_tmp(call);
1802         fallthrough;
1803 
1804         /* Extract the callback count and array in two steps */
1805     case 3:
1806         _debug("extract CB count");
1807         ret = afs_extract_data(call, true);
1808         if (ret < 0)
1809             return ret;
1810 
1811         tmp = ntohl(call->tmp);
1812         _debug("CB count: %u", tmp);
1813         if (tmp != op->nr_files)
1814             return afs_protocol_error(call, afs_eproto_ibulkst_cb_count);
1815         call->count = 0;
1816         call->unmarshall++;
1817     more_cbs:
1818         afs_extract_to_buf(call, 3 * sizeof(__be32));
1819         fallthrough;
1820 
1821     case 4:
1822         _debug("extract CB array");
1823         ret = afs_extract_data(call, true);
1824         if (ret < 0)
1825             return ret;
1826 
1827         _debug("unmarshall CB array");
1828         switch (call->count) {
1829         case 0:
1830             scb = &op->file[0].scb;
1831             break;
1832         case 1:
1833             scb = &op->file[1].scb;
1834             break;
1835         default:
1836             scb = &op->more_files[call->count - 2].scb;
1837             break;
1838         }
1839 
1840         bp = call->buffer;
1841         xdr_decode_AFSCallBack(&bp, call, scb);
1842         call->count++;
1843         if (call->count < op->nr_files)
1844             goto more_cbs;
1845 
1846         afs_extract_to_buf(call, 6 * sizeof(__be32));
1847         call->unmarshall++;
1848         fallthrough;
1849 
1850     case 5:
1851         ret = afs_extract_data(call, false);
1852         if (ret < 0)
1853             return ret;
1854 
1855         bp = call->buffer;
1856         xdr_decode_AFSVolSync(&bp, &op->volsync);
1857 
1858         call->unmarshall++;
1859         fallthrough;
1860 
1861     case 6:
1862         break;
1863     }
1864 
1865     _leave(" = 0 [done]");
1866     return 0;
1867 }
1868 
1869 static void afs_done_fs_inline_bulk_status(struct afs_call *call)
1870 {
1871     if (call->error == -ECONNABORTED &&
1872         call->abort_code == RX_INVALID_OPERATION) {
1873         set_bit(AFS_SERVER_FL_NO_IBULK, &call->server->flags);
1874         if (call->op)
1875             set_bit(AFS_VOLUME_MAYBE_NO_IBULK, &call->op->volume->flags);
1876     }
1877 }
1878 
1879 /*
1880  * FS.InlineBulkStatus operation type
1881  */
1882 static const struct afs_call_type afs_RXFSInlineBulkStatus = {
1883     .name       = "FS.InlineBulkStatus",
1884     .op     = afs_FS_InlineBulkStatus,
1885     .deliver    = afs_deliver_fs_inline_bulk_status,
1886     .done       = afs_done_fs_inline_bulk_status,
1887     .destructor = afs_flat_call_destructor,
1888 };
1889 
1890 /*
1891  * Fetch the status information for up to 50 files
1892  */
1893 void afs_fs_inline_bulk_status(struct afs_operation *op)
1894 {
1895     struct afs_vnode_param *dvp = &op->file[0];
1896     struct afs_vnode_param *vp = &op->file[1];
1897     struct afs_call *call;
1898     __be32 *bp;
1899     int i;
1900 
1901     if (test_bit(AFS_SERVER_FL_NO_IBULK, &op->server->flags)) {
1902         op->error = -ENOTSUPP;
1903         return;
1904     }
1905 
1906     _enter(",%x,{%llx:%llu},%u",
1907            key_serial(op->key), vp->fid.vid, vp->fid.vnode, op->nr_files);
1908 
1909     call = afs_alloc_flat_call(op->net, &afs_RXFSInlineBulkStatus,
1910                    (2 + op->nr_files * 3) * 4,
1911                    21 * 4);
1912     if (!call)
1913         return afs_op_nomem(op);
1914 
1915     /* marshall the parameters */
1916     bp = call->request;
1917     *bp++ = htonl(FSINLINEBULKSTATUS);
1918     *bp++ = htonl(op->nr_files);
1919     *bp++ = htonl(dvp->fid.vid);
1920     *bp++ = htonl(dvp->fid.vnode);
1921     *bp++ = htonl(dvp->fid.unique);
1922     *bp++ = htonl(vp->fid.vid);
1923     *bp++ = htonl(vp->fid.vnode);
1924     *bp++ = htonl(vp->fid.unique);
1925     for (i = 0; i < op->nr_files - 2; i++) {
1926         *bp++ = htonl(op->more_files[i].fid.vid);
1927         *bp++ = htonl(op->more_files[i].fid.vnode);
1928         *bp++ = htonl(op->more_files[i].fid.unique);
1929     }
1930 
1931     trace_afs_make_fs_call(call, &vp->fid);
1932     afs_make_op_call(op, call, GFP_NOFS);
1933 }
1934 
1935 /*
1936  * deliver reply data to an FS.FetchACL
1937  */
1938 static int afs_deliver_fs_fetch_acl(struct afs_call *call)
1939 {
1940     struct afs_operation *op = call->op;
1941     struct afs_vnode_param *vp = &op->file[0];
1942     struct afs_acl *acl;
1943     const __be32 *bp;
1944     unsigned int size;
1945     int ret;
1946 
1947     _enter("{%u}", call->unmarshall);
1948 
1949     switch (call->unmarshall) {
1950     case 0:
1951         afs_extract_to_tmp(call);
1952         call->unmarshall++;
1953         fallthrough;
1954 
1955         /* extract the returned data length */
1956     case 1:
1957         ret = afs_extract_data(call, true);
1958         if (ret < 0)
1959             return ret;
1960 
1961         size = call->count2 = ntohl(call->tmp);
1962         size = round_up(size, 4);
1963 
1964         acl = kmalloc(struct_size(acl, data, size), GFP_KERNEL);
1965         if (!acl)
1966             return -ENOMEM;
1967         op->acl = acl;
1968         acl->size = call->count2;
1969         afs_extract_begin(call, acl->data, size);
1970         call->unmarshall++;
1971         fallthrough;
1972 
1973         /* extract the returned data */
1974     case 2:
1975         ret = afs_extract_data(call, true);
1976         if (ret < 0)
1977             return ret;
1978 
1979         afs_extract_to_buf(call, (21 + 6) * 4);
1980         call->unmarshall++;
1981         fallthrough;
1982 
1983         /* extract the metadata */
1984     case 3:
1985         ret = afs_extract_data(call, false);
1986         if (ret < 0)
1987             return ret;
1988 
1989         bp = call->buffer;
1990         xdr_decode_AFSFetchStatus(&bp, call, &vp->scb);
1991         xdr_decode_AFSVolSync(&bp, &op->volsync);
1992 
1993         call->unmarshall++;
1994         fallthrough;
1995 
1996     case 4:
1997         break;
1998     }
1999 
2000     _leave(" = 0 [done]");
2001     return 0;
2002 }
2003 
2004 /*
2005  * FS.FetchACL operation type
2006  */
2007 static const struct afs_call_type afs_RXFSFetchACL = {
2008     .name       = "FS.FetchACL",
2009     .op     = afs_FS_FetchACL,
2010     .deliver    = afs_deliver_fs_fetch_acl,
2011 };
2012 
2013 /*
2014  * Fetch the ACL for a file.
2015  */
2016 void afs_fs_fetch_acl(struct afs_operation *op)
2017 {
2018     struct afs_vnode_param *vp = &op->file[0];
2019     struct afs_call *call;
2020     __be32 *bp;
2021 
2022     _enter(",%x,{%llx:%llu},,",
2023            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
2024 
2025     call = afs_alloc_flat_call(op->net, &afs_RXFSFetchACL, 16, (21 + 6) * 4);
2026     if (!call)
2027         return afs_op_nomem(op);
2028 
2029     /* marshall the parameters */
2030     bp = call->request;
2031     bp[0] = htonl(FSFETCHACL);
2032     bp[1] = htonl(vp->fid.vid);
2033     bp[2] = htonl(vp->fid.vnode);
2034     bp[3] = htonl(vp->fid.unique);
2035 
2036     trace_afs_make_fs_call(call, &vp->fid);
2037     afs_make_op_call(op, call, GFP_KERNEL);
2038 }
2039 
2040 /*
2041  * FS.StoreACL operation type
2042  */
2043 static const struct afs_call_type afs_RXFSStoreACL = {
2044     .name       = "FS.StoreACL",
2045     .op     = afs_FS_StoreACL,
2046     .deliver    = afs_deliver_fs_file_status_and_vol,
2047     .destructor = afs_flat_call_destructor,
2048 };
2049 
2050 /*
2051  * Fetch the ACL for a file.
2052  */
2053 void afs_fs_store_acl(struct afs_operation *op)
2054 {
2055     struct afs_vnode_param *vp = &op->file[0];
2056     struct afs_call *call;
2057     const struct afs_acl *acl = op->acl;
2058     size_t size;
2059     __be32 *bp;
2060 
2061     _enter(",%x,{%llx:%llu},,",
2062            key_serial(op->key), vp->fid.vid, vp->fid.vnode);
2063 
2064     size = round_up(acl->size, 4);
2065     call = afs_alloc_flat_call(op->net, &afs_RXFSStoreACL,
2066                    5 * 4 + size, (21 + 6) * 4);
2067     if (!call)
2068         return afs_op_nomem(op);
2069 
2070     /* marshall the parameters */
2071     bp = call->request;
2072     bp[0] = htonl(FSSTOREACL);
2073     bp[1] = htonl(vp->fid.vid);
2074     bp[2] = htonl(vp->fid.vnode);
2075     bp[3] = htonl(vp->fid.unique);
2076     bp[4] = htonl(acl->size);
2077     memcpy(&bp[5], acl->data, acl->size);
2078     if (acl->size != size)
2079         memset((void *)&bp[5] + acl->size, 0, size - acl->size);
2080 
2081     trace_afs_make_fs_call(call, &vp->fid);
2082     afs_make_op_call(op, call, GFP_KERNEL);
2083 }