fs/nfs/nfs4proc.c | 54 ----- fs/nfs/nfs4xdr.c | 505 ++++++++---------------------------------------- include/linux/nfs_xdr.h | 44 +--- 3 files changed, 117 insertions(+), 486 deletions(-) diff -u --recursive --new-file --show-c-function linux-2.6.5-27-decompoundify_readdir/fs/nfs/nfs4proc.c linux-2.6.5-28-decompoundify_cleanup/fs/nfs/nfs4proc.c --- linux-2.6.5-27-decompoundify_readdir/fs/nfs/nfs4proc.c 2004-03-24 00:49:12.000000000 -0500 +++ linux-2.6.5-28-decompoundify_cleanup/fs/nfs/nfs4proc.c 2004-03-24 00:49:24.000000000 -0500 @@ -169,19 +169,6 @@ renew_lease(struct nfs_server *server, u spin_unlock(&clp->cl_lock); } -static inline void -process_cinfo(struct nfs4_change_info *info, struct nfs_fattr *fattr) -{ - BUG_ON((fattr->valid & NFS_ATTR_FATTR) == 0); - BUG_ON((fattr->valid & NFS_ATTR_FATTR_V4) == 0); - - if (fattr->change_attr == info->after) { - fattr->pre_change_attr = info->before; - fattr->valid |= NFS_ATTR_PRE_CHANGE; - fattr->timestamp = jiffies; - } -} - static void update_changeattr(struct inode *inode, struct nfs4_change_info *cinfo) { struct nfs_inode *nfsi = NFS_I(inode); @@ -203,12 +190,6 @@ nfs4_open_reclaim(struct nfs4_state_owne struct nfs_fattr fattr = { .valid = 0, }; - struct nfs4_change_info d_cinfo; - struct nfs4_getattr f_getattr = { - .gt_bmval = nfs4_fattr_bitmap, - .gt_attrs = &fattr, - }; - struct nfs_open_reclaimargs o_arg = { .fh = NFS_FH(inode), .seqid = sp->so_seqid, @@ -216,11 +197,10 @@ nfs4_open_reclaim(struct nfs4_state_owne .share_access = state->state, .clientid = server->nfs4_state->cl_clientid, .claim = NFS4_OPEN_CLAIM_PREVIOUS, - .f_getattr = &f_getattr, + .bitmask = nfs4_fattr_bitmap, }; struct nfs_openres o_res = { - .cinfo = &d_cinfo, - .f_getattr = &f_getattr, + .f_attr = &fattr, .server = server, /* Grrr */ }; struct rpc_message msg = { @@ -250,36 +230,21 @@ nfs4_do_open(struct inode *dir, struct q struct nfs4_state *state = NULL; struct nfs_server *server = NFS_SERVER(dir); struct inode *inode = NULL; - struct nfs4_change_info d_cinfo; int status; - struct nfs_fattr d_attr = { - .valid = 0, - }; struct nfs_fattr f_attr = { .valid = 0, }; - struct nfs4_getattr f_getattr = { - .gt_bmval = nfs4_fattr_bitmap, - .gt_attrs = &f_attr, - }; - struct nfs4_getattr d_getattr = { - .gt_bmval = nfs4_fattr_bitmap, - .gt_attrs = &d_attr, - }; struct nfs_openargs o_arg = { .fh = NFS_FH(dir), .share_access = flags & (FMODE_READ|FMODE_WRITE), .opentype = (flags & O_CREAT) ? NFS4_OPEN_CREATE : NFS4_OPEN_NOCREATE, .createmode = (flags & O_EXCL) ? NFS4_CREATE_EXCLUSIVE : NFS4_CREATE_UNCHECKED, .name = name, - .f_getattr = &f_getattr, - .d_getattr = &d_getattr, .server = server, + .bitmask = nfs4_fattr_bitmap, }; struct nfs_openres o_res = { - .cinfo = &d_cinfo, - .f_getattr = &f_getattr, - .d_getattr = &d_getattr, + .f_attr = &f_attr, .server = server, }; struct rpc_message msg = { @@ -312,8 +277,7 @@ retry: nfs4_increment_seqid(status, sp); if (status) goto out_up; - process_cinfo(&d_cinfo, &d_attr); - nfs_refresh_inode(dir, &d_attr); + update_changeattr(dir, &o_res.cinfo); status = -ENOMEM; inode = nfs_fhget(dir->i_sb, &o_res.fh, &f_attr); @@ -395,18 +359,14 @@ nfs4_do_setattr(struct nfs_server *serve struct nfs_fh *fhandle, struct iattr *sattr, struct nfs4_state *state) { - struct nfs4_getattr getattr = { - .gt_bmval = nfs4_fattr_bitmap, - .gt_attrs = fattr, - }; struct nfs_setattrargs arg = { .fh = fhandle, .iap = sattr, - .attr = &getattr, .server = server, + .bitmask = nfs4_fattr_bitmap, }; struct nfs_setattrres res = { - .attr = &getattr, + .fattr = fattr, .server = server, }; struct rpc_message msg = { diff -u --recursive --new-file --show-c-function linux-2.6.5-27-decompoundify_readdir/fs/nfs/nfs4xdr.c linux-2.6.5-28-decompoundify_cleanup/fs/nfs/nfs4xdr.c --- linux-2.6.5-27-decompoundify_readdir/fs/nfs/nfs4xdr.c 2004-03-24 00:49:12.000000000 -0500 +++ linux-2.6.5-28-decompoundify_cleanup/fs/nfs/nfs4xdr.c 2004-03-24 00:49:24.000000000 -0500 @@ -89,8 +89,6 @@ static int nfs_stat_to_errno(int); nfs4_fattr_bitmap_maxsz) #define encode_savefh_maxsz (op_encode_hdr_maxsz) #define decode_savefh_maxsz (op_decode_hdr_maxsz) -#define encode_restorefh_maxsz (op_encode_hdr_maxsz) -#define decode_restorefh_maxsz (op_decode_hdr_maxsz) #define encode_fsinfo_maxsz (op_encode_hdr_maxsz + 2) #define decode_fsinfo_maxsz (op_decode_hdr_maxsz + 11) #define encode_renew_maxsz (op_encode_hdr_maxsz + 3) @@ -158,21 +156,15 @@ static int nfs_stat_to_errno(int); op_decode_hdr_maxsz + 2) #define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ - encode_savefh_maxsz + \ op_encode_hdr_maxsz + \ 13 + 3 + 2 + 64 + \ encode_getattr_maxsz + \ - encode_getfh_maxsz + \ - encode_restorefh_maxsz + \ - encode_getattr_maxsz) + encode_getfh_maxsz) #define NFS4_dec_open_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ - decode_savefh_maxsz + \ op_decode_hdr_maxsz + 4 + 5 + 2 + 3 + \ decode_getattr_maxsz + \ - decode_getfh_maxsz + \ - decode_restorefh_maxsz + \ - decode_getattr_maxsz) + decode_getfh_maxsz) #define NFS4_enc_open_confirm_sz \ (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ @@ -344,8 +336,6 @@ static int nfs_stat_to_errno(int); decode_putfh_maxsz + \ op_decode_hdr_maxsz + 12) - - static struct { unsigned int mode; unsigned int nfs2type; @@ -394,8 +384,7 @@ struct compound_hdr { BUG_ON(!p); \ } while (0) -static int -encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) +static int encode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) { uint32_t *p; @@ -547,8 +536,7 @@ static int encode_access(struct xdr_stre return 0; } -static int -encode_close(struct xdr_stream *xdr, struct nfs_closeargs *arg) +static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg) { uint32_t *p; @@ -560,8 +548,7 @@ encode_close(struct xdr_stream *xdr, str return 0; } -static int -encode_commit(struct xdr_stream *xdr, struct nfs_writeargs *args) +static int encode_commit(struct xdr_stream *xdr, const struct nfs_writeargs *args) { uint32_t *p; @@ -605,8 +592,7 @@ static int encode_create(struct xdr_stre return encode_attrs(xdr, create->attrs, create->server); } -static int -encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap) +static int encode_getattr_one(struct xdr_stream *xdr, uint32_t bitmap) { uint32_t *p; @@ -617,8 +603,7 @@ encode_getattr_one(struct xdr_stream *xd return 0; } -static int -encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1) +static int encode_getattr_two(struct xdr_stream *xdr, uint32_t bm0, uint32_t bm1) { uint32_t *p; @@ -639,15 +624,7 @@ static int encode_getfattr(struct xdr_st bitmask[1] & nfs4_fattr_bitmap[1]); } -static inline int -encode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr) -{ - return encode_getattr_two(xdr, getattr->gt_bmval[0], - getattr->gt_bmval[1]); -} - -static int -encode_fsinfo(struct xdr_stream *xdr) +static int encode_fsinfo(struct xdr_stream *xdr) { return encode_getattr_one(xdr, FATTR4_WORD0_MAXFILESIZE | FATTR4_WORD0_MAXREAD @@ -655,8 +632,7 @@ encode_fsinfo(struct xdr_stream *xdr) | FATTR4_WORD0_LEASE_TIME); } -static int -encode_getfh(struct xdr_stream *xdr) +static int encode_getfh(struct xdr_stream *xdr) { uint32_t *p; @@ -682,8 +658,7 @@ static int encode_link(struct xdr_stream * opcode,type,reclaim,offset,length,new_lock_owner = 32 * open_seqid,open_stateid,lock_seqid,lock_owner.clientid, lock_owner.id = 40 */ -static int -encode_lock(struct xdr_stream *xdr, struct nfs_lockargs *arg) +static int encode_lock(struct xdr_stream *xdr, const struct nfs_lockargs *arg) { uint32_t *p; struct nfs_lock_opargs *opargs = arg->u.lock; @@ -717,8 +692,7 @@ encode_lock(struct xdr_stream *xdr, stru return 0; } -static int -encode_lockt(struct xdr_stream *xdr, struct nfs_lockargs *arg) +static int encode_lockt(struct xdr_stream *xdr, const struct nfs_lockargs *arg) { uint32_t *p; struct nfs_lowner *opargs = arg->u.lockt; @@ -735,8 +709,7 @@ encode_lockt(struct xdr_stream *xdr, str return 0; } -static int -encode_locku(struct xdr_stream *xdr, struct nfs_lockargs *arg) +static int encode_locku(struct xdr_stream *xdr, const struct nfs_lockargs *arg) { uint32_t *p; struct nfs_locku_opargs *opargs = arg->u.locku; @@ -765,8 +738,7 @@ static int encode_lookup(struct xdr_stre return 0; } -static int -encode_open(struct xdr_stream *xdr, struct nfs_openargs *arg) +static int encode_open(struct xdr_stream *xdr, const struct nfs_openargs *arg) { int status; uint32_t *p; @@ -825,8 +797,7 @@ encode_open(struct xdr_stream *xdr, stru return 0; } -static int -encode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmargs *arg) +static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_confirmargs *arg) { uint32_t *p; @@ -839,8 +810,7 @@ encode_open_confirm(struct xdr_stream *x } -static int -encode_open_reclaim(struct xdr_stream *xdr, struct nfs_open_reclaimargs *arg) +static int encode_open_reclaim(struct xdr_stream *xdr, const struct nfs_open_reclaimargs *arg) { uint32_t *p; @@ -874,8 +844,7 @@ encode_open_reclaim(struct xdr_stream *x return 0; } -static int -encode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeargs *arg) +static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closeargs *arg) { uint32_t *p; @@ -904,8 +873,7 @@ encode_putfh(struct xdr_stream *xdr, con return 0; } -static int -encode_putrootfh(struct xdr_stream *xdr) +static int encode_putrootfh(struct xdr_stream *xdr) { uint32_t *p; @@ -915,8 +883,7 @@ encode_putrootfh(struct xdr_stream *xdr) return 0; } -static void -encode_stateid(struct xdr_stream *xdr, struct nfs4_state *state, fl_owner_t lockowner) +static void encode_stateid(struct xdr_stream *xdr, struct nfs4_state *state, fl_owner_t lockowner) { extern nfs4_stateid zero_stateid; nfs4_stateid stateid; @@ -930,8 +897,7 @@ encode_stateid(struct xdr_stream *xdr, s WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data)); } -static int -encode_read(struct xdr_stream *xdr, struct nfs_readargs *args) +static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args) { uint32_t *p; @@ -1021,8 +987,7 @@ static int encode_rename(struct xdr_stre return 0; } -static int -encode_renew(struct xdr_stream *xdr, struct nfs4_client *client_stateid) +static int encode_renew(struct xdr_stream *xdr, const struct nfs4_client *client_stateid) { uint32_t *p; @@ -1034,17 +999,6 @@ encode_renew(struct xdr_stream *xdr, str } static int -encode_restorefh(struct xdr_stream *xdr) -{ - uint32_t *p; - - RESERVE_SPACE(4); - WRITE32(OP_RESTOREFH); - - return 0; -} - -static int encode_savefh(struct xdr_stream *xdr) { uint32_t *p; @@ -1055,9 +1009,7 @@ encode_savefh(struct xdr_stream *xdr) return 0; } -static int -encode_setattr(struct xdr_stream *xdr, struct nfs_setattrargs *arg, - struct nfs_server *server) +static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *arg, const struct nfs_server *server) { int status; uint32_t *p; @@ -1072,8 +1024,7 @@ encode_setattr(struct xdr_stream *xdr, s return 0; } -static int -encode_setclientid(struct xdr_stream *xdr, struct nfs4_setclientid *setclientid) +static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclientid *setclientid) { uint32_t total_len; uint32_t len1, len2, len3; @@ -1100,8 +1051,7 @@ encode_setclientid(struct xdr_stream *xd return 0; } -static int -encode_setclientid_confirm(struct xdr_stream *xdr, struct nfs4_client *client_state) +static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs4_client *client_state) { uint32_t *p; @@ -1113,8 +1063,7 @@ encode_setclientid_confirm(struct xdr_st return 0; } -static int -encode_write(struct xdr_stream *xdr, struct nfs_writeargs *args) +static int encode_write(struct xdr_stream *xdr, const struct nfs_writeargs *args) { uint32_t *p; @@ -1310,8 +1259,7 @@ static int nfs4_xdr_enc_getattr(struct r /* * Encode a CLOSE request */ -static int -nfs4_xdr_enc_close(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args) +static int nfs4_xdr_enc_close(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1332,12 +1280,11 @@ out: /* * Encode an OPEN request */ -static int -nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_openargs *args) +static int nfs4_xdr_enc_open(struct rpc_rqst *req, uint32_t *p, struct nfs_openargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { - .nops = 7, + .nops = 4, }; int status; @@ -1346,22 +1293,13 @@ nfs4_xdr_enc_open(struct rpc_rqst *req, status = encode_putfh(&xdr, args->fh); if (status) goto out; - status = encode_savefh(&xdr); - if (status) - goto out; status = encode_open(&xdr, args); if (status) goto out; - status = encode_getattr(&xdr, args->f_getattr); + status = encode_getfattr(&xdr, args->bitmask); if (status) goto out; status = encode_getfh(&xdr); - if (status) - goto out; - status = encode_restorefh(&xdr); - if (status) - goto out; - status = encode_getattr(&xdr, args->d_getattr); out: return status; } @@ -1369,8 +1307,7 @@ out: /* * Encode an OPEN_CONFIRM request */ -static int -nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_open_confirmargs *args) +static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_open_confirmargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1391,9 +1328,7 @@ out: /* * Encode an OPEN request */ -static int -nfs4_xdr_enc_open_reclaim(struct rpc_rqst *req, uint32_t *p, - struct nfs_open_reclaimargs *args) +static int nfs4_xdr_enc_open_reclaim(struct rpc_rqst *req, uint32_t *p, struct nfs_open_reclaimargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1409,7 +1344,7 @@ nfs4_xdr_enc_open_reclaim(struct rpc_rqs status = encode_open_reclaim(&xdr, args); if (status) goto out; - status = encode_getattr(&xdr, args->f_getattr); + status = encode_getfattr(&xdr, args->bitmask); out: return status; } @@ -1417,8 +1352,7 @@ out: /* * Encode an OPEN_DOWNGRADE request */ -static int -nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args) +static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, uint32_t *p, struct nfs_closeargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1439,8 +1373,7 @@ out: /* * Encode a LOCK request */ -static int -nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) +static int nfs4_xdr_enc_lock(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1461,8 +1394,7 @@ out: /* * Encode a LOCKT request */ -static int -nfs4_xdr_enc_lockt(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) +static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1483,8 +1415,7 @@ out: /* * Encode a LOCKU request */ -static int -nfs4_xdr_enc_locku(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) +static int nfs4_xdr_enc_locku(struct rpc_rqst *req, uint32_t *p, struct nfs_lockargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1547,8 +1478,7 @@ out: /* * Encode a READ request */ -static int -nfs4_xdr_enc_read(struct rpc_rqst *req, uint32_t *p, struct nfs_readargs *args) +static int nfs4_xdr_enc_read(struct rpc_rqst *req, uint32_t *p, struct nfs_readargs *args) { struct rpc_auth *auth = req->rq_task->tk_auth; struct xdr_stream xdr; @@ -1580,8 +1510,7 @@ out: /* * Encode an SETATTR request */ -static int -nfs4_xdr_enc_setattr(struct rpc_rqst *req, uint32_t *p, struct nfs_setattrargs *args) +static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, uint32_t *p, struct nfs_setattrargs *args) { struct xdr_stream xdr; @@ -1598,7 +1527,7 @@ nfs4_xdr_enc_setattr(struct rpc_rqst *re status = encode_setattr(&xdr, args, args->server); if(status) goto out; - status = encode_getattr(&xdr, args->attr); + status = encode_getfattr(&xdr, args->bitmask); out: return status; } @@ -1606,8 +1535,7 @@ out: /* * Encode a WRITE request */ -static int -nfs4_xdr_enc_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args) +static int nfs4_xdr_enc_write(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1628,8 +1556,7 @@ out: /* * a COMMIT request */ -static int -nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args) +static int nfs4_xdr_enc_commit(struct rpc_rqst *req, uint32_t *p, struct nfs_writeargs *args) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1650,8 +1577,7 @@ out: /* * FSINFO request */ -static int -nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, uint32_t *p, void *fhandle) +static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, uint32_t *p, void *fhandle) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1713,8 +1639,7 @@ static int nfs4_xdr_enc_statfs(struct rp /* * a RENEW request */ -static int -nfs4_xdr_enc_renew(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp) +static int nfs4_xdr_enc_renew(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1729,9 +1654,7 @@ nfs4_xdr_enc_renew(struct rpc_rqst *req, /* * a SETCLIENTID request */ -static int -nfs4_xdr_enc_setclientid(struct rpc_rqst *req, uint32_t *p, - struct nfs4_setclientid *sc) +static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, uint32_t *p, struct nfs4_setclientid *sc) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1746,9 +1669,7 @@ nfs4_xdr_enc_setclientid(struct rpc_rqst /* * a SETCLIENTID_CONFIRM request */ -static int -nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, - struct nfs4_client *clp) +static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp) { struct xdr_stream xdr; struct compound_hdr hdr = { @@ -1776,15 +1697,6 @@ nfs4_xdr_enc_setclientid_confirm(struct * task to translate them into Linux-specific versions which are more * consistent with the style used in NFSv2/v3... */ -#define DECODE_TAIL \ - status = 0; \ -out: \ - return status; \ -xdr_error: \ - printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); \ - status = -EIO; \ - goto out - #define READ32(x) (x) = ntohl(*p++) #define READ64(x) do { \ (x) = (u64)ntohl(*p++) << 32; \ @@ -1809,8 +1721,7 @@ xdr_error: \ } \ } while (0) -static int -decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) +static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) { uint32_t *p; @@ -1825,8 +1736,7 @@ decode_compound_hdr(struct xdr_stream *x return 0; } -static int -decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) +static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) { uint32_t *p; uint32_t opnum; @@ -2301,8 +2211,7 @@ static int verify_attr_len(struct xdr_st return 0; } -static int -decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) +static int decode_change_info(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) { uint32_t *p; @@ -2330,8 +2239,7 @@ static int decode_access(struct xdr_stre return 0; } -static int -decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) +static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res) { uint32_t *p; int status; @@ -2344,8 +2252,7 @@ decode_close(struct xdr_stream *xdr, str return 0; } -static int -decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) +static int decode_commit(struct xdr_stream *xdr, struct nfs_writeres *res) { uint32_t *p; int status; @@ -2375,184 +2282,6 @@ static int decode_create(struct xdr_stre return 0; } -static int -decode_getattr(struct xdr_stream *xdr, struct nfs4_getattr *getattr, - struct nfs_server *server) -{ - struct nfs_fattr *nfp = getattr->gt_attrs; - uint32_t attrlen, dummy32, bmlen, - bmval0 = 0, - bmval1 = 0, - len = 0; - uint32_t *p; - unsigned int type; - int fmode = 0; - int status; - - status = decode_op_hdr(xdr, OP_GETATTR); - if (status) - return status; - - READ_BUF(4); - READ32(bmlen); - if (bmlen > 2) - goto xdr_error; - - READ_BUF((bmlen << 2) + 4); - if (bmlen > 0) - READ32(bmval0); - if (bmlen > 1) - READ32(bmval1); - READ32(attrlen); - - if ((bmval0 & ~getattr->gt_bmval[0]) || - (bmval1 & ~getattr->gt_bmval[1])) { - dprintk("read_attrs: server returned bad attributes!\n"); - goto xdr_error; - } - if (nfp) { - nfp->bitmap[0] = bmval0; - nfp->bitmap[1] = bmval1; - } - - /* - * In case the server doesn't return some attributes, - * we initialize them here to some nominal values.. - */ - if (nfp) { - nfp->valid = NFS_ATTR_FATTR | NFS_ATTR_FATTR_V3 | NFS_ATTR_FATTR_V4; - nfp->nlink = 1; - nfp->timestamp = jiffies; - } - if (bmval0 & FATTR4_WORD0_TYPE) { - READ_BUF(4); - len += 4; - READ32(type); - if (type < NF4REG || type > NF4NAMEDATTR) { - dprintk("read_attrs: bad type %d\n", type); - goto xdr_error; - } - nfp->type = nfs_type2fmt[type].nfs2type; - fmode = nfs_type2fmt[type].mode; - dprintk("read_attrs: type=%d\n", (uint32_t)nfp->type); - } - if (bmval0 & FATTR4_WORD0_CHANGE) { - READ_BUF(8); - len += 8; - READ64(nfp->change_attr); - dprintk("read_attrs: changeid=%Ld\n", (long long)nfp->change_attr); - } - if (bmval0 & FATTR4_WORD0_SIZE) { - READ_BUF(8); - len += 8; - READ64(nfp->size); - dprintk("read_attrs: size=%Ld\n", (long long)nfp->size); - } - if (bmval0 & FATTR4_WORD0_FSID) { - READ_BUF(16); - len += 16; - READ64(nfp->fsid_u.nfs4.major); - READ64(nfp->fsid_u.nfs4.minor); - dprintk("read_attrs: fsid=0x%Lx/0x%Lx\n", - (long long)nfp->fsid_u.nfs4.major, - (long long)nfp->fsid_u.nfs4.minor); - } - if (bmval0 & FATTR4_WORD0_FILEID) { - READ_BUF(8); - len += 8; - READ64(nfp->fileid); - dprintk("read_attrs: fileid=%Ld\n", (long long) nfp->fileid); - } - - if (bmval1 & FATTR4_WORD1_MODE) { - READ_BUF(4); - len += 4; - READ32(dummy32); - nfp->mode = (dummy32 & ~S_IFMT) | fmode; - dprintk("read_attrs: mode=0%o\n", nfp->mode); - } - if (bmval1 & FATTR4_WORD1_NUMLINKS) { - READ_BUF(4); - len += 4; - READ32(nfp->nlink); - dprintk("read_attrs: nlinks=0%o\n", nfp->nlink); - } - if (bmval1 & FATTR4_WORD1_OWNER) { - READ_BUF(4); - len += 4; - READ32(dummy32); /* name length */ - if (dummy32 > XDR_MAX_NETOBJ) { - dprintk("read_attrs: name too long!\n"); - goto xdr_error; - } - READ_BUF(dummy32); - len += (XDR_QUADLEN(dummy32) << 2); - if ((status = nfs_map_name_to_uid(server->nfs4_state, (char *)p, dummy32, - &nfp->uid)) < 0) { - dprintk("read_attrs: name-to-uid mapping failed!\n"); - nfp->uid = -2; - } - dprintk("read_attrs: uid=%d\n", (int)nfp->uid); - } - if (bmval1 & FATTR4_WORD1_OWNER_GROUP) { - READ_BUF(4); - len += 4; - READ32(dummy32); - if (dummy32 > XDR_MAX_NETOBJ) { - dprintk("read_attrs: name too long!\n"); - goto xdr_error; - } - READ_BUF(dummy32); - len += (XDR_QUADLEN(dummy32) << 2); - if ((status = nfs_map_group_to_gid(server->nfs4_state, (char *)p, dummy32, - &nfp->gid)) < 0) { - dprintk("read_attrs: group-to-gid mapping failed!\n"); - nfp->gid = -2; - } - dprintk("read_attrs: gid=%d\n", (int)nfp->gid); - } - if (bmval1 & FATTR4_WORD1_RAWDEV) { - uint32_t major, minor; - - READ_BUF(8); - len += 8; - READ32(major); - READ32(minor); - nfp->rdev = MKDEV(major, minor); - if (MAJOR(nfp->rdev) != major || MINOR(nfp->rdev) != minor) - nfp->rdev = 0; - dprintk("read_attrs: rdev=%u:%u\n", major, minor); - } - if (bmval1 & FATTR4_WORD1_SPACE_USED) { - READ_BUF(8); - len += 8; - READ64(nfp->du.nfs3.used); - dprintk("read_attrs: sused=0x%Lx\n", (long long) nfp->du.nfs3.used); - } - if (bmval1 & FATTR4_WORD1_TIME_ACCESS) { - READ_BUF(12); - len += 12; - READTIME(nfp->atime); - dprintk("read_attrs: atime=%ld\n", (long)nfp->atime.tv_sec); - } - if (bmval1 & FATTR4_WORD1_TIME_METADATA) { - READ_BUF(12); - len += 12; - READTIME(nfp->ctime); - dprintk("read_attrs: ctime=%ld\n", (long)nfp->ctime.tv_sec); - } - if (bmval1 & FATTR4_WORD1_TIME_MODIFY) { - READ_BUF(12); - len += 12; - READTIME(nfp->mtime); - dprintk("read_attrs: mtime=%ld\n", (long)nfp->mtime.tv_sec); - } - if (len != attrlen) - goto xdr_error; - - DECODE_TAIL; -} - static int decode_statfs(struct xdr_stream *xdr, struct nfs_fsstat *fsstat) { uint32_t *savep; @@ -2676,8 +2405,7 @@ xdr_error: } -static int -decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) +static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo) { uint32_t *p; uint32_t len, attrlen, bmlen, bmval0 = 0, bmval1 = 0; @@ -2779,8 +2507,7 @@ static int decode_link(struct xdr_stream /* * We create the owner, so we know a proper owner.id length is 4. */ -static int -decode_lock_denied (struct xdr_stream *xdr, struct nfs_lock_denied *denied) +static int decode_lock_denied (struct xdr_stream *xdr, struct nfs_lock_denied *denied) { uint32_t *p; uint32_t namelen; @@ -2797,8 +2524,7 @@ decode_lock_denied (struct xdr_stream *x return -NFS4ERR_DENIED; } -static int -decode_lock(struct xdr_stream *xdr, struct nfs_lockres *res) +static int decode_lock(struct xdr_stream *xdr, struct nfs_lockres *res) { uint32_t *p; int status; @@ -2812,8 +2538,7 @@ decode_lock(struct xdr_stream *xdr, stru return status; } -static int -decode_lockt(struct xdr_stream *xdr, struct nfs_lockres *res) +static int decode_lockt(struct xdr_stream *xdr, struct nfs_lockres *res) { int status; status = decode_op_hdr(xdr, OP_LOCKT); @@ -2822,8 +2547,7 @@ decode_lockt(struct xdr_stream *xdr, str return status; } -static int -decode_locku(struct xdr_stream *xdr, struct nfs_lockres *res) +static int decode_locku(struct xdr_stream *xdr, struct nfs_lockres *res) { uint32_t *p; int status; @@ -2836,14 +2560,12 @@ decode_locku(struct xdr_stream *xdr, str return status; } -static int -decode_lookup(struct xdr_stream *xdr) +static int decode_lookup(struct xdr_stream *xdr) { return decode_op_hdr(xdr, OP_LOOKUP); } -static int -decode_open(struct xdr_stream *xdr, struct nfs_openres *res) +static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res) { uint32_t *p; uint32_t bmlen, delegation_type; @@ -2855,7 +2577,7 @@ decode_open(struct xdr_stream *xdr, stru READ_BUF(sizeof(res->stateid.data)); COPYMEM(res->stateid.data, sizeof(res->stateid.data)); - decode_change_info(xdr, res->cinfo); + decode_change_info(xdr, &res->cinfo); READ_BUF(8); READ32(res->rflags); @@ -2866,14 +2588,14 @@ decode_open(struct xdr_stream *xdr, stru READ_BUF((bmlen << 2) + 4); p += bmlen; READ32(delegation_type); - if (delegation_type != NFS4_OPEN_DELEGATE_NONE) - goto xdr_error; - - DECODE_TAIL; + if (delegation_type == NFS4_OPEN_DELEGATE_NONE) + return 0; +xdr_error: + printk(KERN_NOTICE "%s: xdr error!\n", __FUNCTION__); + return -EIO; } -static int -decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) +static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmres *res) { uint32_t *p; int status; @@ -2886,8 +2608,7 @@ decode_open_confirm(struct xdr_stream *x return 0; } -static int -decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) +static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *res) { uint32_t *p; int status; @@ -2900,20 +2621,17 @@ decode_open_downgrade(struct xdr_stream return 0; } -static int -decode_putfh(struct xdr_stream *xdr) +static int decode_putfh(struct xdr_stream *xdr) { return decode_op_hdr(xdr, OP_PUTFH); } -static int -decode_putrootfh(struct xdr_stream *xdr) +static int decode_putrootfh(struct xdr_stream *xdr) { return decode_op_hdr(xdr, OP_PUTROOTFH); } -static int -decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) +static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_readres *res) { struct iovec *iov = req->rq_rvec; uint32_t *p; @@ -3065,12 +2783,6 @@ static int decode_readlink(struct xdr_st return 0; } -static int -decode_restorefh(struct xdr_stream *xdr) -{ - return decode_op_hdr(xdr, OP_RESTOREFH); -} - static int decode_remove(struct xdr_stream *xdr, struct nfs4_change_info *cinfo) { int status; @@ -3098,8 +2810,7 @@ out: return status; } -static int -decode_renew(struct xdr_stream *xdr) +static int decode_renew(struct xdr_stream *xdr) { return decode_op_hdr(xdr, OP_RENEW); } @@ -3110,8 +2821,7 @@ decode_savefh(struct xdr_stream *xdr) return decode_op_hdr(xdr, OP_SAVEFH); } -static int -decode_setattr(struct xdr_stream *xdr, struct nfs_setattrres *res) +static int decode_setattr(struct xdr_stream *xdr, struct nfs_setattrres *res) { uint32_t *p; uint32_t bmlen; @@ -3127,8 +2837,7 @@ decode_setattr(struct xdr_stream *xdr, s return 0; } -static int -decode_setclientid(struct xdr_stream *xdr, struct nfs4_client *clp) +static int decode_setclientid(struct xdr_stream *xdr, struct nfs4_client *clp) { uint32_t *p; uint32_t opnum; @@ -3166,14 +2875,12 @@ decode_setclientid(struct xdr_stream *xd return 0; } -static int -decode_setclientid_confirm(struct xdr_stream *xdr) +static int decode_setclientid_confirm(struct xdr_stream *xdr) { return decode_op_hdr(xdr, OP_SETCLIENTID_CONFIRM); } -static int -decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) +static int decode_write(struct xdr_stream *xdr, struct nfs_writeres *res) { uint32_t *p; int status; @@ -3192,8 +2899,7 @@ decode_write(struct xdr_stream *xdr, str /* * Decode OPEN_DOWNGRADE response */ -static int -nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res) +static int nfs4_xdr_dec_open_downgrade(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3389,8 +3095,7 @@ out: /* * Decode CLOSE response */ -static int -nfs4_xdr_dec_close(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res) +static int nfs4_xdr_dec_close(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_closeres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3411,8 +3116,7 @@ out: /* * Decode OPEN response */ -static int -nfs4_xdr_dec_open(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res) +static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3425,24 +3129,13 @@ nfs4_xdr_dec_open(struct rpc_rqst *rqstp status = decode_putfh(&xdr); if (status) goto out; - status = decode_savefh(&xdr); - if (status) - goto out; status = decode_open(&xdr, res); if (status) goto out; - status = decode_getattr(&xdr, res->f_getattr, res->server); + status = decode_getfattr(&xdr, res->f_attr, res->server); if (status) goto out; status = decode_getfh(&xdr, &res->fh); - if (status) - goto out; - status = decode_restorefh(&xdr); - if (status) - goto out; - status = decode_getattr(&xdr, res->d_getattr, res->server); - if (status) - goto out; out: return status; } @@ -3450,8 +3143,7 @@ out: /* * Decode OPEN_CONFIRM response */ -static int -nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_open_confirmres *res) +static int nfs4_xdr_dec_open_confirm(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_open_confirmres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3472,8 +3164,7 @@ out: /* * Decode OPEN_RECLAIM response */ -static int -nfs4_xdr_dec_open_reclaim(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res) +static int nfs4_xdr_dec_open_reclaim(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_openres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3489,7 +3180,7 @@ nfs4_xdr_dec_open_reclaim(struct rpc_rqs status = decode_open(&xdr, res); if (status) goto out; - status = decode_getattr(&xdr, res->f_getattr, res->server); + status = decode_getfattr(&xdr, res->f_attr, res->server); out: return status; } @@ -3497,8 +3188,7 @@ out: /* * Decode SETATTR response */ -static int -nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_setattrres *res) +static int nfs4_xdr_dec_setattr(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_setattrres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3514,7 +3204,7 @@ nfs4_xdr_dec_setattr(struct rpc_rqst *rq status = decode_setattr(&xdr, res); if (status) goto out; - status = decode_getattr(&xdr, res->attr, res->server); + status = decode_getfattr(&xdr, res->fattr, res->server); out: return status; } @@ -3522,8 +3212,7 @@ out: /* * Decode LOCK response */ -static int -nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) +static int nfs4_xdr_dec_lock(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3544,8 +3233,7 @@ out: /* * Decode LOCKT response */ -static int -nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) +static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3566,8 +3254,7 @@ out: /* * Decode LOCKU response */ -static int -nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) +static int nfs4_xdr_dec_locku(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_lockres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3630,8 +3317,7 @@ out: /* * Decode Read response */ -static int -nfs4_xdr_dec_read(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_readres *res) +static int nfs4_xdr_dec_read(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_readres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3654,8 +3340,7 @@ out: /* * Decode WRITE response */ -static int -nfs4_xdr_dec_write(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res) +static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3678,8 +3363,7 @@ out: /* * Decode COMMIT response */ -static int -nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res) +static int nfs4_xdr_dec_commit(struct rpc_rqst *rqstp, uint32_t *p, struct nfs_writeres *res) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3700,8 +3384,7 @@ out: /* * FSINFO request */ -static int -nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo) +static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3757,8 +3440,7 @@ static int nfs4_xdr_dec_statfs(struct rp /* * Decode RENEW response */ -static int -nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, uint32_t *p, void *dummy) +static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, uint32_t *p, void *dummy) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3774,8 +3456,7 @@ nfs4_xdr_dec_renew(struct rpc_rqst *rqst /* * a SETCLIENTID request */ -static int -nfs4_xdr_dec_setclientid(struct rpc_rqst *req, uint32_t *p, +static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, uint32_t *p, struct nfs4_client *clp) { struct xdr_stream xdr; @@ -3794,8 +3475,7 @@ nfs4_xdr_dec_setclientid(struct rpc_rqst /* * a SETCLIENTID_CONFIRM request */ -static int -nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo) +static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, uint32_t *p, struct nfs_fsinfo *fsinfo) { struct xdr_stream xdr; struct compound_hdr hdr; @@ -3814,8 +3494,7 @@ nfs4_xdr_dec_setclientid_confirm(struct return status; } -uint32_t * -nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) +uint32_t *nfs4_decode_dirent(uint32_t *p, struct nfs_entry *entry, int plus) { uint32_t len; diff -u --recursive --new-file --show-c-function linux-2.6.5-27-decompoundify_readdir/include/linux/nfs_xdr.h linux-2.6.5-28-decompoundify_cleanup/include/linux/nfs_xdr.h --- linux-2.6.5-27-decompoundify_readdir/include/linux/nfs_xdr.h 2004-03-24 00:49:12.000000000 -0500 +++ linux-2.6.5-28-decompoundify_cleanup/include/linux/nfs_xdr.h 2004-03-24 00:49:24.000000000 -0500 @@ -89,6 +89,12 @@ struct nfs_pathconf { __u32 max_namelen; /* max name length */ }; +struct nfs4_change_info { + u32 atomic; + u64 before; + u64 after; +}; + /* * Arguments to the open call. */ @@ -104,20 +110,18 @@ struct nfs_openargs { struct iattr * attrs; /* UNCHECKED, GUARDED */ nfs4_verifier verifier; /* EXCLUSIVE */ } u; - struct qstr * name; - struct nfs4_getattr * f_getattr; - struct nfs4_getattr * d_getattr; - struct nfs_server * server; /* Needed for ID mapping */ + const struct qstr * name; + const struct nfs_server *server; /* Needed for ID mapping */ + const u32 * bitmask; }; struct nfs_openres { nfs4_stateid stateid; struct nfs_fh fh; - struct nfs4_change_info * cinfo; + struct nfs4_change_info cinfo; __u32 rflags; - struct nfs4_getattr * f_getattr; - struct nfs4_getattr * d_getattr; - struct nfs_server * server; + struct nfs_fattr * f_attr; + const struct nfs_server *server; }; /* @@ -143,7 +147,7 @@ struct nfs_open_reclaimargs { __u32 id; __u32 share_access; __u32 claim; - struct nfs4_getattr * f_getattr; + const __u32 * bitmask; }; /* @@ -217,7 +221,7 @@ struct nfs_lockres { nfs4_stateid stateid;/* LOCK success, LOCKU */ struct nfs_lock_denied denied; /* LOCK failed, LOCKT success */ } u; - struct nfs_server * server; + const struct nfs_server * server; }; /* @@ -323,13 +327,13 @@ struct nfs_setattrargs { struct nfs_fh * fh; nfs4_stateid stateid; struct iattr * iap; - struct nfs4_getattr * attr; - struct nfs_server * server; /* Needed for name mapping */ + const struct nfs_server * server; /* Needed for name mapping */ + const u32 * bitmask; }; struct nfs_setattrres { - struct nfs4_getattr * attr; - struct nfs_server * server; + struct nfs_fattr * fattr; + const struct nfs_server * server; }; struct nfs_linkargs { @@ -480,12 +484,6 @@ struct nfs3_readdirres { typedef u64 clientid4; -struct nfs4_change_info { - u32 atomic; - u64 before; - u64 after; -}; - struct nfs4_accessargs { const struct nfs_fh * fh; u32 access; @@ -519,12 +517,6 @@ struct nfs4_create_res { struct nfs4_change_info dir_cinfo; }; -struct nfs4_getattr { - u32 * gt_bmval; /* request */ - struct nfs_fattr * gt_attrs; /* response */ - struct nfs_fsstat * gt_fsstat; /* response */ -}; - struct nfs4_getattr_arg { const struct nfs_fh * fh; const u32 * bitmask;