diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-03-22 18:43:16 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-30 17:32:15 -0400 |
commit | 0c0c267ba96f606b541ab8e4bcde54e6b3f0198f (patch) | |
tree | 06d1b3added2d439eda545389e13e53eb891751a /fs/nfsd/nfs4xdr.c | |
parent | b64c7f3bdfbb468d9026ca91d55c57675724f516 (diff) |
nfsd4: kill WRITEMEM
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 094a7c585f1e..3844dbe0cb6e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1683,12 +1683,6 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1683 | DECODE_TAIL; | 1683 | DECODE_TAIL; |
1684 | } | 1684 | } |
1685 | 1685 | ||
1686 | #define WRITEMEM(ptr,nbytes) do { if (nbytes > 0) { \ | ||
1687 | *(p + XDR_QUADLEN(nbytes) -1) = 0; \ | ||
1688 | memcpy(p, ptr, nbytes); \ | ||
1689 | p += XDR_QUADLEN(nbytes); \ | ||
1690 | }} while (0) | ||
1691 | |||
1692 | static void write32(__be32 **p, u32 n) | 1686 | static void write32(__be32 **p, u32 n) |
1693 | { | 1687 | { |
1694 | *(*p)++ = htonl(n); | 1688 | *(*p)++ = htonl(n); |
@@ -1769,8 +1763,7 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep, | |||
1769 | p = xdr_reserve_space(xdr, strlen + 4); | 1763 | p = xdr_reserve_space(xdr, strlen + 4); |
1770 | if (!p) | 1764 | if (!p) |
1771 | return nfserr_resource; | 1765 | return nfserr_resource; |
1772 | *p++ = cpu_to_be32(strlen); | 1766 | p = xdr_encode_opaque(p, str, strlen); |
1773 | WRITEMEM(str, strlen); | ||
1774 | count++; | 1767 | count++; |
1775 | } | 1768 | } |
1776 | else | 1769 | else |
@@ -1865,8 +1858,7 @@ static __be32 nfsd4_encode_path(struct xdr_stream *xdr, | |||
1865 | spin_unlock(&dentry->d_lock); | 1858 | spin_unlock(&dentry->d_lock); |
1866 | goto out_free; | 1859 | goto out_free; |
1867 | } | 1860 | } |
1868 | *p++ = cpu_to_be32(len); | 1861 | p = xdr_encode_opaque(p, dentry->d_name.name, len); |
1869 | WRITEMEM(dentry->d_name.name, len); | ||
1870 | dprintk("/%s", dentry->d_name.name); | 1862 | dprintk("/%s", dentry->d_name.name); |
1871 | spin_unlock(&dentry->d_lock); | 1863 | spin_unlock(&dentry->d_lock); |
1872 | dput(dentry); | 1864 | dput(dentry); |
@@ -2239,7 +2231,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, | |||
2239 | *p++ = cpu_to_be32(MINOR(stat.dev)); | 2231 | *p++ = cpu_to_be32(MINOR(stat.dev)); |
2240 | break; | 2232 | break; |
2241 | case FSIDSOURCE_UUID: | 2233 | case FSIDSOURCE_UUID: |
2242 | WRITEMEM(exp->ex_uuid, 16); | 2234 | p = xdr_encode_opaque_fixed(p, exp->ex_uuid, 16); |
2243 | break; | 2235 | break; |
2244 | } | 2236 | } |
2245 | } | 2237 | } |
@@ -2326,8 +2318,8 @@ out_acl: | |||
2326 | p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4); | 2318 | p = xdr_reserve_space(xdr, fhp->fh_handle.fh_size + 4); |
2327 | if (!p) | 2319 | if (!p) |
2328 | goto out_resource; | 2320 | goto out_resource; |
2329 | *p++ = cpu_to_be32(fhp->fh_handle.fh_size); | 2321 | p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base, |
2330 | WRITEMEM(&fhp->fh_handle.fh_base, fhp->fh_handle.fh_size); | 2322 | fhp->fh_handle.fh_size); |
2331 | } | 2323 | } |
2332 | if (bmval0 & FATTR4_WORD0_FILEID) { | 2324 | if (bmval0 & FATTR4_WORD0_FILEID) { |
2333 | p = xdr_reserve_space(xdr, 8); | 2325 | p = xdr_reserve_space(xdr, 8); |
@@ -2748,7 +2740,8 @@ nfsd4_encode_stateid(struct xdr_stream *xdr, stateid_t *sid) | |||
2748 | if (!p) | 2740 | if (!p) |
2749 | return nfserr_resource; | 2741 | return nfserr_resource; |
2750 | *p++ = cpu_to_be32(sid->si_generation); | 2742 | *p++ = cpu_to_be32(sid->si_generation); |
2751 | WRITEMEM(&sid->si_opaque, sizeof(stateid_opaque_t)); | 2743 | p = xdr_encode_opaque_fixed(p, &sid->si_opaque, |
2744 | sizeof(stateid_opaque_t)); | ||
2752 | return 0; | 2745 | return 0; |
2753 | } | 2746 | } |
2754 | 2747 | ||
@@ -2777,7 +2770,8 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, | |||
2777 | p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8); | 2770 | p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8); |
2778 | if (!p) | 2771 | if (!p) |
2779 | return nfserr_resource; | 2772 | return nfserr_resource; |
2780 | WRITEMEM(bcts->sessionid.data, NFS4_MAX_SESSIONID_LEN); | 2773 | p = xdr_encode_opaque_fixed(p, bcts->sessionid.data, |
2774 | NFS4_MAX_SESSIONID_LEN); | ||
2781 | *p++ = cpu_to_be32(bcts->dir); | 2775 | *p++ = cpu_to_be32(bcts->dir); |
2782 | /* Sorry, we do not yet support RDMA over 4.1: */ | 2776 | /* Sorry, we do not yet support RDMA over 4.1: */ |
2783 | *p++ = cpu_to_be32(0); | 2777 | *p++ = cpu_to_be32(0); |
@@ -2807,7 +2801,8 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ | |||
2807 | p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); | 2801 | p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); |
2808 | if (!p) | 2802 | if (!p) |
2809 | return nfserr_resource; | 2803 | return nfserr_resource; |
2810 | WRITEMEM(commit->co_verf.data, NFS4_VERIFIER_SIZE); | 2804 | p = xdr_encode_opaque_fixed(p, commit->co_verf.data, |
2805 | NFS4_VERIFIER_SIZE); | ||
2811 | } | 2806 | } |
2812 | return nfserr; | 2807 | return nfserr; |
2813 | } | 2808 | } |
@@ -2858,8 +2853,7 @@ nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh | |||
2858 | p = xdr_reserve_space(xdr, len + 4); | 2853 | p = xdr_reserve_space(xdr, len + 4); |
2859 | if (!p) | 2854 | if (!p) |
2860 | return nfserr_resource; | 2855 | return nfserr_resource; |
2861 | *p++ = cpu_to_be32(len); | 2856 | p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base, len); |
2862 | WRITEMEM(&fhp->fh_handle.fh_base, len); | ||
2863 | } | 2857 | } |
2864 | return nfserr; | 2858 | return nfserr; |
2865 | } | 2859 | } |
@@ -2892,9 +2886,8 @@ again: | |||
2892 | p = xdr_encode_hyper(p, ld->ld_length); | 2886 | p = xdr_encode_hyper(p, ld->ld_length); |
2893 | *p++ = cpu_to_be32(ld->ld_type); | 2887 | *p++ = cpu_to_be32(ld->ld_type); |
2894 | if (conf->len) { | 2888 | if (conf->len) { |
2895 | WRITEMEM(&ld->ld_clientid, 8); | 2889 | p = xdr_encode_opaque_fixed(p, &ld->ld_clientid, 8); |
2896 | *p++ = cpu_to_be32(conf->len); | 2890 | p = xdr_encode_opaque(p, conf->data, conf->len); |
2897 | WRITEMEM(conf->data, conf->len); | ||
2898 | } else { /* non - nfsv4 lock in conflict, no clientid nor owner */ | 2891 | } else { /* non - nfsv4 lock in conflict, no clientid nor owner */ |
2899 | p = xdr_encode_hyper(p, (u64)0); /* clientid */ | 2892 | p = xdr_encode_hyper(p, (u64)0); /* clientid */ |
2900 | *p++ = cpu_to_be32(0); /* length of owner name */ | 2893 | *p++ = cpu_to_be32(0); /* length of owner name */ |
@@ -3459,8 +3452,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, | |||
3459 | if (!p) | 3452 | if (!p) |
3460 | goto out; | 3453 | goto out; |
3461 | *p++ = cpu_to_be32(RPC_AUTH_GSS); | 3454 | *p++ = cpu_to_be32(RPC_AUTH_GSS); |
3462 | *p++ = cpu_to_be32(info.oid.len); | 3455 | p = xdr_encode_opaque(p, info.oid.data, info.oid.len); |
3463 | WRITEMEM(info.oid.data, info.oid.len); | ||
3464 | *p++ = cpu_to_be32(info.qop); | 3456 | *p++ = cpu_to_be32(info.qop); |
3465 | *p++ = cpu_to_be32(info.service); | 3457 | *p++ = cpu_to_be32(info.service); |
3466 | } else if (pf < RPC_AUTH_MAXFLAVOR) { | 3458 | } else if (pf < RPC_AUTH_MAXFLAVOR) { |
@@ -3542,8 +3534,9 @@ nfsd4_encode_setclientid(struct nfsd4_compoundres *resp, __be32 nfserr, struct n | |||
3542 | p = xdr_reserve_space(xdr, 8 + NFS4_VERIFIER_SIZE); | 3534 | p = xdr_reserve_space(xdr, 8 + NFS4_VERIFIER_SIZE); |
3543 | if (!p) | 3535 | if (!p) |
3544 | return nfserr_resource; | 3536 | return nfserr_resource; |
3545 | WRITEMEM(&scd->se_clientid, 8); | 3537 | p = xdr_encode_opaque_fixed(p, &scd->se_clientid, 8); |
3546 | WRITEMEM(&scd->se_confirm, NFS4_VERIFIER_SIZE); | 3538 | p = xdr_encode_opaque_fixed(p, &scd->se_confirm, |
3539 | NFS4_VERIFIER_SIZE); | ||
3547 | } | 3540 | } |
3548 | else if (nfserr == nfserr_clid_inuse) { | 3541 | else if (nfserr == nfserr_clid_inuse) { |
3549 | p = xdr_reserve_space(xdr, 8); | 3542 | p = xdr_reserve_space(xdr, 8); |
@@ -3567,7 +3560,8 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w | |||
3567 | return nfserr_resource; | 3560 | return nfserr_resource; |
3568 | *p++ = cpu_to_be32(write->wr_bytes_written); | 3561 | *p++ = cpu_to_be32(write->wr_bytes_written); |
3569 | *p++ = cpu_to_be32(write->wr_how_written); | 3562 | *p++ = cpu_to_be32(write->wr_how_written); |
3570 | WRITEMEM(write->wr_verifier.data, NFS4_VERIFIER_SIZE); | 3563 | p = xdr_encode_opaque_fixed(p, write->wr_verifier.data, |
3564 | NFS4_VERIFIER_SIZE); | ||
3571 | } | 3565 | } |
3572 | return nfserr; | 3566 | return nfserr; |
3573 | } | 3567 | } |
@@ -3608,7 +3602,7 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3608 | if (!p) | 3602 | if (!p) |
3609 | return nfserr_resource; | 3603 | return nfserr_resource; |
3610 | 3604 | ||
3611 | WRITEMEM(&exid->clientid, 8); | 3605 | p = xdr_encode_opaque_fixed(p, &exid->clientid, 8); |
3612 | *p++ = cpu_to_be32(exid->seqid); | 3606 | *p++ = cpu_to_be32(exid->seqid); |
3613 | *p++ = cpu_to_be32(exid->flags); | 3607 | *p++ = cpu_to_be32(exid->flags); |
3614 | 3608 | ||
@@ -3648,12 +3642,10 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3648 | /* The server_owner struct */ | 3642 | /* The server_owner struct */ |
3649 | p = xdr_encode_hyper(p, minor_id); /* Minor id */ | 3643 | p = xdr_encode_hyper(p, minor_id); /* Minor id */ |
3650 | /* major id */ | 3644 | /* major id */ |
3651 | *p++ = cpu_to_be32(major_id_sz); | 3645 | p = xdr_encode_opaque(p, major_id, major_id_sz); |
3652 | WRITEMEM(major_id, major_id_sz); | ||
3653 | 3646 | ||
3654 | /* Server scope */ | 3647 | /* Server scope */ |
3655 | *p++ = cpu_to_be32(server_scope_sz); | 3648 | p = xdr_encode_opaque(p, server_scope, server_scope_sz); |
3656 | WRITEMEM(server_scope, server_scope_sz); | ||
3657 | 3649 | ||
3658 | /* Implementation id */ | 3650 | /* Implementation id */ |
3659 | *p++ = cpu_to_be32(0); /* zero length nfs_impl_id4 array */ | 3651 | *p++ = cpu_to_be32(0); /* zero length nfs_impl_id4 array */ |
@@ -3673,7 +3665,8 @@ nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3673 | p = xdr_reserve_space(xdr, 24); | 3665 | p = xdr_reserve_space(xdr, 24); |
3674 | if (!p) | 3666 | if (!p) |
3675 | return nfserr_resource; | 3667 | return nfserr_resource; |
3676 | WRITEMEM(sess->sessionid.data, NFS4_MAX_SESSIONID_LEN); | 3668 | p = xdr_encode_opaque_fixed(p, sess->sessionid.data, |
3669 | NFS4_MAX_SESSIONID_LEN); | ||
3677 | *p++ = cpu_to_be32(sess->seqid); | 3670 | *p++ = cpu_to_be32(sess->seqid); |
3678 | *p++ = cpu_to_be32(sess->flags); | 3671 | *p++ = cpu_to_be32(sess->flags); |
3679 | 3672 | ||
@@ -3728,7 +3721,8 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
3728 | p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 20); | 3721 | p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 20); |
3729 | if (!p) | 3722 | if (!p) |
3730 | return nfserr_resource; | 3723 | return nfserr_resource; |
3731 | WRITEMEM(seq->sessionid.data, NFS4_MAX_SESSIONID_LEN); | 3724 | p = xdr_encode_opaque_fixed(p, seq->sessionid.data, |
3725 | NFS4_MAX_SESSIONID_LEN); | ||
3732 | *p++ = cpu_to_be32(seq->seqid); | 3726 | *p++ = cpu_to_be32(seq->seqid); |
3733 | *p++ = cpu_to_be32(seq->slotid); | 3727 | *p++ = cpu_to_be32(seq->slotid); |
3734 | /* Note slotid's are numbered from zero: */ | 3728 | /* Note slotid's are numbered from zero: */ |
@@ -3957,7 +3951,7 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op) | |||
3957 | *p++ = cpu_to_be32(op->opnum); | 3951 | *p++ = cpu_to_be32(op->opnum); |
3958 | *p++ = rp->rp_status; /* already xdr'ed */ | 3952 | *p++ = rp->rp_status; /* already xdr'ed */ |
3959 | 3953 | ||
3960 | WRITEMEM(rp->rp_buf, rp->rp_buflen); | 3954 | p = xdr_encode_opaque_fixed(p, rp->rp_buf, rp->rp_buflen); |
3961 | } | 3955 | } |
3962 | 3956 | ||
3963 | int | 3957 | int |