of compound_decode_hdr_maxsz.
NFSv4: fix a printk() typo (spotted by Linda Dunaphant).
NFSv4: Ensure that nfs4_open_reclaim() copies the value of the new stateid back into
the shared nfsv4 state structure.
NFSv4: Don't leak NFS4ERR_WRONGSEC errors back into nfs_lookup().
RPC,NFS,Lockd: Mark the debugging code as "unlikely" so that gcc moves it out of the
mainline code paths.
if (data->version != NFS4_MOUNT_VERSION) {
printk("nfs warning: mount version %s than kernel\n",
- data->version < NFS_MOUNT_VERSION ? "older" : "newer");
+ data->version < NFS4_MOUNT_VERSION ? "older" : "newer");
}
p = nfs_copy_user_string(NULL, &data->hostname, 256);
* Declare the space requirements for NFS arguments and replies as
* number of 32bit-words
*/
-#define NFS_fhandle_sz 8
-#define NFS_sattr_sz 8
-#define NFS_filename_sz 1+(NFS2_MAXNAMLEN>>2)
-#define NFS_path_sz 1+(NFS2_MAXPATHLEN>>2)
-#define NFS_fattr_sz 17
-#define NFS_info_sz 5
-#define NFS_entry_sz NFS_filename_sz+3
-
-#define NFS_diropargs_sz NFS_fhandle_sz+NFS_filename_sz
-#define NFS_sattrargs_sz NFS_fhandle_sz+NFS_sattr_sz
-#define NFS_readlinkargs_sz NFS_fhandle_sz
-#define NFS_readargs_sz NFS_fhandle_sz+3
-#define NFS_writeargs_sz NFS_fhandle_sz+4
-#define NFS_createargs_sz NFS_diropargs_sz+NFS_sattr_sz
-#define NFS_renameargs_sz NFS_diropargs_sz+NFS_diropargs_sz
-#define NFS_linkargs_sz NFS_fhandle_sz+NFS_diropargs_sz
-#define NFS_symlinkargs_sz NFS_diropargs_sz+NFS_path_sz+NFS_sattr_sz
-#define NFS_readdirargs_sz NFS_fhandle_sz+2
-
-#define NFS_attrstat_sz 1+NFS_fattr_sz
-#define NFS_diropres_sz 1+NFS_fhandle_sz+NFS_fattr_sz
-#define NFS_readlinkres_sz 1
-#define NFS_readres_sz 1+NFS_fattr_sz+1
-#define NFS_writeres_sz NFS_attrstat_sz
-#define NFS_stat_sz 1
-#define NFS_readdirres_sz 1
-#define NFS_statfsres_sz 1+NFS_info_sz
+#define NFS_fhandle_sz (8)
+#define NFS_sattr_sz (8)
+#define NFS_filename_sz (1+(NFS2_MAXNAMLEN>>2))
+#define NFS_path_sz (1+(NFS2_MAXPATHLEN>>2))
+#define NFS_fattr_sz (17)
+#define NFS_info_sz (5)
+#define NFS_entry_sz (NFS_filename_sz+3)
+
+#define NFS_diropargs_sz (NFS_fhandle_sz+NFS_filename_sz)
+#define NFS_sattrargs_sz (NFS_fhandle_sz+NFS_sattr_sz)
+#define NFS_readlinkargs_sz (NFS_fhandle_sz)
+#define NFS_readargs_sz (NFS_fhandle_sz+3)
+#define NFS_writeargs_sz (NFS_fhandle_sz+4)
+#define NFS_createargs_sz (NFS_diropargs_sz+NFS_sattr_sz)
+#define NFS_renameargs_sz (NFS_diropargs_sz+NFS_diropargs_sz)
+#define NFS_linkargs_sz (NFS_fhandle_sz+NFS_diropargs_sz)
+#define NFS_symlinkargs_sz (NFS_diropargs_sz+NFS_path_sz+NFS_sattr_sz)
+#define NFS_readdirargs_sz (NFS_fhandle_sz+2)
+
+#define NFS_attrstat_sz (1+NFS_fattr_sz)
+#define NFS_diropres_sz (1+NFS_fhandle_sz+NFS_fattr_sz)
+#define NFS_readlinkres_sz (1)
+#define NFS_readres_sz (1+NFS_fattr_sz+1)
+#define NFS_writeres_sz (NFS_attrstat_sz)
+#define NFS_stat_sz (1)
+#define NFS_readdirres_sz (1)
+#define NFS_statfsres_sz (1+NFS_info_sz)
/*
* Common NFS XDR functions as inlines
* Declare the space requirements for NFS arguments and replies as
* number of 32bit-words
*/
-#define NFS3_fhandle_sz 1+16
-#define NFS3_fh_sz NFS3_fhandle_sz /* shorthand */
-#define NFS3_sattr_sz 15
-#define NFS3_filename_sz 1+(NFS3_MAXNAMLEN>>2)
-#define NFS3_path_sz 1+(NFS3_MAXPATHLEN>>2)
-#define NFS3_fattr_sz 21
-#define NFS3_wcc_attr_sz 6
-#define NFS3_pre_op_attr_sz 1+NFS3_wcc_attr_sz
-#define NFS3_post_op_attr_sz 1+NFS3_fattr_sz
-#define NFS3_wcc_data_sz NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz
+#define NFS3_fhandle_sz (1+16)
+#define NFS3_fh_sz (NFS3_fhandle_sz) /* shorthand */
+#define NFS3_sattr_sz (15)
+#define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2))
+#define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2))
+#define NFS3_fattr_sz (21)
+#define NFS3_wcc_attr_sz (6)
+#define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz)
+#define NFS3_post_op_attr_sz (1+NFS3_fattr_sz)
+#define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz)
#define NFS3_fsstat_sz
#define NFS3_fsinfo_sz
#define NFS3_pathconf_sz
-#define NFS3_entry_sz NFS3_filename_sz+3
-
-#define NFS3_sattrargs_sz NFS3_fh_sz+NFS3_sattr_sz+3
-#define NFS3_diropargs_sz NFS3_fh_sz+NFS3_filename_sz
-#define NFS3_accessargs_sz NFS3_fh_sz+1
-#define NFS3_readlinkargs_sz NFS3_fh_sz
-#define NFS3_readargs_sz NFS3_fh_sz+3
-#define NFS3_writeargs_sz NFS3_fh_sz+5
-#define NFS3_createargs_sz NFS3_diropargs_sz+NFS3_sattr_sz
-#define NFS3_mkdirargs_sz NFS3_diropargs_sz+NFS3_sattr_sz
-#define NFS3_symlinkargs_sz NFS3_diropargs_sz+NFS3_path_sz+NFS3_sattr_sz
-#define NFS3_mknodargs_sz NFS3_diropargs_sz+2+NFS3_sattr_sz
-#define NFS3_renameargs_sz NFS3_diropargs_sz+NFS3_diropargs_sz
-#define NFS3_linkargs_sz NFS3_fh_sz+NFS3_diropargs_sz
-#define NFS3_readdirargs_sz NFS3_fh_sz+2
-#define NFS3_commitargs_sz NFS3_fh_sz+3
-
-#define NFS3_attrstat_sz 1+NFS3_fattr_sz
-#define NFS3_wccstat_sz 1+NFS3_wcc_data_sz
-#define NFS3_lookupres_sz 1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz)
-#define NFS3_accessres_sz 1+NFS3_post_op_attr_sz+1
-#define NFS3_readlinkres_sz 1+NFS3_post_op_attr_sz
-#define NFS3_readres_sz 1+NFS3_post_op_attr_sz+3
-#define NFS3_writeres_sz 1+NFS3_wcc_data_sz+4
-#define NFS3_createres_sz 1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz
-#define NFS3_renameres_sz 1+(2 * NFS3_wcc_data_sz)
-#define NFS3_linkres_sz 1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz
-#define NFS3_readdirres_sz 1+NFS3_post_op_attr_sz+2
-#define NFS3_fsstatres_sz 1+NFS3_post_op_attr_sz+13
-#define NFS3_fsinfores_sz 1+NFS3_post_op_attr_sz+12
-#define NFS3_pathconfres_sz 1+NFS3_post_op_attr_sz+6
-#define NFS3_commitres_sz 1+NFS3_wcc_data_sz+2
+#define NFS3_entry_sz (NFS3_filename_sz+3)
+
+#define NFS3_sattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
+#define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
+#define NFS3_accessargs_sz (NFS3_fh_sz+1)
+#define NFS3_readlinkargs_sz (NFS3_fh_sz)
+#define NFS3_readargs_sz (NFS3_fh_sz+3)
+#define NFS3_writeargs_sz (NFS3_fh_sz+5)
+#define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
+#define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
+#define NFS3_symlinkargs_sz (NFS3_diropargs_sz+NFS3_path_sz+NFS3_sattr_sz)
+#define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz)
+#define NFS3_renameargs_sz (NFS3_diropargs_sz+NFS3_diropargs_sz)
+#define NFS3_linkargs_sz (NFS3_fh_sz+NFS3_diropargs_sz)
+#define NFS3_readdirargs_sz (NFS3_fh_sz+2)
+#define NFS3_commitargs_sz (NFS3_fh_sz+3)
+
+#define NFS3_attrstat_sz (1+NFS3_fattr_sz)
+#define NFS3_wccstat_sz (1+NFS3_wcc_data_sz)
+#define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
+#define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
+#define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz)
+#define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3)
+#define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4)
+#define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
+#define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz))
+#define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
+#define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2)
+#define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13)
+#define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12)
+#define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6)
+#define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2)
/*
* Map file type to S_IFMT bits
extern nfs4_stateid zero_stateid;
+/* Prevent leaks of NFSv4 errors into userland */
+static inline int nfs4_map_errors(int err)
+{
+ if (err < -1000) {
+ printk(KERN_WARNING "%s could not handle NFSv4 error %d\n",
+ __FUNCTION__, -err);
+ return -EIO;
+ }
+ return err;
+}
+
static void
nfs4_setup_compound(struct nfs4_compound *cp, struct nfs4_op *ops,
struct nfs_server *server, char *tag)
status = rpc_call_sync(server->client, &msg, 0);
nfs4_increment_seqid(status, sp);
+ if (status == 0)
+ memcpy(&state->stateid, &o_res.stateid, sizeof(state->stateid));
/* Update the inode attributes */
nfs_refresh_inode(inode, &fattr);
return status;
retry:
fattr->valid = 0;
- if (state)
+ if (sattr->ia_valid & ATTR_SIZE)
nfs4_copy_stateid(&arg.stateid, state, 0);
- else
+ else
memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid));
- status = rpc_call_sync(server->client, &msg, 0);
+ status = rpc_call_sync(server->client, &msg, 0);
if (status) {
status = nfs4_handle_error(server, status);
if (!status)
}
out:
if (status)
- return status;
+ return nfs4_map_errors(status);
return nfs4_proc_fsinfo(server, fhandle, info);
}
nfs4_setup_compound(&compound, ops, NFS_SERVER(inode), "getattr");
nfs4_setup_putfh(&compound, NFS_FH(inode));
nfs4_setup_getattr(&compound, fattr);
- return nfs4_call_compound(&compound, NULL, 0);
+ return nfs4_map_errors(nfs4_call_compound(&compound, NULL, 0));
}
/*
if (status >= 0)
status = nfs_refresh_inode(dir, &dir_attr);
- return status;
+ return nfs4_map_errors(status);
}
static int
else if (req_access != resp_access)
status = -EACCES;
}
- return status;
+ return nfs4_map_errors(status);
}
/*
nfs4_setup_compound(&compound, ops, NFS_SERVER(inode), "readlink");
nfs4_setup_putfh(&compound, NFS_FH(inode));
nfs4_setup_readlink(&compound, PAGE_CACHE_SIZE, &page);
- return nfs4_call_compound(&compound, NULL, 0);
+ return nfs4_map_errors(nfs4_call_compound(&compound, NULL, 0));
}
static int
if (!status)
renew_lease(server, timestamp);
dprintk("NFS reply read: %d\n", status);
- return status;
+ return nfs4_map_errors(status);
}
static int
fattr->valid = 0;
status = rpc_call_sync(server->client, &msg, rpcflags);
dprintk("NFS reply write: %d\n", status);
- return status;
+ return nfs4_map_errors(status);
}
static int
fattr->valid = 0;
status = rpc_call_sync(server->client, &msg, 0);
dprintk("NFS reply commit: %d\n", status);
- return status;
+ return nfs4_map_errors(status);
}
/*
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
struct unlink_desc {
nfs_refresh_inode(old_dir, &old_dir_attr);
nfs_refresh_inode(new_dir, &new_dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
nfs_refresh_inode(dir, &dir_attr);
nfs_refresh_inode(inode, &fattr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
nfs4_setup_putfh(&compound, NFS_FH(dir));
nfs4_setup_readdir(&compound, cookie, NFS_COOKIEVERF(dir), &page, count, dentry);
status = nfs4_call_compound(&compound, cred, 0);
+ if (status == 0)
+ memcpy(NFS_COOKIEVERF(dir), ops[1].u.readdir.rd_resp_verifier.data, NFS4_VERIFIER_SIZE);
unlock_kernel();
- return status;
+ return nfs4_map_errors(status);
}
static int
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
nfs4_setup_compound(&compound, ops, server, "statfs");
nfs4_setup_putfh(&compound, fhandle);
nfs4_setup_statfs(&compound, fsstat);
- return nfs4_call_compound(&compound, NULL, 0);
+ return nfs4_map_errors(nfs4_call_compound(&compound, NULL, 0));
}
static int
.rpc_resp = fsinfo,
};
- return rpc_call_sync(server->client, &msg, 0);
+ return nfs4_map_errors(rpc_call_sync(server->client, &msg, 0));
}
static int
nfs4_setup_compound(&compound, ops, server, "statfs");
nfs4_setup_putfh(&compound, fhandle);
nfs4_setup_pathconf(&compound, pathconf);
- return nfs4_call_compound(&compound, NULL, 0);
+ return nfs4_map_errors(nfs4_call_compound(&compound, NULL, 0));
}
static void
{
struct nfs4_client *clp = server->nfs4_state;
- if (!clp)
+ if (!clp || task->tk_status >= 0)
return 0;
switch(task->tk_status) {
case -NFS4ERR_STALE_CLIENTID:
task->tk_status = 0;
return -EAGAIN;
}
+ task->tk_status = nfs4_map_errors(task->tk_status);
return 0;
}
break;
case -NFS4ERR_OLD_STATEID:
ret = 0;
- break;
- default:
- if (errorcode <= -1000) {
- printk(KERN_WARNING "%s could not handle NFSv4 error %d\n",
- __FUNCTION__, -errorcode);
- ret = -EIO;
- }
}
/* We failed to handle the error */
- return ret;
+ return nfs4_map_errors(ret);
}
if (lsp)
nfs4_put_lock_state(lsp);
up(&state->lock_sema);
- return status;
+ return nfs4_map_errors(status);
}
int
nfs4_put_lock_state(lsp);
out:
up(&state->lock_sema);
- return status;
+ return nfs4_map_errors(status);
}
static int
nfs4_put_lock_state(lsp);
out:
up(&state->lock_sema);
- return status;
+ return nfs4_map_errors(status);
}
static int
restart_loop:
spin_lock(&clp->cl_lock);
list_for_each_entry(sp, &clp->cl_state_owners, so_list) {
- if (sp->so_generation - generation <= 0)
+ if (sp->so_generation - generation >= 0)
continue;
atomic_inc(&sp->so_count);
spin_unlock(&clp->cl_lock);
/* lock,open owner id:
* we currently use size 1 (u32) out of (NFS4_OPAQUE_LIMIT >> 2)
*/
-#define owner_id_maxsz 1 + 1
-#define compound_encode_hdr_maxsz 3 + (NFS4_MAXTAGLEN >> 2)
-#define compound_decode_hdr_maxsz 2 + (NFS4_MAXTAGLEN >> 2)
-#define op_encode_hdr_maxsz 1
-#define op_decode_hdr_maxsz 2
-#define encode_putfh_maxsz op_encode_hdr_maxsz + 1 + \
- (NFS4_FHSIZE >> 2)
-#define decode_putfh_maxsz op_decode_hdr_maxsz
-#define encode_putrootfh_maxsz op_encode_hdr_maxsz
-#define decode_putrootfh_maxsz op_decode_hdr_maxsz
-#define encode_getfh_maxsz op_encode_hdr_maxsz
-#define decode_getfh_maxsz op_decode_hdr_maxsz + 1 + \
- (NFS4_FHSIZE >> 2)
-#define encode_getattr_maxsz op_encode_hdr_maxsz + 3
-#define nfs4_fattr_bitmap_maxsz 26 + 2 * ((NFS4_MAXNAMLEN +1) >> 2)
-#define decode_getattr_maxsz op_decode_hdr_maxsz + 3 + \
- 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_read_getattr_maxsz op_encode_hdr_maxsz + 2
-#define decode_read_getattr_maxsz op_decode_hdr_maxsz + 8
-#define encode_pre_write_getattr_maxsz op_encode_hdr_maxsz + 2
-#define decode_pre_write_getattr_maxsz op_decode_hdr_maxsz + 5
-#define encode_post_write_getattr_maxsz op_encode_hdr_maxsz + 2
-#define decode_post_write_getattr_maxsz op_decode_hdr_maxsz + 13
-#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
-#define decode_renew_maxsz op_decode_hdr_maxsz
+#define owner_id_maxsz (1 + 1)
+#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
+#define compound_decode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
+#define op_encode_hdr_maxsz (1)
+#define op_decode_hdr_maxsz (2)
+#define encode_putfh_maxsz (op_encode_hdr_maxsz + 1 + \
+ (NFS4_FHSIZE >> 2))
+#define decode_putfh_maxsz (op_decode_hdr_maxsz)
+#define encode_putrootfh_maxsz (op_encode_hdr_maxsz)
+#define decode_putrootfh_maxsz (op_decode_hdr_maxsz)
+#define encode_getfh_maxsz (op_encode_hdr_maxsz)
+#define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
+ (NFS4_FHSIZE >> 2))
+#define encode_getattr_maxsz (op_encode_hdr_maxsz + 3)
+#define nfs4_fattr_bitmap_maxsz (26 + 2 * ((NFS4_MAXNAMLEN +1) >> 2))
+#define decode_getattr_maxsz (op_decode_hdr_maxsz + 3 + \
+ 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_read_getattr_maxsz (op_encode_hdr_maxsz + 2)
+#define decode_read_getattr_maxsz (op_decode_hdr_maxsz + 8)
+#define encode_pre_write_getattr_maxsz (op_encode_hdr_maxsz + 2)
+#define decode_pre_write_getattr_maxsz (op_decode_hdr_maxsz + 5)
+#define encode_post_write_getattr_maxsz (op_encode_hdr_maxsz + 2)
+#define decode_post_write_getattr_maxsz (op_decode_hdr_maxsz + 13)
+#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)
+#define decode_renew_maxsz (op_decode_hdr_maxsz)
#define encode_setclientid_maxsz \
- op_encode_hdr_maxsz + \
+ (op_encode_hdr_maxsz + \
4 /*server->ip_addr*/ + \
1 /*Netid*/ + \
6 /*uaddr*/ + \
- 6 + (NFS4_VERIFIER_SIZE >> 2)
+ 6 + (NFS4_VERIFIER_SIZE >> 2))
#define decode_setclientid_maxsz \
- op_decode_hdr_maxsz + \
+ (op_decode_hdr_maxsz + \
2 + \
- 1024 /* large value for CLID_INUSE */
+ 1024) /* large value for CLID_INUSE */
#define encode_setclientid_confirm_maxsz \
- op_encode_hdr_maxsz + \
- 3 + (NFS4_VERIFIER_SIZE >> 2)
+ (op_encode_hdr_maxsz + \
+ 3 + (NFS4_VERIFIER_SIZE >> 2))
#define decode_setclientid_confirm_maxsz \
- op_decode_hdr_maxsz
+ (op_decode_hdr_maxsz)
-#define NFS4_enc_compound_sz 1024 /* XXX: large enough? */
-#define NFS4_dec_compound_sz 1024 /* XXX: large enough? */
-#define NFS4_enc_read_sz compound_encode_hdr_maxsz + \
+#define NFS4_enc_compound_sz (1024) /* XXX: large enough? */
+#define NFS4_dec_compound_sz (1024) /* XXX: large enough? */
+#define NFS4_enc_read_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_read_getattr_maxsz + \
- op_encode_hdr_maxsz + 7
-#define NFS4_dec_read_sz compound_decode_hdr_maxsz + \
+ op_encode_hdr_maxsz + 7)
+#define NFS4_dec_read_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
decode_read_getattr_maxsz + \
- op_decode_hdr_maxsz + 2
-#define NFS4_enc_write_sz compound_encode_hdr_maxsz + \
+ op_decode_hdr_maxsz + 2)
+#define NFS4_enc_write_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_pre_write_getattr_maxsz + \
op_encode_hdr_maxsz + 8 + \
- encode_post_write_getattr_maxsz
-#define NFS4_dec_write_sz compound_decode_hdr_maxsz + \
+ encode_post_write_getattr_maxsz)
+#define NFS4_dec_write_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
decode_pre_write_getattr_maxsz + \
op_decode_hdr_maxsz + 4 + \
- decode_post_write_getattr_maxsz
-#define NFS4_enc_commit_sz compound_encode_hdr_maxsz + \
+ decode_post_write_getattr_maxsz)
+#define NFS4_enc_commit_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_pre_write_getattr_maxsz + \
op_encode_hdr_maxsz + 3 + \
- encode_post_write_getattr_maxsz
-#define NFS4_dec_commit_sz compound_decode_hdr_maxsz + \
+ encode_post_write_getattr_maxsz)
+#define NFS4_dec_commit_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
decode_pre_write_getattr_maxsz + \
op_decode_hdr_maxsz + 2 + \
- decode_post_write_getattr_maxsz
-#define NFS4_enc_open_sz compound_encode_hdr_maxsz + \
+ decode_post_write_getattr_maxsz)
+#define NFS4_enc_open_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_savefh_maxsz + \
op_encode_hdr_maxsz + \
encode_getattr_maxsz + \
encode_getfh_maxsz + \
encode_restorefh_maxsz + \
- encode_getattr_maxsz
-#define NFS4_dec_open_sz compound_decode_hdr_maxsz + \
+ encode_getattr_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_getattr_maxsz)
#define NFS4_enc_open_confirm_sz \
- compound_encode_hdr_maxsz + \
+ (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
- op_encode_hdr_maxsz + 5
-#define NFS4_dec_open_confirm_sz compound_decode_hdr_maxsz + \
+ op_encode_hdr_maxsz + 5)
+#define NFS4_dec_open_confirm_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
- op_decode_hdr_maxsz + 4
-#define NFS4_enc_open_reclaim_sz compound_encode_hdr_maxsz + \
+ op_decode_hdr_maxsz + 4)
+#define NFS4_enc_open_reclaim_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
op_encode_hdr_maxsz + \
11 + \
- encode_getattr_maxsz
-#define NFS4_dec_open_reclaim_sz compound_decode_hdr_maxsz + \
+ encode_getattr_maxsz)
+#define NFS4_dec_open_reclaim_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
op_decode_hdr_maxsz + \
4 + 5 + 2 + 3 + \
- decode_getattr_maxsz
+ decode_getattr_maxsz)
#define NFS4_enc_open_downgrade_sz \
- compound_encode_hdr_maxsz + \
+ (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
- op_encode_hdr_maxsz + 7
+ op_encode_hdr_maxsz + 7)
#define NFS4_dec_open_downgrade_sz \
- compound_decode_hdr_maxsz + \
+ (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
- op_decode_hdr_maxsz + 4
-#define NFS4_enc_close_sz compound_encode_hdr_maxsz + \
+ op_decode_hdr_maxsz + 4)
+#define NFS4_enc_close_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
- op_encode_hdr_maxsz + 5
-#define NFS4_dec_close_sz compound_decode_hdr_maxsz + \
+ op_encode_hdr_maxsz + 5)
+#define NFS4_dec_close_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
- op_decode_hdr_maxsz + 4
-#define NFS4_enc_setattr_sz compound_encode_hdr_maxsz + \
+ op_decode_hdr_maxsz + 4)
+#define NFS4_enc_setattr_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
op_encode_hdr_maxsz + 4 + \
nfs4_fattr_bitmap_maxsz + \
- encode_getattr_maxsz
-#define NFS4_dec_setattr_sz compound_decode_hdr_maxsz + \
+ encode_getattr_maxsz)
+#define NFS4_dec_setattr_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
- op_decode_hdr_maxsz + 3
-#define NFS4_enc_fsinfo_sz compound_encode_hdr_maxsz + \
+ op_decode_hdr_maxsz + 3)
+#define NFS4_enc_fsinfo_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
- encode_fsinfo_maxsz
-#define NFS4_dec_fsinfo_sz compound_decode_hdr_maxsz + \
+ encode_fsinfo_maxsz)
+#define NFS4_dec_fsinfo_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
- decode_fsinfo_maxsz
-#define NFS4_enc_renew_sz compound_encode_hdr_maxsz + \
- encode_renew_maxsz
-#define NFS4_dec_renew_sz compound_decode_hdr_maxsz + \
- decode_renew_maxsz
-#define NFS4_enc_setclientid_sz compound_encode_hdr_maxsz + \
- encode_setclientid_maxsz
-#define NFS4_dec_setclientid_sz compound_decode_hdr_maxsz + \
- decode_setclientid_maxsz
+ decode_fsinfo_maxsz)
+#define NFS4_enc_renew_sz (compound_encode_hdr_maxsz + \
+ encode_renew_maxsz)
+#define NFS4_dec_renew_sz (compound_decode_hdr_maxsz + \
+ decode_renew_maxsz)
+#define NFS4_enc_setclientid_sz (compound_encode_hdr_maxsz + \
+ encode_setclientid_maxsz)
+#define NFS4_dec_setclientid_sz (compound_decode_hdr_maxsz + \
+ decode_setclientid_maxsz)
#define NFS4_enc_setclientid_confirm_sz \
- compound_encode_hdr_maxsz + \
+ (compound_encode_hdr_maxsz + \
encode_setclientid_confirm_maxsz + \
encode_putrootfh_maxsz + \
- encode_fsinfo_maxsz
+ encode_fsinfo_maxsz)
#define NFS4_dec_setclientid_confirm_sz \
- compound_decode_hdr_maxsz + \
+ (compound_decode_hdr_maxsz + \
decode_setclientid_confirm_maxsz + \
decode_putrootfh_maxsz + \
- decode_fsinfo_maxsz
-#define NFS4_enc_lock_sz compound_encode_hdr_maxsz + \
+ decode_fsinfo_maxsz)
+#define NFS4_enc_lock_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_getattr_maxsz + \
op_encode_hdr_maxsz + \
1 + 1 + 2 + 2 + \
1 + 4 + 1 + 2 + \
- owner_id_maxsz
-#define NFS4_dec_lock_sz compound_decode_hdr_maxsz + \
+ owner_id_maxsz)
+#define NFS4_dec_lock_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
decode_getattr_maxsz + \
op_decode_hdr_maxsz + \
2 + 2 + 1 + 2 + \
- owner_id_maxsz
-#define NFS4_enc_lockt_sz compound_encode_hdr_maxsz + \
+ owner_id_maxsz)
+#define NFS4_enc_lockt_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_getattr_maxsz + \
op_encode_hdr_maxsz + \
1 + 2 + 2 + 2 + \
- owner_id_maxsz
-#define NFS4_dec_lockt_sz NFS4_dec_lock_sz
-#define NFS4_enc_locku_sz compound_encode_hdr_maxsz + \
+ owner_id_maxsz)
+#define NFS4_dec_lockt_sz (NFS4_dec_lock_sz)
+#define NFS4_enc_locku_sz (compound_encode_hdr_maxsz + \
encode_putfh_maxsz + \
encode_getattr_maxsz + \
op_encode_hdr_maxsz + \
- 1 + 1 + 4 + 2 + 2
-#define NFS4_dec_locku_sz compound_decode_hdr_maxsz + \
+ 1 + 1 + 4 + 2 + 2)
+#define NFS4_dec_locku_sz (compound_decode_hdr_maxsz + \
decode_putfh_maxsz + \
decode_getattr_maxsz + \
- op_decode_hdr_maxsz + 4
+ op_decode_hdr_maxsz + 4)
{ NFS4ERR_SYMLINK, ELOOP },
{ NFS4ERR_OP_ILLEGAL, EOPNOTSUPP },
{ NFS4ERR_DEADLOCK, EDEADLK },
+ { NFS4ERR_WRONGSEC, EPERM }, /* FIXME: this needs
+ * to be handled by a
+ * middle-layer.
+ */
{ -1, EIO }
};
if (nfs_errtbl[i].stat == stat)
return nfs_errtbl[i].errno;
}
+ if (stat < 0) {
+ /* The server is looney tunes. */
+ return ESERVERFAULT;
+ }
/* If we cannot translate the error, the recovery routines should
* handle it.
* Note: remaining NFSv4 error codes have values > 10000, so should
#undef ifdebug
#if defined(RPC_DEBUG) && defined(LOCKD_DEBUG)
-# define ifdebug(flag) if (nlm_debug & NLMDBG_##flag)
+# define ifdebug(flag) if (unlikely(nlm_debug & NLMDBG_##flag))
#else
# define ifdebug(flag) if (0)
#endif
#ifdef __KERNEL__
# undef ifdebug
# ifdef NFS_DEBUG
-# define ifdebug(fac) if (nfs_debug & NFSDBG_##fac)
+# define ifdebug(fac) if (unlikely(nfs_debug & NFSDBG_##fac))
# else
# define ifdebug(fac) if (0)
# endif
#undef ifdebug
#ifdef RPC_DEBUG
-# define ifdebug(fac) if (rpc_debug & RPCDBG_##fac)
+# define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
# define dfprintk(fac, args...) do { ifdebug(fac) printk(args); } while(0)
# define RPC_IFDEBUG(x) x
#else