aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-02 17:33:37 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-05-02 17:33:37 -0400
commiteb1574270a6de8fb8d31ffc3b021e30df0afcda3 (patch)
treed154ba369f222f5108ed1a2462d815d7faadc2e5 /fs/nfs
parentaac10aaa8cc65a6fef6f5bc7d0b96035b0225a61 (diff)
parent69964ea4c7b68c9399f7977aa5b9aa6539a6a98a (diff)
Merge 3.4-rc5 into driver-core-next
This was done to resolve a merge issue with the init/main.c file. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/dir.c4
-rw-r--r--fs/nfs/nfs4_fs.h1
-rw-r--r--fs/nfs/nfs4proc.c44
-rw-r--r--fs/nfs/nfs4state.c31
-rw-r--r--fs/nfs/nfs4xdr.c9
-rw-r--r--fs/nfs/read.c2
-rw-r--r--fs/nfs/super.c8
-rw-r--r--fs/nfs/write.c5
8 files changed, 73 insertions, 31 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4aaf0316d76a..8789210c6905 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1429,7 +1429,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
1429 } 1429 }
1430 1430
1431 open_flags = nd->intent.open.flags; 1431 open_flags = nd->intent.open.flags;
1432 attr.ia_valid = 0; 1432 attr.ia_valid = ATTR_OPEN;
1433 1433
1434 ctx = create_nfs_open_context(dentry, open_flags); 1434 ctx = create_nfs_open_context(dentry, open_flags);
1435 res = ERR_CAST(ctx); 1435 res = ERR_CAST(ctx);
@@ -1536,7 +1536,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1536 if (IS_ERR(ctx)) 1536 if (IS_ERR(ctx))
1537 goto out; 1537 goto out;
1538 1538
1539 attr.ia_valid = 0; 1539 attr.ia_valid = ATTR_OPEN;
1540 if (openflags & O_TRUNC) { 1540 if (openflags & O_TRUNC) {
1541 attr.ia_valid |= ATTR_SIZE; 1541 attr.ia_valid |= ATTR_SIZE;
1542 attr.ia_size = 0; 1542 attr.ia_size = 0;
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 97ecc863dd76..b6db9e33fb7b 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -59,6 +59,7 @@ struct nfs_unique_id {
59 59
60#define NFS_SEQID_CONFIRMED 1 60#define NFS_SEQID_CONFIRMED 1
61struct nfs_seqid_counter { 61struct nfs_seqid_counter {
62 ktime_t create_time;
62 int owner_id; 63 int owner_id;
63 int flags; 64 int flags;
64 u32 counter; 65 u32 counter;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f82bde005a82..60d5f4c26dda 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -838,7 +838,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
838 p->o_arg.open_flags = flags; 838 p->o_arg.open_flags = flags;
839 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); 839 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
840 p->o_arg.clientid = server->nfs_client->cl_clientid; 840 p->o_arg.clientid = server->nfs_client->cl_clientid;
841 p->o_arg.id = sp->so_seqid.owner_id; 841 p->o_arg.id.create_time = ktime_to_ns(sp->so_seqid.create_time);
842 p->o_arg.id.uniquifier = sp->so_seqid.owner_id;
842 p->o_arg.name = &dentry->d_name; 843 p->o_arg.name = &dentry->d_name;
843 p->o_arg.server = server; 844 p->o_arg.server = server;
844 p->o_arg.bitmask = server->attr_bitmask; 845 p->o_arg.bitmask = server->attr_bitmask;
@@ -1466,8 +1467,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
1466 goto unlock_no_action; 1467 goto unlock_no_action;
1467 rcu_read_unlock(); 1468 rcu_read_unlock();
1468 } 1469 }
1469 /* Update sequence id. */ 1470 /* Update client id. */
1470 data->o_arg.id = sp->so_seqid.owner_id;
1471 data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid; 1471 data->o_arg.clientid = sp->so_server->nfs_client->cl_clientid;
1472 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) { 1472 if (data->o_arg.claim == NFS4_OPEN_CLAIM_PREVIOUS) {
1473 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR]; 1473 task->tk_msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_NOATTR];
@@ -1954,10 +1954,19 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
1954 }; 1954 };
1955 int err; 1955 int err;
1956 do { 1956 do {
1957 err = nfs4_handle_exception(server, 1957 err = _nfs4_do_setattr(inode, cred, fattr, sattr, state);
1958 _nfs4_do_setattr(inode, cred, fattr, sattr, state), 1958 switch (err) {
1959 &exception); 1959 case -NFS4ERR_OPENMODE:
1960 if (state && !(state->state & FMODE_WRITE)) {
1961 err = -EBADF;
1962 if (sattr->ia_valid & ATTR_OPEN)
1963 err = -EACCES;
1964 goto out;
1965 }
1966 }
1967 err = nfs4_handle_exception(server, err, &exception);
1960 } while (exception.retry); 1968 } while (exception.retry);
1969out:
1961 return err; 1970 return err;
1962} 1971}
1963 1972
@@ -4558,7 +4567,9 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
4558static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request) 4567static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request)
4559{ 4568{
4560 struct nfs_server *server = NFS_SERVER(state->inode); 4569 struct nfs_server *server = NFS_SERVER(state->inode);
4561 struct nfs4_exception exception = { }; 4570 struct nfs4_exception exception = {
4571 .inode = state->inode,
4572 };
4562 int err; 4573 int err;
4563 4574
4564 do { 4575 do {
@@ -4576,7 +4587,9 @@ static int nfs4_lock_reclaim(struct nfs4_state *state, struct file_lock *request
4576static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request) 4587static int nfs4_lock_expired(struct nfs4_state *state, struct file_lock *request)
4577{ 4588{
4578 struct nfs_server *server = NFS_SERVER(state->inode); 4589 struct nfs_server *server = NFS_SERVER(state->inode);
4579 struct nfs4_exception exception = { }; 4590 struct nfs4_exception exception = {
4591 .inode = state->inode,
4592 };
4580 int err; 4593 int err;
4581 4594
4582 err = nfs4_set_lock_state(state, request); 4595 err = nfs4_set_lock_state(state, request);
@@ -4676,6 +4689,7 @@ static int nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock *
4676{ 4689{
4677 struct nfs4_exception exception = { 4690 struct nfs4_exception exception = {
4678 .state = state, 4691 .state = state,
4692 .inode = state->inode,
4679 }; 4693 };
4680 int err; 4694 int err;
4681 4695
@@ -4721,6 +4735,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
4721 4735
4722 if (state == NULL) 4736 if (state == NULL)
4723 return -ENOLCK; 4737 return -ENOLCK;
4738 /*
4739 * Don't rely on the VFS having checked the file open mode,
4740 * since it won't do this for flock() locks.
4741 */
4742 switch (request->fl_type & (F_RDLCK|F_WRLCK|F_UNLCK)) {
4743 case F_RDLCK:
4744 if (!(filp->f_mode & FMODE_READ))
4745 return -EBADF;
4746 break;
4747 case F_WRLCK:
4748 if (!(filp->f_mode & FMODE_WRITE))
4749 return -EBADF;
4750 }
4751
4724 do { 4752 do {
4725 status = nfs4_proc_setlk(state, cmd, request); 4753 status = nfs4_proc_setlk(state, cmd, request);
4726 if ((status != -EAGAIN) || IS_SETLK(cmd)) 4754 if ((status != -EAGAIN) || IS_SETLK(cmd))
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 0f43414eb25a..7f0fcfc1fe9d 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -393,6 +393,7 @@ nfs4_remove_state_owner_locked(struct nfs4_state_owner *sp)
393static void 393static void
394nfs4_init_seqid_counter(struct nfs_seqid_counter *sc) 394nfs4_init_seqid_counter(struct nfs_seqid_counter *sc)
395{ 395{
396 sc->create_time = ktime_get();
396 sc->flags = 0; 397 sc->flags = 0;
397 sc->counter = 0; 398 sc->counter = 0;
398 spin_lock_init(&sc->lock); 399 spin_lock_init(&sc->lock);
@@ -434,13 +435,17 @@ nfs4_alloc_state_owner(struct nfs_server *server,
434static void 435static void
435nfs4_drop_state_owner(struct nfs4_state_owner *sp) 436nfs4_drop_state_owner(struct nfs4_state_owner *sp)
436{ 437{
437 if (!RB_EMPTY_NODE(&sp->so_server_node)) { 438 struct rb_node *rb_node = &sp->so_server_node;
439
440 if (!RB_EMPTY_NODE(rb_node)) {
438 struct nfs_server *server = sp->so_server; 441 struct nfs_server *server = sp->so_server;
439 struct nfs_client *clp = server->nfs_client; 442 struct nfs_client *clp = server->nfs_client;
440 443
441 spin_lock(&clp->cl_lock); 444 spin_lock(&clp->cl_lock);
442 rb_erase(&sp->so_server_node, &server->state_owners); 445 if (!RB_EMPTY_NODE(rb_node)) {
443 RB_CLEAR_NODE(&sp->so_server_node); 446 rb_erase(rb_node, &server->state_owners);
447 RB_CLEAR_NODE(rb_node);
448 }
444 spin_unlock(&clp->cl_lock); 449 spin_unlock(&clp->cl_lock);
445 } 450 }
446} 451}
@@ -516,6 +521,14 @@ out:
516/** 521/**
517 * nfs4_put_state_owner - Release a nfs4_state_owner 522 * nfs4_put_state_owner - Release a nfs4_state_owner
518 * @sp: state owner data to release 523 * @sp: state owner data to release
524 *
525 * Note that we keep released state owners on an LRU
526 * list.
527 * This caches valid state owners so that they can be
528 * reused, to avoid the OPEN_CONFIRM on minor version 0.
529 * It also pins the uniquifier of dropped state owners for
530 * a while, to ensure that those state owner names are
531 * never reused.
519 */ 532 */
520void nfs4_put_state_owner(struct nfs4_state_owner *sp) 533void nfs4_put_state_owner(struct nfs4_state_owner *sp)
521{ 534{
@@ -525,15 +538,9 @@ void nfs4_put_state_owner(struct nfs4_state_owner *sp)
525 if (!atomic_dec_and_lock(&sp->so_count, &clp->cl_lock)) 538 if (!atomic_dec_and_lock(&sp->so_count, &clp->cl_lock))
526 return; 539 return;
527 540
528 if (!RB_EMPTY_NODE(&sp->so_server_node)) { 541 sp->so_expires = jiffies;
529 sp->so_expires = jiffies; 542 list_add_tail(&sp->so_lru, &server->state_owners_lru);
530 list_add_tail(&sp->so_lru, &server->state_owners_lru); 543 spin_unlock(&clp->cl_lock);
531 spin_unlock(&clp->cl_lock);
532 } else {
533 nfs4_remove_state_owner_locked(sp);
534 spin_unlock(&clp->cl_lock);
535 nfs4_free_state_owner(sp);
536 }
537} 544}
538 545
539/** 546/**
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index c74fdb114b48..77fc5f959c4e 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -74,7 +74,7 @@ static int nfs4_stat_to_errno(int);
74/* lock,open owner id: 74/* lock,open owner id:
75 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2) 75 * we currently use size 2 (u64) out of (NFS4_OPAQUE_LIMIT >> 2)
76 */ 76 */
77#define open_owner_id_maxsz (1 + 1 + 4) 77#define open_owner_id_maxsz (1 + 2 + 1 + 1 + 2)
78#define lock_owner_id_maxsz (1 + 1 + 4) 78#define lock_owner_id_maxsz (1 + 1 + 4)
79#define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ)) 79#define decode_lockowner_maxsz (1 + XDR_QUADLEN(IDMAP_NAMESZ))
80#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2)) 80#define compound_encode_hdr_maxsz (3 + (NFS4_MAXTAGLEN >> 2))
@@ -1340,12 +1340,13 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena
1340 */ 1340 */
1341 encode_nfs4_seqid(xdr, arg->seqid); 1341 encode_nfs4_seqid(xdr, arg->seqid);
1342 encode_share_access(xdr, arg->fmode); 1342 encode_share_access(xdr, arg->fmode);
1343 p = reserve_space(xdr, 32); 1343 p = reserve_space(xdr, 36);
1344 p = xdr_encode_hyper(p, arg->clientid); 1344 p = xdr_encode_hyper(p, arg->clientid);
1345 *p++ = cpu_to_be32(20); 1345 *p++ = cpu_to_be32(24);
1346 p = xdr_encode_opaque_fixed(p, "open id:", 8); 1346 p = xdr_encode_opaque_fixed(p, "open id:", 8);
1347 *p++ = cpu_to_be32(arg->server->s_dev); 1347 *p++ = cpu_to_be32(arg->server->s_dev);
1348 xdr_encode_hyper(p, arg->id); 1348 *p++ = cpu_to_be32(arg->id.uniquifier);
1349 xdr_encode_hyper(p, arg->id.create_time);
1349} 1350}
1350 1351
1351static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg) 1352static inline void encode_createmode(struct xdr_stream *xdr, const struct nfs_openargs *arg)
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 9a0e8ef4a409..0a4be28c2ea3 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -322,7 +322,7 @@ out_bad:
322 while (!list_empty(res)) { 322 while (!list_empty(res)) {
323 data = list_entry(res->next, struct nfs_read_data, list); 323 data = list_entry(res->next, struct nfs_read_data, list);
324 list_del(&data->list); 324 list_del(&data->list);
325 nfs_readdata_free(data); 325 nfs_readdata_release(data);
326 } 326 }
327 nfs_readpage_release(req); 327 nfs_readpage_release(req);
328 return -ENOMEM; 328 return -ENOMEM;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 37412f706b32..1e6715f0616c 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2767,11 +2767,15 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
2767 char *root_devname; 2767 char *root_devname;
2768 size_t len; 2768 size_t len;
2769 2769
2770 len = strlen(hostname) + 3; 2770 len = strlen(hostname) + 5;
2771 root_devname = kmalloc(len, GFP_KERNEL); 2771 root_devname = kmalloc(len, GFP_KERNEL);
2772 if (root_devname == NULL) 2772 if (root_devname == NULL)
2773 return ERR_PTR(-ENOMEM); 2773 return ERR_PTR(-ENOMEM);
2774 snprintf(root_devname, len, "%s:/", hostname); 2774 /* Does hostname needs to be enclosed in brackets? */
2775 if (strchr(hostname, ':'))
2776 snprintf(root_devname, len, "[%s]:/", hostname);
2777 else
2778 snprintf(root_devname, len, "%s:/", hostname);
2775 root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data); 2779 root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data);
2776 kfree(root_devname); 2780 kfree(root_devname);
2777 return root_mnt; 2781 return root_mnt;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 2c68818f68ac..c07462320f6b 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -682,7 +682,8 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
682 req->wb_bytes = rqend - req->wb_offset; 682 req->wb_bytes = rqend - req->wb_offset;
683out_unlock: 683out_unlock:
684 spin_unlock(&inode->i_lock); 684 spin_unlock(&inode->i_lock);
685 nfs_clear_request_commit(req); 685 if (req)
686 nfs_clear_request_commit(req);
686 return req; 687 return req;
687out_flushme: 688out_flushme:
688 spin_unlock(&inode->i_lock); 689 spin_unlock(&inode->i_lock);
@@ -1018,7 +1019,7 @@ out_bad:
1018 while (!list_empty(res)) { 1019 while (!list_empty(res)) {
1019 data = list_entry(res->next, struct nfs_write_data, list); 1020 data = list_entry(res->next, struct nfs_write_data, list);
1020 list_del(&data->list); 1021 list_del(&data->list);
1021 nfs_writedata_free(data); 1022 nfs_writedata_release(data);
1022 } 1023 }
1023 nfs_redirty_request(req); 1024 nfs_redirty_request(req);
1024 return -ENOMEM; 1025 return -ENOMEM;