aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/direct.c6
-rw-r--r--fs/nfs/inode.c5
-rw-r--r--fs/nfs/internal.h2
-rw-r--r--fs/nfs/nfs4client.c44
-rw-r--r--fs/nfs/nfs4proc.c21
5 files changed, 52 insertions, 26 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 10bf07280f4a..294692ff83b1 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -212,6 +212,12 @@ static int nfs_direct_cmp_commit_data_verf(struct nfs_direct_req *dreq,
212 */ 212 */
213ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos) 213ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
214{ 214{
215 struct inode *inode = iocb->ki_filp->f_mapping->host;
216
217 /* we only support swap file calling nfs_direct_IO */
218 if (!IS_SWAPFILE(inode))
219 return 0;
220
215#ifndef CONFIG_NFS_SWAP 221#ifndef CONFIG_NFS_SWAP
216 dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n", 222 dprintk("NFS: nfs_direct_IO (%pD) off/no(%Ld/%lu) EINVAL\n",
217 iocb->ki_filp, (long long) pos, iter->nr_segs); 223 iocb->ki_filp, (long long) pos, iter->nr_segs);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 4bffe637ea32..2211f6ba8736 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -352,8 +352,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
352 352
353 nfs_attr_check_mountpoint(sb, fattr); 353 nfs_attr_check_mountpoint(sb, fattr);
354 354
355 if (((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0) && 355 if (nfs_attr_use_mounted_on_fileid(fattr))
356 !nfs_attr_use_mounted_on_fileid(fattr)) 356 fattr->fileid = fattr->mounted_on_fileid;
357 else if ((fattr->valid & NFS_ATTR_FATTR_FILEID) == 0)
357 goto out_no_inode; 358 goto out_no_inode;
358 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0) 359 if ((fattr->valid & NFS_ATTR_FATTR_TYPE) == 0)
359 goto out_no_inode; 360 goto out_no_inode;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index efaa31c70fbe..b6f34bfa6fe8 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -31,8 +31,6 @@ static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr)
31 (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) && 31 (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) &&
32 ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0))) 32 ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0)))
33 return 0; 33 return 0;
34
35 fattr->fileid = fattr->mounted_on_fileid;
36 return 1; 34 return 1;
37} 35}
38 36
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
index 03311259b0c4..706ad10b8186 100644
--- a/fs/nfs/nfs4client.c
+++ b/fs/nfs/nfs4client.c
@@ -228,6 +228,7 @@ static void nfs4_shutdown_client(struct nfs_client *clp)
228 kfree(clp->cl_serverowner); 228 kfree(clp->cl_serverowner);
229 kfree(clp->cl_serverscope); 229 kfree(clp->cl_serverscope);
230 kfree(clp->cl_implid); 230 kfree(clp->cl_implid);
231 kfree(clp->cl_owner_id);
231} 232}
232 233
233void nfs4_free_client(struct nfs_client *clp) 234void nfs4_free_client(struct nfs_client *clp)
@@ -452,6 +453,14 @@ static void nfs4_swap_callback_idents(struct nfs_client *keep,
452 spin_unlock(&nn->nfs_client_lock); 453 spin_unlock(&nn->nfs_client_lock);
453} 454}
454 455
456static bool nfs4_match_client_owner_id(const struct nfs_client *clp1,
457 const struct nfs_client *clp2)
458{
459 if (clp1->cl_owner_id == NULL || clp2->cl_owner_id == NULL)
460 return true;
461 return strcmp(clp1->cl_owner_id, clp2->cl_owner_id) == 0;
462}
463
455/** 464/**
456 * nfs40_walk_client_list - Find server that recognizes a client ID 465 * nfs40_walk_client_list - Find server that recognizes a client ID
457 * 466 *
@@ -483,9 +492,6 @@ int nfs40_walk_client_list(struct nfs_client *new,
483 if (pos->rpc_ops != new->rpc_ops) 492 if (pos->rpc_ops != new->rpc_ops)
484 continue; 493 continue;
485 494
486 if (pos->cl_proto != new->cl_proto)
487 continue;
488
489 if (pos->cl_minorversion != new->cl_minorversion) 495 if (pos->cl_minorversion != new->cl_minorversion)
490 continue; 496 continue;
491 497
@@ -510,6 +516,9 @@ int nfs40_walk_client_list(struct nfs_client *new,
510 if (pos->cl_clientid != new->cl_clientid) 516 if (pos->cl_clientid != new->cl_clientid)
511 continue; 517 continue;
512 518
519 if (!nfs4_match_client_owner_id(pos, new))
520 continue;
521
513 atomic_inc(&pos->cl_count); 522 atomic_inc(&pos->cl_count);
514 spin_unlock(&nn->nfs_client_lock); 523 spin_unlock(&nn->nfs_client_lock);
515 524
@@ -566,20 +575,14 @@ static bool nfs4_match_clientids(struct nfs_client *a, struct nfs_client *b)
566} 575}
567 576
568/* 577/*
569 * Returns true if the server owners match 578 * Returns true if the server major ids match
570 */ 579 */
571static bool 580static bool
572nfs4_match_serverowners(struct nfs_client *a, struct nfs_client *b) 581nfs4_check_clientid_trunking(struct nfs_client *a, struct nfs_client *b)
573{ 582{
574 struct nfs41_server_owner *o1 = a->cl_serverowner; 583 struct nfs41_server_owner *o1 = a->cl_serverowner;
575 struct nfs41_server_owner *o2 = b->cl_serverowner; 584 struct nfs41_server_owner *o2 = b->cl_serverowner;
576 585
577 if (o1->minor_id != o2->minor_id) {
578 dprintk("NFS: --> %s server owner minor IDs do not match\n",
579 __func__);
580 return false;
581 }
582
583 if (o1->major_id_sz != o2->major_id_sz) 586 if (o1->major_id_sz != o2->major_id_sz)
584 goto out_major_mismatch; 587 goto out_major_mismatch;
585 if (memcmp(o1->major_id, o2->major_id, o1->major_id_sz) != 0) 588 if (memcmp(o1->major_id, o2->major_id, o1->major_id_sz) != 0)
@@ -621,9 +624,6 @@ int nfs41_walk_client_list(struct nfs_client *new,
621 if (pos->rpc_ops != new->rpc_ops) 624 if (pos->rpc_ops != new->rpc_ops)
622 continue; 625 continue;
623 626
624 if (pos->cl_proto != new->cl_proto)
625 continue;
626
627 if (pos->cl_minorversion != new->cl_minorversion) 627 if (pos->cl_minorversion != new->cl_minorversion)
628 continue; 628 continue;
629 629
@@ -639,7 +639,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
639 prev = pos; 639 prev = pos;
640 640
641 status = nfs_wait_client_init_complete(pos); 641 status = nfs_wait_client_init_complete(pos);
642 if (status == 0) { 642 if (pos->cl_cons_state == NFS_CS_SESSION_INITING) {
643 nfs4_schedule_lease_recovery(pos); 643 nfs4_schedule_lease_recovery(pos);
644 status = nfs4_wait_clnt_recover(pos); 644 status = nfs4_wait_clnt_recover(pos);
645 } 645 }
@@ -654,7 +654,19 @@ int nfs41_walk_client_list(struct nfs_client *new,
654 if (!nfs4_match_clientids(pos, new)) 654 if (!nfs4_match_clientids(pos, new))
655 continue; 655 continue;
656 656
657 if (!nfs4_match_serverowners(pos, new)) 657 /*
658 * Note that session trunking is just a special subcase of
659 * client id trunking. In either case, we want to fall back
660 * to using the existing nfs_client.
661 */
662 if (!nfs4_check_clientid_trunking(pos, new))
663 continue;
664
665 /* Unlike NFSv4.0, we know that NFSv4.1 always uses the
666 * uniform string, however someone might switch the
667 * uniquifier string on us.
668 */
669 if (!nfs4_match_client_owner_id(pos, new))
658 continue; 670 continue;
659 671
660 atomic_inc(&pos->cl_count); 672 atomic_inc(&pos->cl_count);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index e7f8d5ff2581..c347705b0161 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1117,8 +1117,6 @@ static int can_open_delegated(struct nfs_delegation *delegation, fmode_t fmode)
1117 return 0; 1117 return 0;
1118 if ((delegation->type & fmode) != fmode) 1118 if ((delegation->type & fmode) != fmode)
1119 return 0; 1119 return 0;
1120 if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags))
1121 return 0;
1122 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) 1120 if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
1123 return 0; 1121 return 0;
1124 nfs_mark_delegation_referenced(delegation); 1122 nfs_mark_delegation_referenced(delegation);
@@ -4917,11 +4915,14 @@ static void nfs4_init_boot_verifier(const struct nfs_client *clp,
4917} 4915}
4918 4916
4919static unsigned int 4917static unsigned int
4920nfs4_init_nonuniform_client_string(const struct nfs_client *clp, 4918nfs4_init_nonuniform_client_string(struct nfs_client *clp,
4921 char *buf, size_t len) 4919 char *buf, size_t len)
4922{ 4920{
4923 unsigned int result; 4921 unsigned int result;
4924 4922
4923 if (clp->cl_owner_id != NULL)
4924 return strlcpy(buf, clp->cl_owner_id, len);
4925
4925 rcu_read_lock(); 4926 rcu_read_lock();
4926 result = scnprintf(buf, len, "Linux NFSv4.0 %s/%s %s", 4927 result = scnprintf(buf, len, "Linux NFSv4.0 %s/%s %s",
4927 clp->cl_ipaddr, 4928 clp->cl_ipaddr,
@@ -4930,24 +4931,32 @@ nfs4_init_nonuniform_client_string(const struct nfs_client *clp,
4930 rpc_peeraddr2str(clp->cl_rpcclient, 4931 rpc_peeraddr2str(clp->cl_rpcclient,
4931 RPC_DISPLAY_PROTO)); 4932 RPC_DISPLAY_PROTO));
4932 rcu_read_unlock(); 4933 rcu_read_unlock();
4934 clp->cl_owner_id = kstrdup(buf, GFP_KERNEL);
4933 return result; 4935 return result;
4934} 4936}
4935 4937
4936static unsigned int 4938static unsigned int
4937nfs4_init_uniform_client_string(const struct nfs_client *clp, 4939nfs4_init_uniform_client_string(struct nfs_client *clp,
4938 char *buf, size_t len) 4940 char *buf, size_t len)
4939{ 4941{
4940 const char *nodename = clp->cl_rpcclient->cl_nodename; 4942 const char *nodename = clp->cl_rpcclient->cl_nodename;
4943 unsigned int result;
4944
4945 if (clp->cl_owner_id != NULL)
4946 return strlcpy(buf, clp->cl_owner_id, len);
4941 4947
4942 if (nfs4_client_id_uniquifier[0] != '\0') 4948 if (nfs4_client_id_uniquifier[0] != '\0')
4943 return scnprintf(buf, len, "Linux NFSv%u.%u %s/%s", 4949 result = scnprintf(buf, len, "Linux NFSv%u.%u %s/%s",
4944 clp->rpc_ops->version, 4950 clp->rpc_ops->version,
4945 clp->cl_minorversion, 4951 clp->cl_minorversion,
4946 nfs4_client_id_uniquifier, 4952 nfs4_client_id_uniquifier,
4947 nodename); 4953 nodename);
4948 return scnprintf(buf, len, "Linux NFSv%u.%u %s", 4954 else
4955 result = scnprintf(buf, len, "Linux NFSv%u.%u %s",
4949 clp->rpc_ops->version, clp->cl_minorversion, 4956 clp->rpc_ops->version, clp->cl_minorversion,
4950 nodename); 4957 nodename);
4958 clp->cl_owner_id = kstrdup(buf, GFP_KERNEL);
4959 return result;
4951} 4960}
4952 4961
4953/* 4962/*