NFS: clarify some NFS error handling
Subsystems (3)
cover NFS: clarify some NFS error handling
While trying to trace how NFS handles certain error conditions, I was confused by some impossible to trigger error checks, and unused return values. These patches remove those.
Fred
PATCH 1/4 RPC: remove check for impossible condition in rpc_make_runnable
queue_work() only returns 0 or 1, never a negative value.
--- net/sunrpc/sched.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
net/sunrpc/sched.c +1 -8
@@ -285,15 +285,8 @@ static void rpc_make_runnable(struct rpc_task *task)if (rpc_test_and_set_running (task))return ;if (RPC_IS_ASYNC (task)) { -int status; -INIT_WORK (&task->u.tk_work, rpc_async_schedule); - status =queue_work (rpciod_workqueue, &task->u.tk_work); -if (status <0 ) { -printk (KERN_WARNING "RPC: failed to add task to queue: error: %d!\n" , status); - task->tk_status = status; -return ; - } +queue_work (rpciod_workqueue, &task->u.tk_work); }else wake_up_bit (&task->tk_runstate,RPC_TASK_QUEUED ); }
Signature · 1 line
1.7.2.1
PATCH 2/4 RPC: clarify rpc_run_task error handling
In reply to Fred Isamanrpc_run_task can only fail if it is not passed in a preallocated task. However, that is not at all clear with the current code. So remove several impossible to occur failure checks.
--- net/sunrpc/clnt.c | 6 ------ net/sunrpc/sched.c | 6 ------ 2 files changed, 0 insertions(+), 12 deletions(-)
net/sunrpc/clnt.c +0 -6
@@ -636,12 +636,6 @@ struct rpc_task *rpc_run_task(const struct rpc_task_setup *task_setup_data)rpc_task_set_client (task, task_setup_data->rpc_client);rpc_task_set_rpc_message (task, task_setup_data->rpc_message); -if (task->tk_status !=0 ) { -int ret = task->tk_status; -rpc_put_task (task); -return ERR_PTR (ret); - } -if (task->tk_action ==NULL )rpc_call_start (task);
net/sunrpc/sched.c +0 -6
@@ -822,12 +822,6 @@ struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data) }rpc_init_task (task, setup_data); -if (task->tk_status <0 ) { -int err = task->tk_status; -rpc_put_task (task); -return ERR_PTR (err); - } - task->tk_flags |= flags;dprintk ("RPC: allocated task %p\n" , task);return task;
Signature · 1 line
1.7.2.1
PATCH 3/4 NFS: remove pointless if statement in nfs_direct_write_result
In reply to Fred IsamanThe code was doing nothing more in either branch of the if.
--- fs/nfs/direct.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
fs/nfs/direct.c +1 -2
@@ -649,8 +649,7 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata) {struct nfs_write_data *data = calldata; -if (nfs_writeback_done (task, data) !=0 ) -return ; +nfs_writeback_done (task, data); }/*
Signature · 1 line
1.7.2.1
PATCH 4/4 NFS: change nfs_writeback_done to return void
In reply to Fred IsamanThe return values are not used by any callers.
--- fs/nfs/write.c | 8 ++++---- include/linux/nfs_fs.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/nfs/write.c +4 -4
@@ -1132,7 +1132,7 @@ static const struct rpc_call_ops nfs_write_full_ops = {/* * This function is called when the WRITE call is complete. */ -int nfs_writeback_done (struct rpc_task *task,struct nfs_write_data *data) +void nfs_writeback_done (struct rpc_task *task,struct nfs_write_data *data) {struct nfs_writeargs *argp = &data->args;struct nfs_writeres *resp = &data->res;
@@ -1151,7 +1151,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)*/ status =NFS_PROTO (data->inode)->write_done (task, data);if (status !=0 ) -return status; +return ;nfs_add_stats (data->inode,NFSIOS_SERVERWRITTENBYTES , resp->count);#if defined(CONFIG_NFS_V3 ) || defined(CONFIG_NFS_V4 )
@@ -1196,7 +1196,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) argp->stable =NFS_FILE_SYNC ; }nfs_restart_rpc (task, server->nfs_client); -return -EAGAIN ; +return ; }if (time_before (complain, jiffies)) { printk(KERN_WARNING
@@ -1207,7 +1207,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)/* Can't do anything about it except throw an error. */ task->tk_status = -EIO ; } -return 0 ; +return ; }
include/linux/nfs_fs.h +1 -1
@@ -501,7 +501,7 @@ extern int nfs_writepage(struct page *page, struct writeback_control *wbc);extern int nfs_writepages (struct address_space *,struct writeback_control *);extern int nfs_flush_incompatible (struct file *file,struct page *page);extern int nfs_updatepage (struct file *,struct page *,unsigned int ,unsigned int ); -extern int nfs_writeback_done (struct rpc_task *,struct nfs_write_data *); +extern void nfs_writeback_done (struct rpc_task *,struct nfs_write_data *);/* * Try to write back everything synchronously (but check the
Signature · 1 line
1.7.2.1