summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@fys.uio.no>2004-03-13 11:47:36 -0500
committerTrond Myklebust <trond.myklebust@fys.uio.no>2004-03-13 11:47:36 -0500
commitd2ac640a44710081a4945f858894a190824343d3 (patch)
tree4f926b54ef6795f048c6a252a5a6f8323e8b4076
parent72cffe4f9165f382c4a274ac15ec3db27fae9318 (diff)
NFSv2/v3/v4: Parenthesize #defines in nfs?xdr.c. Fix an off-by-one error on the value
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.
-rw-r--r--fs/nfs/inode.c2
-rw-r--r--fs/nfs/nfs2xdr.c54
-rw-r--r--fs/nfs/nfs3xdr.c84
-rw-r--r--fs/nfs/nfs4proc.c75
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfs/nfs4xdr.c214
-rw-r--r--include/linux/lockd/debug.h2
-rw-r--r--include/linux/nfs_fs.h2
-rw-r--r--include/linux/sunrpc/debug.h2
9 files changed, 227 insertions, 210 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index cb002677fbd8..9f61e23a5abe 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -1625,7 +1625,7 @@ static struct super_block *nfs4_get_sb(struct file_system_type *fs_type,
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);
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index a6771597ab8a..138afa28c742 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -36,33 +36,33 @@ extern int nfs_stat_to_errno(int stat);
* 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
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index 60acc2b45183..656604de632b 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -33,51 +33,51 @@ extern int nfs_stat_to_errno(int);
* 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
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index e49e5e2d78e5..9efe346181bc 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -61,6 +61,17 @@ extern struct rpc_procinfo nfs4_procedures[];
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)
@@ -506,6 +517,8 @@ nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *state)
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;
@@ -690,12 +703,12 @@ nfs4_do_setattr(struct nfs_server *server, struct nfs_fattr *fattr,
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)
@@ -872,7 +885,7 @@ nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
}
out:
if (status)
- return status;
+ return nfs4_map_errors(status);
return nfs4_proc_fsinfo(server, fhandle, info);
}
@@ -887,7 +900,7 @@ nfs4_proc_getattr(struct inode *inode, struct nfs_fattr *fattr)
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));
}
/*
@@ -973,7 +986,7 @@ nfs4_proc_lookup(struct inode *dir, struct qstr *name,
if (status >= 0)
status = nfs_refresh_inode(dir, &dir_attr);
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -1020,7 +1033,7 @@ nfs4_proc_access(struct inode *inode, struct rpc_cred *cred, int mode)
else if (req_access != resp_access)
status = -EACCES;
}
- return status;
+ return nfs4_map_errors(status);
}
/*
@@ -1056,7 +1069,7 @@ nfs4_proc_readlink(struct inode *inode, struct page *page)
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
@@ -1095,7 +1108,7 @@ nfs4_proc_read(struct nfs_read_data *rdata, struct file *filp)
if (!status)
renew_lease(server, timestamp);
dprintk("NFS reply read: %d\n", status);
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -1131,7 +1144,7 @@ nfs4_proc_write(struct nfs_write_data *wdata, struct file *filp)
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
@@ -1166,7 +1179,7 @@ nfs4_proc_commit(struct nfs_write_data *cdata, struct file *filp)
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);
}
/*
@@ -1233,7 +1246,7 @@ nfs4_proc_remove(struct inode *dir, struct qstr *name)
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
struct unlink_desc {
@@ -1311,7 +1324,7 @@ nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
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
@@ -1341,7 +1354,7 @@ nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
nfs_refresh_inode(dir, &dir_attr);
nfs_refresh_inode(inode, &fattr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -1372,7 +1385,7 @@ nfs4_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -1402,7 +1415,7 @@ nfs4_proc_mkdir(struct inode *dir, struct qstr *name, struct iattr *sattr,
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -1420,9 +1433,11 @@ nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
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
@@ -1452,7 +1467,7 @@ nfs4_proc_mknod(struct inode *dir, struct qstr *name, struct iattr *sattr,
process_cinfo(&dir_cinfo, &dir_attr);
nfs_refresh_inode(dir, &dir_attr);
}
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -1465,7 +1480,7 @@ nfs4_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
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
@@ -1478,7 +1493,7 @@ nfs4_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
.rpc_resp = fsinfo,
};
- return rpc_call_sync(server->client, &msg, 0);
+ return nfs4_map_errors(rpc_call_sync(server->client, &msg, 0));
}
static int
@@ -1491,7 +1506,7 @@ nfs4_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
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
@@ -1829,7 +1844,7 @@ nfs4_async_handle_error(struct rpc_task *task, struct nfs_server *server)
{
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:
@@ -1848,6 +1863,7 @@ nfs4_async_handle_error(struct rpc_task *task, struct nfs_server *server)
task->tk_status = 0;
return -EAGAIN;
}
+ task->tk_status = nfs4_map_errors(task->tk_status);
return 0;
}
@@ -1925,16 +1941,9 @@ nfs4_handle_error(struct nfs_server *server, int errorcode)
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);
}
@@ -2109,7 +2118,7 @@ nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock *request)
if (lsp)
nfs4_put_lock_state(lsp);
up(&state->lock_sema);
- return status;
+ return nfs4_map_errors(status);
}
int
@@ -2154,7 +2163,7 @@ nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
nfs4_put_lock_state(lsp);
out:
up(&state->lock_sema);
- return status;
+ return nfs4_map_errors(status);
}
static int
@@ -2230,7 +2239,7 @@ nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
nfs4_put_lock_state(lsp);
out:
up(&state->lock_sema);
- return status;
+ return nfs4_map_errors(status);
}
static int
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 0694b2e13342..2be56d994d50 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -790,7 +790,7 @@ reclaimer(void *ptr)
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);
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index f0a688fa675d..0c0c85880403 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -69,84 +69,84 @@ static int nfs_stat_to_errno(int);
/* 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 + \
@@ -154,107 +154,107 @@ static int nfs_stat_to_errno(int);
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)
@@ -3165,6 +3165,10 @@ static struct {
{ 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 }
};
@@ -3180,6 +3184,10 @@ nfs_stat_to_errno(int stat)
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
diff --git a/include/linux/lockd/debug.h b/include/linux/lockd/debug.h
index d494aeb6be74..5b6961d739d4 100644
--- a/include/linux/lockd/debug.h
+++ b/include/linux/lockd/debug.h
@@ -23,7 +23,7 @@
#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
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 5e3dba36c02b..6686e0a84323 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -691,7 +691,7 @@ struct nfs4_mount_data;
#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
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index ca9c4ec73b73..aee7a98a9136 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -54,7 +54,7 @@ extern unsigned int nlm_debug;
#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