Merge branch 'bugfixes'

+70 -45
+11
fs/nfs/nfs4_fs.h
··· 303 303 struct rpc_cred *newcred = NULL; 304 304 rpc_authflavor_t flavor; 305 305 306 + if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP || 307 + sp4_mode == NFS_SP4_MACH_CRED_PNFS_CLEANUP) { 308 + /* Using machine creds for cleanup operations 309 + * is only relevent if the client credentials 310 + * might expire. So don't bother for 311 + * RPC_AUTH_UNIX. If file was only exported to 312 + * sec=sys, the PUTFH would fail anyway. 313 + */ 314 + if ((*clntp)->cl_auth->au_flavor == RPC_AUTH_UNIX) 315 + return false; 316 + } 306 317 if (test_bit(sp4_mode, &clp->cl_sp4_flags)) { 307 318 spin_lock(&clp->cl_lock); 308 319 if (clp->cl_machine_cred != NULL)
+40 -37
fs/nfs/pagelist.c
··· 682 682 const struct nfs_pgio_completion_ops *compl_ops, 683 683 const struct nfs_rw_ops *rw_ops, 684 684 size_t bsize, 685 - int io_flags, 686 - gfp_t gfp_flags) 685 + int io_flags) 687 686 { 688 - struct nfs_pgio_mirror *new; 689 - int i; 690 - 691 687 desc->pg_moreio = 0; 692 688 desc->pg_inode = inode; 693 689 desc->pg_ops = pg_ops; ··· 699 703 desc->pg_mirror_count = 1; 700 704 desc->pg_mirror_idx = 0; 701 705 702 - if (pg_ops->pg_get_mirror_count) { 703 - /* until we have a request, we don't have an lseg and no 704 - * idea how many mirrors there will be */ 705 - new = kcalloc(NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX, 706 - sizeof(struct nfs_pgio_mirror), gfp_flags); 707 - desc->pg_mirrors_dynamic = new; 708 - desc->pg_mirrors = new; 709 - 710 - for (i = 0; i < NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX; i++) 711 - nfs_pageio_mirror_init(&desc->pg_mirrors[i], bsize); 712 - } else { 713 - desc->pg_mirrors_dynamic = NULL; 714 - desc->pg_mirrors = desc->pg_mirrors_static; 715 - nfs_pageio_mirror_init(&desc->pg_mirrors[0], bsize); 716 - } 706 + desc->pg_mirrors_dynamic = NULL; 707 + desc->pg_mirrors = desc->pg_mirrors_static; 708 + nfs_pageio_mirror_init(&desc->pg_mirrors[0], bsize); 717 709 } 718 - EXPORT_SYMBOL_GPL(nfs_pageio_init); 719 710 720 711 /** 721 712 * nfs_pgio_result - Basic pageio error handling ··· 819 836 return ret; 820 837 } 821 838 839 + static struct nfs_pgio_mirror * 840 + nfs_pageio_alloc_mirrors(struct nfs_pageio_descriptor *desc, 841 + unsigned int mirror_count) 842 + { 843 + struct nfs_pgio_mirror *ret; 844 + unsigned int i; 845 + 846 + kfree(desc->pg_mirrors_dynamic); 847 + desc->pg_mirrors_dynamic = NULL; 848 + if (mirror_count == 1) 849 + return desc->pg_mirrors_static; 850 + ret = kmalloc_array(mirror_count, sizeof(*ret), GFP_NOFS); 851 + if (ret != NULL) { 852 + for (i = 0; i < mirror_count; i++) 853 + nfs_pageio_mirror_init(&ret[i], desc->pg_bsize); 854 + desc->pg_mirrors_dynamic = ret; 855 + } 856 + return ret; 857 + } 858 + 822 859 /* 823 860 * nfs_pageio_setup_mirroring - determine if mirroring is to be used 824 861 * by calling the pg_get_mirror_count op 825 862 */ 826 - static int nfs_pageio_setup_mirroring(struct nfs_pageio_descriptor *pgio, 863 + static void nfs_pageio_setup_mirroring(struct nfs_pageio_descriptor *pgio, 827 864 struct nfs_page *req) 828 865 { 829 - int mirror_count = 1; 866 + unsigned int mirror_count = 1; 830 867 831 - if (!pgio->pg_ops->pg_get_mirror_count) 832 - return 0; 868 + if (pgio->pg_ops->pg_get_mirror_count) 869 + mirror_count = pgio->pg_ops->pg_get_mirror_count(pgio, req); 870 + if (mirror_count == pgio->pg_mirror_count || pgio->pg_error < 0) 871 + return; 833 872 834 - mirror_count = pgio->pg_ops->pg_get_mirror_count(pgio, req); 873 + if (!mirror_count || mirror_count > NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX) { 874 + pgio->pg_error = -EINVAL; 875 + return; 876 + } 835 877 836 - if (pgio->pg_error < 0) 837 - return pgio->pg_error; 838 - 839 - if (!mirror_count || mirror_count > NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX) 840 - return -EINVAL; 841 - 842 - if (WARN_ON_ONCE(!pgio->pg_mirrors_dynamic)) 843 - return -EINVAL; 844 - 878 + pgio->pg_mirrors = nfs_pageio_alloc_mirrors(pgio, mirror_count); 879 + if (pgio->pg_mirrors == NULL) { 880 + pgio->pg_error = -ENOMEM; 881 + pgio->pg_mirrors = pgio->pg_mirrors_static; 882 + mirror_count = 1; 883 + } 845 884 pgio->pg_mirror_count = mirror_count; 846 - 847 - return 0; 848 885 } 849 886 850 887 /*
+1 -1
fs/nfs/read.c
··· 68 68 pg_ops = server->pnfs_curr_ld->pg_read_ops; 69 69 #endif 70 70 nfs_pageio_init(pgio, inode, pg_ops, compl_ops, &nfs_rw_read_ops, 71 - server->rsize, 0, GFP_KERNEL); 71 + server->rsize, 0); 72 72 } 73 73 EXPORT_SYMBOL_GPL(nfs_pageio_init_read); 74 74
+8 -4
fs/nfs/super.c
··· 1691 1691 rpc_authflavor_t *server_authlist, unsigned int count) 1692 1692 { 1693 1693 rpc_authflavor_t flavor = RPC_AUTH_MAXFLAVOR; 1694 + bool found_auth_null = false; 1694 1695 unsigned int i; 1695 - int use_auth_null = false; 1696 1696 1697 1697 /* 1698 1698 * If the sec= mount option is used, the specified flavor or AUTH_NULL ··· 1701 1701 * AUTH_NULL has a special meaning when it's in the server list - it 1702 1702 * means that the server will ignore the rpc creds, so any flavor 1703 1703 * can be used but still use the sec= that was specified. 1704 + * 1705 + * Note also that the MNT procedure in MNTv1 does not return a list 1706 + * of supported security flavors. In this case, nfs_mount() fabricates 1707 + * a security flavor list containing just AUTH_NULL. 1704 1708 */ 1705 1709 for (i = 0; i < count; i++) { 1706 1710 flavor = server_authlist[i]; ··· 1713 1709 goto out; 1714 1710 1715 1711 if (flavor == RPC_AUTH_NULL) 1716 - use_auth_null = true; 1712 + found_auth_null = true; 1717 1713 } 1718 1714 1719 - if (use_auth_null) { 1720 - flavor = RPC_AUTH_NULL; 1715 + if (found_auth_null) { 1716 + flavor = args->auth_info.flavors[0]; 1721 1717 goto out; 1722 1718 } 1723 1719
+1 -1
fs/nfs/write.c
··· 1424 1424 pg_ops = server->pnfs_curr_ld->pg_write_ops; 1425 1425 #endif 1426 1426 nfs_pageio_init(pgio, inode, pg_ops, compl_ops, &nfs_rw_write_ops, 1427 - server->wsize, ioflags, GFP_NOIO); 1427 + server->wsize, ioflags); 1428 1428 } 1429 1429 EXPORT_SYMBOL_GPL(nfs_pageio_init_write); 1430 1430
+1 -2
include/linux/nfs_page.h
··· 125 125 const struct nfs_pgio_completion_ops *compl_ops, 126 126 const struct nfs_rw_ops *rw_ops, 127 127 size_t bsize, 128 - int how, 129 - gfp_t gfp_flags); 128 + int how); 130 129 extern int nfs_pageio_add_request(struct nfs_pageio_descriptor *, 131 130 struct nfs_page *); 132 131 extern int nfs_pageio_resend(struct nfs_pageio_descriptor *,
+8
net/sunrpc/clnt.c
··· 1903 1903 task->tk_status = 0; 1904 1904 switch (status) { 1905 1905 case -ECONNREFUSED: 1906 + /* A positive refusal suggests a rebind is needed. */ 1907 + if (RPC_IS_SOFTCONN(task)) 1908 + break; 1909 + if (clnt->cl_autobind) { 1910 + rpc_force_rebind(clnt); 1911 + task->tk_action = call_bind; 1912 + return; 1913 + } 1906 1914 case -ECONNRESET: 1907 1915 case -ECONNABORTED: 1908 1916 case -ENETUNREACH: