Merge git://git.linux-nfs.org/projects/trondmy/nfs-2.6
* git://git.linux-nfs.org/projects/trondmy/nfs-2.6: (80 commits) SUNRPC: Invalidate the RPCSEC_GSS session if the server dropped the request make nfs_automount_list static NFS: remove duplicate flags assignment from nfs_validate_mount_data NFS - fix potential NULL pointer dereference v2 SUNRPC: Don't change the RPCSEC_GSS context on a credential that is in use SUNRPC: Fix a race in gss_refresh_upcall() SUNRPC: Don't disconnect more than once if retransmitting NFSv4 requests SUNRPC: Remove the unused export of xprt_force_disconnect SUNRPC: remove XS_SENDMSG_RETRY SUNRPC: Protect creds against early garbage collection NFSv4: Attempt to use machine credentials in SETCLIENTID calls NFSv4: Reintroduce machine creds NFSv4: Don't use cred->cr_ops->cr_name in nfs4_proc_setclientid() nfs: fix printout of multiword bitfields nfs: return negative error value from nfs{,4}_stat_to_errno NLM/lockd: Ensure client locking calls use correct credentials NFS: Remove the buggy lock-if-signalled case from do_setlk() NLM/lockd: Fix a race when cancelling a blocking lock NLM/lockd: Ensure that nlmclnt_cancel() returns results of the CANCEL call NLM: Remove the signal masking in nlmclnt_proc/nlmclnt_cancel ...
Cette révision appartient à :
@@ -5,7 +5,7 @@
|
||||
obj-$(CONFIG_NFS_FS) += nfs.o
|
||||
|
||||
nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \
|
||||
pagelist.o proc.o read.o symlink.o unlink.o \
|
||||
direct.o pagelist.o proc.o read.o symlink.o unlink.o \
|
||||
write.o namespace.o mount_clnt.o
|
||||
nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
|
||||
nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o
|
||||
@@ -14,5 +14,4 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
|
||||
delegation.o idmap.o \
|
||||
callback.o callback_xdr.o callback_proc.o \
|
||||
nfs4namespace.o
|
||||
nfs-$(CONFIG_NFS_DIRECTIO) += direct.o
|
||||
nfs-$(CONFIG_SYSCTL) += sysctl.o
|
||||
|
@@ -112,6 +112,7 @@ struct nfs_client_initdata {
|
||||
static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
|
||||
{
|
||||
struct nfs_client *clp;
|
||||
struct rpc_cred *cred;
|
||||
|
||||
if ((clp = kzalloc(sizeof(*clp), GFP_KERNEL)) == NULL)
|
||||
goto error_0;
|
||||
@@ -150,6 +151,9 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
|
||||
clp->cl_boot_time = CURRENT_TIME;
|
||||
clp->cl_state = 1 << NFS4CLNT_LEASE_EXPIRED;
|
||||
#endif
|
||||
cred = rpc_lookup_machine_cred();
|
||||
if (!IS_ERR(cred))
|
||||
clp->cl_machine_cred = cred;
|
||||
|
||||
return clp;
|
||||
|
||||
@@ -170,6 +174,8 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
|
||||
BUG_ON(!RB_EMPTY_ROOT(&clp->cl_state_owners));
|
||||
if (__test_and_clear_bit(NFS_CS_IDMAP, &clp->cl_res_state))
|
||||
nfs_idmap_delete(clp);
|
||||
|
||||
rpc_destroy_wait_queue(&clp->cl_rpcwaitq);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -189,6 +195,9 @@ static void nfs_free_client(struct nfs_client *clp)
|
||||
if (__test_and_clear_bit(NFS_CS_CALLBACK, &clp->cl_res_state))
|
||||
nfs_callback_down();
|
||||
|
||||
if (clp->cl_machine_cred != NULL)
|
||||
put_rpccred(clp->cl_machine_cred);
|
||||
|
||||
kfree(clp->cl_hostname);
|
||||
kfree(clp);
|
||||
|
||||
@@ -680,10 +689,22 @@ static int nfs_init_server(struct nfs_server *server,
|
||||
if (error < 0)
|
||||
goto error;
|
||||
|
||||
server->port = data->nfs_server.port;
|
||||
|
||||
error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
|
||||
if (error < 0)
|
||||
goto error;
|
||||
|
||||
/* Preserve the values of mount_server-related mount options */
|
||||
if (data->mount_server.addrlen) {
|
||||
memcpy(&server->mountd_address, &data->mount_server.address,
|
||||
data->mount_server.addrlen);
|
||||
server->mountd_addrlen = data->mount_server.addrlen;
|
||||
}
|
||||
server->mountd_version = data->mount_server.version;
|
||||
server->mountd_port = data->mount_server.port;
|
||||
server->mountd_protocol = data->mount_server.protocol;
|
||||
|
||||
server->namelen = data->namlen;
|
||||
/* Create a client RPC handle for the NFSv3 ACL management interface */
|
||||
nfs_init_server_aclclient(server);
|
||||
@@ -1062,6 +1083,8 @@ static int nfs4_init_server(struct nfs_server *server,
|
||||
server->acdirmin = data->acdirmin * HZ;
|
||||
server->acdirmax = data->acdirmax * HZ;
|
||||
|
||||
server->port = data->nfs_server.port;
|
||||
|
||||
error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
|
||||
|
||||
error:
|
||||
|
@@ -1967,7 +1967,7 @@ force_lookup:
|
||||
if (!NFS_PROTO(inode)->access)
|
||||
goto out_notsup;
|
||||
|
||||
cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
|
||||
cred = rpc_lookup_cred();
|
||||
if (!IS_ERR(cred)) {
|
||||
res = nfs_do_access(inode, cred, mask);
|
||||
put_rpccred(cred);
|
||||
|
@@ -229,14 +229,20 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq)
|
||||
static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_read_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
|
||||
if (nfs_readpage_result(task, data) != 0)
|
||||
return;
|
||||
nfs_readpage_result(task, data);
|
||||
}
|
||||
|
||||
static void nfs_direct_read_release(void *calldata)
|
||||
{
|
||||
|
||||
struct nfs_read_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
spin_lock(&dreq->lock);
|
||||
if (unlikely(task->tk_status < 0)) {
|
||||
dreq->error = task->tk_status;
|
||||
if (unlikely(status < 0)) {
|
||||
dreq->error = status;
|
||||
spin_unlock(&dreq->lock);
|
||||
} else {
|
||||
dreq->count += data->res.count;
|
||||
@@ -249,11 +255,12 @@ static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
|
||||
|
||||
if (put_dreq(dreq))
|
||||
nfs_direct_complete(dreq);
|
||||
nfs_readdata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_read_direct_ops = {
|
||||
.rpc_call_done = nfs_direct_read_result,
|
||||
.rpc_release = nfs_readdata_release,
|
||||
.rpc_release = nfs_direct_read_release,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -280,6 +287,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
|
||||
.rpc_client = NFS_CLIENT(inode),
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs_read_direct_ops,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
unsigned int pgbase;
|
||||
@@ -323,7 +331,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
|
||||
data->inode = inode;
|
||||
data->cred = msg.rpc_cred;
|
||||
data->args.fh = NFS_FH(inode);
|
||||
data->args.context = ctx;
|
||||
data->args.context = get_nfs_open_context(ctx);
|
||||
data->args.offset = pos;
|
||||
data->args.pgbase = pgbase;
|
||||
data->args.pages = data->pagevec;
|
||||
@@ -339,8 +347,9 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
|
||||
NFS_PROTO(inode)->read_setup(data, &msg);
|
||||
|
||||
task = rpc_run_task(&task_setup_data);
|
||||
if (!IS_ERR(task))
|
||||
rpc_put_task(task);
|
||||
if (IS_ERR(task))
|
||||
break;
|
||||
rpc_put_task(task);
|
||||
|
||||
dprintk("NFS: %5u initiated direct read call "
|
||||
"(req %s/%Ld, %zu bytes @ offset %Lu)\n",
|
||||
@@ -446,6 +455,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
|
||||
struct rpc_task_setup task_setup_data = {
|
||||
.rpc_client = NFS_CLIENT(inode),
|
||||
.callback_ops = &nfs_write_direct_ops,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
|
||||
@@ -499,27 +509,34 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
|
||||
static void nfs_direct_commit_result(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
|
||||
/* Call the NFS version-specific code */
|
||||
if (NFS_PROTO(data->inode)->commit_done(task, data) != 0)
|
||||
return;
|
||||
if (unlikely(task->tk_status < 0)) {
|
||||
NFS_PROTO(data->inode)->commit_done(task, data);
|
||||
}
|
||||
|
||||
static void nfs_direct_commit_release(void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
if (status < 0) {
|
||||
dprintk("NFS: %5u commit failed with error %d.\n",
|
||||
task->tk_pid, task->tk_status);
|
||||
data->task.tk_pid, status);
|
||||
dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
|
||||
} else if (memcmp(&dreq->verf, &data->verf, sizeof(data->verf))) {
|
||||
dprintk("NFS: %5u commit verify failed\n", task->tk_pid);
|
||||
dprintk("NFS: %5u commit verify failed\n", data->task.tk_pid);
|
||||
dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
|
||||
}
|
||||
|
||||
dprintk("NFS: %5u commit returned %d\n", task->tk_pid, task->tk_status);
|
||||
dprintk("NFS: %5u commit returned %d\n", data->task.tk_pid, status);
|
||||
nfs_direct_write_complete(dreq, data->inode);
|
||||
nfs_commitdata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_commit_direct_ops = {
|
||||
.rpc_call_done = nfs_direct_commit_result,
|
||||
.rpc_release = nfs_commit_release,
|
||||
.rpc_release = nfs_direct_commit_release,
|
||||
};
|
||||
|
||||
static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
|
||||
@@ -537,6 +554,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs_commit_direct_ops,
|
||||
.callback_data = data,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
|
||||
@@ -546,6 +564,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
|
||||
data->args.fh = NFS_FH(data->inode);
|
||||
data->args.offset = 0;
|
||||
data->args.count = 0;
|
||||
data->args.context = get_nfs_open_context(dreq->ctx);
|
||||
data->res.count = 0;
|
||||
data->res.fattr = &data->fattr;
|
||||
data->res.verf = &data->verf;
|
||||
@@ -585,7 +604,7 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
|
||||
|
||||
static void nfs_alloc_commit_data(struct nfs_direct_req *dreq)
|
||||
{
|
||||
dreq->commit_data = nfs_commit_alloc();
|
||||
dreq->commit_data = nfs_commitdata_alloc();
|
||||
if (dreq->commit_data != NULL)
|
||||
dreq->commit_data->req = (struct nfs_page *) dreq;
|
||||
}
|
||||
@@ -606,11 +625,20 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
|
||||
static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
int status = task->tk_status;
|
||||
|
||||
if (nfs_writeback_done(task, data) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* NB: Return the value of the first error return code. Subsequent
|
||||
* errors after the first one are ignored.
|
||||
*/
|
||||
static void nfs_direct_write_release(void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
spin_lock(&dreq->lock);
|
||||
|
||||
@@ -632,23 +660,13 @@ static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
|
||||
break;
|
||||
case NFS_ODIRECT_DO_COMMIT:
|
||||
if (memcmp(&dreq->verf, &data->verf, sizeof(dreq->verf))) {
|
||||
dprintk("NFS: %5u write verify failed\n", task->tk_pid);
|
||||
dprintk("NFS: %5u write verify failed\n", data->task.tk_pid);
|
||||
dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
|
||||
}
|
||||
}
|
||||
}
|
||||
out_unlock:
|
||||
spin_unlock(&dreq->lock);
|
||||
}
|
||||
|
||||
/*
|
||||
* NB: Return the value of the first error return code. Subsequent
|
||||
* errors after the first one are ignored.
|
||||
*/
|
||||
static void nfs_direct_write_release(void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
|
||||
|
||||
if (put_dreq(dreq))
|
||||
nfs_direct_write_complete(dreq, data->inode);
|
||||
@@ -682,6 +700,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
|
||||
.rpc_client = NFS_CLIENT(inode),
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs_write_direct_ops,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
size_t wsize = NFS_SERVER(inode)->wsize;
|
||||
@@ -728,7 +747,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
|
||||
data->inode = inode;
|
||||
data->cred = msg.rpc_cred;
|
||||
data->args.fh = NFS_FH(inode);
|
||||
data->args.context = ctx;
|
||||
data->args.context = get_nfs_open_context(ctx);
|
||||
data->args.offset = pos;
|
||||
data->args.pgbase = pgbase;
|
||||
data->args.pages = data->pagevec;
|
||||
@@ -745,8 +764,9 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
|
||||
NFS_PROTO(inode)->write_setup(data, &msg);
|
||||
|
||||
task = rpc_run_task(&task_setup_data);
|
||||
if (!IS_ERR(task))
|
||||
rpc_put_task(task);
|
||||
if (IS_ERR(task))
|
||||
break;
|
||||
rpc_put_task(task);
|
||||
|
||||
dprintk("NFS: %5u initiated direct write call "
|
||||
"(req %s/%Ld, %zu bytes @ offset %Lu)\n",
|
||||
|
@@ -238,10 +238,8 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
|
||||
ssize_t result;
|
||||
size_t count = iov_length(iov, nr_segs);
|
||||
|
||||
#ifdef CONFIG_NFS_DIRECTIO
|
||||
if (iocb->ki_filp->f_flags & O_DIRECT)
|
||||
return nfs_file_direct_read(iocb, iov, nr_segs, pos);
|
||||
#endif
|
||||
|
||||
dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n",
|
||||
dentry->d_parent->d_name.name, dentry->d_name.name,
|
||||
@@ -387,9 +385,7 @@ const struct address_space_operations nfs_file_aops = {
|
||||
.write_end = nfs_write_end,
|
||||
.invalidatepage = nfs_invalidate_page,
|
||||
.releasepage = nfs_release_page,
|
||||
#ifdef CONFIG_NFS_DIRECTIO
|
||||
.direct_IO = nfs_direct_IO,
|
||||
#endif
|
||||
.launder_page = nfs_launder_page,
|
||||
};
|
||||
|
||||
@@ -447,10 +443,8 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
|
||||
ssize_t result;
|
||||
size_t count = iov_length(iov, nr_segs);
|
||||
|
||||
#ifdef CONFIG_NFS_DIRECTIO
|
||||
if (iocb->ki_filp->f_flags & O_DIRECT)
|
||||
return nfs_file_direct_write(iocb, iov, nr_segs, pos);
|
||||
#endif
|
||||
|
||||
dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%Ld)\n",
|
||||
dentry->d_parent->d_name.name, dentry->d_name.name,
|
||||
@@ -576,17 +570,9 @@ static int do_setlk(struct file *filp, int cmd, struct file_lock *fl)
|
||||
|
||||
lock_kernel();
|
||||
/* Use local locking if mounted with "-onolock" */
|
||||
if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)) {
|
||||
if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM))
|
||||
status = NFS_PROTO(inode)->lock(filp, cmd, fl);
|
||||
/* If we were signalled we still need to ensure that
|
||||
* we clean up any state on the server. We therefore
|
||||
* record the lock call as having succeeded in order to
|
||||
* ensure that locks_remove_posix() cleans it out when
|
||||
* the process exits.
|
||||
*/
|
||||
if (status == -EINTR || status == -ERESTARTSYS)
|
||||
do_vfs_lock(filp, fl);
|
||||
} else
|
||||
else
|
||||
status = do_vfs_lock(filp, fl);
|
||||
unlock_kernel();
|
||||
if (status < 0)
|
||||
|
@@ -523,8 +523,12 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)
|
||||
|
||||
static void __put_nfs_open_context(struct nfs_open_context *ctx, int wait)
|
||||
{
|
||||
struct inode *inode = ctx->path.dentry->d_inode;
|
||||
struct inode *inode;
|
||||
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
|
||||
inode = ctx->path.dentry->d_inode;
|
||||
if (!atomic_dec_and_lock(&ctx->count, &inode->i_lock))
|
||||
return;
|
||||
list_del(&ctx->list);
|
||||
@@ -610,7 +614,7 @@ int nfs_open(struct inode *inode, struct file *filp)
|
||||
struct nfs_open_context *ctx;
|
||||
struct rpc_cred *cred;
|
||||
|
||||
cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
|
||||
cred = rpc_lookup_cred();
|
||||
if (IS_ERR(cred))
|
||||
return PTR_ERR(cred);
|
||||
ctx = alloc_nfs_open_context(filp->f_path.mnt, filp->f_path.dentry, cred);
|
||||
@@ -1218,6 +1222,36 @@ static void nfs_destroy_inodecache(void)
|
||||
kmem_cache_destroy(nfs_inode_cachep);
|
||||
}
|
||||
|
||||
struct workqueue_struct *nfsiod_workqueue;
|
||||
|
||||
/*
|
||||
* start up the nfsiod workqueue
|
||||
*/
|
||||
static int nfsiod_start(void)
|
||||
{
|
||||
struct workqueue_struct *wq;
|
||||
dprintk("RPC: creating workqueue nfsiod\n");
|
||||
wq = create_singlethread_workqueue("nfsiod");
|
||||
if (wq == NULL)
|
||||
return -ENOMEM;
|
||||
nfsiod_workqueue = wq;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy the nfsiod workqueue
|
||||
*/
|
||||
static void nfsiod_stop(void)
|
||||
{
|
||||
struct workqueue_struct *wq;
|
||||
|
||||
wq = nfsiod_workqueue;
|
||||
if (wq == NULL)
|
||||
return;
|
||||
nfsiod_workqueue = NULL;
|
||||
destroy_workqueue(wq);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize NFS
|
||||
*/
|
||||
@@ -1225,6 +1259,10 @@ static int __init init_nfs_fs(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = nfsiod_start();
|
||||
if (err)
|
||||
goto out6;
|
||||
|
||||
err = nfs_fs_proc_init();
|
||||
if (err)
|
||||
goto out5;
|
||||
@@ -1271,6 +1309,8 @@ out3:
|
||||
out4:
|
||||
nfs_fs_proc_exit();
|
||||
out5:
|
||||
nfsiod_stop();
|
||||
out6:
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1286,6 +1326,7 @@ static void __exit exit_nfs_fs(void)
|
||||
#endif
|
||||
unregister_nfs_fs();
|
||||
nfs_fs_proc_exit();
|
||||
nfsiod_stop();
|
||||
}
|
||||
|
||||
/* Not quite true; I just maintain it */
|
||||
|
@@ -46,9 +46,9 @@ struct nfs_parsed_mount_data {
|
||||
struct sockaddr_storage address;
|
||||
size_t addrlen;
|
||||
char *hostname;
|
||||
unsigned int version;
|
||||
u32 version;
|
||||
unsigned short port;
|
||||
int protocol;
|
||||
unsigned short protocol;
|
||||
} mount_server;
|
||||
|
||||
struct {
|
||||
@@ -56,7 +56,8 @@ struct nfs_parsed_mount_data {
|
||||
size_t addrlen;
|
||||
char *hostname;
|
||||
char *export_path;
|
||||
int protocol;
|
||||
unsigned short port;
|
||||
unsigned short protocol;
|
||||
} nfs_server;
|
||||
|
||||
struct security_mnt_opts lsm_opts;
|
||||
@@ -115,13 +116,8 @@ extern void nfs_destroy_readpagecache(void);
|
||||
extern int __init nfs_init_writepagecache(void);
|
||||
extern void nfs_destroy_writepagecache(void);
|
||||
|
||||
#ifdef CONFIG_NFS_DIRECTIO
|
||||
extern int __init nfs_init_directcache(void);
|
||||
extern void nfs_destroy_directcache(void);
|
||||
#else
|
||||
#define nfs_init_directcache() (0)
|
||||
#define nfs_destroy_directcache() do {} while(0)
|
||||
#endif
|
||||
|
||||
/* nfs2xdr.c */
|
||||
extern int nfs_stat_to_errno(int);
|
||||
@@ -146,6 +142,7 @@ extern struct rpc_procinfo nfs4_procedures[];
|
||||
extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask);
|
||||
|
||||
/* inode.c */
|
||||
extern struct workqueue_struct *nfsiod_workqueue;
|
||||
extern struct inode *nfs_alloc_inode(struct super_block *sb);
|
||||
extern void nfs_destroy_inode(struct inode *);
|
||||
extern int nfs_write_inode(struct inode *,int);
|
||||
|
@@ -20,7 +20,7 @@
|
||||
|
||||
static void nfs_expire_automounts(struct work_struct *work);
|
||||
|
||||
LIST_HEAD(nfs_automount_list);
|
||||
static LIST_HEAD(nfs_automount_list);
|
||||
static DECLARE_DELAYED_WORK(nfs_automount_task, nfs_expire_automounts);
|
||||
int nfs_mountpoint_expiry_timeout = 500 * HZ;
|
||||
|
||||
|
113
fs/nfs/nfs2xdr.c
113
fs/nfs/nfs2xdr.c
@@ -267,7 +267,7 @@ nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
p = xdr_decode_fattr(p, res->fattr);
|
||||
|
||||
count = ntohl(*p++);
|
||||
@@ -428,11 +428,11 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
|
||||
size_t hdrlen;
|
||||
unsigned int pglen, recvd;
|
||||
u32 len;
|
||||
int status, nr;
|
||||
int status, nr = 0;
|
||||
__be32 *end, *entry, *kaddr;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
hdrlen = (u8 *) p - (u8 *) iov->iov_base;
|
||||
if (iov->iov_len < hdrlen) {
|
||||
@@ -452,7 +452,12 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
|
||||
kaddr = p = kmap_atomic(*page, KM_USER0);
|
||||
end = (__be32 *)((char *)p + pglen);
|
||||
entry = p;
|
||||
for (nr = 0; *p++; nr++) {
|
||||
|
||||
/* Make sure the packet actually has a value_follows and EOF entry */
|
||||
if ((entry + 1) > end)
|
||||
goto short_pkt;
|
||||
|
||||
for (; *p++; nr++) {
|
||||
if (p + 2 > end)
|
||||
goto short_pkt;
|
||||
p++; /* fileid */
|
||||
@@ -467,18 +472,32 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy)
|
||||
goto short_pkt;
|
||||
entry = p;
|
||||
}
|
||||
if (!nr && (entry[0] != 0 || entry[1] == 0))
|
||||
goto short_pkt;
|
||||
|
||||
/*
|
||||
* Apparently some server sends responses that are a valid size, but
|
||||
* contain no entries, and have value_follows==0 and EOF==0. For
|
||||
* those, just set the EOF marker.
|
||||
*/
|
||||
if (!nr && entry[1] == 0) {
|
||||
dprintk("NFS: readdir reply truncated!\n");
|
||||
entry[1] = 1;
|
||||
}
|
||||
out:
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
return nr;
|
||||
short_pkt:
|
||||
/*
|
||||
* When we get a short packet there are 2 possibilities. We can
|
||||
* return an error, or fix up the response to look like a valid
|
||||
* response and return what we have so far. If there are no
|
||||
* entries and the packet was short, then return -EIO. If there
|
||||
* are valid entries in the response, return them and pretend that
|
||||
* the call was successful, but incomplete. The caller can retry the
|
||||
* readdir starting at the last cookie.
|
||||
*/
|
||||
entry[0] = entry[1] = 0;
|
||||
/* truncate listing ? */
|
||||
if (!nr) {
|
||||
dprintk("NFS: readdir reply truncated!\n");
|
||||
entry[1] = 1;
|
||||
}
|
||||
if (!nr)
|
||||
nr = -errno_NFSERR_IO;
|
||||
goto out;
|
||||
err_unmap:
|
||||
nr = -errno_NFSERR_IO;
|
||||
@@ -518,7 +537,7 @@ nfs_xdr_stat(struct rpc_rqst *req, __be32 *p, void *dummy)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)) != 0)
|
||||
status = -nfs_stat_to_errno(status);
|
||||
status = nfs_stat_to_errno(status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -532,7 +551,7 @@ nfs_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
xdr_decode_fattr(p, fattr);
|
||||
return 0;
|
||||
}
|
||||
@@ -547,7 +566,7 @@ nfs_xdr_diropres(struct rpc_rqst *req, __be32 *p, struct nfs_diropok *res)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
p = xdr_decode_fhandle(p, res->fh);
|
||||
xdr_decode_fattr(p, res->fattr);
|
||||
return 0;
|
||||
@@ -585,7 +604,7 @@ nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
/* Convert length of symlink */
|
||||
len = ntohl(*p++);
|
||||
if (len >= rcvbuf->page_len) {
|
||||
@@ -634,7 +653,7 @@ nfs_xdr_statfsres(struct rpc_rqst *req, __be32 *p, struct nfs2_fsstat *res)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
res->tsize = ntohl(*p++);
|
||||
res->bsize = ntohl(*p++);
|
||||
@@ -653,39 +672,39 @@ static struct {
|
||||
int errno;
|
||||
} nfs_errtbl[] = {
|
||||
{ NFS_OK, 0 },
|
||||
{ NFSERR_PERM, EPERM },
|
||||
{ NFSERR_NOENT, ENOENT },
|
||||
{ NFSERR_IO, errno_NFSERR_IO },
|
||||
{ NFSERR_NXIO, ENXIO },
|
||||
/* { NFSERR_EAGAIN, EAGAIN }, */
|
||||
{ NFSERR_ACCES, EACCES },
|
||||
{ NFSERR_EXIST, EEXIST },
|
||||
{ NFSERR_XDEV, EXDEV },
|
||||
{ NFSERR_NODEV, ENODEV },
|
||||
{ NFSERR_NOTDIR, ENOTDIR },
|
||||
{ NFSERR_ISDIR, EISDIR },
|
||||
{ NFSERR_INVAL, EINVAL },
|
||||
{ NFSERR_FBIG, EFBIG },
|
||||
{ NFSERR_NOSPC, ENOSPC },
|
||||
{ NFSERR_ROFS, EROFS },
|
||||
{ NFSERR_MLINK, EMLINK },
|
||||
{ NFSERR_NAMETOOLONG, ENAMETOOLONG },
|
||||
{ NFSERR_NOTEMPTY, ENOTEMPTY },
|
||||
{ NFSERR_DQUOT, EDQUOT },
|
||||
{ NFSERR_STALE, ESTALE },
|
||||
{ NFSERR_REMOTE, EREMOTE },
|
||||
{ NFSERR_PERM, -EPERM },
|
||||
{ NFSERR_NOENT, -ENOENT },
|
||||
{ NFSERR_IO, -errno_NFSERR_IO},
|
||||
{ NFSERR_NXIO, -ENXIO },
|
||||
/* { NFSERR_EAGAIN, -EAGAIN }, */
|
||||
{ NFSERR_ACCES, -EACCES },
|
||||
{ NFSERR_EXIST, -EEXIST },
|
||||
{ NFSERR_XDEV, -EXDEV },
|
||||
{ NFSERR_NODEV, -ENODEV },
|
||||
{ NFSERR_NOTDIR, -ENOTDIR },
|
||||
{ NFSERR_ISDIR, -EISDIR },
|
||||
{ NFSERR_INVAL, -EINVAL },
|
||||
{ NFSERR_FBIG, -EFBIG },
|
||||
{ NFSERR_NOSPC, -ENOSPC },
|
||||
{ NFSERR_ROFS, -EROFS },
|
||||
{ NFSERR_MLINK, -EMLINK },
|
||||
{ NFSERR_NAMETOOLONG, -ENAMETOOLONG },
|
||||
{ NFSERR_NOTEMPTY, -ENOTEMPTY },
|
||||
{ NFSERR_DQUOT, -EDQUOT },
|
||||
{ NFSERR_STALE, -ESTALE },
|
||||
{ NFSERR_REMOTE, -EREMOTE },
|
||||
#ifdef EWFLUSH
|
||||
{ NFSERR_WFLUSH, EWFLUSH },
|
||||
{ NFSERR_WFLUSH, -EWFLUSH },
|
||||
#endif
|
||||
{ NFSERR_BADHANDLE, EBADHANDLE },
|
||||
{ NFSERR_NOT_SYNC, ENOTSYNC },
|
||||
{ NFSERR_BAD_COOKIE, EBADCOOKIE },
|
||||
{ NFSERR_NOTSUPP, ENOTSUPP },
|
||||
{ NFSERR_TOOSMALL, ETOOSMALL },
|
||||
{ NFSERR_SERVERFAULT, ESERVERFAULT },
|
||||
{ NFSERR_BADTYPE, EBADTYPE },
|
||||
{ NFSERR_JUKEBOX, EJUKEBOX },
|
||||
{ -1, EIO }
|
||||
{ NFSERR_BADHANDLE, -EBADHANDLE },
|
||||
{ NFSERR_NOT_SYNC, -ENOTSYNC },
|
||||
{ NFSERR_BAD_COOKIE, -EBADCOOKIE },
|
||||
{ NFSERR_NOTSUPP, -ENOTSUPP },
|
||||
{ NFSERR_TOOSMALL, -ETOOSMALL },
|
||||
{ NFSERR_SERVERFAULT, -ESERVERFAULT },
|
||||
{ NFSERR_BADTYPE, -EBADTYPE },
|
||||
{ NFSERR_JUKEBOX, -EJUKEBOX },
|
||||
{ -1, -EIO }
|
||||
};
|
||||
|
||||
/*
|
||||
|
@@ -508,14 +508,14 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res
|
||||
struct page **page;
|
||||
size_t hdrlen;
|
||||
u32 len, recvd, pglen;
|
||||
int status, nr;
|
||||
int status, nr = 0;
|
||||
__be32 *entry, *end, *kaddr;
|
||||
|
||||
status = ntohl(*p++);
|
||||
/* Decode post_op_attrs */
|
||||
p = xdr_decode_post_op_attr(p, res->dir_attr);
|
||||
if (status)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
/* Decode verifier cookie */
|
||||
if (res->verf) {
|
||||
res->verf[0] = *p++;
|
||||
@@ -542,7 +542,12 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res
|
||||
kaddr = p = kmap_atomic(*page, KM_USER0);
|
||||
end = (__be32 *)((char *)p + pglen);
|
||||
entry = p;
|
||||
for (nr = 0; *p++; nr++) {
|
||||
|
||||
/* Make sure the packet actually has a value_follows and EOF entry */
|
||||
if ((entry + 1) > end)
|
||||
goto short_pkt;
|
||||
|
||||
for (; *p++; nr++) {
|
||||
if (p + 3 > end)
|
||||
goto short_pkt;
|
||||
p += 2; /* inode # */
|
||||
@@ -581,18 +586,32 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res
|
||||
goto short_pkt;
|
||||
entry = p;
|
||||
}
|
||||
if (!nr && (entry[0] != 0 || entry[1] == 0))
|
||||
goto short_pkt;
|
||||
|
||||
/*
|
||||
* Apparently some server sends responses that are a valid size, but
|
||||
* contain no entries, and have value_follows==0 and EOF==0. For
|
||||
* those, just set the EOF marker.
|
||||
*/
|
||||
if (!nr && entry[1] == 0) {
|
||||
dprintk("NFS: readdir reply truncated!\n");
|
||||
entry[1] = 1;
|
||||
}
|
||||
out:
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
return nr;
|
||||
short_pkt:
|
||||
/*
|
||||
* When we get a short packet there are 2 possibilities. We can
|
||||
* return an error, or fix up the response to look like a valid
|
||||
* response and return what we have so far. If there are no
|
||||
* entries and the packet was short, then return -EIO. If there
|
||||
* are valid entries in the response, return them and pretend that
|
||||
* the call was successful, but incomplete. The caller can retry the
|
||||
* readdir starting at the last cookie.
|
||||
*/
|
||||
entry[0] = entry[1] = 0;
|
||||
/* truncate listing ? */
|
||||
if (!nr) {
|
||||
dprintk("NFS: readdir reply truncated!\n");
|
||||
entry[1] = 1;
|
||||
}
|
||||
if (!nr)
|
||||
nr = -errno_NFSERR_IO;
|
||||
goto out;
|
||||
err_unmap:
|
||||
nr = -errno_NFSERR_IO;
|
||||
@@ -732,7 +751,7 @@ nfs3_xdr_attrstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
xdr_decode_fattr(p, fattr);
|
||||
return 0;
|
||||
}
|
||||
@@ -747,7 +766,7 @@ nfs3_xdr_wccstat(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)))
|
||||
status = -nfs_stat_to_errno(status);
|
||||
status = nfs_stat_to_errno(status);
|
||||
xdr_decode_wcc_data(p, fattr);
|
||||
return status;
|
||||
}
|
||||
@@ -767,7 +786,7 @@ nfs3_xdr_lookupres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++))) {
|
||||
status = -nfs_stat_to_errno(status);
|
||||
status = nfs_stat_to_errno(status);
|
||||
} else {
|
||||
if (!(p = xdr_decode_fhandle(p, res->fh)))
|
||||
return -errno_NFSERR_IO;
|
||||
@@ -787,7 +806,7 @@ nfs3_xdr_accessres(struct rpc_rqst *req, __be32 *p, struct nfs3_accessres *res)
|
||||
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
if (status)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
res->access = ntohl(*p++);
|
||||
return 0;
|
||||
}
|
||||
@@ -824,7 +843,7 @@ nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
|
||||
p = xdr_decode_post_op_attr(p, fattr);
|
||||
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
/* Convert length of symlink */
|
||||
len = ntohl(*p++);
|
||||
@@ -872,7 +891,7 @@ nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res)
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
/* Decode reply count and EOF flag. NFSv3 is somewhat redundant
|
||||
* in that it puts the count both in the res struct and in the
|
||||
@@ -922,7 +941,7 @@ nfs3_xdr_writeres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
|
||||
p = xdr_decode_wcc_data(p, res->fattr);
|
||||
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
res->count = ntohl(*p++);
|
||||
res->verf->committed = (enum nfs3_stable_how)ntohl(*p++);
|
||||
@@ -953,7 +972,7 @@ nfs3_xdr_createres(struct rpc_rqst *req, __be32 *p, struct nfs3_diropres *res)
|
||||
res->fattr->valid = 0;
|
||||
}
|
||||
} else {
|
||||
status = -nfs_stat_to_errno(status);
|
||||
status = nfs_stat_to_errno(status);
|
||||
}
|
||||
p = xdr_decode_wcc_data(p, res->dir_attr);
|
||||
return status;
|
||||
@@ -968,7 +987,7 @@ nfs3_xdr_renameres(struct rpc_rqst *req, __be32 *p, struct nfs3_renameres *res)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)) != 0)
|
||||
status = -nfs_stat_to_errno(status);
|
||||
status = nfs_stat_to_errno(status);
|
||||
p = xdr_decode_wcc_data(p, res->fromattr);
|
||||
p = xdr_decode_wcc_data(p, res->toattr);
|
||||
return status;
|
||||
@@ -983,7 +1002,7 @@ nfs3_xdr_linkres(struct rpc_rqst *req, __be32 *p, struct nfs3_linkres *res)
|
||||
int status;
|
||||
|
||||
if ((status = ntohl(*p++)) != 0)
|
||||
status = -nfs_stat_to_errno(status);
|
||||
status = nfs_stat_to_errno(status);
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
p = xdr_decode_wcc_data(p, res->dir_attr);
|
||||
return status;
|
||||
@@ -1001,7 +1020,7 @@ nfs3_xdr_fsstatres(struct rpc_rqst *req, __be32 *p, struct nfs_fsstat *res)
|
||||
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
p = xdr_decode_hyper(p, &res->tbytes);
|
||||
p = xdr_decode_hyper(p, &res->fbytes);
|
||||
@@ -1026,7 +1045,7 @@ nfs3_xdr_fsinfores(struct rpc_rqst *req, __be32 *p, struct nfs_fsinfo *res)
|
||||
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
res->rtmax = ntohl(*p++);
|
||||
res->rtpref = ntohl(*p++);
|
||||
@@ -1054,7 +1073,7 @@ nfs3_xdr_pathconfres(struct rpc_rqst *req, __be32 *p, struct nfs_pathconf *res)
|
||||
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
res->max_link = ntohl(*p++);
|
||||
res->max_namelen = ntohl(*p++);
|
||||
|
||||
@@ -1073,7 +1092,7 @@ nfs3_xdr_commitres(struct rpc_rqst *req, __be32 *p, struct nfs_writeres *res)
|
||||
status = ntohl(*p++);
|
||||
p = xdr_decode_wcc_data(p, res->fattr);
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
|
||||
res->verf->verifier[0] = *p++;
|
||||
res->verf->verifier[1] = *p++;
|
||||
@@ -1095,7 +1114,7 @@ nfs3_xdr_getaclres(struct rpc_rqst *req, __be32 *p,
|
||||
int err, base;
|
||||
|
||||
if (status != 0)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
p = xdr_decode_post_op_attr(p, res->fattr);
|
||||
res->mask = ntohl(*p++);
|
||||
if (res->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
|
||||
@@ -1122,7 +1141,7 @@ nfs3_xdr_setaclres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr)
|
||||
int status = ntohl(*p++);
|
||||
|
||||
if (status)
|
||||
return -nfs_stat_to_errno(status);
|
||||
return nfs_stat_to_errno(status);
|
||||
xdr_decode_post_op_attr(p, fattr);
|
||||
return 0;
|
||||
}
|
||||
|
@@ -51,6 +51,7 @@
|
||||
|
||||
#include "nfs4_fs.h"
|
||||
#include "delegation.h"
|
||||
#include "internal.h"
|
||||
#include "iostat.h"
|
||||
|
||||
#define NFSDBG_FACILITY NFSDBG_PROC
|
||||
@@ -239,6 +240,8 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p)
|
||||
{
|
||||
p->o_res.f_attr = &p->f_attr;
|
||||
p->o_res.dir_attr = &p->dir_attr;
|
||||
p->o_res.seqid = p->o_arg.seqid;
|
||||
p->c_res.seqid = p->c_arg.seqid;
|
||||
p->o_res.server = p->o_arg.server;
|
||||
nfs_fattr_init(&p->f_attr);
|
||||
nfs_fattr_init(&p->dir_attr);
|
||||
@@ -729,7 +732,6 @@ static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
|
||||
renew_lease(data->o_res.server, data->timestamp);
|
||||
data->rpc_done = 1;
|
||||
}
|
||||
nfs_increment_open_seqid(data->rpc_status, data->c_arg.seqid);
|
||||
}
|
||||
|
||||
static void nfs4_open_confirm_release(void *calldata)
|
||||
@@ -773,6 +775,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs4_open_confirm_ops,
|
||||
.callback_data = data,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
int status;
|
||||
@@ -858,7 +861,6 @@ static void nfs4_open_done(struct rpc_task *task, void *calldata)
|
||||
if (!(data->o_res.rflags & NFS4_OPEN_RESULT_CONFIRM))
|
||||
nfs_confirm_seqid(&data->owner->so_seqid, 0);
|
||||
}
|
||||
nfs_increment_open_seqid(data->rpc_status, data->o_arg.seqid);
|
||||
data->rpc_done = 1;
|
||||
}
|
||||
|
||||
@@ -910,6 +912,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs4_open_ops,
|
||||
.callback_data = data,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
int status;
|
||||
@@ -979,11 +982,8 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
|
||||
if (IS_ERR(opendata))
|
||||
return PTR_ERR(opendata);
|
||||
ret = nfs4_open_recover(opendata, state);
|
||||
if (ret == -ESTALE) {
|
||||
/* Invalidate the state owner so we don't ever use it again */
|
||||
nfs4_drop_state_owner(state->owner);
|
||||
if (ret == -ESTALE)
|
||||
d_drop(ctx->path.dentry);
|
||||
}
|
||||
nfs4_opendata_put(opendata);
|
||||
return ret;
|
||||
}
|
||||
@@ -1226,7 +1226,6 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
|
||||
/* hmm. we are done with the inode, and in the process of freeing
|
||||
* the state_owner. we keep this around to process errors
|
||||
*/
|
||||
nfs_increment_open_seqid(task->tk_status, calldata->arg.seqid);
|
||||
switch (task->tk_status) {
|
||||
case 0:
|
||||
nfs_set_open_stateid(state, &calldata->res.stateid, 0);
|
||||
@@ -1315,6 +1314,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
|
||||
.rpc_client = server->client,
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs4_close_ops,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
int status = -ENOMEM;
|
||||
@@ -1332,6 +1332,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
|
||||
goto out_free_calldata;
|
||||
calldata->arg.bitmask = server->attr_bitmask;
|
||||
calldata->res.fattr = &calldata->fattr;
|
||||
calldata->res.seqid = calldata->arg.seqid;
|
||||
calldata->res.server = server;
|
||||
calldata->path.mnt = mntget(path->mnt);
|
||||
calldata->path.dentry = dget(path->dentry);
|
||||
@@ -1404,7 +1405,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
|
||||
BUG_ON(nd->intent.open.flags & O_CREAT);
|
||||
}
|
||||
|
||||
cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0);
|
||||
cred = rpc_lookup_cred();
|
||||
if (IS_ERR(cred))
|
||||
return (struct dentry *)cred;
|
||||
parent = dentry->d_parent;
|
||||
@@ -1439,7 +1440,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st
|
||||
struct rpc_cred *cred;
|
||||
struct nfs4_state *state;
|
||||
|
||||
cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0);
|
||||
cred = rpc_lookup_cred();
|
||||
if (IS_ERR(cred))
|
||||
return PTR_ERR(cred);
|
||||
state = nfs4_do_open(dir, &path, openflags, NULL, cred);
|
||||
@@ -1656,7 +1657,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
|
||||
|
||||
nfs_fattr_init(fattr);
|
||||
|
||||
cred = rpcauth_lookupcred(NFS_CLIENT(inode)->cl_auth, 0);
|
||||
cred = rpc_lookup_cred();
|
||||
if (IS_ERR(cred))
|
||||
return PTR_ERR(cred);
|
||||
|
||||
@@ -1892,7 +1893,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
|
||||
struct rpc_cred *cred;
|
||||
int status = 0;
|
||||
|
||||
cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0);
|
||||
cred = rpc_lookup_cred();
|
||||
if (IS_ERR(cred)) {
|
||||
status = PTR_ERR(cred);
|
||||
goto out;
|
||||
@@ -2761,10 +2762,10 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server)
|
||||
case -NFS4ERR_STALE_CLIENTID:
|
||||
case -NFS4ERR_STALE_STATEID:
|
||||
case -NFS4ERR_EXPIRED:
|
||||
rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL, NULL);
|
||||
rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL);
|
||||
nfs4_schedule_state_recovery(clp);
|
||||
if (test_bit(NFS4CLNT_STATE_RECOVER, &clp->cl_state) == 0)
|
||||
rpc_wake_up_task(task);
|
||||
rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task);
|
||||
task->tk_status = 0;
|
||||
return -EAGAIN;
|
||||
case -NFS4ERR_DELAY:
|
||||
@@ -2884,7 +2885,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po
|
||||
RPC_DISPLAY_ADDR),
|
||||
rpc_peeraddr2str(clp->cl_rpcclient,
|
||||
RPC_DISPLAY_PROTO),
|
||||
cred->cr_ops->cr_name,
|
||||
clp->cl_rpcclient->cl_auth->au_ops->au_name,
|
||||
clp->cl_id_uniquifier);
|
||||
setclientid.sc_netid_len = scnprintf(setclientid.sc_netid,
|
||||
sizeof(setclientid.sc_netid),
|
||||
@@ -3158,6 +3159,7 @@ static struct nfs4_unlockdata *nfs4_alloc_unlockdata(struct file_lock *fl,
|
||||
p->arg.fh = NFS_FH(inode);
|
||||
p->arg.fl = &p->fl;
|
||||
p->arg.seqid = seqid;
|
||||
p->res.seqid = seqid;
|
||||
p->arg.stateid = &lsp->ls_stateid;
|
||||
p->lsp = lsp;
|
||||
atomic_inc(&lsp->ls_count);
|
||||
@@ -3183,7 +3185,6 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
|
||||
|
||||
if (RPC_ASSASSINATED(task))
|
||||
return;
|
||||
nfs_increment_lock_seqid(task->tk_status, calldata->arg.seqid);
|
||||
switch (task->tk_status) {
|
||||
case 0:
|
||||
memcpy(calldata->lsp->ls_stateid.data,
|
||||
@@ -3235,6 +3236,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
|
||||
.rpc_client = NFS_CLIENT(lsp->ls_state->inode),
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs4_locku_ops,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
|
||||
@@ -3261,6 +3263,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
|
||||
struct nfs4_lock_state *lsp;
|
||||
struct rpc_task *task;
|
||||
int status = 0;
|
||||
unsigned char fl_flags = request->fl_flags;
|
||||
|
||||
status = nfs4_set_lock_state(state, request);
|
||||
/* Unlock _before_ we do the RPC call */
|
||||
@@ -3284,6 +3287,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
|
||||
status = nfs4_wait_for_completion_rpc_task(task);
|
||||
rpc_put_task(task);
|
||||
out:
|
||||
request->fl_flags = fl_flags;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -3320,6 +3324,7 @@ static struct nfs4_lockdata *nfs4_alloc_lockdata(struct file_lock *fl,
|
||||
p->arg.lock_stateid = &lsp->ls_stateid;
|
||||
p->arg.lock_owner.clientid = server->nfs_client->cl_clientid;
|
||||
p->arg.lock_owner.id = lsp->ls_id.id;
|
||||
p->res.lock_seqid = p->arg.lock_seqid;
|
||||
p->lsp = lsp;
|
||||
atomic_inc(&lsp->ls_count);
|
||||
p->ctx = get_nfs_open_context(ctx);
|
||||
@@ -3346,6 +3351,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
|
||||
return;
|
||||
data->arg.open_stateid = &state->stateid;
|
||||
data->arg.new_lock_owner = 1;
|
||||
data->res.open_seqid = data->arg.open_seqid;
|
||||
} else
|
||||
data->arg.new_lock_owner = 0;
|
||||
data->timestamp = jiffies;
|
||||
@@ -3363,7 +3369,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
|
||||
if (RPC_ASSASSINATED(task))
|
||||
goto out;
|
||||
if (data->arg.new_lock_owner != 0) {
|
||||
nfs_increment_open_seqid(data->rpc_status, data->arg.open_seqid);
|
||||
if (data->rpc_status == 0)
|
||||
nfs_confirm_seqid(&data->lsp->ls_seqid, 0);
|
||||
else
|
||||
@@ -3375,7 +3380,6 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
|
||||
data->lsp->ls_flags |= NFS_LOCK_INITIALIZED;
|
||||
renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp);
|
||||
}
|
||||
nfs_increment_lock_seqid(data->rpc_status, data->arg.lock_seqid);
|
||||
out:
|
||||
dprintk("%s: done, ret = %d!\n", __FUNCTION__, data->rpc_status);
|
||||
}
|
||||
@@ -3419,6 +3423,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
|
||||
.rpc_client = NFS_CLIENT(state->inode),
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs4_lock_ops,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC,
|
||||
};
|
||||
int ret;
|
||||
|
@@ -71,6 +71,29 @@ static int nfs4_init_client(struct nfs_client *clp, struct rpc_cred *cred)
|
||||
return status;
|
||||
}
|
||||
|
||||
static struct rpc_cred *nfs4_get_machine_cred(struct nfs_client *clp)
|
||||
{
|
||||
struct rpc_cred *cred = NULL;
|
||||
|
||||
spin_lock(&clp->cl_lock);
|
||||
if (clp->cl_machine_cred != NULL)
|
||||
cred = get_rpccred(clp->cl_machine_cred);
|
||||
spin_unlock(&clp->cl_lock);
|
||||
return cred;
|
||||
}
|
||||
|
||||
static void nfs4_clear_machine_cred(struct nfs_client *clp)
|
||||
{
|
||||
struct rpc_cred *cred;
|
||||
|
||||
spin_lock(&clp->cl_lock);
|
||||
cred = clp->cl_machine_cred;
|
||||
clp->cl_machine_cred = NULL;
|
||||
spin_unlock(&clp->cl_lock);
|
||||
if (cred != NULL)
|
||||
put_rpccred(cred);
|
||||
}
|
||||
|
||||
struct rpc_cred *nfs4_get_renew_cred(struct nfs_client *clp)
|
||||
{
|
||||
struct nfs4_state_owner *sp;
|
||||
@@ -91,13 +114,18 @@ static struct rpc_cred *nfs4_get_setclientid_cred(struct nfs_client *clp)
|
||||
{
|
||||
struct nfs4_state_owner *sp;
|
||||
struct rb_node *pos;
|
||||
struct rpc_cred *cred;
|
||||
|
||||
cred = nfs4_get_machine_cred(clp);
|
||||
if (cred != NULL)
|
||||
goto out;
|
||||
pos = rb_first(&clp->cl_state_owners);
|
||||
if (pos != NULL) {
|
||||
sp = rb_entry(pos, struct nfs4_state_owner, so_client_node);
|
||||
return get_rpccred(sp->so_cred);
|
||||
cred = get_rpccred(sp->so_cred);
|
||||
}
|
||||
return NULL;
|
||||
out:
|
||||
return cred;
|
||||
}
|
||||
|
||||
static void nfs_alloc_unique_id(struct rb_root *root, struct nfs_unique_id *new,
|
||||
@@ -292,8 +320,10 @@ struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *server, struct
|
||||
spin_unlock(&clp->cl_lock);
|
||||
if (sp == new)
|
||||
get_rpccred(cred);
|
||||
else
|
||||
else {
|
||||
rpc_destroy_wait_queue(&new->so_sequence.wait);
|
||||
kfree(new);
|
||||
}
|
||||
return sp;
|
||||
}
|
||||
|
||||
@@ -310,6 +340,7 @@ void nfs4_put_state_owner(struct nfs4_state_owner *sp)
|
||||
return;
|
||||
nfs4_remove_state_owner(clp, sp);
|
||||
spin_unlock(&clp->cl_lock);
|
||||
rpc_destroy_wait_queue(&sp->so_sequence.wait);
|
||||
put_rpccred(cred);
|
||||
kfree(sp);
|
||||
}
|
||||
@@ -529,6 +560,7 @@ static void nfs4_free_lock_state(struct nfs4_lock_state *lsp)
|
||||
spin_lock(&clp->cl_lock);
|
||||
nfs_free_unique_id(&clp->cl_lockowner_id, &lsp->ls_id);
|
||||
spin_unlock(&clp->cl_lock);
|
||||
rpc_destroy_wait_queue(&lsp->ls_sequence.wait);
|
||||
kfree(lsp);
|
||||
}
|
||||
|
||||
@@ -731,7 +763,7 @@ int nfs_wait_on_sequence(struct nfs_seqid *seqid, struct rpc_task *task)
|
||||
list_add_tail(&seqid->list, &sequence->list);
|
||||
if (list_first_entry(&sequence->list, struct nfs_seqid, list) == seqid)
|
||||
goto unlock;
|
||||
rpc_sleep_on(&sequence->wait, task, NULL, NULL);
|
||||
rpc_sleep_on(&sequence->wait, task, NULL);
|
||||
status = -EAGAIN;
|
||||
unlock:
|
||||
spin_unlock(&sequence->lock);
|
||||
@@ -920,10 +952,10 @@ restart_loop:
|
||||
if (cred != NULL) {
|
||||
/* Yes there are: try to renew the old lease */
|
||||
status = nfs4_proc_renew(clp, cred);
|
||||
put_rpccred(cred);
|
||||
switch (status) {
|
||||
case 0:
|
||||
case -NFS4ERR_CB_PATH_DOWN:
|
||||
put_rpccred(cred);
|
||||
goto out;
|
||||
case -NFS4ERR_STALE_CLIENTID:
|
||||
case -NFS4ERR_LEASE_MOVED:
|
||||
@@ -932,14 +964,19 @@ restart_loop:
|
||||
} else {
|
||||
/* "reboot" to ensure we clear all state on the server */
|
||||
clp->cl_boot_time = CURRENT_TIME;
|
||||
cred = nfs4_get_setclientid_cred(clp);
|
||||
}
|
||||
/* We're going to have to re-establish a clientid */
|
||||
nfs4_state_mark_reclaim(clp);
|
||||
status = -ENOENT;
|
||||
cred = nfs4_get_setclientid_cred(clp);
|
||||
if (cred != NULL) {
|
||||
status = nfs4_init_client(clp, cred);
|
||||
put_rpccred(cred);
|
||||
/* Handle case where the user hasn't set up machine creds */
|
||||
if (status == -EACCES && cred == clp->cl_machine_cred) {
|
||||
nfs4_clear_machine_cred(clp);
|
||||
goto restart_loop;
|
||||
}
|
||||
}
|
||||
if (status)
|
||||
goto out_error;
|
||||
|
147
fs/nfs/nfs4xdr.c
147
fs/nfs/nfs4xdr.c
@@ -110,7 +110,7 @@ static int nfs4_stat_to_errno(int);
|
||||
#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 encode_fsinfo_maxsz (encode_getattr_maxsz)
|
||||
#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)
|
||||
@@ -1191,8 +1191,8 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
|
||||
attrs[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
|
||||
WRITE32(attrs[0] & readdir->bitmask[0]);
|
||||
WRITE32(attrs[1] & readdir->bitmask[1]);
|
||||
dprintk("%s: cookie = %Lu, verifier = 0x%x%x, bitmap = 0x%x%x\n",
|
||||
__FUNCTION__,
|
||||
dprintk("%s: cookie = %Lu, verifier = %08x:%08x, bitmap = %08x:%08x\n",
|
||||
__func__,
|
||||
(unsigned long long)readdir->cookie,
|
||||
((u32 *)readdir->verifier.data)[0],
|
||||
((u32 *)readdir->verifier.data)[1],
|
||||
@@ -2241,7 +2241,7 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
|
||||
}
|
||||
READ32(nfserr);
|
||||
if (nfserr != NFS_OK)
|
||||
return -nfs4_stat_to_errno(nfserr);
|
||||
return nfs4_stat_to_errno(nfserr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2291,7 +2291,7 @@ static int decode_attr_supported(struct xdr_stream *xdr, uint32_t *bitmap, uint3
|
||||
bitmap[0] &= ~FATTR4_WORD0_SUPPORTED_ATTRS;
|
||||
} else
|
||||
bitmask[0] = bitmask[1] = 0;
|
||||
dprintk("%s: bitmask=0x%x%x\n", __FUNCTION__, bitmask[0], bitmask[1]);
|
||||
dprintk("%s: bitmask=%08x:%08x\n", __func__, bitmask[0], bitmask[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3005,6 +3005,8 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_CLOSE);
|
||||
if (status != -EIO)
|
||||
nfs_increment_open_seqid(status, res->seqid);
|
||||
if (status)
|
||||
return status;
|
||||
READ_BUF(NFS4_STATEID_SIZE);
|
||||
@@ -3296,11 +3298,17 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_LOCK);
|
||||
if (status == -EIO)
|
||||
goto out;
|
||||
if (status == 0) {
|
||||
READ_BUF(NFS4_STATEID_SIZE);
|
||||
COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
|
||||
} else if (status == -NFS4ERR_DENIED)
|
||||
return decode_lock_denied(xdr, NULL);
|
||||
status = decode_lock_denied(xdr, NULL);
|
||||
if (res->open_seqid != NULL)
|
||||
nfs_increment_open_seqid(status, res->open_seqid);
|
||||
nfs_increment_lock_seqid(status, res->lock_seqid);
|
||||
out:
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -3319,6 +3327,8 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_LOCKU);
|
||||
if (status != -EIO)
|
||||
nfs_increment_lock_seqid(status, res->seqid);
|
||||
if (status == 0) {
|
||||
READ_BUF(NFS4_STATEID_SIZE);
|
||||
COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
|
||||
@@ -3384,6 +3394,8 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_OPEN);
|
||||
if (status != -EIO)
|
||||
nfs_increment_open_seqid(status, res->seqid);
|
||||
if (status)
|
||||
return status;
|
||||
READ_BUF(NFS4_STATEID_SIZE);
|
||||
@@ -3416,6 +3428,8 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
|
||||
if (status != -EIO)
|
||||
nfs_increment_open_seqid(status, res->seqid);
|
||||
if (status)
|
||||
return status;
|
||||
READ_BUF(NFS4_STATEID_SIZE);
|
||||
@@ -3429,6 +3443,8 @@ static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *re
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
|
||||
if (status != -EIO)
|
||||
nfs_increment_open_seqid(status, res->seqid);
|
||||
if (status)
|
||||
return status;
|
||||
READ_BUF(NFS4_STATEID_SIZE);
|
||||
@@ -3481,7 +3497,7 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
|
||||
size_t hdrlen;
|
||||
u32 recvd, pglen = rcvbuf->page_len;
|
||||
__be32 *end, *entry, *p, *kaddr;
|
||||
unsigned int nr;
|
||||
unsigned int nr = 0;
|
||||
int status;
|
||||
|
||||
status = decode_op_hdr(xdr, OP_READDIR);
|
||||
@@ -3489,8 +3505,8 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
|
||||
return status;
|
||||
READ_BUF(8);
|
||||
COPYMEM(readdir->verifier.data, 8);
|
||||
dprintk("%s: verifier = 0x%x%x\n",
|
||||
__FUNCTION__,
|
||||
dprintk("%s: verifier = %08x:%08x\n",
|
||||
__func__,
|
||||
((u32 *)readdir->verifier.data)[0],
|
||||
((u32 *)readdir->verifier.data)[1]);
|
||||
|
||||
@@ -3505,7 +3521,12 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
|
||||
kaddr = p = kmap_atomic(page, KM_USER0);
|
||||
end = p + ((pglen + readdir->pgbase) >> 2);
|
||||
entry = p;
|
||||
for (nr = 0; *p++; nr++) {
|
||||
|
||||
/* Make sure the packet actually has a value_follows and EOF entry */
|
||||
if ((entry + 1) > end)
|
||||
goto short_pkt;
|
||||
|
||||
for (; *p++; nr++) {
|
||||
u32 len, attrlen, xlen;
|
||||
if (end - p < 3)
|
||||
goto short_pkt;
|
||||
@@ -3532,20 +3553,32 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n
|
||||
p += attrlen; /* attributes */
|
||||
entry = p;
|
||||
}
|
||||
if (!nr && (entry[0] != 0 || entry[1] == 0))
|
||||
goto short_pkt;
|
||||
/*
|
||||
* Apparently some server sends responses that are a valid size, but
|
||||
* contain no entries, and have value_follows==0 and EOF==0. For
|
||||
* those, just set the EOF marker.
|
||||
*/
|
||||
if (!nr && entry[1] == 0) {
|
||||
dprintk("NFS: readdir reply truncated!\n");
|
||||
entry[1] = 1;
|
||||
}
|
||||
out:
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
return 0;
|
||||
short_pkt:
|
||||
/*
|
||||
* When we get a short packet there are 2 possibilities. We can
|
||||
* return an error, or fix up the response to look like a valid
|
||||
* response and return what we have so far. If there are no
|
||||
* entries and the packet was short, then return -EIO. If there
|
||||
* are valid entries in the response, return them and pretend that
|
||||
* the call was successful, but incomplete. The caller can retry the
|
||||
* readdir starting at the last cookie.
|
||||
*/
|
||||
dprintk("%s: short packet at entry %d\n", __FUNCTION__, nr);
|
||||
entry[0] = entry[1] = 0;
|
||||
/* truncate listing ? */
|
||||
if (!nr) {
|
||||
dprintk("NFS: readdir reply truncated!\n");
|
||||
entry[1] = 1;
|
||||
}
|
||||
goto out;
|
||||
if (nr)
|
||||
goto out;
|
||||
err_unmap:
|
||||
kunmap_atomic(kaddr, KM_USER0);
|
||||
return -errno_NFSERR_IO;
|
||||
@@ -3727,7 +3760,7 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp)
|
||||
READ_BUF(len);
|
||||
return -NFSERR_CLID_INUSE;
|
||||
} else
|
||||
return -nfs4_stat_to_errno(nfserr);
|
||||
return nfs4_stat_to_errno(nfserr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4389,7 +4422,7 @@ static int nfs4_xdr_dec_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs_fsinf
|
||||
if (!status)
|
||||
status = decode_fsinfo(&xdr, fsinfo);
|
||||
if (!status)
|
||||
status = -nfs4_stat_to_errno(hdr.status);
|
||||
status = nfs4_stat_to_errno(hdr.status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -4479,7 +4512,7 @@ static int nfs4_xdr_dec_setclientid(struct rpc_rqst *req, __be32 *p,
|
||||
if (!status)
|
||||
status = decode_setclientid(&xdr, clp);
|
||||
if (!status)
|
||||
status = -nfs4_stat_to_errno(hdr.status);
|
||||
status = nfs4_stat_to_errno(hdr.status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -4501,7 +4534,7 @@ static int nfs4_xdr_dec_setclientid_confirm(struct rpc_rqst *req, __be32 *p, str
|
||||
if (!status)
|
||||
status = decode_fsinfo(&xdr, fsinfo);
|
||||
if (!status)
|
||||
status = -nfs4_stat_to_errno(hdr.status);
|
||||
status = nfs4_stat_to_errno(hdr.status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -4611,42 +4644,42 @@ static struct {
|
||||
int errno;
|
||||
} nfs_errtbl[] = {
|
||||
{ NFS4_OK, 0 },
|
||||
{ NFS4ERR_PERM, EPERM },
|
||||
{ NFS4ERR_NOENT, ENOENT },
|
||||
{ NFS4ERR_IO, errno_NFSERR_IO },
|
||||
{ NFS4ERR_NXIO, ENXIO },
|
||||
{ NFS4ERR_ACCESS, EACCES },
|
||||
{ NFS4ERR_EXIST, EEXIST },
|
||||
{ NFS4ERR_XDEV, EXDEV },
|
||||
{ NFS4ERR_NOTDIR, ENOTDIR },
|
||||
{ NFS4ERR_ISDIR, EISDIR },
|
||||
{ NFS4ERR_INVAL, EINVAL },
|
||||
{ NFS4ERR_FBIG, EFBIG },
|
||||
{ NFS4ERR_NOSPC, ENOSPC },
|
||||
{ NFS4ERR_ROFS, EROFS },
|
||||
{ NFS4ERR_MLINK, EMLINK },
|
||||
{ NFS4ERR_NAMETOOLONG, ENAMETOOLONG },
|
||||
{ NFS4ERR_NOTEMPTY, ENOTEMPTY },
|
||||
{ NFS4ERR_DQUOT, EDQUOT },
|
||||
{ NFS4ERR_STALE, ESTALE },
|
||||
{ NFS4ERR_BADHANDLE, EBADHANDLE },
|
||||
{ NFS4ERR_BADOWNER, EINVAL },
|
||||
{ NFS4ERR_BADNAME, EINVAL },
|
||||
{ NFS4ERR_BAD_COOKIE, EBADCOOKIE },
|
||||
{ NFS4ERR_NOTSUPP, ENOTSUPP },
|
||||
{ NFS4ERR_TOOSMALL, ETOOSMALL },
|
||||
{ NFS4ERR_SERVERFAULT, ESERVERFAULT },
|
||||
{ NFS4ERR_BADTYPE, EBADTYPE },
|
||||
{ NFS4ERR_LOCKED, EAGAIN },
|
||||
{ NFS4ERR_RESOURCE, EREMOTEIO },
|
||||
{ NFS4ERR_SYMLINK, ELOOP },
|
||||
{ NFS4ERR_OP_ILLEGAL, EOPNOTSUPP },
|
||||
{ NFS4ERR_DEADLOCK, EDEADLK },
|
||||
{ NFS4ERR_WRONGSEC, EPERM }, /* FIXME: this needs
|
||||
{ NFS4ERR_PERM, -EPERM },
|
||||
{ NFS4ERR_NOENT, -ENOENT },
|
||||
{ NFS4ERR_IO, -errno_NFSERR_IO},
|
||||
{ NFS4ERR_NXIO, -ENXIO },
|
||||
{ NFS4ERR_ACCESS, -EACCES },
|
||||
{ NFS4ERR_EXIST, -EEXIST },
|
||||
{ NFS4ERR_XDEV, -EXDEV },
|
||||
{ NFS4ERR_NOTDIR, -ENOTDIR },
|
||||
{ NFS4ERR_ISDIR, -EISDIR },
|
||||
{ NFS4ERR_INVAL, -EINVAL },
|
||||
{ NFS4ERR_FBIG, -EFBIG },
|
||||
{ NFS4ERR_NOSPC, -ENOSPC },
|
||||
{ NFS4ERR_ROFS, -EROFS },
|
||||
{ NFS4ERR_MLINK, -EMLINK },
|
||||
{ NFS4ERR_NAMETOOLONG, -ENAMETOOLONG },
|
||||
{ NFS4ERR_NOTEMPTY, -ENOTEMPTY },
|
||||
{ NFS4ERR_DQUOT, -EDQUOT },
|
||||
{ NFS4ERR_STALE, -ESTALE },
|
||||
{ NFS4ERR_BADHANDLE, -EBADHANDLE },
|
||||
{ NFS4ERR_BADOWNER, -EINVAL },
|
||||
{ NFS4ERR_BADNAME, -EINVAL },
|
||||
{ NFS4ERR_BAD_COOKIE, -EBADCOOKIE },
|
||||
{ NFS4ERR_NOTSUPP, -ENOTSUPP },
|
||||
{ NFS4ERR_TOOSMALL, -ETOOSMALL },
|
||||
{ NFS4ERR_SERVERFAULT, -ESERVERFAULT },
|
||||
{ NFS4ERR_BADTYPE, -EBADTYPE },
|
||||
{ NFS4ERR_LOCKED, -EAGAIN },
|
||||
{ NFS4ERR_RESOURCE, -EREMOTEIO },
|
||||
{ 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 }
|
||||
{ -1, -EIO }
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -4663,14 +4696,14 @@ nfs4_stat_to_errno(int stat)
|
||||
}
|
||||
if (stat <= 10000 || stat > 10100) {
|
||||
/* The server is looney tunes. */
|
||||
return ESERVERFAULT;
|
||||
return -ESERVERFAULT;
|
||||
}
|
||||
/* If we cannot translate the error, the recovery routines should
|
||||
* handle it.
|
||||
* Note: remaining NFSv4 error codes have values > 10000, so should
|
||||
* not conflict with native Linux error codes.
|
||||
*/
|
||||
return stat;
|
||||
return -stat;
|
||||
}
|
||||
|
||||
#define PROC(proc, argtype, restype) \
|
||||
|
@@ -58,22 +58,19 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
|
||||
return p;
|
||||
}
|
||||
|
||||
static void nfs_readdata_rcu_free(struct rcu_head *head)
|
||||
static void nfs_readdata_free(struct nfs_read_data *p)
|
||||
{
|
||||
struct nfs_read_data *p = container_of(head, struct nfs_read_data, task.u.tk_rcu);
|
||||
if (p && (p->pagevec != &p->page_array[0]))
|
||||
kfree(p->pagevec);
|
||||
mempool_free(p, nfs_rdata_mempool);
|
||||
}
|
||||
|
||||
static void nfs_readdata_free(struct nfs_read_data *rdata)
|
||||
{
|
||||
call_rcu_bh(&rdata->task.u.tk_rcu, nfs_readdata_rcu_free);
|
||||
}
|
||||
|
||||
void nfs_readdata_release(void *data)
|
||||
{
|
||||
nfs_readdata_free(data);
|
||||
struct nfs_read_data *rdata = data;
|
||||
|
||||
put_nfs_open_context(rdata->args.context);
|
||||
nfs_readdata_free(rdata);
|
||||
}
|
||||
|
||||
static
|
||||
@@ -156,7 +153,7 @@ static void nfs_readpage_release(struct nfs_page *req)
|
||||
/*
|
||||
* Set up the NFS read request struct
|
||||
*/
|
||||
static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
|
||||
static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
|
||||
const struct rpc_call_ops *call_ops,
|
||||
unsigned int count, unsigned int offset)
|
||||
{
|
||||
@@ -174,6 +171,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = call_ops,
|
||||
.callback_data = data,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = RPC_TASK_ASYNC | swap_flags,
|
||||
};
|
||||
|
||||
@@ -186,7 +184,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
|
||||
data->args.pgbase = req->wb_pgbase + offset;
|
||||
data->args.pages = data->pagevec;
|
||||
data->args.count = count;
|
||||
data->args.context = req->wb_context;
|
||||
data->args.context = get_nfs_open_context(req->wb_context);
|
||||
|
||||
data->res.fattr = &data->fattr;
|
||||
data->res.count = count;
|
||||
@@ -204,8 +202,10 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
|
||||
(unsigned long long)data->args.offset);
|
||||
|
||||
task = rpc_run_task(&task_setup_data);
|
||||
if (!IS_ERR(task))
|
||||
rpc_put_task(task);
|
||||
if (IS_ERR(task))
|
||||
return PTR_ERR(task);
|
||||
rpc_put_task(task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -242,6 +242,7 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
|
||||
size_t rsize = NFS_SERVER(inode)->rsize, nbytes;
|
||||
unsigned int offset;
|
||||
int requests = 0;
|
||||
int ret = 0;
|
||||
LIST_HEAD(list);
|
||||
|
||||
nfs_list_remove_request(req);
|
||||
@@ -253,7 +254,6 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
|
||||
data = nfs_readdata_alloc(1);
|
||||
if (!data)
|
||||
goto out_bad;
|
||||
INIT_LIST_HEAD(&data->pages);
|
||||
list_add(&data->pages, &list);
|
||||
requests++;
|
||||
nbytes -= len;
|
||||
@@ -264,6 +264,8 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
|
||||
offset = 0;
|
||||
nbytes = count;
|
||||
do {
|
||||
int ret2;
|
||||
|
||||
data = list_entry(list.next, struct nfs_read_data, pages);
|
||||
list_del_init(&data->pages);
|
||||
|
||||
@@ -271,13 +273,15 @@ static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigne
|
||||
|
||||
if (nbytes < rsize)
|
||||
rsize = nbytes;
|
||||
nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
|
||||
ret2 = nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
|
||||
rsize, offset);
|
||||
if (ret == 0)
|
||||
ret = ret2;
|
||||
offset += rsize;
|
||||
nbytes -= rsize;
|
||||
} while (nbytes != 0);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
|
||||
out_bad:
|
||||
while (!list_empty(&list)) {
|
||||
@@ -295,12 +299,12 @@ static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned
|
||||
struct nfs_page *req;
|
||||
struct page **pages;
|
||||
struct nfs_read_data *data;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
data = nfs_readdata_alloc(npages);
|
||||
if (!data)
|
||||
goto out_bad;
|
||||
|
||||
INIT_LIST_HEAD(&data->pages);
|
||||
pages = data->pagevec;
|
||||
while (!list_empty(head)) {
|
||||
req = nfs_list_entry(head->next);
|
||||
@@ -311,11 +315,10 @@ static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned
|
||||
}
|
||||
req = nfs_list_entry(data->pages.next);
|
||||
|
||||
nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0);
|
||||
return 0;
|
||||
return nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0);
|
||||
out_bad:
|
||||
nfs_async_read_error(head);
|
||||
return -ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -342,26 +345,25 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
|
||||
static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
|
||||
{
|
||||
struct nfs_readargs *argp = &data->args;
|
||||
struct nfs_readres *resp = &data->res;
|
||||
|
||||
if (resp->eof || resp->count == argp->count)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* This is a short read! */
|
||||
nfs_inc_stats(data->inode, NFSIOS_SHORTREAD);
|
||||
/* Has the server at least made some progress? */
|
||||
if (resp->count == 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* Yes, so retry the read at the end of the data */
|
||||
argp->offset += resp->count;
|
||||
argp->pgbase += resp->count;
|
||||
argp->count -= resp->count;
|
||||
rpc_restart_call(task);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -370,29 +372,37 @@ static int nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
|
||||
static void nfs_readpage_result_partial(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_read_data *data = calldata;
|
||||
struct nfs_page *req = data->req;
|
||||
struct page *page = req->wb_page;
|
||||
|
||||
if (nfs_readpage_result(task, data) != 0)
|
||||
return;
|
||||
if (task->tk_status < 0)
|
||||
return;
|
||||
|
||||
if (likely(task->tk_status >= 0)) {
|
||||
nfs_readpage_truncate_uninitialised_page(data);
|
||||
if (nfs_readpage_retry(task, data) != 0)
|
||||
return;
|
||||
}
|
||||
if (unlikely(task->tk_status < 0))
|
||||
nfs_readpage_truncate_uninitialised_page(data);
|
||||
nfs_readpage_retry(task, data);
|
||||
}
|
||||
|
||||
static void nfs_readpage_release_partial(void *calldata)
|
||||
{
|
||||
struct nfs_read_data *data = calldata;
|
||||
struct nfs_page *req = data->req;
|
||||
struct page *page = req->wb_page;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
if (status < 0)
|
||||
SetPageError(page);
|
||||
|
||||
if (atomic_dec_and_test(&req->wb_complete)) {
|
||||
if (!PageError(page))
|
||||
SetPageUptodate(page);
|
||||
nfs_readpage_release(req);
|
||||
}
|
||||
nfs_readdata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_read_partial_ops = {
|
||||
.rpc_call_done = nfs_readpage_result_partial,
|
||||
.rpc_release = nfs_readdata_release,
|
||||
.rpc_release = nfs_readpage_release_partial,
|
||||
};
|
||||
|
||||
static void nfs_readpage_set_pages_uptodate(struct nfs_read_data *data)
|
||||
@@ -427,29 +437,35 @@ static void nfs_readpage_result_full(struct rpc_task *task, void *calldata)
|
||||
|
||||
if (nfs_readpage_result(task, data) != 0)
|
||||
return;
|
||||
if (task->tk_status < 0)
|
||||
return;
|
||||
/*
|
||||
* Note: nfs_readpage_retry may change the values of
|
||||
* data->args. In the multi-page case, we therefore need
|
||||
* to ensure that we call nfs_readpage_set_pages_uptodate()
|
||||
* first.
|
||||
*/
|
||||
if (likely(task->tk_status >= 0)) {
|
||||
nfs_readpage_truncate_uninitialised_page(data);
|
||||
nfs_readpage_set_pages_uptodate(data);
|
||||
if (nfs_readpage_retry(task, data) != 0)
|
||||
return;
|
||||
}
|
||||
nfs_readpage_truncate_uninitialised_page(data);
|
||||
nfs_readpage_set_pages_uptodate(data);
|
||||
nfs_readpage_retry(task, data);
|
||||
}
|
||||
|
||||
static void nfs_readpage_release_full(void *calldata)
|
||||
{
|
||||
struct nfs_read_data *data = calldata;
|
||||
|
||||
while (!list_empty(&data->pages)) {
|
||||
struct nfs_page *req = nfs_list_entry(data->pages.next);
|
||||
|
||||
nfs_list_remove_request(req);
|
||||
nfs_readpage_release(req);
|
||||
}
|
||||
nfs_readdata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_read_full_ops = {
|
||||
.rpc_call_done = nfs_readpage_result_full,
|
||||
.rpc_release = nfs_readdata_release,
|
||||
.rpc_release = nfs_readpage_release_full,
|
||||
};
|
||||
|
||||
/*
|
||||
|
145
fs/nfs/super.c
145
fs/nfs/super.c
@@ -441,10 +441,52 @@ static const char *nfs_pseudoflavour_to_name(rpc_authflavor_t flavour)
|
||||
return sec_flavours[i].str;
|
||||
}
|
||||
|
||||
static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
|
||||
int showdefaults)
|
||||
{
|
||||
struct sockaddr *sap = (struct sockaddr *)&nfss->mountd_address;
|
||||
|
||||
switch (sap->sa_family) {
|
||||
case AF_INET: {
|
||||
struct sockaddr_in *sin = (struct sockaddr_in *)sap;
|
||||
seq_printf(m, ",mountaddr=" NIPQUAD_FMT,
|
||||
NIPQUAD(sin->sin_addr.s_addr));
|
||||
break;
|
||||
}
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap;
|
||||
seq_printf(m, ",mountaddr=" NIP6_FMT,
|
||||
NIP6(sin6->sin6_addr));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (showdefaults)
|
||||
seq_printf(m, ",mountaddr=unspecified");
|
||||
}
|
||||
|
||||
if (nfss->mountd_version || showdefaults)
|
||||
seq_printf(m, ",mountvers=%u", nfss->mountd_version);
|
||||
if (nfss->mountd_port || showdefaults)
|
||||
seq_printf(m, ",mountport=%u", nfss->mountd_port);
|
||||
|
||||
switch (nfss->mountd_protocol) {
|
||||
case IPPROTO_UDP:
|
||||
seq_printf(m, ",mountproto=udp");
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
seq_printf(m, ",mountproto=tcp");
|
||||
break;
|
||||
default:
|
||||
if (showdefaults)
|
||||
seq_printf(m, ",mountproto=auto");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Describe the mount options in force on this server representation
|
||||
*/
|
||||
static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, int showdefaults)
|
||||
static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
|
||||
int showdefaults)
|
||||
{
|
||||
static const struct proc_nfs_info {
|
||||
int flag;
|
||||
@@ -452,6 +494,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
|
||||
const char *nostr;
|
||||
} nfs_info[] = {
|
||||
{ NFS_MOUNT_SOFT, ",soft", ",hard" },
|
||||
{ NFS_MOUNT_INTR, ",intr", ",nointr" },
|
||||
{ NFS_MOUNT_POSIX, ",posix", "" },
|
||||
{ NFS_MOUNT_NOCTO, ",nocto", "" },
|
||||
{ NFS_MOUNT_NOAC, ",noac", "" },
|
||||
{ NFS_MOUNT_NONLM, ",nolock", "" },
|
||||
@@ -462,18 +506,22 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
|
||||
};
|
||||
const struct proc_nfs_info *nfs_infop;
|
||||
struct nfs_client *clp = nfss->nfs_client;
|
||||
u32 version = clp->rpc_ops->version;
|
||||
|
||||
seq_printf(m, ",vers=%d", clp->rpc_ops->version);
|
||||
seq_printf(m, ",rsize=%d", nfss->rsize);
|
||||
seq_printf(m, ",wsize=%d", nfss->wsize);
|
||||
seq_printf(m, ",vers=%u", version);
|
||||
seq_printf(m, ",rsize=%u", nfss->rsize);
|
||||
seq_printf(m, ",wsize=%u", nfss->wsize);
|
||||
if (nfss->bsize != 0)
|
||||
seq_printf(m, ",bsize=%u", nfss->bsize);
|
||||
seq_printf(m, ",namlen=%u", nfss->namelen);
|
||||
if (nfss->acregmin != 3*HZ || showdefaults)
|
||||
seq_printf(m, ",acregmin=%d", nfss->acregmin/HZ);
|
||||
seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ);
|
||||
if (nfss->acregmax != 60*HZ || showdefaults)
|
||||
seq_printf(m, ",acregmax=%d", nfss->acregmax/HZ);
|
||||
seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ);
|
||||
if (nfss->acdirmin != 30*HZ || showdefaults)
|
||||
seq_printf(m, ",acdirmin=%d", nfss->acdirmin/HZ);
|
||||
seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ);
|
||||
if (nfss->acdirmax != 60*HZ || showdefaults)
|
||||
seq_printf(m, ",acdirmax=%d", nfss->acdirmax/HZ);
|
||||
seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ);
|
||||
for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) {
|
||||
if (nfss->flags & nfs_infop->flag)
|
||||
seq_puts(m, nfs_infop->str);
|
||||
@@ -482,9 +530,24 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss,
|
||||
}
|
||||
seq_printf(m, ",proto=%s",
|
||||
rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO));
|
||||
if (version == 4) {
|
||||
if (nfss->port != NFS_PORT)
|
||||
seq_printf(m, ",port=%u", nfss->port);
|
||||
} else
|
||||
if (nfss->port)
|
||||
seq_printf(m, ",port=%u", nfss->port);
|
||||
|
||||
seq_printf(m, ",timeo=%lu", 10U * nfss->client->cl_timeout->to_initval / HZ);
|
||||
seq_printf(m, ",retrans=%u", nfss->client->cl_timeout->to_retries);
|
||||
seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor));
|
||||
|
||||
if (version != 4)
|
||||
nfs_show_mountd_options(m, nfss, showdefaults);
|
||||
|
||||
#ifdef CONFIG_NFS_V4
|
||||
if (clp->rpc_ops->version == 4)
|
||||
seq_printf(m, ",clientaddr=%s", clp->cl_ipaddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -529,10 +592,10 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
|
||||
|
||||
seq_printf(m, "\n\tcaps:\t");
|
||||
seq_printf(m, "caps=0x%x", nfss->caps);
|
||||
seq_printf(m, ",wtmult=%d", nfss->wtmult);
|
||||
seq_printf(m, ",dtsize=%d", nfss->dtsize);
|
||||
seq_printf(m, ",bsize=%d", nfss->bsize);
|
||||
seq_printf(m, ",namelen=%d", nfss->namelen);
|
||||
seq_printf(m, ",wtmult=%u", nfss->wtmult);
|
||||
seq_printf(m, ",dtsize=%u", nfss->dtsize);
|
||||
seq_printf(m, ",bsize=%u", nfss->bsize);
|
||||
seq_printf(m, ",namlen=%u", nfss->namelen);
|
||||
|
||||
#ifdef CONFIG_NFS_V4
|
||||
if (nfss->nfs_client->rpc_ops->version == 4) {
|
||||
@@ -546,9 +609,9 @@ static int nfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
|
||||
/*
|
||||
* Display security flavor in effect for this mount
|
||||
*/
|
||||
seq_printf(m, "\n\tsec:\tflavor=%d", auth->au_ops->au_flavor);
|
||||
seq_printf(m, "\n\tsec:\tflavor=%u", auth->au_ops->au_flavor);
|
||||
if (auth->au_flavor)
|
||||
seq_printf(m, ",pseudoflavor=%d", auth->au_flavor);
|
||||
seq_printf(m, ",pseudoflavor=%u", auth->au_flavor);
|
||||
|
||||
/*
|
||||
* Display superblock I/O counters
|
||||
@@ -683,7 +746,6 @@ static int nfs_parse_mount_options(char *raw,
|
||||
struct nfs_parsed_mount_data *mnt)
|
||||
{
|
||||
char *p, *string, *secdata;
|
||||
unsigned short port = 0;
|
||||
int rc;
|
||||
|
||||
if (!raw) {
|
||||
@@ -798,7 +860,7 @@ static int nfs_parse_mount_options(char *raw,
|
||||
return 0;
|
||||
if (option < 0 || option > 65535)
|
||||
return 0;
|
||||
port = option;
|
||||
mnt->nfs_server.port = option;
|
||||
break;
|
||||
case Opt_rsize:
|
||||
if (match_int(args, &mnt->rsize))
|
||||
@@ -1048,7 +1110,8 @@ static int nfs_parse_mount_options(char *raw,
|
||||
}
|
||||
}
|
||||
|
||||
nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, port);
|
||||
nfs_set_port((struct sockaddr *)&mnt->nfs_server.address,
|
||||
mnt->nfs_server.port);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1169,7 +1232,9 @@ static int nfs_validate_mount_data(void *options,
|
||||
args->acregmax = 60;
|
||||
args->acdirmin = 30;
|
||||
args->acdirmax = 60;
|
||||
args->mount_server.port = 0; /* autobind unless user sets port */
|
||||
args->mount_server.protocol = XPRT_TRANSPORT_UDP;
|
||||
args->nfs_server.port = 0; /* autobind unless user sets port */
|
||||
args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
|
||||
|
||||
switch (data->version) {
|
||||
@@ -1208,7 +1273,6 @@ static int nfs_validate_mount_data(void *options,
|
||||
args->flags = data->flags;
|
||||
args->rsize = data->rsize;
|
||||
args->wsize = data->wsize;
|
||||
args->flags = data->flags;
|
||||
args->timeo = data->timeo;
|
||||
args->retrans = data->retrans;
|
||||
args->acregmin = data->acregmin;
|
||||
@@ -1230,6 +1294,8 @@ static int nfs_validate_mount_data(void *options,
|
||||
args->namlen = data->namlen;
|
||||
args->bsize = data->bsize;
|
||||
args->auth_flavors[0] = data->pseudoflavor;
|
||||
if (!args->nfs_server.hostname)
|
||||
goto out_nomem;
|
||||
|
||||
/*
|
||||
* The legacy version 6 binary mount data from userspace has a
|
||||
@@ -1276,6 +1342,8 @@ static int nfs_validate_mount_data(void *options,
|
||||
len = c - dev_name;
|
||||
/* N.B. caller will free nfs_server.hostname in all cases */
|
||||
args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL);
|
||||
if (!args->nfs_server.hostname)
|
||||
goto out_nomem;
|
||||
|
||||
c++;
|
||||
if (strlen(c) > NFS_MAXPATHLEN)
|
||||
@@ -1319,6 +1387,10 @@ out_v3_not_compiled:
|
||||
return -EPROTONOSUPPORT;
|
||||
#endif /* !CONFIG_NFS_V3 */
|
||||
|
||||
out_nomem:
|
||||
dfprintk(MOUNT, "NFS: not enough memory to handle mount options\n");
|
||||
return -ENOMEM;
|
||||
|
||||
out_no_address:
|
||||
dfprintk(MOUNT, "NFS: mount program didn't pass remote address\n");
|
||||
return -EINVAL;
|
||||
@@ -1705,28 +1777,6 @@ static void nfs4_fill_super(struct super_block *sb)
|
||||
nfs_initialise_sb(sb);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the user didn't specify a port, set the port number to
|
||||
* the NFS version 4 default port.
|
||||
*/
|
||||
static void nfs4_default_port(struct sockaddr *sap)
|
||||
{
|
||||
switch (sap->sa_family) {
|
||||
case AF_INET: {
|
||||
struct sockaddr_in *ap = (struct sockaddr_in *)sap;
|
||||
if (ap->sin_port == 0)
|
||||
ap->sin_port = htons(NFS_PORT);
|
||||
break;
|
||||
}
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap;
|
||||
if (ap->sin6_port == 0)
|
||||
ap->sin6_port = htons(NFS_PORT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate NFSv4 mount options
|
||||
*/
|
||||
@@ -1751,6 +1801,7 @@ static int nfs4_validate_mount_data(void *options,
|
||||
args->acregmax = 60;
|
||||
args->acdirmin = 30;
|
||||
args->acdirmax = 60;
|
||||
args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
|
||||
args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
|
||||
|
||||
switch (data->version) {
|
||||
@@ -1767,9 +1818,6 @@ static int nfs4_validate_mount_data(void *options,
|
||||
&args->nfs_server.address))
|
||||
goto out_no_address;
|
||||
|
||||
nfs4_default_port((struct sockaddr *)
|
||||
&args->nfs_server.address);
|
||||
|
||||
switch (data->auth_flavourlen) {
|
||||
case 0:
|
||||
args->auth_flavors[0] = RPC_AUTH_UNIX;
|
||||
@@ -1827,9 +1875,6 @@ static int nfs4_validate_mount_data(void *options,
|
||||
&args->nfs_server.address))
|
||||
return -EINVAL;
|
||||
|
||||
nfs4_default_port((struct sockaddr *)
|
||||
&args->nfs_server.address);
|
||||
|
||||
switch (args->auth_flavor_len) {
|
||||
case 0:
|
||||
args->auth_flavors[0] = RPC_AUTH_UNIX;
|
||||
@@ -1852,12 +1897,16 @@ static int nfs4_validate_mount_data(void *options,
|
||||
return -ENAMETOOLONG;
|
||||
/* N.B. caller will free nfs_server.hostname in all cases */
|
||||
args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL);
|
||||
if (!args->nfs_server.hostname)
|
||||
goto out_nomem;
|
||||
|
||||
c++; /* step over the ':' */
|
||||
len = strlen(c);
|
||||
if (len > NFS4_MAXPATHLEN)
|
||||
return -ENAMETOOLONG;
|
||||
args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL);
|
||||
if (!args->nfs_server.export_path)
|
||||
goto out_nomem;
|
||||
|
||||
dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path);
|
||||
|
||||
@@ -1879,6 +1928,10 @@ out_inval_auth:
|
||||
data->auth_flavourlen);
|
||||
return -EINVAL;
|
||||
|
||||
out_nomem:
|
||||
dfprintk(MOUNT, "NFS4: not enough memory to handle mount options\n");
|
||||
return -ENOMEM;
|
||||
|
||||
out_no_address:
|
||||
dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
|
||||
return -EINVAL;
|
||||
|
@@ -234,7 +234,7 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry)
|
||||
if (data == NULL)
|
||||
goto out;
|
||||
|
||||
data->cred = rpcauth_lookupcred(NFS_CLIENT(dir)->cl_auth, 0);
|
||||
data->cred = rpc_lookup_cred();
|
||||
if (IS_ERR(data->cred)) {
|
||||
status = PTR_ERR(data->cred);
|
||||
goto out_free;
|
||||
|
207
fs/nfs/write.c
207
fs/nfs/write.c
@@ -48,7 +48,7 @@ static struct kmem_cache *nfs_wdata_cachep;
|
||||
static mempool_t *nfs_wdata_mempool;
|
||||
static mempool_t *nfs_commit_mempool;
|
||||
|
||||
struct nfs_write_data *nfs_commit_alloc(void)
|
||||
struct nfs_write_data *nfs_commitdata_alloc(void)
|
||||
{
|
||||
struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS);
|
||||
|
||||
@@ -59,19 +59,13 @@ struct nfs_write_data *nfs_commit_alloc(void)
|
||||
return p;
|
||||
}
|
||||
|
||||
static void nfs_commit_rcu_free(struct rcu_head *head)
|
||||
void nfs_commit_free(struct nfs_write_data *p)
|
||||
{
|
||||
struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
|
||||
if (p && (p->pagevec != &p->page_array[0]))
|
||||
kfree(p->pagevec);
|
||||
mempool_free(p, nfs_commit_mempool);
|
||||
}
|
||||
|
||||
void nfs_commit_free(struct nfs_write_data *wdata)
|
||||
{
|
||||
call_rcu_bh(&wdata->task.u.tk_rcu, nfs_commit_rcu_free);
|
||||
}
|
||||
|
||||
struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
|
||||
{
|
||||
struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
|
||||
@@ -93,21 +87,18 @@ struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
|
||||
return p;
|
||||
}
|
||||
|
||||
static void nfs_writedata_rcu_free(struct rcu_head *head)
|
||||
static void nfs_writedata_free(struct nfs_write_data *p)
|
||||
{
|
||||
struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
|
||||
if (p && (p->pagevec != &p->page_array[0]))
|
||||
kfree(p->pagevec);
|
||||
mempool_free(p, nfs_wdata_mempool);
|
||||
}
|
||||
|
||||
static void nfs_writedata_free(struct nfs_write_data *wdata)
|
||||
void nfs_writedata_release(void *data)
|
||||
{
|
||||
call_rcu_bh(&wdata->task.u.tk_rcu, nfs_writedata_rcu_free);
|
||||
}
|
||||
struct nfs_write_data *wdata = data;
|
||||
|
||||
void nfs_writedata_release(void *wdata)
|
||||
{
|
||||
put_nfs_open_context(wdata->args.context);
|
||||
nfs_writedata_free(wdata);
|
||||
}
|
||||
|
||||
@@ -291,8 +282,6 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
|
||||
spin_unlock(&inode->i_lock);
|
||||
if (!nfs_pageio_add_request(pgio, req)) {
|
||||
nfs_redirty_request(req);
|
||||
nfs_end_page_writeback(page);
|
||||
nfs_clear_page_tag_locked(req);
|
||||
return pgio->pg_error;
|
||||
}
|
||||
return 0;
|
||||
@@ -366,15 +355,13 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
|
||||
/*
|
||||
* Insert a write request into an inode
|
||||
*/
|
||||
static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
|
||||
static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
|
||||
{
|
||||
struct nfs_inode *nfsi = NFS_I(inode);
|
||||
int error;
|
||||
|
||||
error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req);
|
||||
BUG_ON(error == -EEXIST);
|
||||
if (error)
|
||||
return error;
|
||||
BUG_ON(error);
|
||||
if (!nfsi->npages) {
|
||||
igrab(inode);
|
||||
if (nfs_have_delegation(inode, FMODE_WRITE))
|
||||
@@ -384,8 +371,8 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
|
||||
set_page_private(req->wb_page, (unsigned long)req);
|
||||
nfsi->npages++;
|
||||
kref_get(&req->wb_kref);
|
||||
radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
|
||||
return 0;
|
||||
radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index,
|
||||
NFS_PAGE_TAG_LOCKED);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -413,7 +400,7 @@ static void nfs_inode_remove_request(struct nfs_page *req)
|
||||
}
|
||||
|
||||
static void
|
||||
nfs_redirty_request(struct nfs_page *req)
|
||||
nfs_mark_request_dirty(struct nfs_page *req)
|
||||
{
|
||||
__set_page_dirty_nobuffers(req->wb_page);
|
||||
}
|
||||
@@ -467,7 +454,7 @@ int nfs_reschedule_unstable_write(struct nfs_page *req)
|
||||
return 1;
|
||||
}
|
||||
if (test_and_clear_bit(PG_NEED_RESCHED, &req->wb_flags)) {
|
||||
nfs_redirty_request(req);
|
||||
nfs_mark_request_dirty(req);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -597,6 +584,13 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
|
||||
/* Loop over all inode entries and see if we find
|
||||
* A request for the page we wish to update
|
||||
*/
|
||||
if (new) {
|
||||
if (radix_tree_preload(GFP_NOFS)) {
|
||||
nfs_release_request(new);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
req = nfs_page_find_request_locked(page);
|
||||
if (req) {
|
||||
@@ -607,28 +601,27 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
|
||||
error = nfs_wait_on_request(req);
|
||||
nfs_release_request(req);
|
||||
if (error < 0) {
|
||||
if (new)
|
||||
if (new) {
|
||||
radix_tree_preload_end();
|
||||
nfs_release_request(new);
|
||||
}
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
spin_unlock(&inode->i_lock);
|
||||
if (new)
|
||||
if (new) {
|
||||
radix_tree_preload_end();
|
||||
nfs_release_request(new);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (new) {
|
||||
int error;
|
||||
nfs_lock_request_dontget(new);
|
||||
error = nfs_inode_add_request(inode, new);
|
||||
if (error) {
|
||||
spin_unlock(&inode->i_lock);
|
||||
nfs_unlock_request(new);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
nfs_inode_add_request(inode, new);
|
||||
spin_unlock(&inode->i_lock);
|
||||
radix_tree_preload_end();
|
||||
req = new;
|
||||
goto zero_page;
|
||||
}
|
||||
@@ -785,7 +778,7 @@ static int flush_task_priority(int how)
|
||||
/*
|
||||
* Set up the argument/result storage required for the RPC call.
|
||||
*/
|
||||
static void nfs_write_rpcsetup(struct nfs_page *req,
|
||||
static int nfs_write_rpcsetup(struct nfs_page *req,
|
||||
struct nfs_write_data *data,
|
||||
const struct rpc_call_ops *call_ops,
|
||||
unsigned int count, unsigned int offset,
|
||||
@@ -806,6 +799,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = call_ops,
|
||||
.callback_data = data,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = flags,
|
||||
.priority = priority,
|
||||
};
|
||||
@@ -822,7 +816,7 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
|
||||
data->args.pgbase = req->wb_pgbase + offset;
|
||||
data->args.pages = data->pagevec;
|
||||
data->args.count = count;
|
||||
data->args.context = req->wb_context;
|
||||
data->args.context = get_nfs_open_context(req->wb_context);
|
||||
data->args.stable = NFS_UNSTABLE;
|
||||
if (how & FLUSH_STABLE) {
|
||||
data->args.stable = NFS_DATA_SYNC;
|
||||
@@ -847,8 +841,21 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
|
||||
(unsigned long long)data->args.offset);
|
||||
|
||||
task = rpc_run_task(&task_setup_data);
|
||||
if (!IS_ERR(task))
|
||||
rpc_put_task(task);
|
||||
if (IS_ERR(task))
|
||||
return PTR_ERR(task);
|
||||
rpc_put_task(task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If a nfs_flush_* function fails, it should remove reqs from @head and
|
||||
* call this on each, which will prepare them to be retried on next
|
||||
* writeback using standard nfs.
|
||||
*/
|
||||
static void nfs_redirty_request(struct nfs_page *req)
|
||||
{
|
||||
nfs_mark_request_dirty(req);
|
||||
nfs_end_page_writeback(req->wb_page);
|
||||
nfs_clear_page_tag_locked(req);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -863,6 +870,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned
|
||||
size_t wsize = NFS_SERVER(inode)->wsize, nbytes;
|
||||
unsigned int offset;
|
||||
int requests = 0;
|
||||
int ret = 0;
|
||||
LIST_HEAD(list);
|
||||
|
||||
nfs_list_remove_request(req);
|
||||
@@ -884,6 +892,8 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned
|
||||
offset = 0;
|
||||
nbytes = count;
|
||||
do {
|
||||
int ret2;
|
||||
|
||||
data = list_entry(list.next, struct nfs_write_data, pages);
|
||||
list_del_init(&data->pages);
|
||||
|
||||
@@ -891,13 +901,15 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned
|
||||
|
||||
if (nbytes < wsize)
|
||||
wsize = nbytes;
|
||||
nfs_write_rpcsetup(req, data, &nfs_write_partial_ops,
|
||||
ret2 = nfs_write_rpcsetup(req, data, &nfs_write_partial_ops,
|
||||
wsize, offset, how);
|
||||
if (ret == 0)
|
||||
ret = ret2;
|
||||
offset += wsize;
|
||||
nbytes -= wsize;
|
||||
} while (nbytes != 0);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
|
||||
out_bad:
|
||||
while (!list_empty(&list)) {
|
||||
@@ -906,8 +918,6 @@ out_bad:
|
||||
nfs_writedata_release(data);
|
||||
}
|
||||
nfs_redirty_request(req);
|
||||
nfs_end_page_writeback(req->wb_page);
|
||||
nfs_clear_page_tag_locked(req);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -940,16 +950,12 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i
|
||||
req = nfs_list_entry(data->pages.next);
|
||||
|
||||
/* Set up the argument struct */
|
||||
nfs_write_rpcsetup(req, data, &nfs_write_full_ops, count, 0, how);
|
||||
|
||||
return 0;
|
||||
return nfs_write_rpcsetup(req, data, &nfs_write_full_ops, count, 0, how);
|
||||
out_bad:
|
||||
while (!list_empty(head)) {
|
||||
req = nfs_list_entry(head->next);
|
||||
nfs_list_remove_request(req);
|
||||
nfs_redirty_request(req);
|
||||
nfs_end_page_writeback(req->wb_page);
|
||||
nfs_clear_page_tag_locked(req);
|
||||
}
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -972,7 +978,6 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_page *req = data->req;
|
||||
struct page *page = req->wb_page;
|
||||
|
||||
dprintk("NFS: write (%s/%Ld %d@%Ld)",
|
||||
req->wb_context->path.dentry->d_inode->i_sb->s_id,
|
||||
@@ -980,13 +985,20 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
|
||||
req->wb_bytes,
|
||||
(long long)req_offset(req));
|
||||
|
||||
if (nfs_writeback_done(task, data) != 0)
|
||||
return;
|
||||
nfs_writeback_done(task, data);
|
||||
}
|
||||
|
||||
if (task->tk_status < 0) {
|
||||
static void nfs_writeback_release_partial(void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_page *req = data->req;
|
||||
struct page *page = req->wb_page;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
if (status < 0) {
|
||||
nfs_set_pageerror(page);
|
||||
nfs_context_set_write_error(req->wb_context, task->tk_status);
|
||||
dprintk(", error = %d\n", task->tk_status);
|
||||
nfs_context_set_write_error(req->wb_context, status);
|
||||
dprintk(", error = %d\n", status);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1011,11 +1023,12 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
|
||||
out:
|
||||
if (atomic_dec_and_test(&req->wb_complete))
|
||||
nfs_writepage_release(req);
|
||||
nfs_writedata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_write_partial_ops = {
|
||||
.rpc_call_done = nfs_writeback_done_partial,
|
||||
.rpc_release = nfs_writedata_release,
|
||||
.rpc_release = nfs_writeback_release_partial,
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1028,17 +1041,21 @@ static const struct rpc_call_ops nfs_write_partial_ops = {
|
||||
static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_page *req;
|
||||
struct page *page;
|
||||
|
||||
if (nfs_writeback_done(task, data) != 0)
|
||||
return;
|
||||
nfs_writeback_done(task, data);
|
||||
}
|
||||
|
||||
static void nfs_writeback_release_full(void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
/* Update attributes as result of writeback. */
|
||||
while (!list_empty(&data->pages)) {
|
||||
req = nfs_list_entry(data->pages.next);
|
||||
struct nfs_page *req = nfs_list_entry(data->pages.next);
|
||||
struct page *page = req->wb_page;
|
||||
|
||||
nfs_list_remove_request(req);
|
||||
page = req->wb_page;
|
||||
|
||||
dprintk("NFS: write (%s/%Ld %d@%Ld)",
|
||||
req->wb_context->path.dentry->d_inode->i_sb->s_id,
|
||||
@@ -1046,10 +1063,10 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
|
||||
req->wb_bytes,
|
||||
(long long)req_offset(req));
|
||||
|
||||
if (task->tk_status < 0) {
|
||||
if (status < 0) {
|
||||
nfs_set_pageerror(page);
|
||||
nfs_context_set_write_error(req->wb_context, task->tk_status);
|
||||
dprintk(", error = %d\n", task->tk_status);
|
||||
nfs_context_set_write_error(req->wb_context, status);
|
||||
dprintk(", error = %d\n", status);
|
||||
goto remove_request;
|
||||
}
|
||||
|
||||
@@ -1069,11 +1086,12 @@ remove_request:
|
||||
next:
|
||||
nfs_clear_page_tag_locked(req);
|
||||
}
|
||||
nfs_writedata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_write_full_ops = {
|
||||
.rpc_call_done = nfs_writeback_done_full,
|
||||
.rpc_release = nfs_writedata_release,
|
||||
.rpc_release = nfs_writeback_release_full,
|
||||
};
|
||||
|
||||
|
||||
@@ -1159,15 +1177,18 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
|
||||
|
||||
|
||||
#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
|
||||
void nfs_commit_release(void *wdata)
|
||||
void nfs_commitdata_release(void *data)
|
||||
{
|
||||
struct nfs_write_data *wdata = data;
|
||||
|
||||
put_nfs_open_context(wdata->args.context);
|
||||
nfs_commit_free(wdata);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the argument/result storage required for the RPC call.
|
||||
*/
|
||||
static void nfs_commit_rpcsetup(struct list_head *head,
|
||||
static int nfs_commit_rpcsetup(struct list_head *head,
|
||||
struct nfs_write_data *data,
|
||||
int how)
|
||||
{
|
||||
@@ -1187,6 +1208,7 @@ static void nfs_commit_rpcsetup(struct list_head *head,
|
||||
.rpc_message = &msg,
|
||||
.callback_ops = &nfs_commit_ops,
|
||||
.callback_data = data,
|
||||
.workqueue = nfsiod_workqueue,
|
||||
.flags = flags,
|
||||
.priority = priority,
|
||||
};
|
||||
@@ -1203,6 +1225,7 @@ static void nfs_commit_rpcsetup(struct list_head *head,
|
||||
/* Note: we always request a commit of the entire inode */
|
||||
data->args.offset = 0;
|
||||
data->args.count = 0;
|
||||
data->args.context = get_nfs_open_context(first->wb_context);
|
||||
data->res.count = 0;
|
||||
data->res.fattr = &data->fattr;
|
||||
data->res.verf = &data->verf;
|
||||
@@ -1214,8 +1237,10 @@ static void nfs_commit_rpcsetup(struct list_head *head,
|
||||
dprintk("NFS: %5u initiated commit call\n", data->task.tk_pid);
|
||||
|
||||
task = rpc_run_task(&task_setup_data);
|
||||
if (!IS_ERR(task))
|
||||
rpc_put_task(task);
|
||||
if (IS_ERR(task))
|
||||
return PTR_ERR(task);
|
||||
rpc_put_task(task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1227,15 +1252,13 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how)
|
||||
struct nfs_write_data *data;
|
||||
struct nfs_page *req;
|
||||
|
||||
data = nfs_commit_alloc();
|
||||
data = nfs_commitdata_alloc();
|
||||
|
||||
if (!data)
|
||||
goto out_bad;
|
||||
|
||||
/* Set up the argument struct */
|
||||
nfs_commit_rpcsetup(head, data, how);
|
||||
|
||||
return 0;
|
||||
return nfs_commit_rpcsetup(head, data, how);
|
||||
out_bad:
|
||||
while (!list_empty(head)) {
|
||||
req = nfs_list_entry(head->next);
|
||||
@@ -1255,7 +1278,6 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how)
|
||||
static void nfs_commit_done(struct rpc_task *task, void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_page *req;
|
||||
|
||||
dprintk("NFS: %5u nfs_commit_done (status %d)\n",
|
||||
task->tk_pid, task->tk_status);
|
||||
@@ -1263,6 +1285,13 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
|
||||
/* Call the NFS version-specific code */
|
||||
if (NFS_PROTO(data->inode)->commit_done(task, data) != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
static void nfs_commit_release(void *calldata)
|
||||
{
|
||||
struct nfs_write_data *data = calldata;
|
||||
struct nfs_page *req;
|
||||
int status = data->task.tk_status;
|
||||
|
||||
while (!list_empty(&data->pages)) {
|
||||
req = nfs_list_entry(data->pages.next);
|
||||
@@ -1277,10 +1306,10 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
|
||||
(long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
|
||||
req->wb_bytes,
|
||||
(long long)req_offset(req));
|
||||
if (task->tk_status < 0) {
|
||||
nfs_context_set_write_error(req->wb_context, task->tk_status);
|
||||
if (status < 0) {
|
||||
nfs_context_set_write_error(req->wb_context, status);
|
||||
nfs_inode_remove_request(req);
|
||||
dprintk(", error = %d\n", task->tk_status);
|
||||
dprintk(", error = %d\n", status);
|
||||
goto next;
|
||||
}
|
||||
|
||||
@@ -1297,10 +1326,11 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
|
||||
}
|
||||
/* We have a mismatch. Write the page again */
|
||||
dprintk(" mismatch\n");
|
||||
nfs_redirty_request(req);
|
||||
nfs_mark_request_dirty(req);
|
||||
next:
|
||||
nfs_clear_page_tag_locked(req);
|
||||
}
|
||||
nfs_commitdata_release(calldata);
|
||||
}
|
||||
|
||||
static const struct rpc_call_ops nfs_commit_ops = {
|
||||
@@ -1487,18 +1517,19 @@ static int nfs_wb_page_priority(struct inode *inode, struct page *page,
|
||||
};
|
||||
int ret;
|
||||
|
||||
BUG_ON(!PageLocked(page));
|
||||
if (clear_page_dirty_for_io(page)) {
|
||||
ret = nfs_writepage_locked(page, &wbc);
|
||||
do {
|
||||
if (clear_page_dirty_for_io(page)) {
|
||||
ret = nfs_writepage_locked(page, &wbc);
|
||||
if (ret < 0)
|
||||
goto out_error;
|
||||
} else if (!PagePrivate(page))
|
||||
break;
|
||||
ret = nfs_sync_mapping_wait(page->mapping, &wbc, how);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
}
|
||||
if (!PagePrivate(page))
|
||||
return 0;
|
||||
ret = nfs_sync_mapping_wait(page->mapping, &wbc, how);
|
||||
if (ret >= 0)
|
||||
return 0;
|
||||
out:
|
||||
goto out_error;
|
||||
} while (PagePrivate(page));
|
||||
return 0;
|
||||
out_error:
|
||||
__mark_inode_dirty(inode, I_DIRTY_PAGES);
|
||||
return ret;
|
||||
}
|
||||
|
Référencer dans un nouveau ticket
Bloquer un utilisateur