diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-15 18:34:16 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-07-15 18:34:16 -0400 |
commit | e89e896d31b11a51a54ddcd3f72a76bd286dd86c (patch) | |
tree | 105a9a93a4021caeeba76e479778ad2dd2b87b57 | |
parent | 3a628b0fd42f7eaf9d052447784d48ceae9ffb8e (diff) | |
parent | d67d1c7bf948341fd8678c8e337ec27f4b46b206 (diff) |
Merge branch 'devel' into next
Conflicts:
fs/nfs/file.c
Fix up the conflict with Jon Corbet's bkl-removal tree
35 files changed, 1844 insertions, 1159 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index 313b2e06ded5..84ab76a206a0 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -1544,10 +1544,6 @@ config UFS_FS | |||
1544 | The recently released UFS2 variant (used in FreeBSD 5.x) is | 1544 | The recently released UFS2 variant (used in FreeBSD 5.x) is |
1545 | READ-ONLY supported. | 1545 | READ-ONLY supported. |
1546 | 1546 | ||
1547 | If you only intend to mount files from some other Unix over the | ||
1548 | network using NFS, you don't need the UFS file system support (but | ||
1549 | you need NFS file system support obviously). | ||
1550 | |||
1551 | Note that this option is generally not needed for floppies, since a | 1547 | Note that this option is generally not needed for floppies, since a |
1552 | good portable way to transport files and directories between unixes | 1548 | good portable way to transport files and directories between unixes |
1553 | (and even other operating systems) is given by the tar program ("man | 1549 | (and even other operating systems) is given by the tar program ("man |
@@ -1587,6 +1583,7 @@ menuconfig NETWORK_FILESYSTEMS | |||
1587 | Say Y here to get to see options for network filesystems and | 1583 | Say Y here to get to see options for network filesystems and |
1588 | filesystem-related networking code, such as NFS daemon and | 1584 | filesystem-related networking code, such as NFS daemon and |
1589 | RPCSEC security modules. | 1585 | RPCSEC security modules. |
1586 | |||
1590 | This option alone does not add any kernel code. | 1587 | This option alone does not add any kernel code. |
1591 | 1588 | ||
1592 | If you say N, all options in this submenu will be skipped and | 1589 | If you say N, all options in this submenu will be skipped and |
@@ -1595,76 +1592,92 @@ menuconfig NETWORK_FILESYSTEMS | |||
1595 | if NETWORK_FILESYSTEMS | 1592 | if NETWORK_FILESYSTEMS |
1596 | 1593 | ||
1597 | config NFS_FS | 1594 | config NFS_FS |
1598 | tristate "NFS file system support" | 1595 | tristate "NFS client support" |
1599 | depends on INET | 1596 | depends on INET |
1600 | select LOCKD | 1597 | select LOCKD |
1601 | select SUNRPC | 1598 | select SUNRPC |
1602 | select NFS_ACL_SUPPORT if NFS_V3_ACL | 1599 | select NFS_ACL_SUPPORT if NFS_V3_ACL |
1603 | help | 1600 | help |
1604 | If you are connected to some other (usually local) Unix computer | 1601 | Choose Y here if you want to access files residing on other |
1605 | (using SLIP, PLIP, PPP or Ethernet) and want to mount files residing | 1602 | computers using Sun's Network File System protocol. To compile |
1606 | on that computer (the NFS server) using the Network File Sharing | 1603 | this file system support as a module, choose M here: the module |
1607 | protocol, say Y. "Mounting files" means that the client can access | 1604 | will be called nfs. |
1608 | the files with usual UNIX commands as if they were sitting on the | ||
1609 | client's hard disk. For this to work, the server must run the | ||
1610 | programs nfsd and mountd (but does not need to have NFS file system | ||
1611 | support enabled in its kernel). NFS is explained in the Network | ||
1612 | Administrator's Guide, available from | ||
1613 | <http://www.tldp.org/docs.html#guide>, on its man page: "man | ||
1614 | nfs", and in the NFS-HOWTO. | ||
1615 | |||
1616 | A superior but less widely used alternative to NFS is provided by | ||
1617 | the Coda file system; see "Coda file system support" below. | ||
1618 | 1605 | ||
1619 | If you say Y here, you should have said Y to TCP/IP networking also. | 1606 | To mount file systems exported by NFS servers, you also need to |
1620 | This option would enlarge your kernel by about 27 KB. | 1607 | install the user space mount.nfs command which can be found in |
1608 | the Linux nfs-utils package, available from http://linux-nfs.org/. | ||
1609 | Information about using the mount command is available in the | ||
1610 | mount(8) man page. More detail about the Linux NFS client | ||
1611 | implementation is available via the nfs(5) man page. | ||
1621 | 1612 | ||
1622 | To compile this file system support as a module, choose M here: the | 1613 | Below you can choose which versions of the NFS protocol are |
1623 | module will be called nfs. | 1614 | available in the kernel to mount NFS servers. Support for NFS |
1615 | version 2 (RFC 1094) is always available when NFS_FS is selected. | ||
1624 | 1616 | ||
1625 | If you are configuring a diskless machine which will mount its root | 1617 | To configure a system which mounts its root file system via NFS |
1626 | file system over NFS at boot time, say Y here and to "Kernel | 1618 | at boot time, say Y here, select "Kernel level IP |
1627 | level IP autoconfiguration" above and to "Root file system on NFS" | 1619 | autoconfiguration" in the NETWORK menu, and select "Root file |
1628 | below. You cannot compile this driver as a module in this case. | 1620 | system on NFS" below. You cannot compile this file system as a |
1629 | There are two packages designed for booting diskless machines over | 1621 | module in this case. |
1630 | the net: netboot, available from | ||
1631 | <http://ftp1.sourceforge.net/netboot/>, and Etherboot, | ||
1632 | available from <http://ftp1.sourceforge.net/etherboot/>. | ||
1633 | 1622 | ||
1634 | If you don't know what all this is about, say N. | 1623 | If unsure, say N. |
1635 | 1624 | ||
1636 | config NFS_V3 | 1625 | config NFS_V3 |
1637 | bool "Provide NFSv3 client support" | 1626 | bool "NFS client support for NFS version 3" |
1638 | depends on NFS_FS | 1627 | depends on NFS_FS |
1639 | help | 1628 | help |
1640 | Say Y here if you want your NFS client to be able to speak version | 1629 | This option enables support for version 3 of the NFS protocol |
1641 | 3 of the NFS protocol. | 1630 | (RFC 1813) in the kernel's NFS client. |
1642 | 1631 | ||
1643 | If unsure, say Y. | 1632 | If unsure, say Y. |
1644 | 1633 | ||
1645 | config NFS_V3_ACL | 1634 | config NFS_V3_ACL |
1646 | bool "Provide client support for the NFSv3 ACL protocol extension" | 1635 | bool "NFS client support for the NFSv3 ACL protocol extension" |
1647 | depends on NFS_V3 | 1636 | depends on NFS_V3 |
1648 | help | 1637 | help |
1649 | Implement the NFSv3 ACL protocol extension for manipulating POSIX | 1638 | Some NFS servers support an auxiliary NFSv3 ACL protocol that |
1650 | Access Control Lists. The server should also be compiled with | 1639 | Sun added to Solaris but never became an official part of the |
1651 | the NFSv3 ACL protocol extension; see the CONFIG_NFSD_V3_ACL option. | 1640 | NFS version 3 protocol. This protocol extension allows |
1641 | applications on NFS clients to manipulate POSIX Access Control | ||
1642 | Lists on files residing on NFS servers. NFS servers enforce | ||
1643 | ACLs on local files whether this protocol is available or not. | ||
1644 | |||
1645 | Choose Y here if your NFS server supports the Solaris NFSv3 ACL | ||
1646 | protocol extension and you want your NFS client to allow | ||
1647 | applications to access and modify ACLs on files on the server. | ||
1648 | |||
1649 | Most NFS servers don't support the Solaris NFSv3 ACL protocol | ||
1650 | extension. You can choose N here or specify the "noacl" mount | ||
1651 | option to prevent your NFS client from trying to use the NFSv3 | ||
1652 | ACL protocol. | ||
1652 | 1653 | ||
1653 | If unsure, say N. | 1654 | If unsure, say N. |
1654 | 1655 | ||
1655 | config NFS_V4 | 1656 | config NFS_V4 |
1656 | bool "Provide NFSv4 client support (EXPERIMENTAL)" | 1657 | bool "NFS client support for NFS version 4 (EXPERIMENTAL)" |
1657 | depends on NFS_FS && EXPERIMENTAL | 1658 | depends on NFS_FS && EXPERIMENTAL |
1658 | select RPCSEC_GSS_KRB5 | 1659 | select RPCSEC_GSS_KRB5 |
1659 | help | 1660 | help |
1660 | Say Y here if you want your NFS client to be able to speak the newer | 1661 | This option enables support for version 4 of the NFS protocol |
1661 | version 4 of the NFS protocol. | 1662 | (RFC 3530) in the kernel's NFS client. |
1662 | 1663 | ||
1663 | Note: Requires auxiliary userspace daemons which may be found on | 1664 | To mount NFS servers using NFSv4, you also need to install user |
1664 | http://www.citi.umich.edu/projects/nfsv4/ | 1665 | space programs which can be found in the Linux nfs-utils package, |
1666 | available from http://linux-nfs.org/. | ||
1665 | 1667 | ||
1666 | If unsure, say N. | 1668 | If unsure, say N. |
1667 | 1669 | ||
1670 | config ROOT_NFS | ||
1671 | bool "Root file system on NFS" | ||
1672 | depends on NFS_FS=y && IP_PNP | ||
1673 | help | ||
1674 | If you want your system to mount its root file system via NFS, | ||
1675 | choose Y here. This is common practice for managing systems | ||
1676 | without local permanent storage. For details, read | ||
1677 | <file:Documentation/filesystems/nfsroot.txt>. | ||
1678 | |||
1679 | Most people say N here. | ||
1680 | |||
1668 | config NFSD | 1681 | config NFSD |
1669 | tristate "NFS server support" | 1682 | tristate "NFS server support" |
1670 | depends on INET | 1683 | depends on INET |
@@ -1746,20 +1759,6 @@ config NFSD_V4 | |||
1746 | 1759 | ||
1747 | If unsure, say N. | 1760 | If unsure, say N. |
1748 | 1761 | ||
1749 | config ROOT_NFS | ||
1750 | bool "Root file system on NFS" | ||
1751 | depends on NFS_FS=y && IP_PNP | ||
1752 | help | ||
1753 | If you want your Linux box to mount its whole root file system (the | ||
1754 | one containing the directory /) from some other computer over the | ||
1755 | net via NFS (presumably because your box doesn't have a hard disk), | ||
1756 | say Y. Read <file:Documentation/filesystems/nfsroot.txt> for | ||
1757 | details. It is likely that in this case, you also want to say Y to | ||
1758 | "Kernel level IP autoconfiguration" so that your box can discover | ||
1759 | its network address at boot time. | ||
1760 | |||
1761 | Most people say N here. | ||
1762 | |||
1763 | config LOCKD | 1762 | config LOCKD |
1764 | tristate | 1763 | tristate |
1765 | 1764 | ||
@@ -1800,27 +1799,6 @@ config SUNRPC_XPRT_RDMA | |||
1800 | 1799 | ||
1801 | If unsure, say N. | 1800 | If unsure, say N. |
1802 | 1801 | ||
1803 | config SUNRPC_BIND34 | ||
1804 | bool "Support for rpcbind versions 3 & 4 (EXPERIMENTAL)" | ||
1805 | depends on SUNRPC && EXPERIMENTAL | ||
1806 | default n | ||
1807 | help | ||
1808 | RPC requests over IPv6 networks require support for larger | ||
1809 | addresses when performing an RPC bind. Sun added support for | ||
1810 | IPv6 addressing by creating two new versions of the rpcbind | ||
1811 | protocol (RFC 1833). | ||
1812 | |||
1813 | This option enables support in the kernel RPC client for | ||
1814 | querying rpcbind servers via versions 3 and 4 of the rpcbind | ||
1815 | protocol. The kernel automatically falls back to version 2 | ||
1816 | if a remote rpcbind service does not support versions 3 or 4. | ||
1817 | By themselves, these new versions do not provide support for | ||
1818 | RPC over IPv6, but the new protocol versions are necessary to | ||
1819 | support it. | ||
1820 | |||
1821 | If unsure, say N to get traditional behavior (version 2 rpcbind | ||
1822 | requests only). | ||
1823 | |||
1824 | config RPCSEC_GSS_KRB5 | 1802 | config RPCSEC_GSS_KRB5 |
1825 | tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)" | 1803 | tristate "Secure RPC: Kerberos V mechanism (EXPERIMENTAL)" |
1826 | depends on SUNRPC && EXPERIMENTAL | 1804 | depends on SUNRPC && EXPERIMENTAL |
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 5df517b81f3f..fd7d4669776e 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c | |||
@@ -430,7 +430,7 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) | |||
430 | * Report the conflicting lock back to the application. | 430 | * Report the conflicting lock back to the application. |
431 | */ | 431 | */ |
432 | fl->fl_start = req->a_res.lock.fl.fl_start; | 432 | fl->fl_start = req->a_res.lock.fl.fl_start; |
433 | fl->fl_end = req->a_res.lock.fl.fl_start; | 433 | fl->fl_end = req->a_res.lock.fl.fl_end; |
434 | fl->fl_type = req->a_res.lock.fl.fl_type; | 434 | fl->fl_type = req->a_res.lock.fl.fl_type; |
435 | fl->fl_pid = 0; | 435 | fl->fl_pid = 0; |
436 | break; | 436 | break; |
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index c1e7c8300629..f447f4b4476c 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | struct nfs_callback_data { | 28 | struct nfs_callback_data { |
29 | unsigned int users; | 29 | unsigned int users; |
30 | struct svc_serv *serv; | 30 | struct svc_rqst *rqst; |
31 | struct task_struct *task; | 31 | struct task_struct *task; |
32 | }; | 32 | }; |
33 | 33 | ||
@@ -91,21 +91,17 @@ nfs_callback_svc(void *vrqstp) | |||
91 | svc_process(rqstp); | 91 | svc_process(rqstp); |
92 | } | 92 | } |
93 | unlock_kernel(); | 93 | unlock_kernel(); |
94 | nfs_callback_info.task = NULL; | ||
95 | svc_exit_thread(rqstp); | ||
96 | return 0; | 94 | return 0; |
97 | } | 95 | } |
98 | 96 | ||
99 | /* | 97 | /* |
100 | * Bring up the server process if it is not already up. | 98 | * Bring up the callback thread if it is not already up. |
101 | */ | 99 | */ |
102 | int nfs_callback_up(void) | 100 | int nfs_callback_up(void) |
103 | { | 101 | { |
104 | struct svc_serv *serv = NULL; | 102 | struct svc_serv *serv = NULL; |
105 | struct svc_rqst *rqstp; | ||
106 | int ret = 0; | 103 | int ret = 0; |
107 | 104 | ||
108 | lock_kernel(); | ||
109 | mutex_lock(&nfs_callback_mutex); | 105 | mutex_lock(&nfs_callback_mutex); |
110 | if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) | 106 | if (nfs_callback_info.users++ || nfs_callback_info.task != NULL) |
111 | goto out; | 107 | goto out; |
@@ -121,22 +117,23 @@ int nfs_callback_up(void) | |||
121 | nfs_callback_tcpport = ret; | 117 | nfs_callback_tcpport = ret; |
122 | dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); | 118 | dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); |
123 | 119 | ||
124 | rqstp = svc_prepare_thread(serv, &serv->sv_pools[0]); | 120 | nfs_callback_info.rqst = svc_prepare_thread(serv, &serv->sv_pools[0]); |
125 | if (IS_ERR(rqstp)) { | 121 | if (IS_ERR(nfs_callback_info.rqst)) { |
126 | ret = PTR_ERR(rqstp); | 122 | ret = PTR_ERR(nfs_callback_info.rqst); |
123 | nfs_callback_info.rqst = NULL; | ||
127 | goto out_err; | 124 | goto out_err; |
128 | } | 125 | } |
129 | 126 | ||
130 | svc_sock_update_bufs(serv); | 127 | svc_sock_update_bufs(serv); |
131 | nfs_callback_info.serv = serv; | ||
132 | 128 | ||
133 | nfs_callback_info.task = kthread_run(nfs_callback_svc, rqstp, | 129 | nfs_callback_info.task = kthread_run(nfs_callback_svc, |
130 | nfs_callback_info.rqst, | ||
134 | "nfsv4-svc"); | 131 | "nfsv4-svc"); |
135 | if (IS_ERR(nfs_callback_info.task)) { | 132 | if (IS_ERR(nfs_callback_info.task)) { |
136 | ret = PTR_ERR(nfs_callback_info.task); | 133 | ret = PTR_ERR(nfs_callback_info.task); |
137 | nfs_callback_info.serv = NULL; | 134 | svc_exit_thread(nfs_callback_info.rqst); |
135 | nfs_callback_info.rqst = NULL; | ||
138 | nfs_callback_info.task = NULL; | 136 | nfs_callback_info.task = NULL; |
139 | svc_exit_thread(rqstp); | ||
140 | goto out_err; | 137 | goto out_err; |
141 | } | 138 | } |
142 | out: | 139 | out: |
@@ -149,7 +146,6 @@ out: | |||
149 | if (serv) | 146 | if (serv) |
150 | svc_destroy(serv); | 147 | svc_destroy(serv); |
151 | mutex_unlock(&nfs_callback_mutex); | 148 | mutex_unlock(&nfs_callback_mutex); |
152 | unlock_kernel(); | ||
153 | return ret; | 149 | return ret; |
154 | out_err: | 150 | out_err: |
155 | dprintk("Couldn't create callback socket or server thread; err = %d\n", | 151 | dprintk("Couldn't create callback socket or server thread; err = %d\n", |
@@ -159,17 +155,19 @@ out_err: | |||
159 | } | 155 | } |
160 | 156 | ||
161 | /* | 157 | /* |
162 | * Kill the server process if it is not already down. | 158 | * Kill the callback thread if it's no longer being used. |
163 | */ | 159 | */ |
164 | void nfs_callback_down(void) | 160 | void nfs_callback_down(void) |
165 | { | 161 | { |
166 | lock_kernel(); | ||
167 | mutex_lock(&nfs_callback_mutex); | 162 | mutex_lock(&nfs_callback_mutex); |
168 | nfs_callback_info.users--; | 163 | nfs_callback_info.users--; |
169 | if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) | 164 | if (nfs_callback_info.users == 0 && nfs_callback_info.task != NULL) { |
170 | kthread_stop(nfs_callback_info.task); | 165 | kthread_stop(nfs_callback_info.task); |
166 | svc_exit_thread(nfs_callback_info.rqst); | ||
167 | nfs_callback_info.rqst = NULL; | ||
168 | nfs_callback_info.task = NULL; | ||
169 | } | ||
171 | mutex_unlock(&nfs_callback_mutex); | 170 | mutex_unlock(&nfs_callback_mutex); |
172 | unlock_kernel(); | ||
173 | } | 171 | } |
174 | 172 | ||
175 | static int nfs_callback_authenticate(struct svc_rqst *rqstp) | 173 | static int nfs_callback_authenticate(struct svc_rqst *rqstp) |
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index f2a092ca69b5..5ee23e7058b3 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -431,14 +431,14 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
431 | { | 431 | { |
432 | to->to_initval = timeo * HZ / 10; | 432 | to->to_initval = timeo * HZ / 10; |
433 | to->to_retries = retrans; | 433 | to->to_retries = retrans; |
434 | if (!to->to_retries) | ||
435 | to->to_retries = 2; | ||
436 | 434 | ||
437 | switch (proto) { | 435 | switch (proto) { |
438 | case XPRT_TRANSPORT_TCP: | 436 | case XPRT_TRANSPORT_TCP: |
439 | case XPRT_TRANSPORT_RDMA: | 437 | case XPRT_TRANSPORT_RDMA: |
438 | if (to->to_retries == 0) | ||
439 | to->to_retries = NFS_DEF_TCP_RETRANS; | ||
440 | if (to->to_initval == 0) | 440 | if (to->to_initval == 0) |
441 | to->to_initval = 60 * HZ; | 441 | to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; |
442 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | 442 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) |
443 | to->to_initval = NFS_MAX_TCP_TIMEOUT; | 443 | to->to_initval = NFS_MAX_TCP_TIMEOUT; |
444 | to->to_increment = to->to_initval; | 444 | to->to_increment = to->to_initval; |
@@ -450,14 +450,17 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
450 | to->to_exponential = 0; | 450 | to->to_exponential = 0; |
451 | break; | 451 | break; |
452 | case XPRT_TRANSPORT_UDP: | 452 | case XPRT_TRANSPORT_UDP: |
453 | default: | 453 | if (to->to_retries == 0) |
454 | to->to_retries = NFS_DEF_UDP_RETRANS; | ||
454 | if (!to->to_initval) | 455 | if (!to->to_initval) |
455 | to->to_initval = 11 * HZ / 10; | 456 | to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; |
456 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) | 457 | if (to->to_initval > NFS_MAX_UDP_TIMEOUT) |
457 | to->to_initval = NFS_MAX_UDP_TIMEOUT; | 458 | to->to_initval = NFS_MAX_UDP_TIMEOUT; |
458 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; | 459 | to->to_maxval = NFS_MAX_UDP_TIMEOUT; |
459 | to->to_exponential = 1; | 460 | to->to_exponential = 1; |
460 | break; | 461 | break; |
462 | default: | ||
463 | BUG(); | ||
461 | } | 464 | } |
462 | } | 465 | } |
463 | 466 | ||
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 982a2064fe4c..b1940660502f 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -133,8 +133,11 @@ nfs_opendir(struct inode *inode, struct file *filp) | |||
133 | { | 133 | { |
134 | int res; | 134 | int res; |
135 | 135 | ||
136 | dfprintk(VFS, "NFS: opendir(%s/%ld)\n", | 136 | dfprintk(FILE, "NFS: open dir(%s/%s)\n", |
137 | inode->i_sb->s_id, inode->i_ino); | 137 | filp->f_path.dentry->d_parent->d_name.name, |
138 | filp->f_path.dentry->d_name.name); | ||
139 | |||
140 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | ||
138 | 141 | ||
139 | lock_kernel(); | 142 | lock_kernel(); |
140 | /* Call generic open code in order to cache credentials */ | 143 | /* Call generic open code in order to cache credentials */ |
@@ -528,7 +531,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
528 | struct nfs_fattr fattr; | 531 | struct nfs_fattr fattr; |
529 | long res; | 532 | long res; |
530 | 533 | ||
531 | dfprintk(VFS, "NFS: readdir(%s/%s) starting at cookie %Lu\n", | 534 | dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", |
532 | dentry->d_parent->d_name.name, dentry->d_name.name, | 535 | dentry->d_parent->d_name.name, dentry->d_name.name, |
533 | (long long)filp->f_pos); | 536 | (long long)filp->f_pos); |
534 | nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); | 537 | nfs_inc_stats(inode, NFSIOS_VFSGETDENTS); |
@@ -595,7 +598,7 @@ out: | |||
595 | unlock_kernel(); | 598 | unlock_kernel(); |
596 | if (res > 0) | 599 | if (res > 0) |
597 | res = 0; | 600 | res = 0; |
598 | dfprintk(VFS, "NFS: readdir(%s/%s) returns %ld\n", | 601 | dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n", |
599 | dentry->d_parent->d_name.name, dentry->d_name.name, | 602 | dentry->d_parent->d_name.name, dentry->d_name.name, |
600 | res); | 603 | res); |
601 | return res; | 604 | return res; |
@@ -603,7 +606,15 @@ out: | |||
603 | 606 | ||
604 | static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) | 607 | static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) |
605 | { | 608 | { |
606 | mutex_lock(&filp->f_path.dentry->d_inode->i_mutex); | 609 | struct dentry *dentry = filp->f_path.dentry; |
610 | struct inode *inode = dentry->d_inode; | ||
611 | |||
612 | dfprintk(FILE, "NFS: llseek dir(%s/%s, %lld, %d)\n", | ||
613 | dentry->d_parent->d_name.name, | ||
614 | dentry->d_name.name, | ||
615 | offset, origin); | ||
616 | |||
617 | mutex_lock(&inode->i_mutex); | ||
607 | switch (origin) { | 618 | switch (origin) { |
608 | case 1: | 619 | case 1: |
609 | offset += filp->f_pos; | 620 | offset += filp->f_pos; |
@@ -619,7 +630,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) | |||
619 | nfs_file_open_context(filp)->dir_cookie = 0; | 630 | nfs_file_open_context(filp)->dir_cookie = 0; |
620 | } | 631 | } |
621 | out: | 632 | out: |
622 | mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex); | 633 | mutex_unlock(&inode->i_mutex); |
623 | return offset; | 634 | return offset; |
624 | } | 635 | } |
625 | 636 | ||
@@ -629,10 +640,11 @@ out: | |||
629 | */ | 640 | */ |
630 | static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) | 641 | static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) |
631 | { | 642 | { |
632 | dfprintk(VFS, "NFS: fsync_dir(%s/%s) datasync %d\n", | 643 | dfprintk(FILE, "NFS: fsync dir(%s/%s) datasync %d\n", |
633 | dentry->d_parent->d_name.name, dentry->d_name.name, | 644 | dentry->d_parent->d_name.name, dentry->d_name.name, |
634 | datasync); | 645 | datasync); |
635 | 646 | ||
647 | nfs_inc_stats(dentry->d_inode, NFSIOS_VFSFSYNC); | ||
636 | return 0; | 648 | return 0; |
637 | } | 649 | } |
638 | 650 | ||
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 4757a2b326a1..08f6b040d289 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -890,7 +890,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov, | |||
890 | count = iov_length(iov, nr_segs); | 890 | count = iov_length(iov, nr_segs); |
891 | nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count); | 891 | nfs_add_stats(mapping->host, NFSIOS_DIRECTREADBYTES, count); |
892 | 892 | ||
893 | dprintk("nfs: direct read(%s/%s, %zd@%Ld)\n", | 893 | dfprintk(FILE, "NFS: direct read(%s/%s, %zd@%Ld)\n", |
894 | file->f_path.dentry->d_parent->d_name.name, | 894 | file->f_path.dentry->d_parent->d_name.name, |
895 | file->f_path.dentry->d_name.name, | 895 | file->f_path.dentry->d_name.name, |
896 | count, (long long) pos); | 896 | count, (long long) pos); |
@@ -947,7 +947,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov, | |||
947 | count = iov_length(iov, nr_segs); | 947 | count = iov_length(iov, nr_segs); |
948 | nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count); | 948 | nfs_add_stats(mapping->host, NFSIOS_DIRECTWRITTENBYTES, count); |
949 | 949 | ||
950 | dfprintk(VFS, "nfs: direct write(%s/%s, %zd@%Ld)\n", | 950 | dfprintk(FILE, "NFS: direct write(%s/%s, %zd@%Ld)\n", |
951 | file->f_path.dentry->d_parent->d_name.name, | 951 | file->f_path.dentry->d_parent->d_name.name, |
952 | file->f_path.dentry->d_name.name, | 952 | file->f_path.dentry->d_name.name, |
953 | count, (long long) pos); | 953 | count, (long long) pos); |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 4e98a56a1777..43164fe86069 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -50,7 +50,7 @@ static ssize_t nfs_file_read(struct kiocb *, const struct iovec *iov, | |||
50 | static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, | 50 | static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, |
51 | unsigned long nr_segs, loff_t pos); | 51 | unsigned long nr_segs, loff_t pos); |
52 | static int nfs_file_flush(struct file *, fl_owner_t id); | 52 | static int nfs_file_flush(struct file *, fl_owner_t id); |
53 | static int nfs_fsync(struct file *, struct dentry *dentry, int datasync); | 53 | static int nfs_file_fsync(struct file *, struct dentry *dentry, int datasync); |
54 | static int nfs_check_flags(int flags); | 54 | static int nfs_check_flags(int flags); |
55 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); | 55 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); |
56 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); | 56 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); |
@@ -72,7 +72,7 @@ const struct file_operations nfs_file_operations = { | |||
72 | .open = nfs_file_open, | 72 | .open = nfs_file_open, |
73 | .flush = nfs_file_flush, | 73 | .flush = nfs_file_flush, |
74 | .release = nfs_file_release, | 74 | .release = nfs_file_release, |
75 | .fsync = nfs_fsync, | 75 | .fsync = nfs_file_fsync, |
76 | .lock = nfs_lock, | 76 | .lock = nfs_lock, |
77 | .flock = nfs_flock, | 77 | .flock = nfs_flock, |
78 | .splice_read = nfs_file_splice_read, | 78 | .splice_read = nfs_file_splice_read, |
@@ -119,13 +119,17 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
119 | { | 119 | { |
120 | int res; | 120 | int res; |
121 | 121 | ||
122 | dprintk("NFS: open file(%s/%s)\n", | ||
123 | filp->f_path.dentry->d_parent->d_name.name, | ||
124 | filp->f_path.dentry->d_name.name); | ||
125 | |||
122 | res = nfs_check_flags(filp->f_flags); | 126 | res = nfs_check_flags(filp->f_flags); |
123 | if (res) | 127 | if (res) |
124 | return res; | 128 | return res; |
125 | 129 | ||
126 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); | 130 | nfs_inc_stats(inode, NFSIOS_VFSOPEN); |
127 | lock_kernel(); | 131 | lock_kernel(); |
128 | res = NFS_PROTO(inode)->file_open(inode, filp); | 132 | res = nfs_open(inode, filp); |
129 | unlock_kernel(); | 133 | unlock_kernel(); |
130 | return res; | 134 | return res; |
131 | } | 135 | } |
@@ -133,11 +137,17 @@ nfs_file_open(struct inode *inode, struct file *filp) | |||
133 | static int | 137 | static int |
134 | nfs_file_release(struct inode *inode, struct file *filp) | 138 | nfs_file_release(struct inode *inode, struct file *filp) |
135 | { | 139 | { |
140 | struct dentry *dentry = filp->f_path.dentry; | ||
141 | |||
142 | dprintk("NFS: release(%s/%s)\n", | ||
143 | dentry->d_parent->d_name.name, | ||
144 | dentry->d_name.name); | ||
145 | |||
136 | /* Ensure that dirty pages are flushed out with the right creds */ | 146 | /* Ensure that dirty pages are flushed out with the right creds */ |
137 | if (filp->f_mode & FMODE_WRITE) | 147 | if (filp->f_mode & FMODE_WRITE) |
138 | nfs_wb_all(filp->f_path.dentry->d_inode); | 148 | nfs_wb_all(dentry->d_inode); |
139 | nfs_inc_stats(inode, NFSIOS_VFSRELEASE); | 149 | nfs_inc_stats(inode, NFSIOS_VFSRELEASE); |
140 | return NFS_PROTO(inode)->file_release(inode, filp); | 150 | return nfs_release(inode, filp); |
141 | } | 151 | } |
142 | 152 | ||
143 | /** | 153 | /** |
@@ -171,6 +181,12 @@ force_reval: | |||
171 | static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | 181 | static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) |
172 | { | 182 | { |
173 | loff_t loff; | 183 | loff_t loff; |
184 | |||
185 | dprintk("NFS: llseek file(%s/%s, %lld, %d)\n", | ||
186 | filp->f_path.dentry->d_parent->d_name.name, | ||
187 | filp->f_path.dentry->d_name.name, | ||
188 | offset, origin); | ||
189 | |||
174 | /* origin == SEEK_END => we must revalidate the cached file length */ | 190 | /* origin == SEEK_END => we must revalidate the cached file length */ |
175 | if (origin == SEEK_END) { | 191 | if (origin == SEEK_END) { |
176 | struct inode *inode = filp->f_mapping->host; | 192 | struct inode *inode = filp->f_mapping->host; |
@@ -185,7 +201,7 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | |||
185 | } | 201 | } |
186 | 202 | ||
187 | /* | 203 | /* |
188 | * Helper for nfs_file_flush() and nfs_fsync() | 204 | * Helper for nfs_file_flush() and nfs_file_fsync() |
189 | * | 205 | * |
190 | * Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to | 206 | * Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to |
191 | * disk, but it retrieves and clears ctx->error after synching, despite | 207 | * disk, but it retrieves and clears ctx->error after synching, despite |
@@ -211,16 +227,18 @@ static int nfs_do_fsync(struct nfs_open_context *ctx, struct inode *inode) | |||
211 | 227 | ||
212 | /* | 228 | /* |
213 | * Flush all dirty pages, and check for write errors. | 229 | * Flush all dirty pages, and check for write errors. |
214 | * | ||
215 | */ | 230 | */ |
216 | static int | 231 | static int |
217 | nfs_file_flush(struct file *file, fl_owner_t id) | 232 | nfs_file_flush(struct file *file, fl_owner_t id) |
218 | { | 233 | { |
219 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 234 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
220 | struct inode *inode = file->f_path.dentry->d_inode; | 235 | struct dentry *dentry = file->f_path.dentry; |
236 | struct inode *inode = dentry->d_inode; | ||
221 | int status; | 237 | int status; |
222 | 238 | ||
223 | dfprintk(VFS, "nfs: flush(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); | 239 | dprintk("NFS: flush(%s/%s)\n", |
240 | dentry->d_parent->d_name.name, | ||
241 | dentry->d_name.name); | ||
224 | 242 | ||
225 | if ((file->f_mode & FMODE_WRITE) == 0) | 243 | if ((file->f_mode & FMODE_WRITE) == 0) |
226 | return 0; | 244 | return 0; |
@@ -245,7 +263,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, | |||
245 | if (iocb->ki_filp->f_flags & O_DIRECT) | 263 | if (iocb->ki_filp->f_flags & O_DIRECT) |
246 | return nfs_file_direct_read(iocb, iov, nr_segs, pos); | 264 | return nfs_file_direct_read(iocb, iov, nr_segs, pos); |
247 | 265 | ||
248 | dfprintk(VFS, "nfs: read(%s/%s, %lu@%lu)\n", | 266 | dprintk("NFS: read(%s/%s, %lu@%lu)\n", |
249 | dentry->d_parent->d_name.name, dentry->d_name.name, | 267 | dentry->d_parent->d_name.name, dentry->d_name.name, |
250 | (unsigned long) count, (unsigned long) pos); | 268 | (unsigned long) count, (unsigned long) pos); |
251 | 269 | ||
@@ -265,7 +283,7 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos, | |||
265 | struct inode *inode = dentry->d_inode; | 283 | struct inode *inode = dentry->d_inode; |
266 | ssize_t res; | 284 | ssize_t res; |
267 | 285 | ||
268 | dfprintk(VFS, "nfs: splice_read(%s/%s, %lu@%Lu)\n", | 286 | dprintk("NFS: splice_read(%s/%s, %lu@%Lu)\n", |
269 | dentry->d_parent->d_name.name, dentry->d_name.name, | 287 | dentry->d_parent->d_name.name, dentry->d_name.name, |
270 | (unsigned long) count, (unsigned long long) *ppos); | 288 | (unsigned long) count, (unsigned long long) *ppos); |
271 | 289 | ||
@@ -282,7 +300,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
282 | struct inode *inode = dentry->d_inode; | 300 | struct inode *inode = dentry->d_inode; |
283 | int status; | 301 | int status; |
284 | 302 | ||
285 | dfprintk(VFS, "nfs: mmap(%s/%s)\n", | 303 | dprintk("NFS: mmap(%s/%s)\n", |
286 | dentry->d_parent->d_name.name, dentry->d_name.name); | 304 | dentry->d_parent->d_name.name, dentry->d_name.name); |
287 | 305 | ||
288 | status = nfs_revalidate_mapping(inode, file->f_mapping); | 306 | status = nfs_revalidate_mapping(inode, file->f_mapping); |
@@ -300,12 +318,14 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
300 | * whether any write errors occurred for this process. | 318 | * whether any write errors occurred for this process. |
301 | */ | 319 | */ |
302 | static int | 320 | static int |
303 | nfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 321 | nfs_file_fsync(struct file *file, struct dentry *dentry, int datasync) |
304 | { | 322 | { |
305 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 323 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
306 | struct inode *inode = dentry->d_inode; | 324 | struct inode *inode = dentry->d_inode; |
307 | 325 | ||
308 | dfprintk(VFS, "nfs: fsync(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); | 326 | dprintk("NFS: fsync file(%s/%s) datasync %d\n", |
327 | dentry->d_parent->d_name.name, dentry->d_name.name, | ||
328 | datasync); | ||
309 | 329 | ||
310 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); | 330 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); |
311 | return nfs_do_fsync(ctx, inode); | 331 | return nfs_do_fsync(ctx, inode); |
@@ -328,6 +348,11 @@ static int nfs_write_begin(struct file *file, struct address_space *mapping, | |||
328 | struct page *page; | 348 | struct page *page; |
329 | index = pos >> PAGE_CACHE_SHIFT; | 349 | index = pos >> PAGE_CACHE_SHIFT; |
330 | 350 | ||
351 | dfprintk(PAGECACHE, "NFS: write_begin(%s/%s(%ld), %u@%lld)\n", | ||
352 | file->f_path.dentry->d_parent->d_name.name, | ||
353 | file->f_path.dentry->d_name.name, | ||
354 | mapping->host->i_ino, len, (long long) pos); | ||
355 | |||
331 | page = __grab_cache_page(mapping, index); | 356 | page = __grab_cache_page(mapping, index); |
332 | if (!page) | 357 | if (!page) |
333 | return -ENOMEM; | 358 | return -ENOMEM; |
@@ -348,6 +373,31 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, | |||
348 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); | 373 | unsigned offset = pos & (PAGE_CACHE_SIZE - 1); |
349 | int status; | 374 | int status; |
350 | 375 | ||
376 | dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n", | ||
377 | file->f_path.dentry->d_parent->d_name.name, | ||
378 | file->f_path.dentry->d_name.name, | ||
379 | mapping->host->i_ino, len, (long long) pos); | ||
380 | |||
381 | /* | ||
382 | * Zero any uninitialised parts of the page, and then mark the page | ||
383 | * as up to date if it turns out that we're extending the file. | ||
384 | */ | ||
385 | if (!PageUptodate(page)) { | ||
386 | unsigned pglen = nfs_page_length(page); | ||
387 | unsigned end = offset + len; | ||
388 | |||
389 | if (pglen == 0) { | ||
390 | zero_user_segments(page, 0, offset, | ||
391 | end, PAGE_CACHE_SIZE); | ||
392 | SetPageUptodate(page); | ||
393 | } else if (end >= pglen) { | ||
394 | zero_user_segment(page, end, PAGE_CACHE_SIZE); | ||
395 | if (offset == 0) | ||
396 | SetPageUptodate(page); | ||
397 | } else | ||
398 | zero_user_segment(page, pglen, PAGE_CACHE_SIZE); | ||
399 | } | ||
400 | |||
351 | lock_kernel(); | 401 | lock_kernel(); |
352 | status = nfs_updatepage(file, page, offset, copied); | 402 | status = nfs_updatepage(file, page, offset, copied); |
353 | unlock_kernel(); | 403 | unlock_kernel(); |
@@ -362,6 +412,8 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, | |||
362 | 412 | ||
363 | static void nfs_invalidate_page(struct page *page, unsigned long offset) | 413 | static void nfs_invalidate_page(struct page *page, unsigned long offset) |
364 | { | 414 | { |
415 | dfprintk(PAGECACHE, "NFS: invalidate_page(%p, %lu)\n", page, offset); | ||
416 | |||
365 | if (offset != 0) | 417 | if (offset != 0) |
366 | return; | 418 | return; |
367 | /* Cancel any unstarted writes on this page */ | 419 | /* Cancel any unstarted writes on this page */ |
@@ -370,13 +422,20 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset) | |||
370 | 422 | ||
371 | static int nfs_release_page(struct page *page, gfp_t gfp) | 423 | static int nfs_release_page(struct page *page, gfp_t gfp) |
372 | { | 424 | { |
425 | dfprintk(PAGECACHE, "NFS: release_page(%p)\n", page); | ||
426 | |||
373 | /* If PagePrivate() is set, then the page is not freeable */ | 427 | /* If PagePrivate() is set, then the page is not freeable */ |
374 | return 0; | 428 | return 0; |
375 | } | 429 | } |
376 | 430 | ||
377 | static int nfs_launder_page(struct page *page) | 431 | static int nfs_launder_page(struct page *page) |
378 | { | 432 | { |
379 | return nfs_wb_page(page->mapping->host, page); | 433 | struct inode *inode = page->mapping->host; |
434 | |||
435 | dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n", | ||
436 | inode->i_ino, (long long)page_offset(page)); | ||
437 | |||
438 | return nfs_wb_page(inode, page); | ||
380 | } | 439 | } |
381 | 440 | ||
382 | const struct address_space_operations nfs_file_aops = { | 441 | const struct address_space_operations nfs_file_aops = { |
@@ -396,13 +455,19 @@ const struct address_space_operations nfs_file_aops = { | |||
396 | static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page) | 455 | static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page) |
397 | { | 456 | { |
398 | struct file *filp = vma->vm_file; | 457 | struct file *filp = vma->vm_file; |
458 | struct dentry *dentry = filp->f_path.dentry; | ||
399 | unsigned pagelen; | 459 | unsigned pagelen; |
400 | int ret = -EINVAL; | 460 | int ret = -EINVAL; |
401 | struct address_space *mapping; | 461 | struct address_space *mapping; |
402 | 462 | ||
463 | dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n", | ||
464 | dentry->d_parent->d_name.name, dentry->d_name.name, | ||
465 | filp->f_mapping->host->i_ino, | ||
466 | (long long)page_offset(page)); | ||
467 | |||
403 | lock_page(page); | 468 | lock_page(page); |
404 | mapping = page->mapping; | 469 | mapping = page->mapping; |
405 | if (mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping) | 470 | if (mapping != dentry->d_inode->i_mapping) |
406 | goto out_unlock; | 471 | goto out_unlock; |
407 | 472 | ||
408 | ret = 0; | 473 | ret = 0; |
@@ -450,9 +515,9 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
450 | if (iocb->ki_filp->f_flags & O_DIRECT) | 515 | if (iocb->ki_filp->f_flags & O_DIRECT) |
451 | return nfs_file_direct_write(iocb, iov, nr_segs, pos); | 516 | return nfs_file_direct_write(iocb, iov, nr_segs, pos); |
452 | 517 | ||
453 | dfprintk(VFS, "nfs: write(%s/%s(%ld), %lu@%Ld)\n", | 518 | dprintk("NFS: write(%s/%s, %lu@%Ld)\n", |
454 | dentry->d_parent->d_name.name, dentry->d_name.name, | 519 | dentry->d_parent->d_name.name, dentry->d_name.name, |
455 | inode->i_ino, (unsigned long) count, (long long) pos); | 520 | (unsigned long) count, (long long) pos); |
456 | 521 | ||
457 | result = -EBUSY; | 522 | result = -EBUSY; |
458 | if (IS_SWAPFILE(inode)) | 523 | if (IS_SWAPFILE(inode)) |
@@ -586,7 +651,8 @@ static int do_setlk(struct file *filp, int cmd, struct file_lock *fl) | |||
586 | * This makes locking act as a cache coherency point. | 651 | * This makes locking act as a cache coherency point. |
587 | */ | 652 | */ |
588 | nfs_sync_mapping(filp->f_mapping); | 653 | nfs_sync_mapping(filp->f_mapping); |
589 | nfs_zap_caches(inode); | 654 | if (!nfs_have_delegation(inode, FMODE_READ)) |
655 | nfs_zap_caches(inode); | ||
590 | out: | 656 | out: |
591 | return status; | 657 | return status; |
592 | } | 658 | } |
@@ -596,23 +662,35 @@ out: | |||
596 | */ | 662 | */ |
597 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) | 663 | static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) |
598 | { | 664 | { |
599 | struct inode * inode = filp->f_mapping->host; | 665 | struct inode *inode = filp->f_mapping->host; |
666 | int ret = -ENOLCK; | ||
600 | 667 | ||
601 | dprintk("NFS: nfs_lock(f=%s/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n", | 668 | dprintk("NFS: lock(%s/%s, t=%x, fl=%x, r=%lld:%lld)\n", |
602 | inode->i_sb->s_id, inode->i_ino, | 669 | filp->f_path.dentry->d_parent->d_name.name, |
670 | filp->f_path.dentry->d_name.name, | ||
603 | fl->fl_type, fl->fl_flags, | 671 | fl->fl_type, fl->fl_flags, |
604 | (long long)fl->fl_start, (long long)fl->fl_end); | 672 | (long long)fl->fl_start, (long long)fl->fl_end); |
673 | |||
605 | nfs_inc_stats(inode, NFSIOS_VFSLOCK); | 674 | nfs_inc_stats(inode, NFSIOS_VFSLOCK); |
606 | 675 | ||
607 | /* No mandatory locks over NFS */ | 676 | /* No mandatory locks over NFS */ |
608 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) | 677 | if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) |
609 | return -ENOLCK; | 678 | goto out_err; |
679 | |||
680 | if (NFS_PROTO(inode)->lock_check_bounds != NULL) { | ||
681 | ret = NFS_PROTO(inode)->lock_check_bounds(fl); | ||
682 | if (ret < 0) | ||
683 | goto out_err; | ||
684 | } | ||
610 | 685 | ||
611 | if (IS_GETLK(cmd)) | 686 | if (IS_GETLK(cmd)) |
612 | return do_getlk(filp, cmd, fl); | 687 | ret = do_getlk(filp, cmd, fl); |
613 | if (fl->fl_type == F_UNLCK) | 688 | else if (fl->fl_type == F_UNLCK) |
614 | return do_unlk(filp, cmd, fl); | 689 | ret = do_unlk(filp, cmd, fl); |
615 | return do_setlk(filp, cmd, fl); | 690 | else |
691 | ret = do_setlk(filp, cmd, fl); | ||
692 | out_err: | ||
693 | return ret; | ||
616 | } | 694 | } |
617 | 695 | ||
618 | /* | 696 | /* |
@@ -620,9 +698,9 @@ static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
620 | */ | 698 | */ |
621 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) | 699 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) |
622 | { | 700 | { |
623 | dprintk("NFS: nfs_flock(f=%s/%ld, t=%x, fl=%x)\n", | 701 | dprintk("NFS: flock(%s/%s, t=%x, fl=%x)\n", |
624 | filp->f_path.dentry->d_inode->i_sb->s_id, | 702 | filp->f_path.dentry->d_parent->d_name.name, |
625 | filp->f_path.dentry->d_inode->i_ino, | 703 | filp->f_path.dentry->d_name.name, |
626 | fl->fl_type, fl->fl_flags); | 704 | fl->fl_type, fl->fl_flags); |
627 | 705 | ||
628 | /* | 706 | /* |
@@ -645,12 +723,15 @@ static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) | |||
645 | return do_setlk(filp, cmd, fl); | 723 | return do_setlk(filp, cmd, fl); |
646 | } | 724 | } |
647 | 725 | ||
726 | /* | ||
727 | * There is no protocol support for leases, so we have no way to implement | ||
728 | * them correctly in the face of opens by other clients. | ||
729 | */ | ||
648 | static int nfs_setlease(struct file *file, long arg, struct file_lock **fl) | 730 | static int nfs_setlease(struct file *file, long arg, struct file_lock **fl) |
649 | { | 731 | { |
650 | /* | 732 | dprintk("NFS: setlease(%s/%s, arg=%ld)\n", |
651 | * There is no protocol support for leases, so we have no way | 733 | file->f_path.dentry->d_parent->d_name.name, |
652 | * to implement them correctly in the face of opens by other | 734 | file->f_path.dentry->d_name.name, arg); |
653 | * clients. | 735 | |
654 | */ | ||
655 | return -EINVAL; | 736 | return -EINVAL; |
656 | } | 737 | } |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 596c5d8e86f4..2c23d067e2a6 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -57,8 +57,6 @@ static int enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED; | |||
57 | static void nfs_invalidate_inode(struct inode *); | 57 | static void nfs_invalidate_inode(struct inode *); |
58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); | 58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); |
59 | 59 | ||
60 | static void nfs_zap_acl_cache(struct inode *); | ||
61 | |||
62 | static struct kmem_cache * nfs_inode_cachep; | 60 | static struct kmem_cache * nfs_inode_cachep; |
63 | 61 | ||
64 | static inline unsigned long | 62 | static inline unsigned long |
@@ -167,7 +165,7 @@ void nfs_zap_mapping(struct inode *inode, struct address_space *mapping) | |||
167 | } | 165 | } |
168 | } | 166 | } |
169 | 167 | ||
170 | static void nfs_zap_acl_cache(struct inode *inode) | 168 | void nfs_zap_acl_cache(struct inode *inode) |
171 | { | 169 | { |
172 | void (*clear_acl_cache)(struct inode *); | 170 | void (*clear_acl_cache)(struct inode *); |
173 | 171 | ||
@@ -347,7 +345,7 @@ out_no_inode: | |||
347 | goto out; | 345 | goto out; |
348 | } | 346 | } |
349 | 347 | ||
350 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET) | 348 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE) |
351 | 349 | ||
352 | int | 350 | int |
353 | nfs_setattr(struct dentry *dentry, struct iattr *attr) | 351 | nfs_setattr(struct dentry *dentry, struct iattr *attr) |
@@ -369,7 +367,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
369 | 367 | ||
370 | /* Optimization: if the end result is no change, don't RPC */ | 368 | /* Optimization: if the end result is no change, don't RPC */ |
371 | attr->ia_valid &= NFS_VALID_ATTRS; | 369 | attr->ia_valid &= NFS_VALID_ATTRS; |
372 | if (attr->ia_valid == 0) | 370 | if ((attr->ia_valid & ~ATTR_FILE) == 0) |
373 | return 0; | 371 | return 0; |
374 | 372 | ||
375 | lock_kernel(); | 373 | lock_kernel(); |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 04ae867dddba..24241fcbb98d 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -150,6 +150,7 @@ extern void nfs_clear_inode(struct inode *); | |||
150 | #ifdef CONFIG_NFS_V4 | 150 | #ifdef CONFIG_NFS_V4 |
151 | extern void nfs4_clear_inode(struct inode *); | 151 | extern void nfs4_clear_inode(struct inode *); |
152 | #endif | 152 | #endif |
153 | void nfs_zap_acl_cache(struct inode *inode); | ||
153 | 154 | ||
154 | /* super.c */ | 155 | /* super.c */ |
155 | extern struct file_system_type nfs_xdev_fs_type; | 156 | extern struct file_system_type nfs_xdev_fs_type; |
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h index 6350ecbde589..a36952810032 100644 --- a/fs/nfs/iostat.h +++ b/fs/nfs/iostat.h | |||
@@ -5,135 +5,41 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> | 6 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> |
7 | * | 7 | * |
8 | * NFS client per-mount statistics provide information about the health of | ||
9 | * the NFS client and the health of each NFS mount point. Generally these | ||
10 | * are not for detailed problem diagnosis, but simply to indicate that there | ||
11 | * is a problem. | ||
12 | * | ||
13 | * These counters are not meant to be human-readable, but are meant to be | ||
14 | * integrated into system monitoring tools such as "sar" and "iostat". As | ||
15 | * such, the counters are sampled by the tools over time, and are never | ||
16 | * zeroed after a file system is mounted. Moving averages can be computed | ||
17 | * by the tools by taking the difference between two instantaneous samples | ||
18 | * and dividing that by the time between the samples. | ||
19 | */ | 8 | */ |
20 | 9 | ||
21 | #ifndef _NFS_IOSTAT | 10 | #ifndef _NFS_IOSTAT |
22 | #define _NFS_IOSTAT | 11 | #define _NFS_IOSTAT |
23 | 12 | ||
24 | #define NFS_IOSTAT_VERS "1.0" | ||
25 | |||
26 | /* | ||
27 | * NFS byte counters | ||
28 | * | ||
29 | * 1. SERVER - the number of payload bytes read from or written to the | ||
30 | * server by the NFS client via an NFS READ or WRITE request. | ||
31 | * | ||
32 | * 2. NORMAL - the number of bytes read or written by applications via | ||
33 | * the read(2) and write(2) system call interfaces. | ||
34 | * | ||
35 | * 3. DIRECT - the number of bytes read or written from files opened | ||
36 | * with the O_DIRECT flag. | ||
37 | * | ||
38 | * These counters give a view of the data throughput into and out of the NFS | ||
39 | * client. Comparing the number of bytes requested by an application with the | ||
40 | * number of bytes the client requests from the server can provide an | ||
41 | * indication of client efficiency (per-op, cache hits, etc). | ||
42 | * | ||
43 | * These counters can also help characterize which access methods are in | ||
44 | * use. DIRECT by itself shows whether there is any O_DIRECT traffic. | ||
45 | * NORMAL + DIRECT shows how much data is going through the system call | ||
46 | * interface. A large amount of SERVER traffic without much NORMAL or | ||
47 | * DIRECT traffic shows that applications are using mapped files. | ||
48 | * | ||
49 | * NFS page counters | ||
50 | * | ||
51 | * These count the number of pages read or written via nfs_readpage(), | ||
52 | * nfs_readpages(), or their write equivalents. | ||
53 | */ | ||
54 | enum nfs_stat_bytecounters { | ||
55 | NFSIOS_NORMALREADBYTES = 0, | ||
56 | NFSIOS_NORMALWRITTENBYTES, | ||
57 | NFSIOS_DIRECTREADBYTES, | ||
58 | NFSIOS_DIRECTWRITTENBYTES, | ||
59 | NFSIOS_SERVERREADBYTES, | ||
60 | NFSIOS_SERVERWRITTENBYTES, | ||
61 | NFSIOS_READPAGES, | ||
62 | NFSIOS_WRITEPAGES, | ||
63 | __NFSIOS_BYTESMAX, | ||
64 | }; | ||
65 | |||
66 | /* | ||
67 | * NFS event counters | ||
68 | * | ||
69 | * These counters provide a low-overhead way of monitoring client activity | ||
70 | * without enabling NFS trace debugging. The counters show the rate at | ||
71 | * which VFS requests are made, and how often the client invalidates its | ||
72 | * data and attribute caches. This allows system administrators to monitor | ||
73 | * such things as how close-to-open is working, and answer questions such | ||
74 | * as "why are there so many GETATTR requests on the wire?" | ||
75 | * | ||
76 | * They also count anamolous events such as short reads and writes, silly | ||
77 | * renames due to close-after-delete, and operations that change the size | ||
78 | * of a file (such operations can often be the source of data corruption | ||
79 | * if applications aren't using file locking properly). | ||
80 | */ | ||
81 | enum nfs_stat_eventcounters { | ||
82 | NFSIOS_INODEREVALIDATE = 0, | ||
83 | NFSIOS_DENTRYREVALIDATE, | ||
84 | NFSIOS_DATAINVALIDATE, | ||
85 | NFSIOS_ATTRINVALIDATE, | ||
86 | NFSIOS_VFSOPEN, | ||
87 | NFSIOS_VFSLOOKUP, | ||
88 | NFSIOS_VFSACCESS, | ||
89 | NFSIOS_VFSUPDATEPAGE, | ||
90 | NFSIOS_VFSREADPAGE, | ||
91 | NFSIOS_VFSREADPAGES, | ||
92 | NFSIOS_VFSWRITEPAGE, | ||
93 | NFSIOS_VFSWRITEPAGES, | ||
94 | NFSIOS_VFSGETDENTS, | ||
95 | NFSIOS_VFSSETATTR, | ||
96 | NFSIOS_VFSFLUSH, | ||
97 | NFSIOS_VFSFSYNC, | ||
98 | NFSIOS_VFSLOCK, | ||
99 | NFSIOS_VFSRELEASE, | ||
100 | NFSIOS_CONGESTIONWAIT, | ||
101 | NFSIOS_SETATTRTRUNC, | ||
102 | NFSIOS_EXTENDWRITE, | ||
103 | NFSIOS_SILLYRENAME, | ||
104 | NFSIOS_SHORTREAD, | ||
105 | NFSIOS_SHORTWRITE, | ||
106 | NFSIOS_DELAY, | ||
107 | __NFSIOS_COUNTSMAX, | ||
108 | }; | ||
109 | |||
110 | #ifdef __KERNEL__ | ||
111 | |||
112 | #include <linux/percpu.h> | 13 | #include <linux/percpu.h> |
113 | #include <linux/cache.h> | 14 | #include <linux/cache.h> |
15 | #include <linux/nfs_iostat.h> | ||
114 | 16 | ||
115 | struct nfs_iostats { | 17 | struct nfs_iostats { |
116 | unsigned long long bytes[__NFSIOS_BYTESMAX]; | 18 | unsigned long long bytes[__NFSIOS_BYTESMAX]; |
117 | unsigned long events[__NFSIOS_COUNTSMAX]; | 19 | unsigned long events[__NFSIOS_COUNTSMAX]; |
118 | } ____cacheline_aligned; | 20 | } ____cacheline_aligned; |
119 | 21 | ||
120 | static inline void nfs_inc_server_stats(struct nfs_server *server, enum nfs_stat_eventcounters stat) | 22 | static inline void nfs_inc_server_stats(const struct nfs_server *server, |
23 | enum nfs_stat_eventcounters stat) | ||
121 | { | 24 | { |
122 | struct nfs_iostats *iostats; | 25 | struct nfs_iostats *iostats; |
123 | int cpu; | 26 | int cpu; |
124 | 27 | ||
125 | cpu = get_cpu(); | 28 | cpu = get_cpu(); |
126 | iostats = per_cpu_ptr(server->io_stats, cpu); | 29 | iostats = per_cpu_ptr(server->io_stats, cpu); |
127 | iostats->events[stat] ++; | 30 | iostats->events[stat]++; |
128 | put_cpu_no_resched(); | 31 | put_cpu_no_resched(); |
129 | } | 32 | } |
130 | 33 | ||
131 | static inline void nfs_inc_stats(struct inode *inode, enum nfs_stat_eventcounters stat) | 34 | static inline void nfs_inc_stats(const struct inode *inode, |
35 | enum nfs_stat_eventcounters stat) | ||
132 | { | 36 | { |
133 | nfs_inc_server_stats(NFS_SERVER(inode), stat); | 37 | nfs_inc_server_stats(NFS_SERVER(inode), stat); |
134 | } | 38 | } |
135 | 39 | ||
136 | static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat_bytecounters stat, unsigned long addend) | 40 | static inline void nfs_add_server_stats(const struct nfs_server *server, |
41 | enum nfs_stat_bytecounters stat, | ||
42 | unsigned long addend) | ||
137 | { | 43 | { |
138 | struct nfs_iostats *iostats; | 44 | struct nfs_iostats *iostats; |
139 | int cpu; | 45 | int cpu; |
@@ -144,7 +50,9 @@ static inline void nfs_add_server_stats(struct nfs_server *server, enum nfs_stat | |||
144 | put_cpu_no_resched(); | 50 | put_cpu_no_resched(); |
145 | } | 51 | } |
146 | 52 | ||
147 | static inline void nfs_add_stats(struct inode *inode, enum nfs_stat_bytecounters stat, unsigned long addend) | 53 | static inline void nfs_add_stats(const struct inode *inode, |
54 | enum nfs_stat_bytecounters stat, | ||
55 | unsigned long addend) | ||
148 | { | 56 | { |
149 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); | 57 | nfs_add_server_stats(NFS_SERVER(inode), stat, addend); |
150 | } | 58 | } |
@@ -160,5 +68,4 @@ static inline void nfs_free_iostats(struct nfs_iostats *stats) | |||
160 | free_percpu(stats); | 68 | free_percpu(stats); |
161 | } | 69 | } |
162 | 70 | ||
163 | #endif | 71 | #endif /* _NFS_IOSTAT */ |
164 | #endif | ||
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 9b7362565c0c..423842f51ac9 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
@@ -5,6 +5,8 @@ | |||
5 | #include <linux/posix_acl_xattr.h> | 5 | #include <linux/posix_acl_xattr.h> |
6 | #include <linux/nfsacl.h> | 6 | #include <linux/nfsacl.h> |
7 | 7 | ||
8 | #include "internal.h" | ||
9 | |||
8 | #define NFSDBG_FACILITY NFSDBG_PROC | 10 | #define NFSDBG_FACILITY NFSDBG_PROC |
9 | 11 | ||
10 | ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size) | 12 | ssize_t nfs3_listxattr(struct dentry *dentry, char *buffer, size_t size) |
@@ -205,6 +207,8 @@ struct posix_acl *nfs3_proc_getacl(struct inode *inode, int type) | |||
205 | status = nfs_revalidate_inode(server, inode); | 207 | status = nfs_revalidate_inode(server, inode); |
206 | if (status < 0) | 208 | if (status < 0) |
207 | return ERR_PTR(status); | 209 | return ERR_PTR(status); |
210 | if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL) | ||
211 | nfs_zap_acl_cache(inode); | ||
208 | acl = nfs3_get_cached_acl(inode, type); | 212 | acl = nfs3_get_cached_acl(inode, type); |
209 | if (acl != ERR_PTR(-EAGAIN)) | 213 | if (acl != ERR_PTR(-EAGAIN)) |
210 | return acl; | 214 | return acl; |
@@ -319,9 +323,8 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
319 | dprintk("NFS call setacl\n"); | 323 | dprintk("NFS call setacl\n"); |
320 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; | 324 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; |
321 | status = rpc_call_sync(server->client_acl, &msg, 0); | 325 | status = rpc_call_sync(server->client_acl, &msg, 0); |
322 | spin_lock(&inode->i_lock); | 326 | nfs_access_zap_cache(inode); |
323 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS; | 327 | nfs_zap_acl_cache(inode); |
324 | spin_unlock(&inode->i_lock); | ||
325 | dprintk("NFS reply setacl: %d\n", status); | 328 | dprintk("NFS reply setacl: %d\n", status); |
326 | 329 | ||
327 | /* pages may have been allocated at the xdr layer. */ | 330 | /* pages may have been allocated at the xdr layer. */ |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index c3523ad03ed1..1e750e4574a9 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -129,6 +129,8 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
129 | int status; | 129 | int status; |
130 | 130 | ||
131 | dprintk("NFS call setattr\n"); | 131 | dprintk("NFS call setattr\n"); |
132 | if (sattr->ia_valid & ATTR_FILE) | ||
133 | msg.rpc_cred = nfs_file_cred(sattr->ia_file); | ||
132 | nfs_fattr_init(fattr); | 134 | nfs_fattr_init(fattr); |
133 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 135 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
134 | if (status == 0) | 136 | if (status == 0) |
@@ -248,6 +250,53 @@ static int nfs3_proc_readlink(struct inode *inode, struct page *page, | |||
248 | return status; | 250 | return status; |
249 | } | 251 | } |
250 | 252 | ||
253 | struct nfs3_createdata { | ||
254 | struct rpc_message msg; | ||
255 | union { | ||
256 | struct nfs3_createargs create; | ||
257 | struct nfs3_mkdirargs mkdir; | ||
258 | struct nfs3_symlinkargs symlink; | ||
259 | struct nfs3_mknodargs mknod; | ||
260 | } arg; | ||
261 | struct nfs3_diropres res; | ||
262 | struct nfs_fh fh; | ||
263 | struct nfs_fattr fattr; | ||
264 | struct nfs_fattr dir_attr; | ||
265 | }; | ||
266 | |||
267 | static struct nfs3_createdata *nfs3_alloc_createdata(void) | ||
268 | { | ||
269 | struct nfs3_createdata *data; | ||
270 | |||
271 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
272 | if (data != NULL) { | ||
273 | data->msg.rpc_argp = &data->arg; | ||
274 | data->msg.rpc_resp = &data->res; | ||
275 | data->res.fh = &data->fh; | ||
276 | data->res.fattr = &data->fattr; | ||
277 | data->res.dir_attr = &data->dir_attr; | ||
278 | nfs_fattr_init(data->res.fattr); | ||
279 | nfs_fattr_init(data->res.dir_attr); | ||
280 | } | ||
281 | return data; | ||
282 | } | ||
283 | |||
284 | static int nfs3_do_create(struct inode *dir, struct dentry *dentry, struct nfs3_createdata *data) | ||
285 | { | ||
286 | int status; | ||
287 | |||
288 | status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0); | ||
289 | nfs_post_op_update_inode(dir, data->res.dir_attr); | ||
290 | if (status == 0) | ||
291 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); | ||
292 | return status; | ||
293 | } | ||
294 | |||
295 | static void nfs3_free_createdata(struct nfs3_createdata *data) | ||
296 | { | ||
297 | kfree(data); | ||
298 | } | ||
299 | |||
251 | /* | 300 | /* |
252 | * Create a regular file. | 301 | * Create a regular file. |
253 | * For now, we don't implement O_EXCL. | 302 | * For now, we don't implement O_EXCL. |
@@ -256,70 +305,60 @@ static int | |||
256 | nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 305 | nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
257 | int flags, struct nameidata *nd) | 306 | int flags, struct nameidata *nd) |
258 | { | 307 | { |
259 | struct nfs_fh fhandle; | 308 | struct nfs3_createdata *data; |
260 | struct nfs_fattr fattr; | ||
261 | struct nfs_fattr dir_attr; | ||
262 | struct nfs3_createargs arg = { | ||
263 | .fh = NFS_FH(dir), | ||
264 | .name = dentry->d_name.name, | ||
265 | .len = dentry->d_name.len, | ||
266 | .sattr = sattr, | ||
267 | }; | ||
268 | struct nfs3_diropres res = { | ||
269 | .dir_attr = &dir_attr, | ||
270 | .fh = &fhandle, | ||
271 | .fattr = &fattr | ||
272 | }; | ||
273 | struct rpc_message msg = { | ||
274 | .rpc_proc = &nfs3_procedures[NFS3PROC_CREATE], | ||
275 | .rpc_argp = &arg, | ||
276 | .rpc_resp = &res, | ||
277 | }; | ||
278 | mode_t mode = sattr->ia_mode; | 309 | mode_t mode = sattr->ia_mode; |
279 | int status; | 310 | int status = -ENOMEM; |
280 | 311 | ||
281 | dprintk("NFS call create %s\n", dentry->d_name.name); | 312 | dprintk("NFS call create %s\n", dentry->d_name.name); |
282 | arg.createmode = NFS3_CREATE_UNCHECKED; | 313 | |
314 | data = nfs3_alloc_createdata(); | ||
315 | if (data == NULL) | ||
316 | goto out; | ||
317 | |||
318 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_CREATE]; | ||
319 | data->arg.create.fh = NFS_FH(dir); | ||
320 | data->arg.create.name = dentry->d_name.name; | ||
321 | data->arg.create.len = dentry->d_name.len; | ||
322 | data->arg.create.sattr = sattr; | ||
323 | |||
324 | data->arg.create.createmode = NFS3_CREATE_UNCHECKED; | ||
283 | if (flags & O_EXCL) { | 325 | if (flags & O_EXCL) { |
284 | arg.createmode = NFS3_CREATE_EXCLUSIVE; | 326 | data->arg.create.createmode = NFS3_CREATE_EXCLUSIVE; |
285 | arg.verifier[0] = jiffies; | 327 | data->arg.create.verifier[0] = jiffies; |
286 | arg.verifier[1] = current->pid; | 328 | data->arg.create.verifier[1] = current->pid; |
287 | } | 329 | } |
288 | 330 | ||
289 | sattr->ia_mode &= ~current->fs->umask; | 331 | sattr->ia_mode &= ~current->fs->umask; |
290 | 332 | ||
291 | again: | 333 | for (;;) { |
292 | nfs_fattr_init(&dir_attr); | 334 | status = nfs3_do_create(dir, dentry, data); |
293 | nfs_fattr_init(&fattr); | ||
294 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
295 | nfs_refresh_inode(dir, &dir_attr); | ||
296 | 335 | ||
297 | /* If the server doesn't support the exclusive creation semantics, | 336 | if (status != -ENOTSUPP) |
298 | * try again with simple 'guarded' mode. */ | 337 | break; |
299 | if (status == -ENOTSUPP) { | 338 | /* If the server doesn't support the exclusive creation |
300 | switch (arg.createmode) { | 339 | * semantics, try again with simple 'guarded' mode. */ |
340 | switch (data->arg.create.createmode) { | ||
301 | case NFS3_CREATE_EXCLUSIVE: | 341 | case NFS3_CREATE_EXCLUSIVE: |
302 | arg.createmode = NFS3_CREATE_GUARDED; | 342 | data->arg.create.createmode = NFS3_CREATE_GUARDED; |
303 | break; | 343 | break; |
304 | 344 | ||
305 | case NFS3_CREATE_GUARDED: | 345 | case NFS3_CREATE_GUARDED: |
306 | arg.createmode = NFS3_CREATE_UNCHECKED; | 346 | data->arg.create.createmode = NFS3_CREATE_UNCHECKED; |
307 | break; | 347 | break; |
308 | 348 | ||
309 | case NFS3_CREATE_UNCHECKED: | 349 | case NFS3_CREATE_UNCHECKED: |
310 | goto out; | 350 | goto out; |
311 | } | 351 | } |
312 | goto again; | 352 | nfs_fattr_init(data->res.dir_attr); |
353 | nfs_fattr_init(data->res.fattr); | ||
313 | } | 354 | } |
314 | 355 | ||
315 | if (status == 0) | ||
316 | status = nfs_instantiate(dentry, &fhandle, &fattr); | ||
317 | if (status != 0) | 356 | if (status != 0) |
318 | goto out; | 357 | goto out; |
319 | 358 | ||
320 | /* When we created the file with exclusive semantics, make | 359 | /* When we created the file with exclusive semantics, make |
321 | * sure we set the attributes afterwards. */ | 360 | * sure we set the attributes afterwards. */ |
322 | if (arg.createmode == NFS3_CREATE_EXCLUSIVE) { | 361 | if (data->arg.create.createmode == NFS3_CREATE_EXCLUSIVE) { |
323 | dprintk("NFS call setattr (post-create)\n"); | 362 | dprintk("NFS call setattr (post-create)\n"); |
324 | 363 | ||
325 | if (!(sattr->ia_valid & ATTR_ATIME_SET)) | 364 | if (!(sattr->ia_valid & ATTR_ATIME_SET)) |
@@ -330,14 +369,15 @@ again: | |||
330 | /* Note: we could use a guarded setattr here, but I'm | 369 | /* Note: we could use a guarded setattr here, but I'm |
331 | * not sure this buys us anything (and I'd have | 370 | * not sure this buys us anything (and I'd have |
332 | * to revamp the NFSv3 XDR code) */ | 371 | * to revamp the NFSv3 XDR code) */ |
333 | status = nfs3_proc_setattr(dentry, &fattr, sattr); | 372 | status = nfs3_proc_setattr(dentry, data->res.fattr, sattr); |
334 | nfs_post_op_update_inode(dentry->d_inode, &fattr); | 373 | nfs_post_op_update_inode(dentry->d_inode, data->res.fattr); |
335 | dprintk("NFS reply setattr (post-create): %d\n", status); | 374 | dprintk("NFS reply setattr (post-create): %d\n", status); |
375 | if (status != 0) | ||
376 | goto out; | ||
336 | } | 377 | } |
337 | if (status != 0) | ||
338 | goto out; | ||
339 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); | 378 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); |
340 | out: | 379 | out: |
380 | nfs3_free_createdata(data); | ||
341 | dprintk("NFS reply create: %d\n", status); | 381 | dprintk("NFS reply create: %d\n", status); |
342 | return status; | 382 | return status; |
343 | } | 383 | } |
@@ -452,40 +492,28 @@ static int | |||
452 | nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, | 492 | nfs3_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page, |
453 | unsigned int len, struct iattr *sattr) | 493 | unsigned int len, struct iattr *sattr) |
454 | { | 494 | { |
455 | struct nfs_fh fhandle; | 495 | struct nfs3_createdata *data; |
456 | struct nfs_fattr fattr, dir_attr; | 496 | int status = -ENOMEM; |
457 | struct nfs3_symlinkargs arg = { | ||
458 | .fromfh = NFS_FH(dir), | ||
459 | .fromname = dentry->d_name.name, | ||
460 | .fromlen = dentry->d_name.len, | ||
461 | .pages = &page, | ||
462 | .pathlen = len, | ||
463 | .sattr = sattr | ||
464 | }; | ||
465 | struct nfs3_diropres res = { | ||
466 | .dir_attr = &dir_attr, | ||
467 | .fh = &fhandle, | ||
468 | .fattr = &fattr | ||
469 | }; | ||
470 | struct rpc_message msg = { | ||
471 | .rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK], | ||
472 | .rpc_argp = &arg, | ||
473 | .rpc_resp = &res, | ||
474 | }; | ||
475 | int status; | ||
476 | 497 | ||
477 | if (len > NFS3_MAXPATHLEN) | 498 | if (len > NFS3_MAXPATHLEN) |
478 | return -ENAMETOOLONG; | 499 | return -ENAMETOOLONG; |
479 | 500 | ||
480 | dprintk("NFS call symlink %s\n", dentry->d_name.name); | 501 | dprintk("NFS call symlink %s\n", dentry->d_name.name); |
481 | 502 | ||
482 | nfs_fattr_init(&dir_attr); | 503 | data = nfs3_alloc_createdata(); |
483 | nfs_fattr_init(&fattr); | 504 | if (data == NULL) |
484 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
485 | nfs_post_op_update_inode(dir, &dir_attr); | ||
486 | if (status != 0) | ||
487 | goto out; | 505 | goto out; |
488 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 506 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK]; |
507 | data->arg.symlink.fromfh = NFS_FH(dir); | ||
508 | data->arg.symlink.fromname = dentry->d_name.name; | ||
509 | data->arg.symlink.fromlen = dentry->d_name.len; | ||
510 | data->arg.symlink.pages = &page; | ||
511 | data->arg.symlink.pathlen = len; | ||
512 | data->arg.symlink.sattr = sattr; | ||
513 | |||
514 | status = nfs3_do_create(dir, dentry, data); | ||
515 | |||
516 | nfs3_free_createdata(data); | ||
489 | out: | 517 | out: |
490 | dprintk("NFS reply symlink: %d\n", status); | 518 | dprintk("NFS reply symlink: %d\n", status); |
491 | return status; | 519 | return status; |
@@ -494,42 +522,31 @@ out: | |||
494 | static int | 522 | static int |
495 | nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) | 523 | nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) |
496 | { | 524 | { |
497 | struct nfs_fh fhandle; | 525 | struct nfs3_createdata *data; |
498 | struct nfs_fattr fattr, dir_attr; | ||
499 | struct nfs3_mkdirargs arg = { | ||
500 | .fh = NFS_FH(dir), | ||
501 | .name = dentry->d_name.name, | ||
502 | .len = dentry->d_name.len, | ||
503 | .sattr = sattr | ||
504 | }; | ||
505 | struct nfs3_diropres res = { | ||
506 | .dir_attr = &dir_attr, | ||
507 | .fh = &fhandle, | ||
508 | .fattr = &fattr | ||
509 | }; | ||
510 | struct rpc_message msg = { | ||
511 | .rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR], | ||
512 | .rpc_argp = &arg, | ||
513 | .rpc_resp = &res, | ||
514 | }; | ||
515 | int mode = sattr->ia_mode; | 526 | int mode = sattr->ia_mode; |
516 | int status; | 527 | int status = -ENOMEM; |
517 | 528 | ||
518 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); | 529 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); |
519 | 530 | ||
520 | sattr->ia_mode &= ~current->fs->umask; | 531 | sattr->ia_mode &= ~current->fs->umask; |
521 | 532 | ||
522 | nfs_fattr_init(&dir_attr); | 533 | data = nfs3_alloc_createdata(); |
523 | nfs_fattr_init(&fattr); | 534 | if (data == NULL) |
524 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
525 | nfs_post_op_update_inode(dir, &dir_attr); | ||
526 | if (status != 0) | ||
527 | goto out; | 535 | goto out; |
528 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 536 | |
537 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR]; | ||
538 | data->arg.mkdir.fh = NFS_FH(dir); | ||
539 | data->arg.mkdir.name = dentry->d_name.name; | ||
540 | data->arg.mkdir.len = dentry->d_name.len; | ||
541 | data->arg.mkdir.sattr = sattr; | ||
542 | |||
543 | status = nfs3_do_create(dir, dentry, data); | ||
529 | if (status != 0) | 544 | if (status != 0) |
530 | goto out; | 545 | goto out; |
546 | |||
531 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); | 547 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); |
532 | out: | 548 | out: |
549 | nfs3_free_createdata(data); | ||
533 | dprintk("NFS reply mkdir: %d\n", status); | 550 | dprintk("NFS reply mkdir: %d\n", status); |
534 | return status; | 551 | return status; |
535 | } | 552 | } |
@@ -615,52 +632,50 @@ static int | |||
615 | nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | 632 | nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, |
616 | dev_t rdev) | 633 | dev_t rdev) |
617 | { | 634 | { |
618 | struct nfs_fh fh; | 635 | struct nfs3_createdata *data; |
619 | struct nfs_fattr fattr, dir_attr; | ||
620 | struct nfs3_mknodargs arg = { | ||
621 | .fh = NFS_FH(dir), | ||
622 | .name = dentry->d_name.name, | ||
623 | .len = dentry->d_name.len, | ||
624 | .sattr = sattr, | ||
625 | .rdev = rdev | ||
626 | }; | ||
627 | struct nfs3_diropres res = { | ||
628 | .dir_attr = &dir_attr, | ||
629 | .fh = &fh, | ||
630 | .fattr = &fattr | ||
631 | }; | ||
632 | struct rpc_message msg = { | ||
633 | .rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD], | ||
634 | .rpc_argp = &arg, | ||
635 | .rpc_resp = &res, | ||
636 | }; | ||
637 | mode_t mode = sattr->ia_mode; | 636 | mode_t mode = sattr->ia_mode; |
638 | int status; | 637 | int status = -ENOMEM; |
639 | |||
640 | switch (sattr->ia_mode & S_IFMT) { | ||
641 | case S_IFBLK: arg.type = NF3BLK; break; | ||
642 | case S_IFCHR: arg.type = NF3CHR; break; | ||
643 | case S_IFIFO: arg.type = NF3FIFO; break; | ||
644 | case S_IFSOCK: arg.type = NF3SOCK; break; | ||
645 | default: return -EINVAL; | ||
646 | } | ||
647 | 638 | ||
648 | dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name, | 639 | dprintk("NFS call mknod %s %u:%u\n", dentry->d_name.name, |
649 | MAJOR(rdev), MINOR(rdev)); | 640 | MAJOR(rdev), MINOR(rdev)); |
650 | 641 | ||
651 | sattr->ia_mode &= ~current->fs->umask; | 642 | sattr->ia_mode &= ~current->fs->umask; |
652 | 643 | ||
653 | nfs_fattr_init(&dir_attr); | 644 | data = nfs3_alloc_createdata(); |
654 | nfs_fattr_init(&fattr); | 645 | if (data == NULL) |
655 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | ||
656 | nfs_post_op_update_inode(dir, &dir_attr); | ||
657 | if (status != 0) | ||
658 | goto out; | 646 | goto out; |
659 | status = nfs_instantiate(dentry, &fh, &fattr); | 647 | |
648 | data->msg.rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD]; | ||
649 | data->arg.mknod.fh = NFS_FH(dir); | ||
650 | data->arg.mknod.name = dentry->d_name.name; | ||
651 | data->arg.mknod.len = dentry->d_name.len; | ||
652 | data->arg.mknod.sattr = sattr; | ||
653 | data->arg.mknod.rdev = rdev; | ||
654 | |||
655 | switch (sattr->ia_mode & S_IFMT) { | ||
656 | case S_IFBLK: | ||
657 | data->arg.mknod.type = NF3BLK; | ||
658 | break; | ||
659 | case S_IFCHR: | ||
660 | data->arg.mknod.type = NF3CHR; | ||
661 | break; | ||
662 | case S_IFIFO: | ||
663 | data->arg.mknod.type = NF3FIFO; | ||
664 | break; | ||
665 | case S_IFSOCK: | ||
666 | data->arg.mknod.type = NF3SOCK; | ||
667 | break; | ||
668 | default: | ||
669 | status = -EINVAL; | ||
670 | goto out; | ||
671 | } | ||
672 | |||
673 | status = nfs3_do_create(dir, dentry, data); | ||
660 | if (status != 0) | 674 | if (status != 0) |
661 | goto out; | 675 | goto out; |
662 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); | 676 | status = nfs3_proc_set_default_acl(dir, dentry->d_inode, mode); |
663 | out: | 677 | out: |
678 | nfs3_free_createdata(data); | ||
664 | dprintk("NFS reply mknod: %d\n", status); | 679 | dprintk("NFS reply mknod: %d\n", status); |
665 | return status; | 680 | return status; |
666 | } | 681 | } |
@@ -801,8 +816,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { | |||
801 | .write_done = nfs3_write_done, | 816 | .write_done = nfs3_write_done, |
802 | .commit_setup = nfs3_proc_commit_setup, | 817 | .commit_setup = nfs3_proc_commit_setup, |
803 | .commit_done = nfs3_commit_done, | 818 | .commit_done = nfs3_commit_done, |
804 | .file_open = nfs_open, | ||
805 | .file_release = nfs_release, | ||
806 | .lock = nfs3_proc_lock, | 819 | .lock = nfs3_proc_lock, |
807 | .clear_acl_cache = nfs3_forget_cached_acls, | 820 | .clear_acl_cache = nfs3_forget_cached_acls, |
808 | }; | 821 | }; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 1293e0acd82b..4451287a81d1 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -1139,8 +1139,9 @@ static struct nfs4_state *nfs4_do_open(struct inode *dir, struct path *path, int | |||
1139 | return res; | 1139 | return res; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | 1142 | static int _nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, |
1143 | struct iattr *sattr, struct nfs4_state *state) | 1143 | struct nfs_fattr *fattr, struct iattr *sattr, |
1144 | struct nfs4_state *state) | ||
1144 | { | 1145 | { |
1145 | struct nfs_server *server = NFS_SERVER(inode); | 1146 | struct nfs_server *server = NFS_SERVER(inode); |
1146 | struct nfs_setattrargs arg = { | 1147 | struct nfs_setattrargs arg = { |
@@ -1154,9 +1155,10 @@ static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | |||
1154 | .server = server, | 1155 | .server = server, |
1155 | }; | 1156 | }; |
1156 | struct rpc_message msg = { | 1157 | struct rpc_message msg = { |
1157 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR], | 1158 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR], |
1158 | .rpc_argp = &arg, | 1159 | .rpc_argp = &arg, |
1159 | .rpc_resp = &res, | 1160 | .rpc_resp = &res, |
1161 | .rpc_cred = cred, | ||
1160 | }; | 1162 | }; |
1161 | unsigned long timestamp = jiffies; | 1163 | unsigned long timestamp = jiffies; |
1162 | int status; | 1164 | int status; |
@@ -1166,7 +1168,6 @@ static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | |||
1166 | if (nfs4_copy_delegation_stateid(&arg.stateid, inode)) { | 1168 | if (nfs4_copy_delegation_stateid(&arg.stateid, inode)) { |
1167 | /* Use that stateid */ | 1169 | /* Use that stateid */ |
1168 | } else if (state != NULL) { | 1170 | } else if (state != NULL) { |
1169 | msg.rpc_cred = state->owner->so_cred; | ||
1170 | nfs4_copy_stateid(&arg.stateid, state, current->files); | 1171 | nfs4_copy_stateid(&arg.stateid, state, current->files); |
1171 | } else | 1172 | } else |
1172 | memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); | 1173 | memcpy(&arg.stateid, &zero_stateid, sizeof(arg.stateid)); |
@@ -1177,15 +1178,16 @@ static int _nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | |||
1177 | return status; | 1178 | return status; |
1178 | } | 1179 | } |
1179 | 1180 | ||
1180 | static int nfs4_do_setattr(struct inode *inode, struct nfs_fattr *fattr, | 1181 | static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, |
1181 | struct iattr *sattr, struct nfs4_state *state) | 1182 | struct nfs_fattr *fattr, struct iattr *sattr, |
1183 | struct nfs4_state *state) | ||
1182 | { | 1184 | { |
1183 | struct nfs_server *server = NFS_SERVER(inode); | 1185 | struct nfs_server *server = NFS_SERVER(inode); |
1184 | struct nfs4_exception exception = { }; | 1186 | struct nfs4_exception exception = { }; |
1185 | int err; | 1187 | int err; |
1186 | do { | 1188 | do { |
1187 | err = nfs4_handle_exception(server, | 1189 | err = nfs4_handle_exception(server, |
1188 | _nfs4_do_setattr(inode, fattr, sattr, state), | 1190 | _nfs4_do_setattr(inode, cred, fattr, sattr, state), |
1189 | &exception); | 1191 | &exception); |
1190 | } while (exception.retry); | 1192 | } while (exception.retry); |
1191 | return err; | 1193 | return err; |
@@ -1647,29 +1649,25 @@ static int | |||
1647 | nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | 1649 | nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, |
1648 | struct iattr *sattr) | 1650 | struct iattr *sattr) |
1649 | { | 1651 | { |
1650 | struct rpc_cred *cred; | ||
1651 | struct inode *inode = dentry->d_inode; | 1652 | struct inode *inode = dentry->d_inode; |
1652 | struct nfs_open_context *ctx; | 1653 | struct rpc_cred *cred = NULL; |
1653 | struct nfs4_state *state = NULL; | 1654 | struct nfs4_state *state = NULL; |
1654 | int status; | 1655 | int status; |
1655 | 1656 | ||
1656 | nfs_fattr_init(fattr); | 1657 | nfs_fattr_init(fattr); |
1657 | 1658 | ||
1658 | cred = rpc_lookup_cred(); | ||
1659 | if (IS_ERR(cred)) | ||
1660 | return PTR_ERR(cred); | ||
1661 | |||
1662 | /* Search for an existing open(O_WRITE) file */ | 1659 | /* Search for an existing open(O_WRITE) file */ |
1663 | ctx = nfs_find_open_context(inode, cred, FMODE_WRITE); | 1660 | if (sattr->ia_valid & ATTR_FILE) { |
1664 | if (ctx != NULL) | 1661 | struct nfs_open_context *ctx; |
1662 | |||
1663 | ctx = nfs_file_open_context(sattr->ia_file); | ||
1664 | cred = ctx->cred; | ||
1665 | state = ctx->state; | 1665 | state = ctx->state; |
1666 | } | ||
1666 | 1667 | ||
1667 | status = nfs4_do_setattr(inode, fattr, sattr, state); | 1668 | status = nfs4_do_setattr(inode, cred, fattr, sattr, state); |
1668 | if (status == 0) | 1669 | if (status == 0) |
1669 | nfs_setattr_update_inode(inode, sattr); | 1670 | nfs_setattr_update_inode(inode, sattr); |
1670 | if (ctx != NULL) | ||
1671 | put_nfs_open_context(ctx); | ||
1672 | put_rpccred(cred); | ||
1673 | return status; | 1671 | return status; |
1674 | } | 1672 | } |
1675 | 1673 | ||
@@ -1897,17 +1895,16 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
1897 | goto out; | 1895 | goto out; |
1898 | } | 1896 | } |
1899 | state = nfs4_do_open(dir, &path, flags, sattr, cred); | 1897 | state = nfs4_do_open(dir, &path, flags, sattr, cred); |
1900 | put_rpccred(cred); | ||
1901 | d_drop(dentry); | 1898 | d_drop(dentry); |
1902 | if (IS_ERR(state)) { | 1899 | if (IS_ERR(state)) { |
1903 | status = PTR_ERR(state); | 1900 | status = PTR_ERR(state); |
1904 | goto out; | 1901 | goto out_putcred; |
1905 | } | 1902 | } |
1906 | d_add(dentry, igrab(state->inode)); | 1903 | d_add(dentry, igrab(state->inode)); |
1907 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1904 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1908 | if (flags & O_EXCL) { | 1905 | if (flags & O_EXCL) { |
1909 | struct nfs_fattr fattr; | 1906 | struct nfs_fattr fattr; |
1910 | status = nfs4_do_setattr(state->inode, &fattr, sattr, state); | 1907 | status = nfs4_do_setattr(state->inode, cred, &fattr, sattr, state); |
1911 | if (status == 0) | 1908 | if (status == 0) |
1912 | nfs_setattr_update_inode(state->inode, sattr); | 1909 | nfs_setattr_update_inode(state->inode, sattr); |
1913 | nfs_post_op_update_inode(state->inode, &fattr); | 1910 | nfs_post_op_update_inode(state->inode, &fattr); |
@@ -1916,6 +1913,8 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
1916 | status = nfs4_intent_set_file(nd, &path, state); | 1913 | status = nfs4_intent_set_file(nd, &path, state); |
1917 | else | 1914 | else |
1918 | nfs4_close_sync(&path, state, flags); | 1915 | nfs4_close_sync(&path, state, flags); |
1916 | out_putcred: | ||
1917 | put_rpccred(cred); | ||
1919 | out: | 1918 | out: |
1920 | return status; | 1919 | return status; |
1921 | } | 1920 | } |
@@ -2079,47 +2078,81 @@ static int nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr *n | |||
2079 | return err; | 2078 | return err; |
2080 | } | 2079 | } |
2081 | 2080 | ||
2081 | struct nfs4_createdata { | ||
2082 | struct rpc_message msg; | ||
2083 | struct nfs4_create_arg arg; | ||
2084 | struct nfs4_create_res res; | ||
2085 | struct nfs_fh fh; | ||
2086 | struct nfs_fattr fattr; | ||
2087 | struct nfs_fattr dir_fattr; | ||
2088 | }; | ||
2089 | |||
2090 | static struct nfs4_createdata *nfs4_alloc_createdata(struct inode *dir, | ||
2091 | struct qstr *name, struct iattr *sattr, u32 ftype) | ||
2092 | { | ||
2093 | struct nfs4_createdata *data; | ||
2094 | |||
2095 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
2096 | if (data != NULL) { | ||
2097 | struct nfs_server *server = NFS_SERVER(dir); | ||
2098 | |||
2099 | data->msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE]; | ||
2100 | data->msg.rpc_argp = &data->arg; | ||
2101 | data->msg.rpc_resp = &data->res; | ||
2102 | data->arg.dir_fh = NFS_FH(dir); | ||
2103 | data->arg.server = server; | ||
2104 | data->arg.name = name; | ||
2105 | data->arg.attrs = sattr; | ||
2106 | data->arg.ftype = ftype; | ||
2107 | data->arg.bitmask = server->attr_bitmask; | ||
2108 | data->res.server = server; | ||
2109 | data->res.fh = &data->fh; | ||
2110 | data->res.fattr = &data->fattr; | ||
2111 | data->res.dir_fattr = &data->dir_fattr; | ||
2112 | nfs_fattr_init(data->res.fattr); | ||
2113 | nfs_fattr_init(data->res.dir_fattr); | ||
2114 | } | ||
2115 | return data; | ||
2116 | } | ||
2117 | |||
2118 | static int nfs4_do_create(struct inode *dir, struct dentry *dentry, struct nfs4_createdata *data) | ||
2119 | { | ||
2120 | int status = rpc_call_sync(NFS_CLIENT(dir), &data->msg, 0); | ||
2121 | if (status == 0) { | ||
2122 | update_changeattr(dir, &data->res.dir_cinfo); | ||
2123 | nfs_post_op_update_inode(dir, data->res.dir_fattr); | ||
2124 | status = nfs_instantiate(dentry, data->res.fh, data->res.fattr); | ||
2125 | } | ||
2126 | return status; | ||
2127 | } | ||
2128 | |||
2129 | static void nfs4_free_createdata(struct nfs4_createdata *data) | ||
2130 | { | ||
2131 | kfree(data); | ||
2132 | } | ||
2133 | |||
2082 | static int _nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, | 2134 | static int _nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, |
2083 | struct page *page, unsigned int len, struct iattr *sattr) | 2135 | struct page *page, unsigned int len, struct iattr *sattr) |
2084 | { | 2136 | { |
2085 | struct nfs_server *server = NFS_SERVER(dir); | 2137 | struct nfs4_createdata *data; |
2086 | struct nfs_fh fhandle; | 2138 | int status = -ENAMETOOLONG; |
2087 | struct nfs_fattr fattr, dir_fattr; | ||
2088 | struct nfs4_create_arg arg = { | ||
2089 | .dir_fh = NFS_FH(dir), | ||
2090 | .server = server, | ||
2091 | .name = &dentry->d_name, | ||
2092 | .attrs = sattr, | ||
2093 | .ftype = NF4LNK, | ||
2094 | .bitmask = server->attr_bitmask, | ||
2095 | }; | ||
2096 | struct nfs4_create_res res = { | ||
2097 | .server = server, | ||
2098 | .fh = &fhandle, | ||
2099 | .fattr = &fattr, | ||
2100 | .dir_fattr = &dir_fattr, | ||
2101 | }; | ||
2102 | struct rpc_message msg = { | ||
2103 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK], | ||
2104 | .rpc_argp = &arg, | ||
2105 | .rpc_resp = &res, | ||
2106 | }; | ||
2107 | int status; | ||
2108 | 2139 | ||
2109 | if (len > NFS4_MAXPATHLEN) | 2140 | if (len > NFS4_MAXPATHLEN) |
2110 | return -ENAMETOOLONG; | 2141 | goto out; |
2111 | 2142 | ||
2112 | arg.u.symlink.pages = &page; | 2143 | status = -ENOMEM; |
2113 | arg.u.symlink.len = len; | 2144 | data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4LNK); |
2114 | nfs_fattr_init(&fattr); | 2145 | if (data == NULL) |
2115 | nfs_fattr_init(&dir_fattr); | 2146 | goto out; |
2147 | |||
2148 | data->msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SYMLINK]; | ||
2149 | data->arg.u.symlink.pages = &page; | ||
2150 | data->arg.u.symlink.len = len; | ||
2116 | 2151 | ||
2117 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2152 | status = nfs4_do_create(dir, dentry, data); |
2118 | if (!status) { | 2153 | |
2119 | update_changeattr(dir, &res.dir_cinfo); | 2154 | nfs4_free_createdata(data); |
2120 | nfs_post_op_update_inode(dir, res.dir_fattr); | 2155 | out: |
2121 | status = nfs_instantiate(dentry, &fhandle, &fattr); | ||
2122 | } | ||
2123 | return status; | 2156 | return status; |
2124 | } | 2157 | } |
2125 | 2158 | ||
@@ -2140,39 +2173,17 @@ static int nfs4_proc_symlink(struct inode *dir, struct dentry *dentry, | |||
2140 | static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, | 2173 | static int _nfs4_proc_mkdir(struct inode *dir, struct dentry *dentry, |
2141 | struct iattr *sattr) | 2174 | struct iattr *sattr) |
2142 | { | 2175 | { |
2143 | struct nfs_server *server = NFS_SERVER(dir); | 2176 | struct nfs4_createdata *data; |
2144 | struct nfs_fh fhandle; | 2177 | int status = -ENOMEM; |
2145 | struct nfs_fattr fattr, dir_fattr; | ||
2146 | struct nfs4_create_arg arg = { | ||
2147 | .dir_fh = NFS_FH(dir), | ||
2148 | .server = server, | ||
2149 | .name = &dentry->d_name, | ||
2150 | .attrs = sattr, | ||
2151 | .ftype = NF4DIR, | ||
2152 | .bitmask = server->attr_bitmask, | ||
2153 | }; | ||
2154 | struct nfs4_create_res res = { | ||
2155 | .server = server, | ||
2156 | .fh = &fhandle, | ||
2157 | .fattr = &fattr, | ||
2158 | .dir_fattr = &dir_fattr, | ||
2159 | }; | ||
2160 | struct rpc_message msg = { | ||
2161 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], | ||
2162 | .rpc_argp = &arg, | ||
2163 | .rpc_resp = &res, | ||
2164 | }; | ||
2165 | int status; | ||
2166 | 2178 | ||
2167 | nfs_fattr_init(&fattr); | 2179 | data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4DIR); |
2168 | nfs_fattr_init(&dir_fattr); | 2180 | if (data == NULL) |
2169 | 2181 | goto out; | |
2170 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2182 | |
2171 | if (!status) { | 2183 | status = nfs4_do_create(dir, dentry, data); |
2172 | update_changeattr(dir, &res.dir_cinfo); | 2184 | |
2173 | nfs_post_op_update_inode(dir, res.dir_fattr); | 2185 | nfs4_free_createdata(data); |
2174 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 2186 | out: |
2175 | } | ||
2176 | return status; | 2187 | return status; |
2177 | } | 2188 | } |
2178 | 2189 | ||
@@ -2242,56 +2253,34 @@ static int nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
2242 | static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, | 2253 | static int _nfs4_proc_mknod(struct inode *dir, struct dentry *dentry, |
2243 | struct iattr *sattr, dev_t rdev) | 2254 | struct iattr *sattr, dev_t rdev) |
2244 | { | 2255 | { |
2245 | struct nfs_server *server = NFS_SERVER(dir); | 2256 | struct nfs4_createdata *data; |
2246 | struct nfs_fh fh; | 2257 | int mode = sattr->ia_mode; |
2247 | struct nfs_fattr fattr, dir_fattr; | 2258 | int status = -ENOMEM; |
2248 | struct nfs4_create_arg arg = { | ||
2249 | .dir_fh = NFS_FH(dir), | ||
2250 | .server = server, | ||
2251 | .name = &dentry->d_name, | ||
2252 | .attrs = sattr, | ||
2253 | .bitmask = server->attr_bitmask, | ||
2254 | }; | ||
2255 | struct nfs4_create_res res = { | ||
2256 | .server = server, | ||
2257 | .fh = &fh, | ||
2258 | .fattr = &fattr, | ||
2259 | .dir_fattr = &dir_fattr, | ||
2260 | }; | ||
2261 | struct rpc_message msg = { | ||
2262 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE], | ||
2263 | .rpc_argp = &arg, | ||
2264 | .rpc_resp = &res, | ||
2265 | }; | ||
2266 | int status; | ||
2267 | int mode = sattr->ia_mode; | ||
2268 | |||
2269 | nfs_fattr_init(&fattr); | ||
2270 | nfs_fattr_init(&dir_fattr); | ||
2271 | 2259 | ||
2272 | BUG_ON(!(sattr->ia_valid & ATTR_MODE)); | 2260 | BUG_ON(!(sattr->ia_valid & ATTR_MODE)); |
2273 | BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); | 2261 | BUG_ON(!S_ISFIFO(mode) && !S_ISBLK(mode) && !S_ISCHR(mode) && !S_ISSOCK(mode)); |
2262 | |||
2263 | data = nfs4_alloc_createdata(dir, &dentry->d_name, sattr, NF4SOCK); | ||
2264 | if (data == NULL) | ||
2265 | goto out; | ||
2266 | |||
2274 | if (S_ISFIFO(mode)) | 2267 | if (S_ISFIFO(mode)) |
2275 | arg.ftype = NF4FIFO; | 2268 | data->arg.ftype = NF4FIFO; |
2276 | else if (S_ISBLK(mode)) { | 2269 | else if (S_ISBLK(mode)) { |
2277 | arg.ftype = NF4BLK; | 2270 | data->arg.ftype = NF4BLK; |
2278 | arg.u.device.specdata1 = MAJOR(rdev); | 2271 | data->arg.u.device.specdata1 = MAJOR(rdev); |
2279 | arg.u.device.specdata2 = MINOR(rdev); | 2272 | data->arg.u.device.specdata2 = MINOR(rdev); |
2280 | } | 2273 | } |
2281 | else if (S_ISCHR(mode)) { | 2274 | else if (S_ISCHR(mode)) { |
2282 | arg.ftype = NF4CHR; | 2275 | data->arg.ftype = NF4CHR; |
2283 | arg.u.device.specdata1 = MAJOR(rdev); | 2276 | data->arg.u.device.specdata1 = MAJOR(rdev); |
2284 | arg.u.device.specdata2 = MINOR(rdev); | 2277 | data->arg.u.device.specdata2 = MINOR(rdev); |
2285 | } | 2278 | } |
2286 | else | ||
2287 | arg.ftype = NF4SOCK; | ||
2288 | 2279 | ||
2289 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2280 | status = nfs4_do_create(dir, dentry, data); |
2290 | if (status == 0) { | 2281 | |
2291 | update_changeattr(dir, &res.dir_cinfo); | 2282 | nfs4_free_createdata(data); |
2292 | nfs_post_op_update_inode(dir, res.dir_fattr); | 2283 | out: |
2293 | status = nfs_instantiate(dentry, &fh, &fattr); | ||
2294 | } | ||
2295 | return status; | 2284 | return status; |
2296 | } | 2285 | } |
2297 | 2286 | ||
@@ -2706,6 +2695,8 @@ static ssize_t nfs4_proc_get_acl(struct inode *inode, void *buf, size_t buflen) | |||
2706 | ret = nfs_revalidate_inode(server, inode); | 2695 | ret = nfs_revalidate_inode(server, inode); |
2707 | if (ret < 0) | 2696 | if (ret < 0) |
2708 | return ret; | 2697 | return ret; |
2698 | if (NFS_I(inode)->cache_validity & NFS_INO_INVALID_ACL) | ||
2699 | nfs_zap_acl_cache(inode); | ||
2709 | ret = nfs4_read_cached_acl(inode, buf, buflen); | 2700 | ret = nfs4_read_cached_acl(inode, buf, buflen); |
2710 | if (ret != -ENOENT) | 2701 | if (ret != -ENOENT) |
2711 | return ret; | 2702 | return ret; |
@@ -2733,7 +2724,8 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl | |||
2733 | nfs_inode_return_delegation(inode); | 2724 | nfs_inode_return_delegation(inode); |
2734 | buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); | 2725 | buf_to_pages(buf, buflen, arg.acl_pages, &arg.acl_pgbase); |
2735 | ret = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 2726 | ret = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
2736 | nfs_zap_caches(inode); | 2727 | nfs_access_zap_cache(inode); |
2728 | nfs_zap_acl_cache(inode); | ||
2737 | return ret; | 2729 | return ret; |
2738 | } | 2730 | } |
2739 | 2731 | ||
@@ -2767,8 +2759,7 @@ nfs4_async_handle_error(struct rpc_task *task, const struct nfs_server *server) | |||
2767 | task->tk_status = 0; | 2759 | task->tk_status = 0; |
2768 | return -EAGAIN; | 2760 | return -EAGAIN; |
2769 | case -NFS4ERR_DELAY: | 2761 | case -NFS4ERR_DELAY: |
2770 | nfs_inc_server_stats((struct nfs_server *) server, | 2762 | nfs_inc_server_stats(server, NFSIOS_DELAY); |
2771 | NFSIOS_DELAY); | ||
2772 | case -NFS4ERR_GRACE: | 2763 | case -NFS4ERR_GRACE: |
2773 | rpc_delay(task, NFS4_POLL_RETRY_MAX); | 2764 | rpc_delay(task, NFS4_POLL_RETRY_MAX); |
2774 | task->tk_status = 0; | 2765 | task->tk_status = 0; |
@@ -2933,7 +2924,7 @@ static int _nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cre | |||
2933 | 2924 | ||
2934 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) | 2925 | int nfs4_proc_setclientid_confirm(struct nfs_client *clp, struct rpc_cred *cred) |
2935 | { | 2926 | { |
2936 | long timeout; | 2927 | long timeout = 0; |
2937 | int err; | 2928 | int err; |
2938 | do { | 2929 | do { |
2939 | err = _nfs4_proc_setclientid_confirm(clp, cred); | 2930 | err = _nfs4_proc_setclientid_confirm(clp, cred); |
@@ -3725,8 +3716,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { | |||
3725 | .write_done = nfs4_write_done, | 3716 | .write_done = nfs4_write_done, |
3726 | .commit_setup = nfs4_proc_commit_setup, | 3717 | .commit_setup = nfs4_proc_commit_setup, |
3727 | .commit_done = nfs4_commit_done, | 3718 | .commit_done = nfs4_commit_done, |
3728 | .file_open = nfs_open, | ||
3729 | .file_release = nfs_release, | ||
3730 | .lock = nfs4_proc_lock, | 3719 | .lock = nfs4_proc_lock, |
3731 | .clear_acl_cache = nfs4_zap_acl_attr, | 3720 | .clear_acl_cache = nfs4_zap_acl_attr, |
3732 | }; | 3721 | }; |
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 531379d36823..46763d1cd397 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: nfsroot.c,v 1.45 1998/03/07 10:44:46 mj Exp $ | ||
3 | * | ||
4 | * Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de> | 2 | * Copyright (C) 1995, 1996 Gero Kuhlmann <gero@gkminix.han.de> |
5 | * | 3 | * |
6 | * Allow an NFS filesystem to be mounted as root. The way this works is: | 4 | * Allow an NFS filesystem to be mounted as root. The way this works is: |
@@ -297,10 +295,10 @@ static int __init root_nfs_name(char *name) | |||
297 | nfs_data.flags = NFS_MOUNT_NONLM; /* No lockd in nfs root yet */ | 295 | nfs_data.flags = NFS_MOUNT_NONLM; /* No lockd in nfs root yet */ |
298 | nfs_data.rsize = NFS_DEF_FILE_IO_SIZE; | 296 | nfs_data.rsize = NFS_DEF_FILE_IO_SIZE; |
299 | nfs_data.wsize = NFS_DEF_FILE_IO_SIZE; | 297 | nfs_data.wsize = NFS_DEF_FILE_IO_SIZE; |
300 | nfs_data.acregmin = 3; | 298 | nfs_data.acregmin = NFS_DEF_ACREGMIN; |
301 | nfs_data.acregmax = 60; | 299 | nfs_data.acregmax = NFS_DEF_ACREGMAX; |
302 | nfs_data.acdirmin = 30; | 300 | nfs_data.acdirmin = NFS_DEF_ACDIRMIN; |
303 | nfs_data.acdirmax = 60; | 301 | nfs_data.acdirmax = NFS_DEF_ACDIRMAX; |
304 | strcpy(buf, NFS_ROOT); | 302 | strcpy(buf, NFS_ROOT); |
305 | 303 | ||
306 | /* Process options received from the remote server */ | 304 | /* Process options received from the remote server */ |
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 03599bfe81cf..4dbb84df1b68 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -129,6 +129,8 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
129 | sattr->ia_mode &= S_IALLUGO; | 129 | sattr->ia_mode &= S_IALLUGO; |
130 | 130 | ||
131 | dprintk("NFS call setattr\n"); | 131 | dprintk("NFS call setattr\n"); |
132 | if (sattr->ia_valid & ATTR_FILE) | ||
133 | msg.rpc_cred = nfs_file_cred(sattr->ia_file); | ||
132 | nfs_fattr_init(fattr); | 134 | nfs_fattr_init(fattr); |
133 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 135 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
134 | if (status == 0) | 136 | if (status == 0) |
@@ -598,6 +600,29 @@ nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl) | |||
598 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); | 600 | return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl); |
599 | } | 601 | } |
600 | 602 | ||
603 | /* Helper functions for NFS lock bounds checking */ | ||
604 | #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL) | ||
605 | static int nfs_lock_check_bounds(const struct file_lock *fl) | ||
606 | { | ||
607 | __s32 start, end; | ||
608 | |||
609 | start = (__s32)fl->fl_start; | ||
610 | if ((loff_t)start != fl->fl_start) | ||
611 | goto out_einval; | ||
612 | |||
613 | if (fl->fl_end != OFFSET_MAX) { | ||
614 | end = (__s32)fl->fl_end; | ||
615 | if ((loff_t)end != fl->fl_end) | ||
616 | goto out_einval; | ||
617 | } else | ||
618 | end = NFS_LOCK32_OFFSET_MAX; | ||
619 | |||
620 | if (start < 0 || start > end) | ||
621 | goto out_einval; | ||
622 | return 0; | ||
623 | out_einval: | ||
624 | return -EINVAL; | ||
625 | } | ||
601 | 626 | ||
602 | const struct nfs_rpc_ops nfs_v2_clientops = { | 627 | const struct nfs_rpc_ops nfs_v2_clientops = { |
603 | .version = 2, /* protocol version */ | 628 | .version = 2, /* protocol version */ |
@@ -630,7 +655,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { | |||
630 | .write_setup = nfs_proc_write_setup, | 655 | .write_setup = nfs_proc_write_setup, |
631 | .write_done = nfs_write_done, | 656 | .write_done = nfs_write_done, |
632 | .commit_setup = nfs_proc_commit_setup, | 657 | .commit_setup = nfs_proc_commit_setup, |
633 | .file_open = nfs_open, | ||
634 | .file_release = nfs_release, | ||
635 | .lock = nfs_proc_lock, | 658 | .lock = nfs_proc_lock, |
659 | .lock_check_bounds = nfs_lock_check_bounds, | ||
636 | }; | 660 | }; |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 614efeed5437..47cf83e917be 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/inet.h> | 47 | #include <linux/inet.h> |
48 | #include <linux/in6.h> | 48 | #include <linux/in6.h> |
49 | #include <net/ipv6.h> | 49 | #include <net/ipv6.h> |
50 | #include <linux/netdevice.h> | ||
50 | #include <linux/nfs_xdr.h> | 51 | #include <linux/nfs_xdr.h> |
51 | #include <linux/magic.h> | 52 | #include <linux/magic.h> |
52 | #include <linux/parser.h> | 53 | #include <linux/parser.h> |
@@ -65,7 +66,6 @@ | |||
65 | enum { | 66 | enum { |
66 | /* Mount options that take no arguments */ | 67 | /* Mount options that take no arguments */ |
67 | Opt_soft, Opt_hard, | 68 | Opt_soft, Opt_hard, |
68 | Opt_intr, Opt_nointr, | ||
69 | Opt_posix, Opt_noposix, | 69 | Opt_posix, Opt_noposix, |
70 | Opt_cto, Opt_nocto, | 70 | Opt_cto, Opt_nocto, |
71 | Opt_ac, Opt_noac, | 71 | Opt_ac, Opt_noac, |
@@ -92,8 +92,8 @@ enum { | |||
92 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, | 92 | Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost, |
93 | Opt_addr, Opt_mountaddr, Opt_clientaddr, | 93 | Opt_addr, Opt_mountaddr, Opt_clientaddr, |
94 | 94 | ||
95 | /* Mount options that are ignored */ | 95 | /* Special mount options */ |
96 | Opt_userspace, Opt_deprecated, | 96 | Opt_userspace, Opt_deprecated, Opt_sloppy, |
97 | 97 | ||
98 | Opt_err | 98 | Opt_err |
99 | }; | 99 | }; |
@@ -101,10 +101,14 @@ enum { | |||
101 | static match_table_t nfs_mount_option_tokens = { | 101 | static match_table_t nfs_mount_option_tokens = { |
102 | { Opt_userspace, "bg" }, | 102 | { Opt_userspace, "bg" }, |
103 | { Opt_userspace, "fg" }, | 103 | { Opt_userspace, "fg" }, |
104 | { Opt_userspace, "retry=%s" }, | ||
105 | |||
106 | { Opt_sloppy, "sloppy" }, | ||
107 | |||
104 | { Opt_soft, "soft" }, | 108 | { Opt_soft, "soft" }, |
105 | { Opt_hard, "hard" }, | 109 | { Opt_hard, "hard" }, |
106 | { Opt_intr, "intr" }, | 110 | { Opt_deprecated, "intr" }, |
107 | { Opt_nointr, "nointr" }, | 111 | { Opt_deprecated, "nointr" }, |
108 | { Opt_posix, "posix" }, | 112 | { Opt_posix, "posix" }, |
109 | { Opt_noposix, "noposix" }, | 113 | { Opt_noposix, "noposix" }, |
110 | { Opt_cto, "cto" }, | 114 | { Opt_cto, "cto" }, |
@@ -136,7 +140,6 @@ static match_table_t nfs_mount_option_tokens = { | |||
136 | { Opt_acdirmin, "acdirmin=%u" }, | 140 | { Opt_acdirmin, "acdirmin=%u" }, |
137 | { Opt_acdirmax, "acdirmax=%u" }, | 141 | { Opt_acdirmax, "acdirmax=%u" }, |
138 | { Opt_actimeo, "actimeo=%u" }, | 142 | { Opt_actimeo, "actimeo=%u" }, |
139 | { Opt_userspace, "retry=%u" }, | ||
140 | { Opt_namelen, "namlen=%u" }, | 143 | { Opt_namelen, "namlen=%u" }, |
141 | { Opt_mountport, "mountport=%u" }, | 144 | { Opt_mountport, "mountport=%u" }, |
142 | { Opt_mountvers, "mountvers=%u" }, | 145 | { Opt_mountvers, "mountvers=%u" }, |
@@ -207,6 +210,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, | |||
207 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 210 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
208 | static void nfs_kill_super(struct super_block *); | 211 | static void nfs_kill_super(struct super_block *); |
209 | static void nfs_put_super(struct super_block *); | 212 | static void nfs_put_super(struct super_block *); |
213 | static int nfs_remount(struct super_block *sb, int *flags, char *raw_data); | ||
210 | 214 | ||
211 | static struct file_system_type nfs_fs_type = { | 215 | static struct file_system_type nfs_fs_type = { |
212 | .owner = THIS_MODULE, | 216 | .owner = THIS_MODULE, |
@@ -234,6 +238,7 @@ static const struct super_operations nfs_sops = { | |||
234 | .umount_begin = nfs_umount_begin, | 238 | .umount_begin = nfs_umount_begin, |
235 | .show_options = nfs_show_options, | 239 | .show_options = nfs_show_options, |
236 | .show_stats = nfs_show_stats, | 240 | .show_stats = nfs_show_stats, |
241 | .remount_fs = nfs_remount, | ||
237 | }; | 242 | }; |
238 | 243 | ||
239 | #ifdef CONFIG_NFS_V4 | 244 | #ifdef CONFIG_NFS_V4 |
@@ -278,6 +283,7 @@ static const struct super_operations nfs4_sops = { | |||
278 | .umount_begin = nfs_umount_begin, | 283 | .umount_begin = nfs_umount_begin, |
279 | .show_options = nfs_show_options, | 284 | .show_options = nfs_show_options, |
280 | .show_stats = nfs_show_stats, | 285 | .show_stats = nfs_show_stats, |
286 | .remount_fs = nfs_remount, | ||
281 | }; | 287 | }; |
282 | #endif | 288 | #endif |
283 | 289 | ||
@@ -514,13 +520,13 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
514 | if (nfss->bsize != 0) | 520 | if (nfss->bsize != 0) |
515 | seq_printf(m, ",bsize=%u", nfss->bsize); | 521 | seq_printf(m, ",bsize=%u", nfss->bsize); |
516 | seq_printf(m, ",namlen=%u", nfss->namelen); | 522 | seq_printf(m, ",namlen=%u", nfss->namelen); |
517 | if (nfss->acregmin != 3*HZ || showdefaults) | 523 | if (nfss->acregmin != NFS_DEF_ACREGMIN*HZ || showdefaults) |
518 | seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ); | 524 | seq_printf(m, ",acregmin=%u", nfss->acregmin/HZ); |
519 | if (nfss->acregmax != 60*HZ || showdefaults) | 525 | if (nfss->acregmax != NFS_DEF_ACREGMAX*HZ || showdefaults) |
520 | seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ); | 526 | seq_printf(m, ",acregmax=%u", nfss->acregmax/HZ); |
521 | if (nfss->acdirmin != 30*HZ || showdefaults) | 527 | if (nfss->acdirmin != NFS_DEF_ACDIRMIN*HZ || showdefaults) |
522 | seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ); | 528 | seq_printf(m, ",acdirmin=%u", nfss->acdirmin/HZ); |
523 | if (nfss->acdirmax != 60*HZ || showdefaults) | 529 | if (nfss->acdirmax != NFS_DEF_ACDIRMAX*HZ || showdefaults) |
524 | seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ); | 530 | seq_printf(m, ",acdirmax=%u", nfss->acdirmax/HZ); |
525 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { | 531 | for (nfs_infop = nfs_info; nfs_infop->flag; nfs_infop++) { |
526 | if (nfss->flags & nfs_infop->flag) | 532 | if (nfss->flags & nfs_infop->flag) |
@@ -702,49 +708,233 @@ static int nfs_verify_server_address(struct sockaddr *addr) | |||
702 | return 0; | 708 | return 0; |
703 | } | 709 | } |
704 | 710 | ||
711 | static void nfs_parse_ipv4_address(char *string, size_t str_len, | ||
712 | struct sockaddr *sap, size_t *addr_len) | ||
713 | { | ||
714 | struct sockaddr_in *sin = (struct sockaddr_in *)sap; | ||
715 | u8 *addr = (u8 *)&sin->sin_addr.s_addr; | ||
716 | |||
717 | if (str_len <= INET_ADDRSTRLEN) { | ||
718 | dfprintk(MOUNT, "NFS: parsing IPv4 address %*s\n", | ||
719 | (int)str_len, string); | ||
720 | |||
721 | sin->sin_family = AF_INET; | ||
722 | *addr_len = sizeof(*sin); | ||
723 | if (in4_pton(string, str_len, addr, '\0', NULL)) | ||
724 | return; | ||
725 | } | ||
726 | |||
727 | sap->sa_family = AF_UNSPEC; | ||
728 | *addr_len = 0; | ||
729 | } | ||
730 | |||
731 | #define IPV6_SCOPE_DELIMITER '%' | ||
732 | |||
733 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
734 | static void nfs_parse_ipv6_scope_id(const char *string, const size_t str_len, | ||
735 | const char *delim, | ||
736 | struct sockaddr_in6 *sin6) | ||
737 | { | ||
738 | char *p; | ||
739 | size_t len; | ||
740 | |||
741 | if (!(ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)) | ||
742 | return ; | ||
743 | if (*delim != IPV6_SCOPE_DELIMITER) | ||
744 | return; | ||
745 | |||
746 | len = (string + str_len) - delim - 1; | ||
747 | p = kstrndup(delim + 1, len, GFP_KERNEL); | ||
748 | if (p) { | ||
749 | unsigned long scope_id = 0; | ||
750 | struct net_device *dev; | ||
751 | |||
752 | dev = dev_get_by_name(&init_net, p); | ||
753 | if (dev != NULL) { | ||
754 | scope_id = dev->ifindex; | ||
755 | dev_put(dev); | ||
756 | } else { | ||
757 | /* scope_id is set to zero on error */ | ||
758 | strict_strtoul(p, 10, &scope_id); | ||
759 | } | ||
760 | |||
761 | kfree(p); | ||
762 | sin6->sin6_scope_id = scope_id; | ||
763 | dfprintk(MOUNT, "NFS: IPv6 scope ID = %lu\n", scope_id); | ||
764 | } | ||
765 | } | ||
766 | |||
767 | static void nfs_parse_ipv6_address(char *string, size_t str_len, | ||
768 | struct sockaddr *sap, size_t *addr_len) | ||
769 | { | ||
770 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sap; | ||
771 | u8 *addr = (u8 *)&sin6->sin6_addr.in6_u; | ||
772 | const char *delim; | ||
773 | |||
774 | if (str_len <= INET6_ADDRSTRLEN) { | ||
775 | dfprintk(MOUNT, "NFS: parsing IPv6 address %*s\n", | ||
776 | (int)str_len, string); | ||
777 | |||
778 | sin6->sin6_family = AF_INET6; | ||
779 | *addr_len = sizeof(*sin6); | ||
780 | if (in6_pton(string, str_len, addr, IPV6_SCOPE_DELIMITER, &delim)) { | ||
781 | nfs_parse_ipv6_scope_id(string, str_len, delim, sin6); | ||
782 | return; | ||
783 | } | ||
784 | } | ||
785 | |||
786 | sap->sa_family = AF_UNSPEC; | ||
787 | *addr_len = 0; | ||
788 | } | ||
789 | #else | ||
790 | static void nfs_parse_ipv6_address(char *string, size_t str_len, | ||
791 | struct sockaddr *sap, size_t *addr_len) | ||
792 | { | ||
793 | sap->sa_family = AF_UNSPEC; | ||
794 | *addr_len = 0; | ||
795 | } | ||
796 | #endif | ||
797 | |||
705 | /* | 798 | /* |
706 | * Parse string addresses passed in via a mount option, | 799 | * Construct a sockaddr based on the contents of a string that contains |
707 | * and construct a sockaddr based on the result. | 800 | * an IP address in presentation format. |
708 | * | 801 | * |
709 | * If address parsing fails, set the sockaddr's address | 802 | * If there is a problem constructing the new sockaddr, set the address |
710 | * family to AF_UNSPEC to force nfs_verify_server_address() | 803 | * family to AF_UNSPEC. |
711 | * to punt the mount. | ||
712 | */ | 804 | */ |
713 | static void nfs_parse_server_address(char *value, | 805 | static void nfs_parse_ip_address(char *string, size_t str_len, |
714 | struct sockaddr *sap, | 806 | struct sockaddr *sap, size_t *addr_len) |
715 | size_t *len) | ||
716 | { | 807 | { |
717 | if (strchr(value, ':')) { | 808 | unsigned int i, colons; |
718 | struct sockaddr_in6 *ap = (struct sockaddr_in6 *)sap; | ||
719 | u8 *addr = (u8 *)&ap->sin6_addr.in6_u; | ||
720 | 809 | ||
721 | ap->sin6_family = AF_INET6; | 810 | colons = 0; |
722 | *len = sizeof(*ap); | 811 | for (i = 0; i < str_len; i++) |
723 | if (in6_pton(value, -1, addr, '\0', NULL)) | 812 | if (string[i] == ':') |
724 | return; | 813 | colons++; |
725 | } else { | ||
726 | struct sockaddr_in *ap = (struct sockaddr_in *)sap; | ||
727 | u8 *addr = (u8 *)&ap->sin_addr.s_addr; | ||
728 | 814 | ||
729 | ap->sin_family = AF_INET; | 815 | if (colons >= 2) |
730 | *len = sizeof(*ap); | 816 | nfs_parse_ipv6_address(string, str_len, sap, addr_len); |
731 | if (in4_pton(value, -1, addr, '\0', NULL)) | 817 | else |
818 | nfs_parse_ipv4_address(string, str_len, sap, addr_len); | ||
819 | } | ||
820 | |||
821 | /* | ||
822 | * Sanity check the NFS transport protocol. | ||
823 | * | ||
824 | */ | ||
825 | static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt) | ||
826 | { | ||
827 | switch (mnt->nfs_server.protocol) { | ||
828 | case XPRT_TRANSPORT_UDP: | ||
829 | case XPRT_TRANSPORT_TCP: | ||
830 | case XPRT_TRANSPORT_RDMA: | ||
831 | break; | ||
832 | default: | ||
833 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | ||
834 | } | ||
835 | } | ||
836 | |||
837 | /* | ||
838 | * For text based NFSv2/v3 mounts, the mount protocol transport default | ||
839 | * settings should depend upon the specified NFS transport. | ||
840 | */ | ||
841 | static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt) | ||
842 | { | ||
843 | nfs_validate_transport_protocol(mnt); | ||
844 | |||
845 | if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP || | ||
846 | mnt->mount_server.protocol == XPRT_TRANSPORT_TCP) | ||
732 | return; | 847 | return; |
848 | switch (mnt->nfs_server.protocol) { | ||
849 | case XPRT_TRANSPORT_UDP: | ||
850 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; | ||
851 | break; | ||
852 | case XPRT_TRANSPORT_TCP: | ||
853 | case XPRT_TRANSPORT_RDMA: | ||
854 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; | ||
733 | } | 855 | } |
856 | } | ||
734 | 857 | ||
735 | sap->sa_family = AF_UNSPEC; | 858 | /* |
736 | *len = 0; | 859 | * Parse the value of the 'sec=' option. |
860 | * | ||
861 | * The flavor_len setting is for v4 mounts. | ||
862 | */ | ||
863 | static int nfs_parse_security_flavors(char *value, | ||
864 | struct nfs_parsed_mount_data *mnt) | ||
865 | { | ||
866 | substring_t args[MAX_OPT_ARGS]; | ||
867 | |||
868 | dfprintk(MOUNT, "NFS: parsing sec=%s option\n", value); | ||
869 | |||
870 | switch (match_token(value, nfs_secflavor_tokens, args)) { | ||
871 | case Opt_sec_none: | ||
872 | mnt->auth_flavor_len = 0; | ||
873 | mnt->auth_flavors[0] = RPC_AUTH_NULL; | ||
874 | break; | ||
875 | case Opt_sec_sys: | ||
876 | mnt->auth_flavor_len = 0; | ||
877 | mnt->auth_flavors[0] = RPC_AUTH_UNIX; | ||
878 | break; | ||
879 | case Opt_sec_krb5: | ||
880 | mnt->auth_flavor_len = 1; | ||
881 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5; | ||
882 | break; | ||
883 | case Opt_sec_krb5i: | ||
884 | mnt->auth_flavor_len = 1; | ||
885 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I; | ||
886 | break; | ||
887 | case Opt_sec_krb5p: | ||
888 | mnt->auth_flavor_len = 1; | ||
889 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P; | ||
890 | break; | ||
891 | case Opt_sec_lkey: | ||
892 | mnt->auth_flavor_len = 1; | ||
893 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY; | ||
894 | break; | ||
895 | case Opt_sec_lkeyi: | ||
896 | mnt->auth_flavor_len = 1; | ||
897 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI; | ||
898 | break; | ||
899 | case Opt_sec_lkeyp: | ||
900 | mnt->auth_flavor_len = 1; | ||
901 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP; | ||
902 | break; | ||
903 | case Opt_sec_spkm: | ||
904 | mnt->auth_flavor_len = 1; | ||
905 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM; | ||
906 | break; | ||
907 | case Opt_sec_spkmi: | ||
908 | mnt->auth_flavor_len = 1; | ||
909 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI; | ||
910 | break; | ||
911 | case Opt_sec_spkmp: | ||
912 | mnt->auth_flavor_len = 1; | ||
913 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP; | ||
914 | break; | ||
915 | default: | ||
916 | return 0; | ||
917 | } | ||
918 | |||
919 | return 1; | ||
920 | } | ||
921 | |||
922 | static void nfs_parse_invalid_value(const char *option) | ||
923 | { | ||
924 | dfprintk(MOUNT, "NFS: bad value specified for %s option\n", option); | ||
737 | } | 925 | } |
738 | 926 | ||
739 | /* | 927 | /* |
740 | * Error-check and convert a string of mount options from user space into | 928 | * Error-check and convert a string of mount options from user space into |
741 | * a data structure | 929 | * a data structure. The whole mount string is processed; bad options are |
930 | * skipped as they are encountered. If there were no errors, return 1; | ||
931 | * otherwise return 0 (zero). | ||
742 | */ | 932 | */ |
743 | static int nfs_parse_mount_options(char *raw, | 933 | static int nfs_parse_mount_options(char *raw, |
744 | struct nfs_parsed_mount_data *mnt) | 934 | struct nfs_parsed_mount_data *mnt) |
745 | { | 935 | { |
746 | char *p, *string, *secdata; | 936 | char *p, *string, *secdata; |
747 | int rc; | 937 | int rc, sloppy = 0, errors = 0; |
748 | 938 | ||
749 | if (!raw) { | 939 | if (!raw) { |
750 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); | 940 | dfprintk(MOUNT, "NFS: mount options string was NULL.\n"); |
@@ -777,15 +967,16 @@ static int nfs_parse_mount_options(char *raw, | |||
777 | 967 | ||
778 | token = match_token(p, nfs_mount_option_tokens, args); | 968 | token = match_token(p, nfs_mount_option_tokens, args); |
779 | switch (token) { | 969 | switch (token) { |
970 | |||
971 | /* | ||
972 | * boolean options: foo/nofoo | ||
973 | */ | ||
780 | case Opt_soft: | 974 | case Opt_soft: |
781 | mnt->flags |= NFS_MOUNT_SOFT; | 975 | mnt->flags |= NFS_MOUNT_SOFT; |
782 | break; | 976 | break; |
783 | case Opt_hard: | 977 | case Opt_hard: |
784 | mnt->flags &= ~NFS_MOUNT_SOFT; | 978 | mnt->flags &= ~NFS_MOUNT_SOFT; |
785 | break; | 979 | break; |
786 | case Opt_intr: | ||
787 | case Opt_nointr: | ||
788 | break; | ||
789 | case Opt_posix: | 980 | case Opt_posix: |
790 | mnt->flags |= NFS_MOUNT_POSIX; | 981 | mnt->flags |= NFS_MOUNT_POSIX; |
791 | break; | 982 | break; |
@@ -819,20 +1010,14 @@ static int nfs_parse_mount_options(char *raw, | |||
819 | case Opt_udp: | 1010 | case Opt_udp: |
820 | mnt->flags &= ~NFS_MOUNT_TCP; | 1011 | mnt->flags &= ~NFS_MOUNT_TCP; |
821 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1012 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
822 | mnt->timeo = 7; | ||
823 | mnt->retrans = 5; | ||
824 | break; | 1013 | break; |
825 | case Opt_tcp: | 1014 | case Opt_tcp: |
826 | mnt->flags |= NFS_MOUNT_TCP; | 1015 | mnt->flags |= NFS_MOUNT_TCP; |
827 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1016 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
828 | mnt->timeo = 600; | ||
829 | mnt->retrans = 2; | ||
830 | break; | 1017 | break; |
831 | case Opt_rdma: | 1018 | case Opt_rdma: |
832 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ | 1019 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ |
833 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | 1020 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; |
834 | mnt->timeo = 600; | ||
835 | mnt->retrans = 2; | ||
836 | break; | 1021 | break; |
837 | case Opt_acl: | 1022 | case Opt_acl: |
838 | mnt->flags &= ~NFS_MOUNT_NOACL; | 1023 | mnt->flags &= ~NFS_MOUNT_NOACL; |
@@ -853,165 +1038,144 @@ static int nfs_parse_mount_options(char *raw, | |||
853 | mnt->flags |= NFS_MOUNT_UNSHARED; | 1038 | mnt->flags |= NFS_MOUNT_UNSHARED; |
854 | break; | 1039 | break; |
855 | 1040 | ||
1041 | /* | ||
1042 | * options that take numeric values | ||
1043 | */ | ||
856 | case Opt_port: | 1044 | case Opt_port: |
857 | if (match_int(args, &option)) | 1045 | if (match_int(args, &option) || |
858 | return 0; | 1046 | option < 0 || option > USHORT_MAX) { |
859 | if (option < 0 || option > 65535) | 1047 | errors++; |
860 | return 0; | 1048 | nfs_parse_invalid_value("port"); |
861 | mnt->nfs_server.port = option; | 1049 | } else |
1050 | mnt->nfs_server.port = option; | ||
862 | break; | 1051 | break; |
863 | case Opt_rsize: | 1052 | case Opt_rsize: |
864 | if (match_int(args, &mnt->rsize)) | 1053 | if (match_int(args, &option) || option < 0) { |
865 | return 0; | 1054 | errors++; |
1055 | nfs_parse_invalid_value("rsize"); | ||
1056 | } else | ||
1057 | mnt->rsize = option; | ||
866 | break; | 1058 | break; |
867 | case Opt_wsize: | 1059 | case Opt_wsize: |
868 | if (match_int(args, &mnt->wsize)) | 1060 | if (match_int(args, &option) || option < 0) { |
869 | return 0; | 1061 | errors++; |
1062 | nfs_parse_invalid_value("wsize"); | ||
1063 | } else | ||
1064 | mnt->wsize = option; | ||
870 | break; | 1065 | break; |
871 | case Opt_bsize: | 1066 | case Opt_bsize: |
872 | if (match_int(args, &option)) | 1067 | if (match_int(args, &option) || option < 0) { |
873 | return 0; | 1068 | errors++; |
874 | if (option < 0) | 1069 | nfs_parse_invalid_value("bsize"); |
875 | return 0; | 1070 | } else |
876 | mnt->bsize = option; | 1071 | mnt->bsize = option; |
877 | break; | 1072 | break; |
878 | case Opt_timeo: | 1073 | case Opt_timeo: |
879 | if (match_int(args, &mnt->timeo)) | 1074 | if (match_int(args, &option) || option <= 0) { |
880 | return 0; | 1075 | errors++; |
1076 | nfs_parse_invalid_value("timeo"); | ||
1077 | } else | ||
1078 | mnt->timeo = option; | ||
881 | break; | 1079 | break; |
882 | case Opt_retrans: | 1080 | case Opt_retrans: |
883 | if (match_int(args, &mnt->retrans)) | 1081 | if (match_int(args, &option) || option <= 0) { |
884 | return 0; | 1082 | errors++; |
1083 | nfs_parse_invalid_value("retrans"); | ||
1084 | } else | ||
1085 | mnt->retrans = option; | ||
885 | break; | 1086 | break; |
886 | case Opt_acregmin: | 1087 | case Opt_acregmin: |
887 | if (match_int(args, &mnt->acregmin)) | 1088 | if (match_int(args, &option) || option < 0) { |
888 | return 0; | 1089 | errors++; |
1090 | nfs_parse_invalid_value("acregmin"); | ||
1091 | } else | ||
1092 | mnt->acregmin = option; | ||
889 | break; | 1093 | break; |
890 | case Opt_acregmax: | 1094 | case Opt_acregmax: |
891 | if (match_int(args, &mnt->acregmax)) | 1095 | if (match_int(args, &option) || option < 0) { |
892 | return 0; | 1096 | errors++; |
1097 | nfs_parse_invalid_value("acregmax"); | ||
1098 | } else | ||
1099 | mnt->acregmax = option; | ||
893 | break; | 1100 | break; |
894 | case Opt_acdirmin: | 1101 | case Opt_acdirmin: |
895 | if (match_int(args, &mnt->acdirmin)) | 1102 | if (match_int(args, &option) || option < 0) { |
896 | return 0; | 1103 | errors++; |
1104 | nfs_parse_invalid_value("acdirmin"); | ||
1105 | } else | ||
1106 | mnt->acdirmin = option; | ||
897 | break; | 1107 | break; |
898 | case Opt_acdirmax: | 1108 | case Opt_acdirmax: |
899 | if (match_int(args, &mnt->acdirmax)) | 1109 | if (match_int(args, &option) || option < 0) { |
900 | return 0; | 1110 | errors++; |
1111 | nfs_parse_invalid_value("acdirmax"); | ||
1112 | } else | ||
1113 | mnt->acdirmax = option; | ||
901 | break; | 1114 | break; |
902 | case Opt_actimeo: | 1115 | case Opt_actimeo: |
903 | if (match_int(args, &option)) | 1116 | if (match_int(args, &option) || option < 0) { |
904 | return 0; | 1117 | errors++; |
905 | if (option < 0) | 1118 | nfs_parse_invalid_value("actimeo"); |
906 | return 0; | 1119 | } else |
907 | mnt->acregmin = | 1120 | mnt->acregmin = mnt->acregmax = |
908 | mnt->acregmax = | 1121 | mnt->acdirmin = mnt->acdirmax = option; |
909 | mnt->acdirmin = | ||
910 | mnt->acdirmax = option; | ||
911 | break; | 1122 | break; |
912 | case Opt_namelen: | 1123 | case Opt_namelen: |
913 | if (match_int(args, &mnt->namlen)) | 1124 | if (match_int(args, &option) || option < 0) { |
914 | return 0; | 1125 | errors++; |
1126 | nfs_parse_invalid_value("namlen"); | ||
1127 | } else | ||
1128 | mnt->namlen = option; | ||
915 | break; | 1129 | break; |
916 | case Opt_mountport: | 1130 | case Opt_mountport: |
917 | if (match_int(args, &option)) | 1131 | if (match_int(args, &option) || |
918 | return 0; | 1132 | option < 0 || option > USHORT_MAX) { |
919 | if (option < 0 || option > 65535) | 1133 | errors++; |
920 | return 0; | 1134 | nfs_parse_invalid_value("mountport"); |
921 | mnt->mount_server.port = option; | 1135 | } else |
1136 | mnt->mount_server.port = option; | ||
922 | break; | 1137 | break; |
923 | case Opt_mountvers: | 1138 | case Opt_mountvers: |
924 | if (match_int(args, &option)) | 1139 | if (match_int(args, &option) || |
925 | return 0; | 1140 | option < NFS_MNT_VERSION || |
926 | if (option < 0) | 1141 | option > NFS_MNT3_VERSION) { |
927 | return 0; | 1142 | errors++; |
928 | mnt->mount_server.version = option; | 1143 | nfs_parse_invalid_value("mountvers"); |
1144 | } else | ||
1145 | mnt->mount_server.version = option; | ||
929 | break; | 1146 | break; |
930 | case Opt_nfsvers: | 1147 | case Opt_nfsvers: |
931 | if (match_int(args, &option)) | 1148 | if (match_int(args, &option)) { |
932 | return 0; | 1149 | errors++; |
1150 | nfs_parse_invalid_value("nfsvers"); | ||
1151 | break; | ||
1152 | } | ||
933 | switch (option) { | 1153 | switch (option) { |
934 | case 2: | 1154 | case NFS2_VERSION: |
935 | mnt->flags &= ~NFS_MOUNT_VER3; | 1155 | mnt->flags &= ~NFS_MOUNT_VER3; |
936 | break; | 1156 | break; |
937 | case 3: | 1157 | case NFS3_VERSION: |
938 | mnt->flags |= NFS_MOUNT_VER3; | 1158 | mnt->flags |= NFS_MOUNT_VER3; |
939 | break; | 1159 | break; |
940 | default: | 1160 | default: |
941 | goto out_unrec_vers; | 1161 | errors++; |
1162 | nfs_parse_invalid_value("nfsvers"); | ||
942 | } | 1163 | } |
943 | break; | 1164 | break; |
944 | 1165 | ||
1166 | /* | ||
1167 | * options that take text values | ||
1168 | */ | ||
945 | case Opt_sec: | 1169 | case Opt_sec: |
946 | string = match_strdup(args); | 1170 | string = match_strdup(args); |
947 | if (string == NULL) | 1171 | if (string == NULL) |
948 | goto out_nomem; | 1172 | goto out_nomem; |
949 | token = match_token(string, nfs_secflavor_tokens, args); | 1173 | rc = nfs_parse_security_flavors(string, mnt); |
950 | kfree(string); | 1174 | kfree(string); |
951 | 1175 | if (!rc) { | |
952 | /* | 1176 | errors++; |
953 | * The flags setting is for v2/v3. The flavor_len | 1177 | dfprintk(MOUNT, "NFS: unrecognized " |
954 | * setting is for v4. v2/v3 also need to know the | 1178 | "security flavor\n"); |
955 | * difference between NULL and UNIX. | ||
956 | */ | ||
957 | switch (token) { | ||
958 | case Opt_sec_none: | ||
959 | mnt->flags &= ~NFS_MOUNT_SECFLAVOUR; | ||
960 | mnt->auth_flavor_len = 0; | ||
961 | mnt->auth_flavors[0] = RPC_AUTH_NULL; | ||
962 | break; | ||
963 | case Opt_sec_sys: | ||
964 | mnt->flags &= ~NFS_MOUNT_SECFLAVOUR; | ||
965 | mnt->auth_flavor_len = 0; | ||
966 | mnt->auth_flavors[0] = RPC_AUTH_UNIX; | ||
967 | break; | ||
968 | case Opt_sec_krb5: | ||
969 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
970 | mnt->auth_flavor_len = 1; | ||
971 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5; | ||
972 | break; | ||
973 | case Opt_sec_krb5i: | ||
974 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
975 | mnt->auth_flavor_len = 1; | ||
976 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5I; | ||
977 | break; | ||
978 | case Opt_sec_krb5p: | ||
979 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
980 | mnt->auth_flavor_len = 1; | ||
981 | mnt->auth_flavors[0] = RPC_AUTH_GSS_KRB5P; | ||
982 | break; | ||
983 | case Opt_sec_lkey: | ||
984 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
985 | mnt->auth_flavor_len = 1; | ||
986 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEY; | ||
987 | break; | ||
988 | case Opt_sec_lkeyi: | ||
989 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
990 | mnt->auth_flavor_len = 1; | ||
991 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYI; | ||
992 | break; | ||
993 | case Opt_sec_lkeyp: | ||
994 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
995 | mnt->auth_flavor_len = 1; | ||
996 | mnt->auth_flavors[0] = RPC_AUTH_GSS_LKEYP; | ||
997 | break; | ||
998 | case Opt_sec_spkm: | ||
999 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
1000 | mnt->auth_flavor_len = 1; | ||
1001 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKM; | ||
1002 | break; | ||
1003 | case Opt_sec_spkmi: | ||
1004 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
1005 | mnt->auth_flavor_len = 1; | ||
1006 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMI; | ||
1007 | break; | ||
1008 | case Opt_sec_spkmp: | ||
1009 | mnt->flags |= NFS_MOUNT_SECFLAVOUR; | ||
1010 | mnt->auth_flavor_len = 1; | ||
1011 | mnt->auth_flavors[0] = RPC_AUTH_GSS_SPKMP; | ||
1012 | break; | ||
1013 | default: | ||
1014 | goto out_unrec_sec; | ||
1015 | } | 1179 | } |
1016 | break; | 1180 | break; |
1017 | case Opt_proto: | 1181 | case Opt_proto: |
@@ -1026,24 +1190,20 @@ static int nfs_parse_mount_options(char *raw, | |||
1026 | case Opt_xprt_udp: | 1190 | case Opt_xprt_udp: |
1027 | mnt->flags &= ~NFS_MOUNT_TCP; | 1191 | mnt->flags &= ~NFS_MOUNT_TCP; |
1028 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; | 1192 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
1029 | mnt->timeo = 7; | ||
1030 | mnt->retrans = 5; | ||
1031 | break; | 1193 | break; |
1032 | case Opt_xprt_tcp: | 1194 | case Opt_xprt_tcp: |
1033 | mnt->flags |= NFS_MOUNT_TCP; | 1195 | mnt->flags |= NFS_MOUNT_TCP; |
1034 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1196 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1035 | mnt->timeo = 600; | ||
1036 | mnt->retrans = 2; | ||
1037 | break; | 1197 | break; |
1038 | case Opt_xprt_rdma: | 1198 | case Opt_xprt_rdma: |
1039 | /* vector side protocols to TCP */ | 1199 | /* vector side protocols to TCP */ |
1040 | mnt->flags |= NFS_MOUNT_TCP; | 1200 | mnt->flags |= NFS_MOUNT_TCP; |
1041 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | 1201 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; |
1042 | mnt->timeo = 600; | ||
1043 | mnt->retrans = 2; | ||
1044 | break; | 1202 | break; |
1045 | default: | 1203 | default: |
1046 | goto out_unrec_xprt; | 1204 | errors++; |
1205 | dfprintk(MOUNT, "NFS: unrecognized " | ||
1206 | "transport protocol\n"); | ||
1047 | } | 1207 | } |
1048 | break; | 1208 | break; |
1049 | case Opt_mountproto: | 1209 | case Opt_mountproto: |
@@ -1063,16 +1223,19 @@ static int nfs_parse_mount_options(char *raw, | |||
1063 | break; | 1223 | break; |
1064 | case Opt_xprt_rdma: /* not used for side protocols */ | 1224 | case Opt_xprt_rdma: /* not used for side protocols */ |
1065 | default: | 1225 | default: |
1066 | goto out_unrec_xprt; | 1226 | errors++; |
1227 | dfprintk(MOUNT, "NFS: unrecognized " | ||
1228 | "transport protocol\n"); | ||
1067 | } | 1229 | } |
1068 | break; | 1230 | break; |
1069 | case Opt_addr: | 1231 | case Opt_addr: |
1070 | string = match_strdup(args); | 1232 | string = match_strdup(args); |
1071 | if (string == NULL) | 1233 | if (string == NULL) |
1072 | goto out_nomem; | 1234 | goto out_nomem; |
1073 | nfs_parse_server_address(string, (struct sockaddr *) | 1235 | nfs_parse_ip_address(string, strlen(string), |
1074 | &mnt->nfs_server.address, | 1236 | (struct sockaddr *) |
1075 | &mnt->nfs_server.addrlen); | 1237 | &mnt->nfs_server.address, |
1238 | &mnt->nfs_server.addrlen); | ||
1076 | kfree(string); | 1239 | kfree(string); |
1077 | break; | 1240 | break; |
1078 | case Opt_clientaddr: | 1241 | case Opt_clientaddr: |
@@ -1093,24 +1256,33 @@ static int nfs_parse_mount_options(char *raw, | |||
1093 | string = match_strdup(args); | 1256 | string = match_strdup(args); |
1094 | if (string == NULL) | 1257 | if (string == NULL) |
1095 | goto out_nomem; | 1258 | goto out_nomem; |
1096 | nfs_parse_server_address(string, (struct sockaddr *) | 1259 | nfs_parse_ip_address(string, strlen(string), |
1097 | &mnt->mount_server.address, | 1260 | (struct sockaddr *) |
1098 | &mnt->mount_server.addrlen); | 1261 | &mnt->mount_server.address, |
1262 | &mnt->mount_server.addrlen); | ||
1099 | kfree(string); | 1263 | kfree(string); |
1100 | break; | 1264 | break; |
1101 | 1265 | ||
1266 | /* | ||
1267 | * Special options | ||
1268 | */ | ||
1269 | case Opt_sloppy: | ||
1270 | sloppy = 1; | ||
1271 | dfprintk(MOUNT, "NFS: relaxing parsing rules\n"); | ||
1272 | break; | ||
1102 | case Opt_userspace: | 1273 | case Opt_userspace: |
1103 | case Opt_deprecated: | 1274 | case Opt_deprecated: |
1275 | dfprintk(MOUNT, "NFS: ignoring mount option " | ||
1276 | "'%s'\n", p); | ||
1104 | break; | 1277 | break; |
1105 | 1278 | ||
1106 | default: | 1279 | default: |
1107 | goto out_unknown; | 1280 | errors++; |
1281 | dfprintk(MOUNT, "NFS: unrecognized mount option " | ||
1282 | "'%s'\n", p); | ||
1108 | } | 1283 | } |
1109 | } | 1284 | } |
1110 | 1285 | ||
1111 | nfs_set_port((struct sockaddr *)&mnt->nfs_server.address, | ||
1112 | mnt->nfs_server.port); | ||
1113 | |||
1114 | return 1; | 1286 | return 1; |
1115 | 1287 | ||
1116 | out_nomem: | 1288 | out_nomem: |
@@ -1120,21 +1292,6 @@ out_security_failure: | |||
1120 | free_secdata(secdata); | 1292 | free_secdata(secdata); |
1121 | printk(KERN_INFO "NFS: security options invalid: %d\n", rc); | 1293 | printk(KERN_INFO "NFS: security options invalid: %d\n", rc); |
1122 | return 0; | 1294 | return 0; |
1123 | out_unrec_vers: | ||
1124 | printk(KERN_INFO "NFS: unrecognized NFS version number\n"); | ||
1125 | return 0; | ||
1126 | |||
1127 | out_unrec_xprt: | ||
1128 | printk(KERN_INFO "NFS: unrecognized transport protocol\n"); | ||
1129 | return 0; | ||
1130 | |||
1131 | out_unrec_sec: | ||
1132 | printk(KERN_INFO "NFS: unrecognized security flavor\n"); | ||
1133 | return 0; | ||
1134 | |||
1135 | out_unknown: | ||
1136 | printk(KERN_INFO "NFS: unknown mount option: %s\n", p); | ||
1137 | return 0; | ||
1138 | } | 1295 | } |
1139 | 1296 | ||
1140 | /* | 1297 | /* |
@@ -1188,11 +1345,146 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, | |||
1188 | if (status == 0) | 1345 | if (status == 0) |
1189 | return 0; | 1346 | return 0; |
1190 | 1347 | ||
1191 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d", | 1348 | dfprintk(MOUNT, "NFS: unable to mount server %s, error %d\n", |
1192 | hostname, status); | 1349 | hostname, status); |
1193 | return status; | 1350 | return status; |
1194 | } | 1351 | } |
1195 | 1352 | ||
1353 | static int nfs_parse_simple_hostname(const char *dev_name, | ||
1354 | char **hostname, size_t maxnamlen, | ||
1355 | char **export_path, size_t maxpathlen) | ||
1356 | { | ||
1357 | size_t len; | ||
1358 | char *colon, *comma; | ||
1359 | |||
1360 | colon = strchr(dev_name, ':'); | ||
1361 | if (colon == NULL) | ||
1362 | goto out_bad_devname; | ||
1363 | |||
1364 | len = colon - dev_name; | ||
1365 | if (len > maxnamlen) | ||
1366 | goto out_hostname; | ||
1367 | |||
1368 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1369 | *hostname = kstrndup(dev_name, len, GFP_KERNEL); | ||
1370 | if (!*hostname) | ||
1371 | goto out_nomem; | ||
1372 | |||
1373 | /* kill possible hostname list: not supported */ | ||
1374 | comma = strchr(*hostname, ','); | ||
1375 | if (comma != NULL) { | ||
1376 | if (comma == *hostname) | ||
1377 | goto out_bad_devname; | ||
1378 | *comma = '\0'; | ||
1379 | } | ||
1380 | |||
1381 | colon++; | ||
1382 | len = strlen(colon); | ||
1383 | if (len > maxpathlen) | ||
1384 | goto out_path; | ||
1385 | *export_path = kstrndup(colon, len, GFP_KERNEL); | ||
1386 | if (!*export_path) | ||
1387 | goto out_nomem; | ||
1388 | |||
1389 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *export_path); | ||
1390 | return 0; | ||
1391 | |||
1392 | out_bad_devname: | ||
1393 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); | ||
1394 | return -EINVAL; | ||
1395 | |||
1396 | out_nomem: | ||
1397 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); | ||
1398 | return -ENOMEM; | ||
1399 | |||
1400 | out_hostname: | ||
1401 | dfprintk(MOUNT, "NFS: server hostname too long\n"); | ||
1402 | return -ENAMETOOLONG; | ||
1403 | |||
1404 | out_path: | ||
1405 | dfprintk(MOUNT, "NFS: export pathname too long\n"); | ||
1406 | return -ENAMETOOLONG; | ||
1407 | } | ||
1408 | |||
1409 | /* | ||
1410 | * Hostname has square brackets around it because it contains one or | ||
1411 | * more colons. We look for the first closing square bracket, and a | ||
1412 | * colon must follow it. | ||
1413 | */ | ||
1414 | static int nfs_parse_protected_hostname(const char *dev_name, | ||
1415 | char **hostname, size_t maxnamlen, | ||
1416 | char **export_path, size_t maxpathlen) | ||
1417 | { | ||
1418 | size_t len; | ||
1419 | char *start, *end; | ||
1420 | |||
1421 | start = (char *)(dev_name + 1); | ||
1422 | |||
1423 | end = strchr(start, ']'); | ||
1424 | if (end == NULL) | ||
1425 | goto out_bad_devname; | ||
1426 | if (*(end + 1) != ':') | ||
1427 | goto out_bad_devname; | ||
1428 | |||
1429 | len = end - start; | ||
1430 | if (len > maxnamlen) | ||
1431 | goto out_hostname; | ||
1432 | |||
1433 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1434 | *hostname = kstrndup(start, len, GFP_KERNEL); | ||
1435 | if (*hostname == NULL) | ||
1436 | goto out_nomem; | ||
1437 | |||
1438 | end += 2; | ||
1439 | len = strlen(end); | ||
1440 | if (len > maxpathlen) | ||
1441 | goto out_path; | ||
1442 | *export_path = kstrndup(end, len, GFP_KERNEL); | ||
1443 | if (!*export_path) | ||
1444 | goto out_nomem; | ||
1445 | |||
1446 | return 0; | ||
1447 | |||
1448 | out_bad_devname: | ||
1449 | dfprintk(MOUNT, "NFS: device name not in host:path format\n"); | ||
1450 | return -EINVAL; | ||
1451 | |||
1452 | out_nomem: | ||
1453 | dfprintk(MOUNT, "NFS: not enough memory to parse device name\n"); | ||
1454 | return -ENOMEM; | ||
1455 | |||
1456 | out_hostname: | ||
1457 | dfprintk(MOUNT, "NFS: server hostname too long\n"); | ||
1458 | return -ENAMETOOLONG; | ||
1459 | |||
1460 | out_path: | ||
1461 | dfprintk(MOUNT, "NFS: export pathname too long\n"); | ||
1462 | return -ENAMETOOLONG; | ||
1463 | } | ||
1464 | |||
1465 | /* | ||
1466 | * Split "dev_name" into "hostname:export_path". | ||
1467 | * | ||
1468 | * The leftmost colon demarks the split between the server's hostname | ||
1469 | * and the export path. If the hostname starts with a left square | ||
1470 | * bracket, then it may contain colons. | ||
1471 | * | ||
1472 | * Note: caller frees hostname and export path, even on error. | ||
1473 | */ | ||
1474 | static int nfs_parse_devname(const char *dev_name, | ||
1475 | char **hostname, size_t maxnamlen, | ||
1476 | char **export_path, size_t maxpathlen) | ||
1477 | { | ||
1478 | if (*dev_name == '[') | ||
1479 | return nfs_parse_protected_hostname(dev_name, | ||
1480 | hostname, maxnamlen, | ||
1481 | export_path, maxpathlen); | ||
1482 | |||
1483 | return nfs_parse_simple_hostname(dev_name, | ||
1484 | hostname, maxnamlen, | ||
1485 | export_path, maxpathlen); | ||
1486 | } | ||
1487 | |||
1196 | /* | 1488 | /* |
1197 | * Validate the NFS2/NFS3 mount data | 1489 | * Validate the NFS2/NFS3 mount data |
1198 | * - fills in the mount root filehandle | 1490 | * - fills in the mount root filehandle |
@@ -1222,16 +1514,14 @@ static int nfs_validate_mount_data(void *options, | |||
1222 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); | 1514 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); |
1223 | args->rsize = NFS_MAX_FILE_IO_SIZE; | 1515 | args->rsize = NFS_MAX_FILE_IO_SIZE; |
1224 | args->wsize = NFS_MAX_FILE_IO_SIZE; | 1516 | args->wsize = NFS_MAX_FILE_IO_SIZE; |
1225 | args->timeo = 600; | 1517 | args->acregmin = NFS_DEF_ACREGMIN; |
1226 | args->retrans = 2; | 1518 | args->acregmax = NFS_DEF_ACREGMAX; |
1227 | args->acregmin = 3; | 1519 | args->acdirmin = NFS_DEF_ACDIRMIN; |
1228 | args->acregmax = 60; | 1520 | args->acdirmax = NFS_DEF_ACDIRMAX; |
1229 | args->acdirmin = 30; | ||
1230 | args->acdirmax = 60; | ||
1231 | args->mount_server.port = 0; /* autobind unless user sets port */ | 1521 | args->mount_server.port = 0; /* autobind unless user sets port */ |
1232 | args->mount_server.protocol = XPRT_TRANSPORT_UDP; | ||
1233 | args->nfs_server.port = 0; /* autobind unless user sets port */ | 1522 | args->nfs_server.port = 0; /* autobind unless user sets port */ |
1234 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 1523 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
1524 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1235 | 1525 | ||
1236 | switch (data->version) { | 1526 | switch (data->version) { |
1237 | case 1: | 1527 | case 1: |
@@ -1289,7 +1579,9 @@ static int nfs_validate_mount_data(void *options, | |||
1289 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); | 1579 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); |
1290 | args->namlen = data->namlen; | 1580 | args->namlen = data->namlen; |
1291 | args->bsize = data->bsize; | 1581 | args->bsize = data->bsize; |
1292 | args->auth_flavors[0] = data->pseudoflavor; | 1582 | |
1583 | if (data->flags & NFS_MOUNT_SECFLAVOUR) | ||
1584 | args->auth_flavors[0] = data->pseudoflavor; | ||
1293 | if (!args->nfs_server.hostname) | 1585 | if (!args->nfs_server.hostname) |
1294 | goto out_nomem; | 1586 | goto out_nomem; |
1295 | 1587 | ||
@@ -1321,8 +1613,6 @@ static int nfs_validate_mount_data(void *options, | |||
1321 | 1613 | ||
1322 | break; | 1614 | break; |
1323 | default: { | 1615 | default: { |
1324 | unsigned int len; | ||
1325 | char *c; | ||
1326 | int status; | 1616 | int status; |
1327 | 1617 | ||
1328 | if (nfs_parse_mount_options((char *)options, args) == 0) | 1618 | if (nfs_parse_mount_options((char *)options, args) == 0) |
@@ -1332,21 +1622,22 @@ static int nfs_validate_mount_data(void *options, | |||
1332 | &args->nfs_server.address)) | 1622 | &args->nfs_server.address)) |
1333 | goto out_no_address; | 1623 | goto out_no_address; |
1334 | 1624 | ||
1335 | c = strchr(dev_name, ':'); | 1625 | nfs_set_port((struct sockaddr *)&args->nfs_server.address, |
1336 | if (c == NULL) | 1626 | args->nfs_server.port); |
1337 | return -EINVAL; | ||
1338 | len = c - dev_name; | ||
1339 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1340 | args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); | ||
1341 | if (!args->nfs_server.hostname) | ||
1342 | goto out_nomem; | ||
1343 | 1627 | ||
1344 | c++; | 1628 | nfs_set_mount_transport_protocol(args); |
1345 | if (strlen(c) > NFS_MAXPATHLEN) | 1629 | |
1346 | return -ENAMETOOLONG; | 1630 | status = nfs_parse_devname(dev_name, |
1347 | args->nfs_server.export_path = c; | 1631 | &args->nfs_server.hostname, |
1632 | PAGE_SIZE, | ||
1633 | &args->nfs_server.export_path, | ||
1634 | NFS_MAXPATHLEN); | ||
1635 | if (!status) | ||
1636 | status = nfs_try_mount(args, mntfh); | ||
1637 | |||
1638 | kfree(args->nfs_server.export_path); | ||
1639 | args->nfs_server.export_path = NULL; | ||
1348 | 1640 | ||
1349 | status = nfs_try_mount(args, mntfh); | ||
1350 | if (status) | 1641 | if (status) |
1351 | return status; | 1642 | return status; |
1352 | 1643 | ||
@@ -1354,9 +1645,6 @@ static int nfs_validate_mount_data(void *options, | |||
1354 | } | 1645 | } |
1355 | } | 1646 | } |
1356 | 1647 | ||
1357 | if (!(args->flags & NFS_MOUNT_SECFLAVOUR)) | ||
1358 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1359 | |||
1360 | #ifndef CONFIG_NFS_V3 | 1648 | #ifndef CONFIG_NFS_V3 |
1361 | if (args->flags & NFS_MOUNT_VER3) | 1649 | if (args->flags & NFS_MOUNT_VER3) |
1362 | goto out_v3_not_compiled; | 1650 | goto out_v3_not_compiled; |
@@ -1396,6 +1684,80 @@ out_invalid_fh: | |||
1396 | return -EINVAL; | 1684 | return -EINVAL; |
1397 | } | 1685 | } |
1398 | 1686 | ||
1687 | static int | ||
1688 | nfs_compare_remount_data(struct nfs_server *nfss, | ||
1689 | struct nfs_parsed_mount_data *data) | ||
1690 | { | ||
1691 | if (data->flags != nfss->flags || | ||
1692 | data->rsize != nfss->rsize || | ||
1693 | data->wsize != nfss->wsize || | ||
1694 | data->retrans != nfss->client->cl_timeout->to_retries || | ||
1695 | data->auth_flavors[0] != nfss->client->cl_auth->au_flavor || | ||
1696 | data->acregmin != nfss->acregmin / HZ || | ||
1697 | data->acregmax != nfss->acregmax / HZ || | ||
1698 | data->acdirmin != nfss->acdirmin / HZ || | ||
1699 | data->acdirmax != nfss->acdirmax / HZ || | ||
1700 | data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) || | ||
1701 | data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen || | ||
1702 | memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr, | ||
1703 | data->nfs_server.addrlen) != 0) | ||
1704 | return -EINVAL; | ||
1705 | |||
1706 | return 0; | ||
1707 | } | ||
1708 | |||
1709 | static int | ||
1710 | nfs_remount(struct super_block *sb, int *flags, char *raw_data) | ||
1711 | { | ||
1712 | int error; | ||
1713 | struct nfs_server *nfss = sb->s_fs_info; | ||
1714 | struct nfs_parsed_mount_data *data; | ||
1715 | struct nfs_mount_data *options = (struct nfs_mount_data *)raw_data; | ||
1716 | struct nfs4_mount_data *options4 = (struct nfs4_mount_data *)raw_data; | ||
1717 | u32 nfsvers = nfss->nfs_client->rpc_ops->version; | ||
1718 | |||
1719 | /* | ||
1720 | * Userspace mount programs that send binary options generally send | ||
1721 | * them populated with default values. We have no way to know which | ||
1722 | * ones were explicitly specified. Fall back to legacy behavior and | ||
1723 | * just return success. | ||
1724 | */ | ||
1725 | if ((nfsvers == 4 && options4->version == 1) || | ||
1726 | (nfsvers <= 3 && options->version >= 1 && | ||
1727 | options->version <= 6)) | ||
1728 | return 0; | ||
1729 | |||
1730 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
1731 | if (data == NULL) | ||
1732 | return -ENOMEM; | ||
1733 | |||
1734 | /* fill out struct with values from existing mount */ | ||
1735 | data->flags = nfss->flags; | ||
1736 | data->rsize = nfss->rsize; | ||
1737 | data->wsize = nfss->wsize; | ||
1738 | data->retrans = nfss->client->cl_timeout->to_retries; | ||
1739 | data->auth_flavors[0] = nfss->client->cl_auth->au_flavor; | ||
1740 | data->acregmin = nfss->acregmin / HZ; | ||
1741 | data->acregmax = nfss->acregmax / HZ; | ||
1742 | data->acdirmin = nfss->acdirmin / HZ; | ||
1743 | data->acdirmax = nfss->acdirmax / HZ; | ||
1744 | data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ; | ||
1745 | data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen; | ||
1746 | memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr, | ||
1747 | data->nfs_server.addrlen); | ||
1748 | |||
1749 | /* overwrite those values with any that were specified */ | ||
1750 | error = nfs_parse_mount_options((char *)options, data); | ||
1751 | if (error < 0) | ||
1752 | goto out; | ||
1753 | |||
1754 | /* compare new mount options with old ones */ | ||
1755 | error = nfs_compare_remount_data(nfss, data); | ||
1756 | out: | ||
1757 | kfree(data); | ||
1758 | return error; | ||
1759 | } | ||
1760 | |||
1399 | /* | 1761 | /* |
1400 | * Initialise the common bits of the superblock | 1762 | * Initialise the common bits of the superblock |
1401 | */ | 1763 | */ |
@@ -1811,14 +2173,13 @@ static int nfs4_validate_mount_data(void *options, | |||
1811 | 2173 | ||
1812 | args->rsize = NFS_MAX_FILE_IO_SIZE; | 2174 | args->rsize = NFS_MAX_FILE_IO_SIZE; |
1813 | args->wsize = NFS_MAX_FILE_IO_SIZE; | 2175 | args->wsize = NFS_MAX_FILE_IO_SIZE; |
1814 | args->timeo = 600; | 2176 | args->acregmin = NFS_DEF_ACREGMIN; |
1815 | args->retrans = 2; | 2177 | args->acregmax = NFS_DEF_ACREGMAX; |
1816 | args->acregmin = 3; | 2178 | args->acdirmin = NFS_DEF_ACDIRMIN; |
1817 | args->acregmax = 60; | 2179 | args->acdirmax = NFS_DEF_ACDIRMAX; |
1818 | args->acdirmin = 30; | ||
1819 | args->acdirmax = 60; | ||
1820 | args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ | 2180 | args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ |
1821 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | 2181 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
2182 | args->auth_flavor_len = 0; | ||
1822 | 2183 | ||
1823 | switch (data->version) { | 2184 | switch (data->version) { |
1824 | case 1: | 2185 | case 1: |
@@ -1834,18 +2195,13 @@ static int nfs4_validate_mount_data(void *options, | |||
1834 | &args->nfs_server.address)) | 2195 | &args->nfs_server.address)) |
1835 | goto out_no_address; | 2196 | goto out_no_address; |
1836 | 2197 | ||
1837 | switch (data->auth_flavourlen) { | 2198 | if (data->auth_flavourlen) { |
1838 | case 0: | 2199 | if (data->auth_flavourlen > 1) |
1839 | args->auth_flavors[0] = RPC_AUTH_UNIX; | 2200 | goto out_inval_auth; |
1840 | break; | ||
1841 | case 1: | ||
1842 | if (copy_from_user(&args->auth_flavors[0], | 2201 | if (copy_from_user(&args->auth_flavors[0], |
1843 | data->auth_flavours, | 2202 | data->auth_flavours, |
1844 | sizeof(args->auth_flavors[0]))) | 2203 | sizeof(args->auth_flavors[0]))) |
1845 | return -EFAULT; | 2204 | return -EFAULT; |
1846 | break; | ||
1847 | default: | ||
1848 | goto out_inval_auth; | ||
1849 | } | 2205 | } |
1850 | 2206 | ||
1851 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); | 2207 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); |
@@ -1879,10 +2235,11 @@ static int nfs4_validate_mount_data(void *options, | |||
1879 | args->acdirmin = data->acdirmin; | 2235 | args->acdirmin = data->acdirmin; |
1880 | args->acdirmax = data->acdirmax; | 2236 | args->acdirmax = data->acdirmax; |
1881 | args->nfs_server.protocol = data->proto; | 2237 | args->nfs_server.protocol = data->proto; |
2238 | nfs_validate_transport_protocol(args); | ||
1882 | 2239 | ||
1883 | break; | 2240 | break; |
1884 | default: { | 2241 | default: { |
1885 | unsigned int len; | 2242 | int status; |
1886 | 2243 | ||
1887 | if (nfs_parse_mount_options((char *)options, args) == 0) | 2244 | if (nfs_parse_mount_options((char *)options, args) == 0) |
1888 | return -EINVAL; | 2245 | return -EINVAL; |
@@ -1891,44 +2248,25 @@ static int nfs4_validate_mount_data(void *options, | |||
1891 | &args->nfs_server.address)) | 2248 | &args->nfs_server.address)) |
1892 | return -EINVAL; | 2249 | return -EINVAL; |
1893 | 2250 | ||
1894 | switch (args->auth_flavor_len) { | 2251 | nfs_set_port((struct sockaddr *)&args->nfs_server.address, |
1895 | case 0: | 2252 | args->nfs_server.port); |
1896 | args->auth_flavors[0] = RPC_AUTH_UNIX; | ||
1897 | break; | ||
1898 | case 1: | ||
1899 | break; | ||
1900 | default: | ||
1901 | goto out_inval_auth; | ||
1902 | } | ||
1903 | 2253 | ||
1904 | /* | 2254 | nfs_validate_transport_protocol(args); |
1905 | * Split "dev_name" into "hostname:mntpath". | ||
1906 | */ | ||
1907 | c = strchr(dev_name, ':'); | ||
1908 | if (c == NULL) | ||
1909 | return -EINVAL; | ||
1910 | /* while calculating len, pretend ':' is '\0' */ | ||
1911 | len = c - dev_name; | ||
1912 | if (len > NFS4_MAXNAMLEN) | ||
1913 | return -ENAMETOOLONG; | ||
1914 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1915 | args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); | ||
1916 | if (!args->nfs_server.hostname) | ||
1917 | goto out_nomem; | ||
1918 | |||
1919 | c++; /* step over the ':' */ | ||
1920 | len = strlen(c); | ||
1921 | if (len > NFS4_MAXPATHLEN) | ||
1922 | return -ENAMETOOLONG; | ||
1923 | args->nfs_server.export_path = kstrndup(c, len, GFP_KERNEL); | ||
1924 | if (!args->nfs_server.export_path) | ||
1925 | goto out_nomem; | ||
1926 | 2255 | ||
1927 | dprintk("NFS: MNTPATH: '%s'\n", args->nfs_server.export_path); | 2256 | if (args->auth_flavor_len > 1) |
2257 | goto out_inval_auth; | ||
1928 | 2258 | ||
1929 | if (args->client_address == NULL) | 2259 | if (args->client_address == NULL) |
1930 | goto out_no_client_address; | 2260 | goto out_no_client_address; |
1931 | 2261 | ||
2262 | status = nfs_parse_devname(dev_name, | ||
2263 | &args->nfs_server.hostname, | ||
2264 | NFS4_MAXNAMLEN, | ||
2265 | &args->nfs_server.export_path, | ||
2266 | NFS4_MAXPATHLEN); | ||
2267 | if (status < 0) | ||
2268 | return status; | ||
2269 | |||
1932 | break; | 2270 | break; |
1933 | } | 2271 | } |
1934 | } | 2272 | } |
@@ -1944,10 +2282,6 @@ out_inval_auth: | |||
1944 | data->auth_flavourlen); | 2282 | data->auth_flavourlen); |
1945 | return -EINVAL; | 2283 | return -EINVAL; |
1946 | 2284 | ||
1947 | out_nomem: | ||
1948 | dfprintk(MOUNT, "NFS4: not enough memory to handle mount options\n"); | ||
1949 | return -ENOMEM; | ||
1950 | |||
1951 | out_no_address: | 2285 | out_no_address: |
1952 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); | 2286 | dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n"); |
1953 | return -EINVAL; | 2287 | return -EINVAL; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index f333848fd3be..feca8c648766 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -34,9 +34,6 @@ | |||
34 | /* | 34 | /* |
35 | * Local function declarations | 35 | * Local function declarations |
36 | */ | 36 | */ |
37 | static struct nfs_page * nfs_update_request(struct nfs_open_context*, | ||
38 | struct page *, | ||
39 | unsigned int, unsigned int); | ||
40 | static void nfs_pageio_init_write(struct nfs_pageio_descriptor *desc, | 37 | static void nfs_pageio_init_write(struct nfs_pageio_descriptor *desc, |
41 | struct inode *inode, int ioflags); | 38 | struct inode *inode, int ioflags); |
42 | static void nfs_redirty_request(struct nfs_page *req); | 39 | static void nfs_redirty_request(struct nfs_page *req); |
@@ -169,29 +166,6 @@ static void nfs_mark_uptodate(struct page *page, unsigned int base, unsigned int | |||
169 | SetPageUptodate(page); | 166 | SetPageUptodate(page); |
170 | } | 167 | } |
171 | 168 | ||
172 | static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page, | ||
173 | unsigned int offset, unsigned int count) | ||
174 | { | ||
175 | struct nfs_page *req; | ||
176 | int ret; | ||
177 | |||
178 | for (;;) { | ||
179 | req = nfs_update_request(ctx, page, offset, count); | ||
180 | if (!IS_ERR(req)) | ||
181 | break; | ||
182 | ret = PTR_ERR(req); | ||
183 | if (ret != -EBUSY) | ||
184 | return ret; | ||
185 | ret = nfs_wb_page(page->mapping->host, page); | ||
186 | if (ret != 0) | ||
187 | return ret; | ||
188 | } | ||
189 | /* Update file length */ | ||
190 | nfs_grow_file(page, offset, count); | ||
191 | nfs_clear_page_tag_locked(req); | ||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static int wb_priority(struct writeback_control *wbc) | 169 | static int wb_priority(struct writeback_control *wbc) |
196 | { | 170 | { |
197 | if (wbc->for_reclaim) | 171 | if (wbc->for_reclaim) |
@@ -268,12 +242,9 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | |||
268 | return ret; | 242 | return ret; |
269 | spin_lock(&inode->i_lock); | 243 | spin_lock(&inode->i_lock); |
270 | } | 244 | } |
271 | if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) { | 245 | if (test_bit(PG_CLEAN, &req->wb_flags)) { |
272 | /* This request is marked for commit */ | ||
273 | spin_unlock(&inode->i_lock); | 246 | spin_unlock(&inode->i_lock); |
274 | nfs_clear_page_tag_locked(req); | 247 | BUG(); |
275 | nfs_pageio_complete(pgio); | ||
276 | return 0; | ||
277 | } | 248 | } |
278 | if (nfs_set_page_writeback(page) != 0) { | 249 | if (nfs_set_page_writeback(page) != 0) { |
279 | spin_unlock(&inode->i_lock); | 250 | spin_unlock(&inode->i_lock); |
@@ -355,11 +326,19 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | |||
355 | /* | 326 | /* |
356 | * Insert a write request into an inode | 327 | * Insert a write request into an inode |
357 | */ | 328 | */ |
358 | static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | 329 | static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) |
359 | { | 330 | { |
360 | struct nfs_inode *nfsi = NFS_I(inode); | 331 | struct nfs_inode *nfsi = NFS_I(inode); |
361 | int error; | 332 | int error; |
362 | 333 | ||
334 | error = radix_tree_preload(GFP_NOFS); | ||
335 | if (error != 0) | ||
336 | goto out; | ||
337 | |||
338 | /* Lock the request! */ | ||
339 | nfs_lock_request_dontget(req); | ||
340 | |||
341 | spin_lock(&inode->i_lock); | ||
363 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); | 342 | error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req); |
364 | BUG_ON(error); | 343 | BUG_ON(error); |
365 | if (!nfsi->npages) { | 344 | if (!nfsi->npages) { |
@@ -373,6 +352,10 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
373 | kref_get(&req->wb_kref); | 352 | kref_get(&req->wb_kref); |
374 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, | 353 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, |
375 | NFS_PAGE_TAG_LOCKED); | 354 | NFS_PAGE_TAG_LOCKED); |
355 | spin_unlock(&inode->i_lock); | ||
356 | radix_tree_preload_end(); | ||
357 | out: | ||
358 | return error; | ||
376 | } | 359 | } |
377 | 360 | ||
378 | /* | 361 | /* |
@@ -405,19 +388,6 @@ nfs_mark_request_dirty(struct nfs_page *req) | |||
405 | __set_page_dirty_nobuffers(req->wb_page); | 388 | __set_page_dirty_nobuffers(req->wb_page); |
406 | } | 389 | } |
407 | 390 | ||
408 | /* | ||
409 | * Check if a request is dirty | ||
410 | */ | ||
411 | static inline int | ||
412 | nfs_dirty_request(struct nfs_page *req) | ||
413 | { | ||
414 | struct page *page = req->wb_page; | ||
415 | |||
416 | if (page == NULL || test_bit(PG_NEED_COMMIT, &req->wb_flags)) | ||
417 | return 0; | ||
418 | return !PageWriteback(page); | ||
419 | } | ||
420 | |||
421 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) | 391 | #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) |
422 | /* | 392 | /* |
423 | * Add a request to the inode's commit list. | 393 | * Add a request to the inode's commit list. |
@@ -430,7 +400,7 @@ nfs_mark_request_commit(struct nfs_page *req) | |||
430 | 400 | ||
431 | spin_lock(&inode->i_lock); | 401 | spin_lock(&inode->i_lock); |
432 | nfsi->ncommit++; | 402 | nfsi->ncommit++; |
433 | set_bit(PG_NEED_COMMIT, &(req)->wb_flags); | 403 | set_bit(PG_CLEAN, &(req)->wb_flags); |
434 | radix_tree_tag_set(&nfsi->nfs_page_tree, | 404 | radix_tree_tag_set(&nfsi->nfs_page_tree, |
435 | req->wb_index, | 405 | req->wb_index, |
436 | NFS_PAGE_TAG_COMMIT); | 406 | NFS_PAGE_TAG_COMMIT); |
@@ -440,6 +410,19 @@ nfs_mark_request_commit(struct nfs_page *req) | |||
440 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); | 410 | __mark_inode_dirty(inode, I_DIRTY_DATASYNC); |
441 | } | 411 | } |
442 | 412 | ||
413 | static int | ||
414 | nfs_clear_request_commit(struct nfs_page *req) | ||
415 | { | ||
416 | struct page *page = req->wb_page; | ||
417 | |||
418 | if (test_and_clear_bit(PG_CLEAN, &(req)->wb_flags)) { | ||
419 | dec_zone_page_state(page, NR_UNSTABLE_NFS); | ||
420 | dec_bdi_stat(page->mapping->backing_dev_info, BDI_RECLAIMABLE); | ||
421 | return 1; | ||
422 | } | ||
423 | return 0; | ||
424 | } | ||
425 | |||
443 | static inline | 426 | static inline |
444 | int nfs_write_need_commit(struct nfs_write_data *data) | 427 | int nfs_write_need_commit(struct nfs_write_data *data) |
445 | { | 428 | { |
@@ -449,7 +432,7 @@ int nfs_write_need_commit(struct nfs_write_data *data) | |||
449 | static inline | 432 | static inline |
450 | int nfs_reschedule_unstable_write(struct nfs_page *req) | 433 | int nfs_reschedule_unstable_write(struct nfs_page *req) |
451 | { | 434 | { |
452 | if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) { | 435 | if (test_and_clear_bit(PG_NEED_COMMIT, &req->wb_flags)) { |
453 | nfs_mark_request_commit(req); | 436 | nfs_mark_request_commit(req); |
454 | return 1; | 437 | return 1; |
455 | } | 438 | } |
@@ -465,6 +448,12 @@ nfs_mark_request_commit(struct nfs_page *req) | |||
465 | { | 448 | { |
466 | } | 449 | } |
467 | 450 | ||
451 | static inline int | ||
452 | nfs_clear_request_commit(struct nfs_page *req) | ||
453 | { | ||
454 | return 0; | ||
455 | } | ||
456 | |||
468 | static inline | 457 | static inline |
469 | int nfs_write_need_commit(struct nfs_write_data *data) | 458 | int nfs_write_need_commit(struct nfs_write_data *data) |
470 | { | 459 | { |
@@ -522,11 +511,8 @@ static void nfs_cancel_commit_list(struct list_head *head) | |||
522 | 511 | ||
523 | while(!list_empty(head)) { | 512 | while(!list_empty(head)) { |
524 | req = nfs_list_entry(head->next); | 513 | req = nfs_list_entry(head->next); |
525 | dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); | ||
526 | dec_bdi_stat(req->wb_page->mapping->backing_dev_info, | ||
527 | BDI_RECLAIMABLE); | ||
528 | nfs_list_remove_request(req); | 514 | nfs_list_remove_request(req); |
529 | clear_bit(PG_NEED_COMMIT, &(req)->wb_flags); | 515 | nfs_clear_request_commit(req); |
530 | nfs_inode_remove_request(req); | 516 | nfs_inode_remove_request(req); |
531 | nfs_unlock_request(req); | 517 | nfs_unlock_request(req); |
532 | } | 518 | } |
@@ -564,110 +550,124 @@ static inline int nfs_scan_commit(struct inode *inode, struct list_head *dst, pg | |||
564 | #endif | 550 | #endif |
565 | 551 | ||
566 | /* | 552 | /* |
567 | * Try to update any existing write request, or create one if there is none. | 553 | * Search for an existing write request, and attempt to update |
568 | * In order to match, the request's credentials must match those of | 554 | * it to reflect a new dirty region on a given page. |
569 | * the calling process. | ||
570 | * | 555 | * |
571 | * Note: Should always be called with the Page Lock held! | 556 | * If the attempt fails, then the existing request is flushed out |
557 | * to disk. | ||
572 | */ | 558 | */ |
573 | static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx, | 559 | static struct nfs_page *nfs_try_to_update_request(struct inode *inode, |
574 | struct page *page, unsigned int offset, unsigned int bytes) | 560 | struct page *page, |
561 | unsigned int offset, | ||
562 | unsigned int bytes) | ||
575 | { | 563 | { |
576 | struct address_space *mapping = page->mapping; | 564 | struct nfs_page *req; |
577 | struct inode *inode = mapping->host; | 565 | unsigned int rqend; |
578 | struct nfs_page *req, *new = NULL; | 566 | unsigned int end; |
579 | pgoff_t rqend, end; | 567 | int error; |
568 | |||
569 | if (!PagePrivate(page)) | ||
570 | return NULL; | ||
580 | 571 | ||
581 | end = offset + bytes; | 572 | end = offset + bytes; |
573 | spin_lock(&inode->i_lock); | ||
582 | 574 | ||
583 | for (;;) { | 575 | for (;;) { |
584 | /* Loop over all inode entries and see if we find | 576 | req = nfs_page_find_request_locked(page); |
585 | * A request for the page we wish to update | 577 | if (req == NULL) |
578 | goto out_unlock; | ||
579 | |||
580 | rqend = req->wb_offset + req->wb_bytes; | ||
581 | /* | ||
582 | * Tell the caller to flush out the request if | ||
583 | * the offsets are non-contiguous. | ||
584 | * Note: nfs_flush_incompatible() will already | ||
585 | * have flushed out requests having wrong owners. | ||
586 | */ | 586 | */ |
587 | if (new) { | 587 | if (offset > rqend |
588 | if (radix_tree_preload(GFP_NOFS)) { | 588 | || end < req->wb_offset) |
589 | nfs_release_request(new); | 589 | goto out_flushme; |
590 | return ERR_PTR(-ENOMEM); | ||
591 | } | ||
592 | } | ||
593 | 590 | ||
594 | spin_lock(&inode->i_lock); | 591 | if (nfs_set_page_tag_locked(req)) |
595 | req = nfs_page_find_request_locked(page); | ||
596 | if (req) { | ||
597 | if (!nfs_set_page_tag_locked(req)) { | ||
598 | int error; | ||
599 | |||
600 | spin_unlock(&inode->i_lock); | ||
601 | error = nfs_wait_on_request(req); | ||
602 | nfs_release_request(req); | ||
603 | if (error < 0) { | ||
604 | if (new) { | ||
605 | radix_tree_preload_end(); | ||
606 | nfs_release_request(new); | ||
607 | } | ||
608 | return ERR_PTR(error); | ||
609 | } | ||
610 | continue; | ||
611 | } | ||
612 | spin_unlock(&inode->i_lock); | ||
613 | if (new) { | ||
614 | radix_tree_preload_end(); | ||
615 | nfs_release_request(new); | ||
616 | } | ||
617 | break; | 592 | break; |
618 | } | ||
619 | 593 | ||
620 | if (new) { | 594 | /* The request is locked, so wait and then retry */ |
621 | nfs_lock_request_dontget(new); | ||
622 | nfs_inode_add_request(inode, new); | ||
623 | spin_unlock(&inode->i_lock); | ||
624 | radix_tree_preload_end(); | ||
625 | req = new; | ||
626 | goto zero_page; | ||
627 | } | ||
628 | spin_unlock(&inode->i_lock); | 595 | spin_unlock(&inode->i_lock); |
629 | 596 | error = nfs_wait_on_request(req); | |
630 | new = nfs_create_request(ctx, inode, page, offset, bytes); | 597 | nfs_release_request(req); |
631 | if (IS_ERR(new)) | 598 | if (error != 0) |
632 | return new; | 599 | goto out_err; |
600 | spin_lock(&inode->i_lock); | ||
633 | } | 601 | } |
634 | 602 | ||
635 | /* We have a request for our page. | 603 | if (nfs_clear_request_commit(req)) |
636 | * If the creds don't match, or the | 604 | radix_tree_tag_clear(&NFS_I(inode)->nfs_page_tree, |
637 | * page addresses don't match, | 605 | req->wb_index, NFS_PAGE_TAG_COMMIT); |
638 | * tell the caller to wait on the conflicting | ||
639 | * request. | ||
640 | */ | ||
641 | rqend = req->wb_offset + req->wb_bytes; | ||
642 | if (req->wb_context != ctx | ||
643 | || req->wb_page != page | ||
644 | || !nfs_dirty_request(req) | ||
645 | || offset > rqend || end < req->wb_offset) { | ||
646 | nfs_clear_page_tag_locked(req); | ||
647 | return ERR_PTR(-EBUSY); | ||
648 | } | ||
649 | 606 | ||
650 | /* Okay, the request matches. Update the region */ | 607 | /* Okay, the request matches. Update the region */ |
651 | if (offset < req->wb_offset) { | 608 | if (offset < req->wb_offset) { |
652 | req->wb_offset = offset; | 609 | req->wb_offset = offset; |
653 | req->wb_pgbase = offset; | 610 | req->wb_pgbase = offset; |
654 | req->wb_bytes = max(end, rqend) - req->wb_offset; | ||
655 | goto zero_page; | ||
656 | } | 611 | } |
657 | |||
658 | if (end > rqend) | 612 | if (end > rqend) |
659 | req->wb_bytes = end - req->wb_offset; | 613 | req->wb_bytes = end - req->wb_offset; |
660 | 614 | else | |
615 | req->wb_bytes = rqend - req->wb_offset; | ||
616 | out_unlock: | ||
617 | spin_unlock(&inode->i_lock); | ||
661 | return req; | 618 | return req; |
662 | zero_page: | 619 | out_flushme: |
663 | /* If this page might potentially be marked as up to date, | 620 | spin_unlock(&inode->i_lock); |
664 | * then we need to zero any uninitalised data. */ | 621 | nfs_release_request(req); |
665 | if (req->wb_pgbase == 0 && req->wb_bytes != PAGE_CACHE_SIZE | 622 | error = nfs_wb_page(inode, page); |
666 | && !PageUptodate(req->wb_page)) | 623 | out_err: |
667 | zero_user_segment(req->wb_page, req->wb_bytes, PAGE_CACHE_SIZE); | 624 | return ERR_PTR(error); |
625 | } | ||
626 | |||
627 | /* | ||
628 | * Try to update an existing write request, or create one if there is none. | ||
629 | * | ||
630 | * Note: Should always be called with the Page Lock held to prevent races | ||
631 | * if we have to add a new request. Also assumes that the caller has | ||
632 | * already called nfs_flush_incompatible() if necessary. | ||
633 | */ | ||
634 | static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx, | ||
635 | struct page *page, unsigned int offset, unsigned int bytes) | ||
636 | { | ||
637 | struct inode *inode = page->mapping->host; | ||
638 | struct nfs_page *req; | ||
639 | int error; | ||
640 | |||
641 | req = nfs_try_to_update_request(inode, page, offset, bytes); | ||
642 | if (req != NULL) | ||
643 | goto out; | ||
644 | req = nfs_create_request(ctx, inode, page, offset, bytes); | ||
645 | if (IS_ERR(req)) | ||
646 | goto out; | ||
647 | error = nfs_inode_add_request(inode, req); | ||
648 | if (error != 0) { | ||
649 | nfs_release_request(req); | ||
650 | req = ERR_PTR(error); | ||
651 | } | ||
652 | out: | ||
668 | return req; | 653 | return req; |
669 | } | 654 | } |
670 | 655 | ||
656 | static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page, | ||
657 | unsigned int offset, unsigned int count) | ||
658 | { | ||
659 | struct nfs_page *req; | ||
660 | |||
661 | req = nfs_setup_write_request(ctx, page, offset, count); | ||
662 | if (IS_ERR(req)) | ||
663 | return PTR_ERR(req); | ||
664 | /* Update file length */ | ||
665 | nfs_grow_file(page, offset, count); | ||
666 | nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes); | ||
667 | nfs_clear_page_tag_locked(req); | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | int nfs_flush_incompatible(struct file *file, struct page *page) | 671 | int nfs_flush_incompatible(struct file *file, struct page *page) |
672 | { | 672 | { |
673 | struct nfs_open_context *ctx = nfs_file_open_context(file); | 673 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
@@ -685,8 +685,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page) | |||
685 | req = nfs_page_find_request(page); | 685 | req = nfs_page_find_request(page); |
686 | if (req == NULL) | 686 | if (req == NULL) |
687 | return 0; | 687 | return 0; |
688 | do_flush = req->wb_page != page || req->wb_context != ctx | 688 | do_flush = req->wb_page != page || req->wb_context != ctx; |
689 | || !nfs_dirty_request(req); | ||
690 | nfs_release_request(req); | 689 | nfs_release_request(req); |
691 | if (!do_flush) | 690 | if (!do_flush) |
692 | return 0; | 691 | return 0; |
@@ -721,10 +720,10 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
721 | 720 | ||
722 | nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); | 721 | nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); |
723 | 722 | ||
724 | dprintk("NFS: nfs_updatepage(%s/%s %d@%Ld)\n", | 723 | dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n", |
725 | file->f_path.dentry->d_parent->d_name.name, | 724 | file->f_path.dentry->d_parent->d_name.name, |
726 | file->f_path.dentry->d_name.name, count, | 725 | file->f_path.dentry->d_name.name, count, |
727 | (long long)(page_offset(page) +offset)); | 726 | (long long)(page_offset(page) + offset)); |
728 | 727 | ||
729 | /* If we're not using byte range locks, and we know the page | 728 | /* If we're not using byte range locks, and we know the page |
730 | * is up to date, it may be more efficient to extend the write | 729 | * is up to date, it may be more efficient to extend the write |
@@ -744,7 +743,7 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
744 | else | 743 | else |
745 | __set_page_dirty_nobuffers(page); | 744 | __set_page_dirty_nobuffers(page); |
746 | 745 | ||
747 | dprintk("NFS: nfs_updatepage returns %d (isize %Ld)\n", | 746 | dprintk("NFS: nfs_updatepage returns %d (isize %lld)\n", |
748 | status, (long long)i_size_read(inode)); | 747 | status, (long long)i_size_read(inode)); |
749 | return status; | 748 | return status; |
750 | } | 749 | } |
@@ -752,12 +751,7 @@ int nfs_updatepage(struct file *file, struct page *page, | |||
752 | static void nfs_writepage_release(struct nfs_page *req) | 751 | static void nfs_writepage_release(struct nfs_page *req) |
753 | { | 752 | { |
754 | 753 | ||
755 | if (PageError(req->wb_page)) { | 754 | if (PageError(req->wb_page) || !nfs_reschedule_unstable_write(req)) { |
756 | nfs_end_page_writeback(req->wb_page); | ||
757 | nfs_inode_remove_request(req); | ||
758 | } else if (!nfs_reschedule_unstable_write(req)) { | ||
759 | /* Set the PG_uptodate flag */ | ||
760 | nfs_mark_uptodate(req->wb_page, req->wb_pgbase, req->wb_bytes); | ||
761 | nfs_end_page_writeback(req->wb_page); | 755 | nfs_end_page_writeback(req->wb_page); |
762 | nfs_inode_remove_request(req); | 756 | nfs_inode_remove_request(req); |
763 | } else | 757 | } else |
@@ -834,7 +828,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req, | |||
834 | NFS_PROTO(inode)->write_setup(data, &msg); | 828 | NFS_PROTO(inode)->write_setup(data, &msg); |
835 | 829 | ||
836 | dprintk("NFS: %5u initiated write call " | 830 | dprintk("NFS: %5u initiated write call " |
837 | "(req %s/%Ld, %u bytes @ offset %Lu)\n", | 831 | "(req %s/%lld, %u bytes @ offset %llu)\n", |
838 | data->task.tk_pid, | 832 | data->task.tk_pid, |
839 | inode->i_sb->s_id, | 833 | inode->i_sb->s_id, |
840 | (long long)NFS_FILEID(inode), | 834 | (long long)NFS_FILEID(inode), |
@@ -978,13 +972,13 @@ static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, | |||
978 | static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata) | 972 | static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata) |
979 | { | 973 | { |
980 | struct nfs_write_data *data = calldata; | 974 | struct nfs_write_data *data = calldata; |
981 | struct nfs_page *req = data->req; | ||
982 | 975 | ||
983 | dprintk("NFS: write (%s/%Ld %d@%Ld)", | 976 | dprintk("NFS: %5u write(%s/%lld %d@%lld)", |
984 | req->wb_context->path.dentry->d_inode->i_sb->s_id, | 977 | task->tk_pid, |
985 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), | 978 | data->req->wb_context->path.dentry->d_inode->i_sb->s_id, |
986 | req->wb_bytes, | 979 | (long long) |
987 | (long long)req_offset(req)); | 980 | NFS_FILEID(data->req->wb_context->path.dentry->d_inode), |
981 | data->req->wb_bytes, (long long)req_offset(data->req)); | ||
988 | 982 | ||
989 | nfs_writeback_done(task, data); | 983 | nfs_writeback_done(task, data); |
990 | } | 984 | } |
@@ -1058,7 +1052,8 @@ static void nfs_writeback_release_full(void *calldata) | |||
1058 | 1052 | ||
1059 | nfs_list_remove_request(req); | 1053 | nfs_list_remove_request(req); |
1060 | 1054 | ||
1061 | dprintk("NFS: write (%s/%Ld %d@%Ld)", | 1055 | dprintk("NFS: %5u write (%s/%lld %d@%lld)", |
1056 | data->task.tk_pid, | ||
1062 | req->wb_context->path.dentry->d_inode->i_sb->s_id, | 1057 | req->wb_context->path.dentry->d_inode->i_sb->s_id, |
1063 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), | 1058 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), |
1064 | req->wb_bytes, | 1059 | req->wb_bytes, |
@@ -1078,8 +1073,6 @@ static void nfs_writeback_release_full(void *calldata) | |||
1078 | dprintk(" marked for commit\n"); | 1073 | dprintk(" marked for commit\n"); |
1079 | goto next; | 1074 | goto next; |
1080 | } | 1075 | } |
1081 | /* Set the PG_uptodate flag? */ | ||
1082 | nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes); | ||
1083 | dprintk(" OK\n"); | 1076 | dprintk(" OK\n"); |
1084 | remove_request: | 1077 | remove_request: |
1085 | nfs_end_page_writeback(page); | 1078 | nfs_end_page_writeback(page); |
@@ -1133,7 +1126,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data) | |||
1133 | static unsigned long complain; | 1126 | static unsigned long complain; |
1134 | 1127 | ||
1135 | if (time_before(complain, jiffies)) { | 1128 | if (time_before(complain, jiffies)) { |
1136 | dprintk("NFS: faulty NFS server %s:" | 1129 | dprintk("NFS: faulty NFS server %s:" |
1137 | " (committed = %d) != (stable = %d)\n", | 1130 | " (committed = %d) != (stable = %d)\n", |
1138 | NFS_SERVER(data->inode)->nfs_client->cl_hostname, | 1131 | NFS_SERVER(data->inode)->nfs_client->cl_hostname, |
1139 | resp->verf->committed, argp->stable); | 1132 | resp->verf->committed, argp->stable); |
@@ -1297,12 +1290,9 @@ static void nfs_commit_release(void *calldata) | |||
1297 | while (!list_empty(&data->pages)) { | 1290 | while (!list_empty(&data->pages)) { |
1298 | req = nfs_list_entry(data->pages.next); | 1291 | req = nfs_list_entry(data->pages.next); |
1299 | nfs_list_remove_request(req); | 1292 | nfs_list_remove_request(req); |
1300 | clear_bit(PG_NEED_COMMIT, &(req)->wb_flags); | 1293 | nfs_clear_request_commit(req); |
1301 | dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); | ||
1302 | dec_bdi_stat(req->wb_page->mapping->backing_dev_info, | ||
1303 | BDI_RECLAIMABLE); | ||
1304 | 1294 | ||
1305 | dprintk("NFS: commit (%s/%Ld %d@%Ld)", | 1295 | dprintk("NFS: commit (%s/%lld %d@%lld)", |
1306 | req->wb_context->path.dentry->d_inode->i_sb->s_id, | 1296 | req->wb_context->path.dentry->d_inode->i_sb->s_id, |
1307 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), | 1297 | (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), |
1308 | req->wb_bytes, | 1298 | req->wb_bytes, |
@@ -1318,9 +1308,6 @@ static void nfs_commit_release(void *calldata) | |||
1318 | * returned by the server against all stored verfs. */ | 1308 | * returned by the server against all stored verfs. */ |
1319 | if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) { | 1309 | if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) { |
1320 | /* We have a match */ | 1310 | /* We have a match */ |
1321 | /* Set the PG_uptodate flag */ | ||
1322 | nfs_mark_uptodate(req->wb_page, req->wb_pgbase, | ||
1323 | req->wb_bytes); | ||
1324 | nfs_inode_remove_request(req); | 1311 | nfs_inode_remove_request(req); |
1325 | dprintk(" OK\n"); | 1312 | dprintk(" OK\n"); |
1326 | goto next; | 1313 | goto next; |
@@ -1479,7 +1466,7 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page) | |||
1479 | req = nfs_page_find_request(page); | 1466 | req = nfs_page_find_request(page); |
1480 | if (req == NULL) | 1467 | if (req == NULL) |
1481 | goto out; | 1468 | goto out; |
1482 | if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) { | 1469 | if (test_bit(PG_CLEAN, &req->wb_flags)) { |
1483 | nfs_release_request(req); | 1470 | nfs_release_request(req); |
1484 | break; | 1471 | break; |
1485 | } | 1472 | } |
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 4d4760e687c3..702fa577aa6e 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -381,7 +381,7 @@ static int do_probe_callback(void *data) | |||
381 | .program = &cb_program, | 381 | .program = &cb_program, |
382 | .version = nfs_cb_version[1]->number, | 382 | .version = nfs_cb_version[1]->number, |
383 | .authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */ | 383 | .authflavor = RPC_AUTH_UNIX, /* XXX: need AUTH_GSS... */ |
384 | .flags = (RPC_CLNT_CREATE_NOPING), | 384 | .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), |
385 | }; | 385 | }; |
386 | struct rpc_message msg = { | 386 | struct rpc_message msg = { |
387 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], | 387 | .rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL], |
diff --git a/include/linux/inet.h b/include/linux/inet.h index 1354080cf8cf..4cca05c9678e 100644 --- a/include/linux/inet.h +++ b/include/linux/inet.h | |||
@@ -44,6 +44,13 @@ | |||
44 | 44 | ||
45 | #include <linux/types.h> | 45 | #include <linux/types.h> |
46 | 46 | ||
47 | /* | ||
48 | * These mimic similar macros defined in user-space for inet_ntop(3). | ||
49 | * See /usr/include/netinet/in.h . | ||
50 | */ | ||
51 | #define INET_ADDRSTRLEN (16) | ||
52 | #define INET6_ADDRSTRLEN (48) | ||
53 | |||
47 | extern __be32 in_aton(const char *str); | 54 | extern __be32 in_aton(const char *str); |
48 | extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); | 55 | extern int in4_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); |
49 | extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); | 56 | extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char **end); |
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 27d6a8d98cef..29d261918734 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h | |||
@@ -12,9 +12,19 @@ | |||
12 | #include <linux/magic.h> | 12 | #include <linux/magic.h> |
13 | 13 | ||
14 | /* Default timeout values */ | 14 | /* Default timeout values */ |
15 | #define NFS_DEF_UDP_TIMEO (11) | ||
16 | #define NFS_DEF_UDP_RETRANS (3) | ||
17 | #define NFS_DEF_TCP_TIMEO (600) | ||
18 | #define NFS_DEF_TCP_RETRANS (2) | ||
19 | |||
15 | #define NFS_MAX_UDP_TIMEOUT (60*HZ) | 20 | #define NFS_MAX_UDP_TIMEOUT (60*HZ) |
16 | #define NFS_MAX_TCP_TIMEOUT (600*HZ) | 21 | #define NFS_MAX_TCP_TIMEOUT (600*HZ) |
17 | 22 | ||
23 | #define NFS_DEF_ACREGMIN (3) | ||
24 | #define NFS_DEF_ACREGMAX (60) | ||
25 | #define NFS_DEF_ACDIRMIN (30) | ||
26 | #define NFS_DEF_ACDIRMAX (60) | ||
27 | |||
18 | /* | 28 | /* |
19 | * When flushing a cluster of dirty pages, there can be different | 29 | * When flushing a cluster of dirty pages, there can be different |
20 | * strategies: | 30 | * strategies: |
diff --git a/include/linux/nfs_iostat.h b/include/linux/nfs_iostat.h new file mode 100644 index 000000000000..1cb9a3fed2b3 --- /dev/null +++ b/include/linux/nfs_iostat.h | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * User-space visible declarations for NFS client per-mount | ||
3 | * point statistics | ||
4 | * | ||
5 | * Copyright (C) 2005, 2006 Chuck Lever <cel@netapp.com> | ||
6 | * | ||
7 | * NFS client per-mount statistics provide information about the | ||
8 | * health of the NFS client and the health of each NFS mount point. | ||
9 | * Generally these are not for detailed problem diagnosis, but | ||
10 | * simply to indicate that there is a problem. | ||
11 | * | ||
12 | * These counters are not meant to be human-readable, but are meant | ||
13 | * to be integrated into system monitoring tools such as "sar" and | ||
14 | * "iostat". As such, the counters are sampled by the tools over | ||
15 | * time, and are never zeroed after a file system is mounted. | ||
16 | * Moving averages can be computed by the tools by taking the | ||
17 | * difference between two instantaneous samples and dividing that | ||
18 | * by the time between the samples. | ||
19 | */ | ||
20 | |||
21 | #ifndef _LINUX_NFS_IOSTAT | ||
22 | #define _LINUX_NFS_IOSTAT | ||
23 | |||
24 | #define NFS_IOSTAT_VERS "1.0" | ||
25 | |||
26 | /* | ||
27 | * NFS byte counters | ||
28 | * | ||
29 | * 1. SERVER - the number of payload bytes read from or written | ||
30 | * to the server by the NFS client via an NFS READ or WRITE | ||
31 | * request. | ||
32 | * | ||
33 | * 2. NORMAL - the number of bytes read or written by applications | ||
34 | * via the read(2) and write(2) system call interfaces. | ||
35 | * | ||
36 | * 3. DIRECT - the number of bytes read or written from files | ||
37 | * opened with the O_DIRECT flag. | ||
38 | * | ||
39 | * These counters give a view of the data throughput into and out | ||
40 | * of the NFS client. Comparing the number of bytes requested by | ||
41 | * an application with the number of bytes the client requests from | ||
42 | * the server can provide an indication of client efficiency | ||
43 | * (per-op, cache hits, etc). | ||
44 | * | ||
45 | * These counters can also help characterize which access methods | ||
46 | * are in use. DIRECT by itself shows whether there is any O_DIRECT | ||
47 | * traffic. NORMAL + DIRECT shows how much data is going through | ||
48 | * the system call interface. A large amount of SERVER traffic | ||
49 | * without much NORMAL or DIRECT traffic shows that applications | ||
50 | * are using mapped files. | ||
51 | * | ||
52 | * NFS page counters | ||
53 | * | ||
54 | * These count the number of pages read or written via nfs_readpage(), | ||
55 | * nfs_readpages(), or their write equivalents. | ||
56 | * | ||
57 | * NB: When adding new byte counters, please include the measured | ||
58 | * units in the name of each byte counter to help users of this | ||
59 | * interface determine what exactly is being counted. | ||
60 | */ | ||
61 | enum nfs_stat_bytecounters { | ||
62 | NFSIOS_NORMALREADBYTES = 0, | ||
63 | NFSIOS_NORMALWRITTENBYTES, | ||
64 | NFSIOS_DIRECTREADBYTES, | ||
65 | NFSIOS_DIRECTWRITTENBYTES, | ||
66 | NFSIOS_SERVERREADBYTES, | ||
67 | NFSIOS_SERVERWRITTENBYTES, | ||
68 | NFSIOS_READPAGES, | ||
69 | NFSIOS_WRITEPAGES, | ||
70 | __NFSIOS_BYTESMAX, | ||
71 | }; | ||
72 | |||
73 | /* | ||
74 | * NFS event counters | ||
75 | * | ||
76 | * These counters provide a low-overhead way of monitoring client | ||
77 | * activity without enabling NFS trace debugging. The counters | ||
78 | * show the rate at which VFS requests are made, and how often the | ||
79 | * client invalidates its data and attribute caches. This allows | ||
80 | * system administrators to monitor such things as how close-to-open | ||
81 | * is working, and answer questions such as "why are there so many | ||
82 | * GETATTR requests on the wire?" | ||
83 | * | ||
84 | * They also count anamolous events such as short reads and writes, | ||
85 | * silly renames due to close-after-delete, and operations that | ||
86 | * change the size of a file (such operations can often be the | ||
87 | * source of data corruption if applications aren't using file | ||
88 | * locking properly). | ||
89 | */ | ||
90 | enum nfs_stat_eventcounters { | ||
91 | NFSIOS_INODEREVALIDATE = 0, | ||
92 | NFSIOS_DENTRYREVALIDATE, | ||
93 | NFSIOS_DATAINVALIDATE, | ||
94 | NFSIOS_ATTRINVALIDATE, | ||
95 | NFSIOS_VFSOPEN, | ||
96 | NFSIOS_VFSLOOKUP, | ||
97 | NFSIOS_VFSACCESS, | ||
98 | NFSIOS_VFSUPDATEPAGE, | ||
99 | NFSIOS_VFSREADPAGE, | ||
100 | NFSIOS_VFSREADPAGES, | ||
101 | NFSIOS_VFSWRITEPAGE, | ||
102 | NFSIOS_VFSWRITEPAGES, | ||
103 | NFSIOS_VFSGETDENTS, | ||
104 | NFSIOS_VFSSETATTR, | ||
105 | NFSIOS_VFSFLUSH, | ||
106 | NFSIOS_VFSFSYNC, | ||
107 | NFSIOS_VFSLOCK, | ||
108 | NFSIOS_VFSRELEASE, | ||
109 | NFSIOS_CONGESTIONWAIT, | ||
110 | NFSIOS_SETATTRTRUNC, | ||
111 | NFSIOS_EXTENDWRITE, | ||
112 | NFSIOS_SILLYRENAME, | ||
113 | NFSIOS_SHORTREAD, | ||
114 | NFSIOS_SHORTWRITE, | ||
115 | NFSIOS_DELAY, | ||
116 | __NFSIOS_COUNTSMAX, | ||
117 | }; | ||
118 | |||
119 | #endif /* _LINUX_NFS_IOSTAT */ | ||
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h index a1676e19e491..3c60685d972b 100644 --- a/include/linux/nfs_page.h +++ b/include/linux/nfs_page.h | |||
@@ -27,9 +27,12 @@ | |||
27 | /* | 27 | /* |
28 | * Valid flags for a dirty buffer | 28 | * Valid flags for a dirty buffer |
29 | */ | 29 | */ |
30 | #define PG_BUSY 0 | 30 | enum { |
31 | #define PG_NEED_COMMIT 1 | 31 | PG_BUSY = 0, |
32 | #define PG_NEED_RESCHED 2 | 32 | PG_CLEAN, |
33 | PG_NEED_COMMIT, | ||
34 | PG_NEED_RESCHED, | ||
35 | }; | ||
33 | 36 | ||
34 | struct nfs_inode; | 37 | struct nfs_inode; |
35 | struct nfs_page { | 38 | struct nfs_page { |
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 24263bb8e0be..8c77c11224d1 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h | |||
@@ -829,9 +829,8 @@ struct nfs_rpc_ops { | |||
829 | int (*write_done) (struct rpc_task *, struct nfs_write_data *); | 829 | int (*write_done) (struct rpc_task *, struct nfs_write_data *); |
830 | void (*commit_setup) (struct nfs_write_data *, struct rpc_message *); | 830 | void (*commit_setup) (struct nfs_write_data *, struct rpc_message *); |
831 | int (*commit_done) (struct rpc_task *, struct nfs_write_data *); | 831 | int (*commit_done) (struct rpc_task *, struct nfs_write_data *); |
832 | int (*file_open) (struct inode *, struct file *); | ||
833 | int (*file_release) (struct inode *, struct file *); | ||
834 | int (*lock)(struct file *, int, struct file_lock *); | 832 | int (*lock)(struct file *, int, struct file_lock *); |
833 | int (*lock_check_bounds)(const struct file_lock *); | ||
835 | void (*clear_acl_cache)(struct inode *); | 834 | void (*clear_acl_cache)(struct inode *); |
836 | }; | 835 | }; |
837 | 836 | ||
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 6fff7f82ef12..e5bfe01ee305 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
@@ -42,7 +42,8 @@ struct rpc_clnt { | |||
42 | 42 | ||
43 | unsigned int cl_softrtry : 1,/* soft timeouts */ | 43 | unsigned int cl_softrtry : 1,/* soft timeouts */ |
44 | cl_discrtry : 1,/* disconnect before retry */ | 44 | cl_discrtry : 1,/* disconnect before retry */ |
45 | cl_autobind : 1;/* use getport() */ | 45 | cl_autobind : 1,/* use getport() */ |
46 | cl_chatty : 1;/* be verbose */ | ||
46 | 47 | ||
47 | struct rpc_rtt * cl_rtt; /* RTO estimator data */ | 48 | struct rpc_rtt * cl_rtt; /* RTO estimator data */ |
48 | const struct rpc_timeout *cl_timeout; /* Timeout strategy */ | 49 | const struct rpc_timeout *cl_timeout; /* Timeout strategy */ |
@@ -114,6 +115,7 @@ struct rpc_create_args { | |||
114 | #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3) | 115 | #define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3) |
115 | #define RPC_CLNT_CREATE_NOPING (1UL << 4) | 116 | #define RPC_CLNT_CREATE_NOPING (1UL << 4) |
116 | #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5) | 117 | #define RPC_CLNT_CREATE_DISCRTRY (1UL << 5) |
118 | #define RPC_CLNT_CREATE_QUIET (1UL << 6) | ||
117 | 119 | ||
118 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); | 120 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); |
119 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, | 121 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, |
@@ -123,6 +125,9 @@ void rpc_shutdown_client(struct rpc_clnt *); | |||
123 | void rpc_release_client(struct rpc_clnt *); | 125 | void rpc_release_client(struct rpc_clnt *); |
124 | 126 | ||
125 | int rpcb_register(u32, u32, int, unsigned short, int *); | 127 | int rpcb_register(u32, u32, int, unsigned short, int *); |
128 | int rpcb_v4_register(const u32 program, const u32 version, | ||
129 | const struct sockaddr *address, | ||
130 | const char *netid, int *result); | ||
126 | int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int); | 131 | int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int); |
127 | void rpcb_getport_async(struct rpc_task *); | 132 | void rpcb_getport_async(struct rpc_task *); |
128 | 133 | ||
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index d1a5c8c1a0f1..64981a2f1cae 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h | |||
@@ -135,7 +135,6 @@ struct rpc_task_setup { | |||
135 | #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) | 135 | #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) |
136 | #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) | 136 | #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) |
137 | #define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) | 137 | #define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) |
138 | #define RPC_DO_CALLBACK(t) ((t)->tk_callback != NULL) | ||
139 | #define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) | 138 | #define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) |
140 | 139 | ||
141 | #define RPC_TASK_RUNNING 0 | 140 | #define RPC_TASK_RUNNING 0 |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index cc12d5f5d5da..834a83199bdf 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
@@ -63,22 +63,11 @@ static const struct rpc_credops gss_nullops; | |||
63 | # define RPCDBG_FACILITY RPCDBG_AUTH | 63 | # define RPCDBG_FACILITY RPCDBG_AUTH |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #define NFS_NGROUPS 16 | 66 | #define GSS_CRED_SLACK 1024 |
67 | |||
68 | #define GSS_CRED_SLACK 1024 /* XXX: unused */ | ||
69 | /* length of a krb5 verifier (48), plus data added before arguments when | 67 | /* length of a krb5 verifier (48), plus data added before arguments when |
70 | * using integrity (two 4-byte integers): */ | 68 | * using integrity (two 4-byte integers): */ |
71 | #define GSS_VERF_SLACK 100 | 69 | #define GSS_VERF_SLACK 100 |
72 | 70 | ||
73 | /* XXX this define must match the gssd define | ||
74 | * as it is passed to gssd to signal the use of | ||
75 | * machine creds should be part of the shared rpc interface */ | ||
76 | |||
77 | #define CA_RUN_AS_MACHINE 0x00000200 | ||
78 | |||
79 | /* dump the buffer in `emacs-hexl' style */ | ||
80 | #define isprint(c) ((c > 0x1f) && (c < 0x7f)) | ||
81 | |||
82 | struct gss_auth { | 71 | struct gss_auth { |
83 | struct kref kref; | 72 | struct kref kref; |
84 | struct rpc_auth rpc_auth; | 73 | struct rpc_auth rpc_auth; |
@@ -146,7 +135,7 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest) | |||
146 | q = (const void *)((const char *)p + len); | 135 | q = (const void *)((const char *)p + len); |
147 | if (unlikely(q > end || q < p)) | 136 | if (unlikely(q > end || q < p)) |
148 | return ERR_PTR(-EFAULT); | 137 | return ERR_PTR(-EFAULT); |
149 | dest->data = kmemdup(p, len, GFP_KERNEL); | 138 | dest->data = kmemdup(p, len, GFP_NOFS); |
150 | if (unlikely(dest->data == NULL)) | 139 | if (unlikely(dest->data == NULL)) |
151 | return ERR_PTR(-ENOMEM); | 140 | return ERR_PTR(-ENOMEM); |
152 | dest->len = len; | 141 | dest->len = len; |
@@ -171,7 +160,7 @@ gss_alloc_context(void) | |||
171 | { | 160 | { |
172 | struct gss_cl_ctx *ctx; | 161 | struct gss_cl_ctx *ctx; |
173 | 162 | ||
174 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | 163 | ctx = kzalloc(sizeof(*ctx), GFP_NOFS); |
175 | if (ctx != NULL) { | 164 | if (ctx != NULL) { |
176 | ctx->gc_proc = RPC_GSS_PROC_DATA; | 165 | ctx->gc_proc = RPC_GSS_PROC_DATA; |
177 | ctx->gc_seq = 1; /* NetApp 6.4R1 doesn't accept seq. no. 0 */ | 166 | ctx->gc_seq = 1; /* NetApp 6.4R1 doesn't accept seq. no. 0 */ |
@@ -272,7 +261,7 @@ __gss_find_upcall(struct rpc_inode *rpci, uid_t uid) | |||
272 | return NULL; | 261 | return NULL; |
273 | } | 262 | } |
274 | 263 | ||
275 | /* Try to add a upcall to the pipefs queue. | 264 | /* Try to add an upcall to the pipefs queue. |
276 | * If an upcall owned by our uid already exists, then we return a reference | 265 | * If an upcall owned by our uid already exists, then we return a reference |
277 | * to that upcall instead of adding the new upcall. | 266 | * to that upcall instead of adding the new upcall. |
278 | */ | 267 | */ |
@@ -341,7 +330,7 @@ gss_alloc_msg(struct gss_auth *gss_auth, uid_t uid) | |||
341 | { | 330 | { |
342 | struct gss_upcall_msg *gss_msg; | 331 | struct gss_upcall_msg *gss_msg; |
343 | 332 | ||
344 | gss_msg = kzalloc(sizeof(*gss_msg), GFP_KERNEL); | 333 | gss_msg = kzalloc(sizeof(*gss_msg), GFP_NOFS); |
345 | if (gss_msg != NULL) { | 334 | if (gss_msg != NULL) { |
346 | INIT_LIST_HEAD(&gss_msg->list); | 335 | INIT_LIST_HEAD(&gss_msg->list); |
347 | rpc_init_wait_queue(&gss_msg->rpc_waitqueue, "RPCSEC_GSS upcall waitq"); | 336 | rpc_init_wait_queue(&gss_msg->rpc_waitqueue, "RPCSEC_GSS upcall waitq"); |
@@ -493,7 +482,6 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
493 | { | 482 | { |
494 | const void *p, *end; | 483 | const void *p, *end; |
495 | void *buf; | 484 | void *buf; |
496 | struct rpc_clnt *clnt; | ||
497 | struct gss_upcall_msg *gss_msg; | 485 | struct gss_upcall_msg *gss_msg; |
498 | struct inode *inode = filp->f_path.dentry->d_inode; | 486 | struct inode *inode = filp->f_path.dentry->d_inode; |
499 | struct gss_cl_ctx *ctx; | 487 | struct gss_cl_ctx *ctx; |
@@ -503,11 +491,10 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen) | |||
503 | if (mlen > MSG_BUF_MAXSIZE) | 491 | if (mlen > MSG_BUF_MAXSIZE) |
504 | goto out; | 492 | goto out; |
505 | err = -ENOMEM; | 493 | err = -ENOMEM; |
506 | buf = kmalloc(mlen, GFP_KERNEL); | 494 | buf = kmalloc(mlen, GFP_NOFS); |
507 | if (!buf) | 495 | if (!buf) |
508 | goto out; | 496 | goto out; |
509 | 497 | ||
510 | clnt = RPC_I(inode)->private; | ||
511 | err = -EFAULT; | 498 | err = -EFAULT; |
512 | if (copy_from_user(buf, src, mlen)) | 499 | if (copy_from_user(buf, src, mlen)) |
513 | goto err; | 500 | goto err; |
@@ -806,7 +793,7 @@ gss_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | |||
806 | dprintk("RPC: gss_create_cred for uid %d, flavor %d\n", | 793 | dprintk("RPC: gss_create_cred for uid %d, flavor %d\n", |
807 | acred->uid, auth->au_flavor); | 794 | acred->uid, auth->au_flavor); |
808 | 795 | ||
809 | if (!(cred = kzalloc(sizeof(*cred), GFP_KERNEL))) | 796 | if (!(cred = kzalloc(sizeof(*cred), GFP_NOFS))) |
810 | goto out_err; | 797 | goto out_err; |
811 | 798 | ||
812 | rpcauth_init_cred(&cred->gc_base, acred, auth, &gss_credops); | 799 | rpcauth_init_cred(&cred->gc_base, acred, auth, &gss_credops); |
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 60c3dba545d7..ef45eba22485 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c | |||
@@ -70,7 +70,7 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res) | |||
70 | q = (const void *)((const char *)p + len); | 70 | q = (const void *)((const char *)p + len); |
71 | if (unlikely(q > end || q < p)) | 71 | if (unlikely(q > end || q < p)) |
72 | return ERR_PTR(-EFAULT); | 72 | return ERR_PTR(-EFAULT); |
73 | res->data = kmemdup(p, len, GFP_KERNEL); | 73 | res->data = kmemdup(p, len, GFP_NOFS); |
74 | if (unlikely(res->data == NULL)) | 74 | if (unlikely(res->data == NULL)) |
75 | return ERR_PTR(-ENOMEM); | 75 | return ERR_PTR(-ENOMEM); |
76 | res->len = len; | 76 | res->len = len; |
@@ -131,7 +131,7 @@ gss_import_sec_context_kerberos(const void *p, | |||
131 | struct krb5_ctx *ctx; | 131 | struct krb5_ctx *ctx; |
132 | int tmp; | 132 | int tmp; |
133 | 133 | ||
134 | if (!(ctx = kzalloc(sizeof(*ctx), GFP_KERNEL))) | 134 | if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) |
135 | goto out_err; | 135 | goto out_err; |
136 | 136 | ||
137 | p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); | 137 | p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); |
diff --git a/net/sunrpc/auth_gss/gss_spkm3_mech.c b/net/sunrpc/auth_gss/gss_spkm3_mech.c index 5deb4b6e4514..035e1dd6af1b 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_mech.c +++ b/net/sunrpc/auth_gss/gss_spkm3_mech.c | |||
@@ -76,7 +76,7 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *res) | |||
76 | q = (const void *)((const char *)p + len); | 76 | q = (const void *)((const char *)p + len); |
77 | if (unlikely(q > end || q < p)) | 77 | if (unlikely(q > end || q < p)) |
78 | return ERR_PTR(-EFAULT); | 78 | return ERR_PTR(-EFAULT); |
79 | res->data = kmemdup(p, len, GFP_KERNEL); | 79 | res->data = kmemdup(p, len, GFP_NOFS); |
80 | if (unlikely(res->data == NULL)) | 80 | if (unlikely(res->data == NULL)) |
81 | return ERR_PTR(-ENOMEM); | 81 | return ERR_PTR(-ENOMEM); |
82 | return q; | 82 | return q; |
@@ -90,7 +90,7 @@ gss_import_sec_context_spkm3(const void *p, size_t len, | |||
90 | struct spkm3_ctx *ctx; | 90 | struct spkm3_ctx *ctx; |
91 | int version; | 91 | int version; |
92 | 92 | ||
93 | if (!(ctx = kzalloc(sizeof(*ctx), GFP_KERNEL))) | 93 | if (!(ctx = kzalloc(sizeof(*ctx), GFP_NOFS))) |
94 | goto out_err; | 94 | goto out_err; |
95 | 95 | ||
96 | p = simple_get_bytes(p, end, &version, sizeof(version)); | 96 | p = simple_get_bytes(p, end, &version, sizeof(version)); |
diff --git a/net/sunrpc/auth_gss/gss_spkm3_token.c b/net/sunrpc/auth_gss/gss_spkm3_token.c index 6cdd241ad267..3308157436d2 100644 --- a/net/sunrpc/auth_gss/gss_spkm3_token.c +++ b/net/sunrpc/auth_gss/gss_spkm3_token.c | |||
@@ -90,7 +90,7 @@ asn1_bitstring_len(struct xdr_netobj *in, int *enclen, int *zerobits) | |||
90 | int | 90 | int |
91 | decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen) | 91 | decode_asn1_bitstring(struct xdr_netobj *out, char *in, int enclen, int explen) |
92 | { | 92 | { |
93 | if (!(out->data = kzalloc(explen,GFP_KERNEL))) | 93 | if (!(out->data = kzalloc(explen,GFP_NOFS))) |
94 | return 0; | 94 | return 0; |
95 | out->len = explen; | 95 | out->len = explen; |
96 | memcpy(out->data, in, enclen); | 96 | memcpy(out->data, in, enclen); |
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 44920b90bdc4..46b2647c5bd2 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -66,7 +66,7 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags) | |||
66 | dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", | 66 | dprintk("RPC: allocating UNIX cred for uid %d gid %d\n", |
67 | acred->uid, acred->gid); | 67 | acred->uid, acred->gid); |
68 | 68 | ||
69 | if (!(cred = kmalloc(sizeof(*cred), GFP_KERNEL))) | 69 | if (!(cred = kmalloc(sizeof(*cred), GFP_NOFS))) |
70 | return ERR_PTR(-ENOMEM); | 70 | return ERR_PTR(-ENOMEM); |
71 | 71 | ||
72 | rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops); | 72 | rpcauth_init_cred(&cred->uc_base, acred, auth, &unix_credops); |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 8945307556ec..76739e928d0d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/kallsyms.h> | ||
28 | #include <linux/mm.h> | 29 | #include <linux/mm.h> |
29 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
30 | #include <linux/smp_lock.h> | 31 | #include <linux/smp_lock.h> |
@@ -58,7 +59,6 @@ static void call_start(struct rpc_task *task); | |||
58 | static void call_reserve(struct rpc_task *task); | 59 | static void call_reserve(struct rpc_task *task); |
59 | static void call_reserveresult(struct rpc_task *task); | 60 | static void call_reserveresult(struct rpc_task *task); |
60 | static void call_allocate(struct rpc_task *task); | 61 | static void call_allocate(struct rpc_task *task); |
61 | static void call_encode(struct rpc_task *task); | ||
62 | static void call_decode(struct rpc_task *task); | 62 | static void call_decode(struct rpc_task *task); |
63 | static void call_bind(struct rpc_task *task); | 63 | static void call_bind(struct rpc_task *task); |
64 | static void call_bind_status(struct rpc_task *task); | 64 | static void call_bind_status(struct rpc_task *task); |
@@ -70,9 +70,9 @@ static void call_refreshresult(struct rpc_task *task); | |||
70 | static void call_timeout(struct rpc_task *task); | 70 | static void call_timeout(struct rpc_task *task); |
71 | static void call_connect(struct rpc_task *task); | 71 | static void call_connect(struct rpc_task *task); |
72 | static void call_connect_status(struct rpc_task *task); | 72 | static void call_connect_status(struct rpc_task *task); |
73 | static __be32 * call_header(struct rpc_task *task); | ||
74 | static __be32 * call_verify(struct rpc_task *task); | ||
75 | 73 | ||
74 | static __be32 *rpc_encode_header(struct rpc_task *task); | ||
75 | static __be32 *rpc_verify_header(struct rpc_task *task); | ||
76 | static int rpc_ping(struct rpc_clnt *clnt, int flags); | 76 | static int rpc_ping(struct rpc_clnt *clnt, int flags); |
77 | 77 | ||
78 | static void rpc_register_client(struct rpc_clnt *clnt) | 78 | static void rpc_register_client(struct rpc_clnt *clnt) |
@@ -324,6 +324,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) | |||
324 | clnt->cl_autobind = 1; | 324 | clnt->cl_autobind = 1; |
325 | if (args->flags & RPC_CLNT_CREATE_DISCRTRY) | 325 | if (args->flags & RPC_CLNT_CREATE_DISCRTRY) |
326 | clnt->cl_discrtry = 1; | 326 | clnt->cl_discrtry = 1; |
327 | if (!(args->flags & RPC_CLNT_CREATE_QUIET)) | ||
328 | clnt->cl_chatty = 1; | ||
327 | 329 | ||
328 | return clnt; | 330 | return clnt; |
329 | } | 331 | } |
@@ -690,6 +692,21 @@ rpc_restart_call(struct rpc_task *task) | |||
690 | } | 692 | } |
691 | EXPORT_SYMBOL_GPL(rpc_restart_call); | 693 | EXPORT_SYMBOL_GPL(rpc_restart_call); |
692 | 694 | ||
695 | #ifdef RPC_DEBUG | ||
696 | static const char *rpc_proc_name(const struct rpc_task *task) | ||
697 | { | ||
698 | const struct rpc_procinfo *proc = task->tk_msg.rpc_proc; | ||
699 | |||
700 | if (proc) { | ||
701 | if (proc->p_name) | ||
702 | return proc->p_name; | ||
703 | else | ||
704 | return "NULL"; | ||
705 | } else | ||
706 | return "no proc"; | ||
707 | } | ||
708 | #endif | ||
709 | |||
693 | /* | 710 | /* |
694 | * 0. Initial state | 711 | * 0. Initial state |
695 | * | 712 | * |
@@ -701,9 +718,9 @@ call_start(struct rpc_task *task) | |||
701 | { | 718 | { |
702 | struct rpc_clnt *clnt = task->tk_client; | 719 | struct rpc_clnt *clnt = task->tk_client; |
703 | 720 | ||
704 | dprintk("RPC: %5u call_start %s%d proc %d (%s)\n", task->tk_pid, | 721 | dprintk("RPC: %5u call_start %s%d proc %s (%s)\n", task->tk_pid, |
705 | clnt->cl_protname, clnt->cl_vers, | 722 | clnt->cl_protname, clnt->cl_vers, |
706 | task->tk_msg.rpc_proc->p_proc, | 723 | rpc_proc_name(task), |
707 | (RPC_IS_ASYNC(task) ? "async" : "sync")); | 724 | (RPC_IS_ASYNC(task) ? "async" : "sync")); |
708 | 725 | ||
709 | /* Increment call count */ | 726 | /* Increment call count */ |
@@ -861,7 +878,7 @@ rpc_xdr_buf_init(struct xdr_buf *buf, void *start, size_t len) | |||
861 | * 3. Encode arguments of an RPC call | 878 | * 3. Encode arguments of an RPC call |
862 | */ | 879 | */ |
863 | static void | 880 | static void |
864 | call_encode(struct rpc_task *task) | 881 | rpc_xdr_encode(struct rpc_task *task) |
865 | { | 882 | { |
866 | struct rpc_rqst *req = task->tk_rqstp; | 883 | struct rpc_rqst *req = task->tk_rqstp; |
867 | kxdrproc_t encode; | 884 | kxdrproc_t encode; |
@@ -876,23 +893,19 @@ call_encode(struct rpc_task *task) | |||
876 | (char *)req->rq_buffer + req->rq_callsize, | 893 | (char *)req->rq_buffer + req->rq_callsize, |
877 | req->rq_rcvsize); | 894 | req->rq_rcvsize); |
878 | 895 | ||
879 | /* Encode header and provided arguments */ | 896 | p = rpc_encode_header(task); |
880 | encode = task->tk_msg.rpc_proc->p_encode; | 897 | if (p == NULL) { |
881 | if (!(p = call_header(task))) { | 898 | printk(KERN_INFO "RPC: couldn't encode RPC header, exit EIO\n"); |
882 | printk(KERN_INFO "RPC: call_header failed, exit EIO\n"); | ||
883 | rpc_exit(task, -EIO); | 899 | rpc_exit(task, -EIO); |
884 | return; | 900 | return; |
885 | } | 901 | } |
902 | |||
903 | encode = task->tk_msg.rpc_proc->p_encode; | ||
886 | if (encode == NULL) | 904 | if (encode == NULL) |
887 | return; | 905 | return; |
888 | 906 | ||
889 | task->tk_status = rpcauth_wrap_req(task, encode, req, p, | 907 | task->tk_status = rpcauth_wrap_req(task, encode, req, p, |
890 | task->tk_msg.rpc_argp); | 908 | task->tk_msg.rpc_argp); |
891 | if (task->tk_status == -ENOMEM) { | ||
892 | /* XXX: Is this sane? */ | ||
893 | rpc_delay(task, 3*HZ); | ||
894 | task->tk_status = -EAGAIN; | ||
895 | } | ||
896 | } | 909 | } |
897 | 910 | ||
898 | /* | 911 | /* |
@@ -929,11 +942,9 @@ call_bind_status(struct rpc_task *task) | |||
929 | } | 942 | } |
930 | 943 | ||
931 | switch (task->tk_status) { | 944 | switch (task->tk_status) { |
932 | case -EAGAIN: | 945 | case -ENOMEM: |
933 | dprintk("RPC: %5u rpcbind waiting for another request " | 946 | dprintk("RPC: %5u rpcbind out of memory\n", task->tk_pid); |
934 | "to finish\n", task->tk_pid); | 947 | rpc_delay(task, HZ >> 2); |
935 | /* avoid busy-waiting here -- could be a network outage. */ | ||
936 | rpc_delay(task, 5*HZ); | ||
937 | goto retry_timeout; | 948 | goto retry_timeout; |
938 | case -EACCES: | 949 | case -EACCES: |
939 | dprintk("RPC: %5u remote rpcbind: RPC program/version " | 950 | dprintk("RPC: %5u remote rpcbind: RPC program/version " |
@@ -1046,10 +1057,16 @@ call_transmit(struct rpc_task *task) | |||
1046 | /* Encode here so that rpcsec_gss can use correct sequence number. */ | 1057 | /* Encode here so that rpcsec_gss can use correct sequence number. */ |
1047 | if (rpc_task_need_encode(task)) { | 1058 | if (rpc_task_need_encode(task)) { |
1048 | BUG_ON(task->tk_rqstp->rq_bytes_sent != 0); | 1059 | BUG_ON(task->tk_rqstp->rq_bytes_sent != 0); |
1049 | call_encode(task); | 1060 | rpc_xdr_encode(task); |
1050 | /* Did the encode result in an error condition? */ | 1061 | /* Did the encode result in an error condition? */ |
1051 | if (task->tk_status != 0) | 1062 | if (task->tk_status != 0) { |
1063 | /* Was the error nonfatal? */ | ||
1064 | if (task->tk_status == -EAGAIN) | ||
1065 | rpc_delay(task, HZ >> 4); | ||
1066 | else | ||
1067 | rpc_exit(task, task->tk_status); | ||
1052 | return; | 1068 | return; |
1069 | } | ||
1053 | } | 1070 | } |
1054 | xprt_transmit(task); | 1071 | xprt_transmit(task); |
1055 | if (task->tk_status < 0) | 1072 | if (task->tk_status < 0) |
@@ -1132,7 +1149,8 @@ call_status(struct rpc_task *task) | |||
1132 | rpc_exit(task, status); | 1149 | rpc_exit(task, status); |
1133 | break; | 1150 | break; |
1134 | default: | 1151 | default: |
1135 | printk("%s: RPC call returned error %d\n", | 1152 | if (clnt->cl_chatty) |
1153 | printk("%s: RPC call returned error %d\n", | ||
1136 | clnt->cl_protname, -status); | 1154 | clnt->cl_protname, -status); |
1137 | rpc_exit(task, status); | 1155 | rpc_exit(task, status); |
1138 | } | 1156 | } |
@@ -1157,7 +1175,8 @@ call_timeout(struct rpc_task *task) | |||
1157 | task->tk_timeouts++; | 1175 | task->tk_timeouts++; |
1158 | 1176 | ||
1159 | if (RPC_IS_SOFT(task)) { | 1177 | if (RPC_IS_SOFT(task)) { |
1160 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", | 1178 | if (clnt->cl_chatty) |
1179 | printk(KERN_NOTICE "%s: server %s not responding, timed out\n", | ||
1161 | clnt->cl_protname, clnt->cl_server); | 1180 | clnt->cl_protname, clnt->cl_server); |
1162 | rpc_exit(task, -EIO); | 1181 | rpc_exit(task, -EIO); |
1163 | return; | 1182 | return; |
@@ -1165,7 +1184,8 @@ call_timeout(struct rpc_task *task) | |||
1165 | 1184 | ||
1166 | if (!(task->tk_flags & RPC_CALL_MAJORSEEN)) { | 1185 | if (!(task->tk_flags & RPC_CALL_MAJORSEEN)) { |
1167 | task->tk_flags |= RPC_CALL_MAJORSEEN; | 1186 | task->tk_flags |= RPC_CALL_MAJORSEEN; |
1168 | printk(KERN_NOTICE "%s: server %s not responding, still trying\n", | 1187 | if (clnt->cl_chatty) |
1188 | printk(KERN_NOTICE "%s: server %s not responding, still trying\n", | ||
1169 | clnt->cl_protname, clnt->cl_server); | 1189 | clnt->cl_protname, clnt->cl_server); |
1170 | } | 1190 | } |
1171 | rpc_force_rebind(clnt); | 1191 | rpc_force_rebind(clnt); |
@@ -1196,8 +1216,9 @@ call_decode(struct rpc_task *task) | |||
1196 | task->tk_pid, task->tk_status); | 1216 | task->tk_pid, task->tk_status); |
1197 | 1217 | ||
1198 | if (task->tk_flags & RPC_CALL_MAJORSEEN) { | 1218 | if (task->tk_flags & RPC_CALL_MAJORSEEN) { |
1199 | printk(KERN_NOTICE "%s: server %s OK\n", | 1219 | if (clnt->cl_chatty) |
1200 | clnt->cl_protname, clnt->cl_server); | 1220 | printk(KERN_NOTICE "%s: server %s OK\n", |
1221 | clnt->cl_protname, clnt->cl_server); | ||
1201 | task->tk_flags &= ~RPC_CALL_MAJORSEEN; | 1222 | task->tk_flags &= ~RPC_CALL_MAJORSEEN; |
1202 | } | 1223 | } |
1203 | 1224 | ||
@@ -1224,8 +1245,7 @@ call_decode(struct rpc_task *task) | |||
1224 | goto out_retry; | 1245 | goto out_retry; |
1225 | } | 1246 | } |
1226 | 1247 | ||
1227 | /* Verify the RPC header */ | 1248 | p = rpc_verify_header(task); |
1228 | p = call_verify(task); | ||
1229 | if (IS_ERR(p)) { | 1249 | if (IS_ERR(p)) { |
1230 | if (p == ERR_PTR(-EAGAIN)) | 1250 | if (p == ERR_PTR(-EAGAIN)) |
1231 | goto out_retry; | 1251 | goto out_retry; |
@@ -1243,7 +1263,7 @@ call_decode(struct rpc_task *task) | |||
1243 | return; | 1263 | return; |
1244 | out_retry: | 1264 | out_retry: |
1245 | task->tk_status = 0; | 1265 | task->tk_status = 0; |
1246 | /* Note: call_verify() may have freed the RPC slot */ | 1266 | /* Note: rpc_verify_header() may have freed the RPC slot */ |
1247 | if (task->tk_rqstp == req) { | 1267 | if (task->tk_rqstp == req) { |
1248 | req->rq_received = req->rq_rcv_buf.len = 0; | 1268 | req->rq_received = req->rq_rcv_buf.len = 0; |
1249 | if (task->tk_client->cl_discrtry) | 1269 | if (task->tk_client->cl_discrtry) |
@@ -1290,11 +1310,8 @@ call_refreshresult(struct rpc_task *task) | |||
1290 | return; | 1310 | return; |
1291 | } | 1311 | } |
1292 | 1312 | ||
1293 | /* | ||
1294 | * Call header serialization | ||
1295 | */ | ||
1296 | static __be32 * | 1313 | static __be32 * |
1297 | call_header(struct rpc_task *task) | 1314 | rpc_encode_header(struct rpc_task *task) |
1298 | { | 1315 | { |
1299 | struct rpc_clnt *clnt = task->tk_client; | 1316 | struct rpc_clnt *clnt = task->tk_client; |
1300 | struct rpc_rqst *req = task->tk_rqstp; | 1317 | struct rpc_rqst *req = task->tk_rqstp; |
@@ -1314,11 +1331,8 @@ call_header(struct rpc_task *task) | |||
1314 | return p; | 1331 | return p; |
1315 | } | 1332 | } |
1316 | 1333 | ||
1317 | /* | ||
1318 | * Reply header verification | ||
1319 | */ | ||
1320 | static __be32 * | 1334 | static __be32 * |
1321 | call_verify(struct rpc_task *task) | 1335 | rpc_verify_header(struct rpc_task *task) |
1322 | { | 1336 | { |
1323 | struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0]; | 1337 | struct kvec *iov = &task->tk_rqstp->rq_rcv_buf.head[0]; |
1324 | int len = task->tk_rqstp->rq_rcv_buf.len >> 2; | 1338 | int len = task->tk_rqstp->rq_rcv_buf.len >> 2; |
@@ -1392,7 +1406,7 @@ call_verify(struct rpc_task *task) | |||
1392 | task->tk_action = call_bind; | 1406 | task->tk_action = call_bind; |
1393 | goto out_retry; | 1407 | goto out_retry; |
1394 | case RPC_AUTH_TOOWEAK: | 1408 | case RPC_AUTH_TOOWEAK: |
1395 | printk(KERN_NOTICE "call_verify: server %s requires stronger " | 1409 | printk(KERN_NOTICE "RPC: server %s requires stronger " |
1396 | "authentication.\n", task->tk_client->cl_server); | 1410 | "authentication.\n", task->tk_client->cl_server); |
1397 | break; | 1411 | break; |
1398 | default: | 1412 | default: |
@@ -1431,10 +1445,10 @@ call_verify(struct rpc_task *task) | |||
1431 | error = -EPROTONOSUPPORT; | 1445 | error = -EPROTONOSUPPORT; |
1432 | goto out_err; | 1446 | goto out_err; |
1433 | case RPC_PROC_UNAVAIL: | 1447 | case RPC_PROC_UNAVAIL: |
1434 | dprintk("RPC: %5u %s: proc %p unsupported by program %u, " | 1448 | dprintk("RPC: %5u %s: proc %s unsupported by program %u, " |
1435 | "version %u on server %s\n", | 1449 | "version %u on server %s\n", |
1436 | task->tk_pid, __func__, | 1450 | task->tk_pid, __func__, |
1437 | task->tk_msg.rpc_proc, | 1451 | rpc_proc_name(task), |
1438 | task->tk_client->cl_prog, | 1452 | task->tk_client->cl_prog, |
1439 | task->tk_client->cl_vers, | 1453 | task->tk_client->cl_vers, |
1440 | task->tk_client->cl_server); | 1454 | task->tk_client->cl_server); |
@@ -1517,44 +1531,53 @@ struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int | |||
1517 | EXPORT_SYMBOL_GPL(rpc_call_null); | 1531 | EXPORT_SYMBOL_GPL(rpc_call_null); |
1518 | 1532 | ||
1519 | #ifdef RPC_DEBUG | 1533 | #ifdef RPC_DEBUG |
1534 | static void rpc_show_header(void) | ||
1535 | { | ||
1536 | printk(KERN_INFO "-pid- flgs status -client- --rqstp- " | ||
1537 | "-timeout ---ops--\n"); | ||
1538 | } | ||
1539 | |||
1540 | static void rpc_show_task(const struct rpc_clnt *clnt, | ||
1541 | const struct rpc_task *task) | ||
1542 | { | ||
1543 | const char *rpc_waitq = "none"; | ||
1544 | char *p, action[KSYM_SYMBOL_LEN]; | ||
1545 | |||
1546 | if (RPC_IS_QUEUED(task)) | ||
1547 | rpc_waitq = rpc_qname(task->tk_waitqueue); | ||
1548 | |||
1549 | /* map tk_action pointer to a function name; then trim off | ||
1550 | * the "+0x0 [sunrpc]" */ | ||
1551 | sprint_symbol(action, (unsigned long)task->tk_action); | ||
1552 | p = strchr(action, '+'); | ||
1553 | if (p) | ||
1554 | *p = '\0'; | ||
1555 | |||
1556 | printk(KERN_INFO "%5u %04x %6d %8p %8p %8ld %8p %sv%u %s a:%s q:%s\n", | ||
1557 | task->tk_pid, task->tk_flags, task->tk_status, | ||
1558 | clnt, task->tk_rqstp, task->tk_timeout, task->tk_ops, | ||
1559 | clnt->cl_protname, clnt->cl_vers, rpc_proc_name(task), | ||
1560 | action, rpc_waitq); | ||
1561 | } | ||
1562 | |||
1520 | void rpc_show_tasks(void) | 1563 | void rpc_show_tasks(void) |
1521 | { | 1564 | { |
1522 | struct rpc_clnt *clnt; | 1565 | struct rpc_clnt *clnt; |
1523 | struct rpc_task *t; | 1566 | struct rpc_task *task; |
1567 | int header = 0; | ||
1524 | 1568 | ||
1525 | spin_lock(&rpc_client_lock); | 1569 | spin_lock(&rpc_client_lock); |
1526 | if (list_empty(&all_clients)) | ||
1527 | goto out; | ||
1528 | printk("-pid- proc flgs status -client- -prog- --rqstp- -timeout " | ||
1529 | "-rpcwait -action- ---ops--\n"); | ||
1530 | list_for_each_entry(clnt, &all_clients, cl_clients) { | 1570 | list_for_each_entry(clnt, &all_clients, cl_clients) { |
1531 | if (list_empty(&clnt->cl_tasks)) | ||
1532 | continue; | ||
1533 | spin_lock(&clnt->cl_lock); | 1571 | spin_lock(&clnt->cl_lock); |
1534 | list_for_each_entry(t, &clnt->cl_tasks, tk_task) { | 1572 | list_for_each_entry(task, &clnt->cl_tasks, tk_task) { |
1535 | const char *rpc_waitq = "none"; | 1573 | if (!header) { |
1536 | int proc; | 1574 | rpc_show_header(); |
1537 | 1575 | header++; | |
1538 | if (t->tk_msg.rpc_proc) | 1576 | } |
1539 | proc = t->tk_msg.rpc_proc->p_proc; | 1577 | rpc_show_task(clnt, task); |
1540 | else | ||
1541 | proc = -1; | ||
1542 | |||
1543 | if (RPC_IS_QUEUED(t)) | ||
1544 | rpc_waitq = rpc_qname(t->tk_waitqueue); | ||
1545 | |||
1546 | printk("%5u %04d %04x %6d %8p %6d %8p %8ld %8s %8p %8p\n", | ||
1547 | t->tk_pid, proc, | ||
1548 | t->tk_flags, t->tk_status, | ||
1549 | t->tk_client, | ||
1550 | (t->tk_client ? t->tk_client->cl_prog : 0), | ||
1551 | t->tk_rqstp, t->tk_timeout, | ||
1552 | rpc_waitq, | ||
1553 | t->tk_action, t->tk_ops); | ||
1554 | } | 1578 | } |
1555 | spin_unlock(&clnt->cl_lock); | 1579 | spin_unlock(&clnt->cl_lock); |
1556 | } | 1580 | } |
1557 | out: | ||
1558 | spin_unlock(&rpc_client_lock); | 1581 | spin_unlock(&rpc_client_lock); |
1559 | } | 1582 | } |
1560 | #endif | 1583 | #endif |
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c index e6fb21b19b86..24db2b4d12d3 100644 --- a/net/sunrpc/rpcb_clnt.c +++ b/net/sunrpc/rpcb_clnt.c | |||
@@ -32,6 +32,10 @@ | |||
32 | #define RPCBIND_PROGRAM (100000u) | 32 | #define RPCBIND_PROGRAM (100000u) |
33 | #define RPCBIND_PORT (111u) | 33 | #define RPCBIND_PORT (111u) |
34 | 34 | ||
35 | #define RPCBVERS_2 (2u) | ||
36 | #define RPCBVERS_3 (3u) | ||
37 | #define RPCBVERS_4 (4u) | ||
38 | |||
35 | enum { | 39 | enum { |
36 | RPCBPROC_NULL, | 40 | RPCBPROC_NULL, |
37 | RPCBPROC_SET, | 41 | RPCBPROC_SET, |
@@ -64,6 +68,7 @@ enum { | |||
64 | #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING) | 68 | #define RPCB_MAXOWNERLEN sizeof(RPCB_OWNER_STRING) |
65 | 69 | ||
66 | static void rpcb_getport_done(struct rpc_task *, void *); | 70 | static void rpcb_getport_done(struct rpc_task *, void *); |
71 | static void rpcb_map_release(void *data); | ||
67 | static struct rpc_program rpcb_program; | 72 | static struct rpc_program rpcb_program; |
68 | 73 | ||
69 | struct rpcbind_args { | 74 | struct rpcbind_args { |
@@ -76,41 +81,73 @@ struct rpcbind_args { | |||
76 | const char * r_netid; | 81 | const char * r_netid; |
77 | const char * r_addr; | 82 | const char * r_addr; |
78 | const char * r_owner; | 83 | const char * r_owner; |
84 | |||
85 | int r_status; | ||
79 | }; | 86 | }; |
80 | 87 | ||
81 | static struct rpc_procinfo rpcb_procedures2[]; | 88 | static struct rpc_procinfo rpcb_procedures2[]; |
82 | static struct rpc_procinfo rpcb_procedures3[]; | 89 | static struct rpc_procinfo rpcb_procedures3[]; |
90 | static struct rpc_procinfo rpcb_procedures4[]; | ||
83 | 91 | ||
84 | struct rpcb_info { | 92 | struct rpcb_info { |
85 | int rpc_vers; | 93 | u32 rpc_vers; |
86 | struct rpc_procinfo * rpc_proc; | 94 | struct rpc_procinfo * rpc_proc; |
87 | }; | 95 | }; |
88 | 96 | ||
89 | static struct rpcb_info rpcb_next_version[]; | 97 | static struct rpcb_info rpcb_next_version[]; |
90 | static struct rpcb_info rpcb_next_version6[]; | 98 | static struct rpcb_info rpcb_next_version6[]; |
91 | 99 | ||
100 | static const struct rpc_call_ops rpcb_getport_ops = { | ||
101 | .rpc_call_done = rpcb_getport_done, | ||
102 | .rpc_release = rpcb_map_release, | ||
103 | }; | ||
104 | |||
105 | static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status) | ||
106 | { | ||
107 | xprt_clear_binding(xprt); | ||
108 | rpc_wake_up_status(&xprt->binding, status); | ||
109 | } | ||
110 | |||
92 | static void rpcb_map_release(void *data) | 111 | static void rpcb_map_release(void *data) |
93 | { | 112 | { |
94 | struct rpcbind_args *map = data; | 113 | struct rpcbind_args *map = data; |
95 | 114 | ||
115 | rpcb_wake_rpcbind_waiters(map->r_xprt, map->r_status); | ||
96 | xprt_put(map->r_xprt); | 116 | xprt_put(map->r_xprt); |
97 | kfree(map); | 117 | kfree(map); |
98 | } | 118 | } |
99 | 119 | ||
100 | static const struct rpc_call_ops rpcb_getport_ops = { | 120 | static const struct sockaddr_in rpcb_inaddr_loopback = { |
101 | .rpc_call_done = rpcb_getport_done, | 121 | .sin_family = AF_INET, |
102 | .rpc_release = rpcb_map_release, | 122 | .sin_addr.s_addr = htonl(INADDR_LOOPBACK), |
123 | .sin_port = htons(RPCBIND_PORT), | ||
103 | }; | 124 | }; |
104 | 125 | ||
105 | static void rpcb_wake_rpcbind_waiters(struct rpc_xprt *xprt, int status) | 126 | static const struct sockaddr_in6 rpcb_in6addr_loopback = { |
127 | .sin6_family = AF_INET6, | ||
128 | .sin6_addr = IN6ADDR_LOOPBACK_INIT, | ||
129 | .sin6_port = htons(RPCBIND_PORT), | ||
130 | }; | ||
131 | |||
132 | static struct rpc_clnt *rpcb_create_local(struct sockaddr *addr, | ||
133 | size_t addrlen, u32 version) | ||
106 | { | 134 | { |
107 | xprt_clear_binding(xprt); | 135 | struct rpc_create_args args = { |
108 | rpc_wake_up_status(&xprt->binding, status); | 136 | .protocol = XPRT_TRANSPORT_UDP, |
137 | .address = addr, | ||
138 | .addrsize = addrlen, | ||
139 | .servername = "localhost", | ||
140 | .program = &rpcb_program, | ||
141 | .version = version, | ||
142 | .authflavor = RPC_AUTH_UNIX, | ||
143 | .flags = RPC_CLNT_CREATE_NOPING, | ||
144 | }; | ||
145 | |||
146 | return rpc_create(&args); | ||
109 | } | 147 | } |
110 | 148 | ||
111 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | 149 | static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, |
112 | size_t salen, int proto, u32 version, | 150 | size_t salen, int proto, u32 version) |
113 | int privileged) | ||
114 | { | 151 | { |
115 | struct rpc_create_args args = { | 152 | struct rpc_create_args args = { |
116 | .protocol = proto, | 153 | .protocol = proto, |
@@ -120,7 +157,8 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | |||
120 | .program = &rpcb_program, | 157 | .program = &rpcb_program, |
121 | .version = version, | 158 | .version = version, |
122 | .authflavor = RPC_AUTH_UNIX, | 159 | .authflavor = RPC_AUTH_UNIX, |
123 | .flags = RPC_CLNT_CREATE_NOPING, | 160 | .flags = (RPC_CLNT_CREATE_NOPING | |
161 | RPC_CLNT_CREATE_NONPRIVPORT), | ||
124 | }; | 162 | }; |
125 | 163 | ||
126 | switch (srvaddr->sa_family) { | 164 | switch (srvaddr->sa_family) { |
@@ -134,29 +172,72 @@ static struct rpc_clnt *rpcb_create(char *hostname, struct sockaddr *srvaddr, | |||
134 | return NULL; | 172 | return NULL; |
135 | } | 173 | } |
136 | 174 | ||
137 | if (!privileged) | ||
138 | args.flags |= RPC_CLNT_CREATE_NONPRIVPORT; | ||
139 | return rpc_create(&args); | 175 | return rpc_create(&args); |
140 | } | 176 | } |
141 | 177 | ||
178 | static int rpcb_register_call(struct sockaddr *addr, size_t addrlen, | ||
179 | u32 version, struct rpc_message *msg, | ||
180 | int *result) | ||
181 | { | ||
182 | struct rpc_clnt *rpcb_clnt; | ||
183 | int error = 0; | ||
184 | |||
185 | *result = 0; | ||
186 | |||
187 | rpcb_clnt = rpcb_create_local(addr, addrlen, version); | ||
188 | if (!IS_ERR(rpcb_clnt)) { | ||
189 | error = rpc_call_sync(rpcb_clnt, msg, 0); | ||
190 | rpc_shutdown_client(rpcb_clnt); | ||
191 | } else | ||
192 | error = PTR_ERR(rpcb_clnt); | ||
193 | |||
194 | if (error < 0) | ||
195 | printk(KERN_WARNING "RPC: failed to contact local rpcbind " | ||
196 | "server (errno %d).\n", -error); | ||
197 | dprintk("RPC: registration status %d/%d\n", error, *result); | ||
198 | |||
199 | return error; | ||
200 | } | ||
201 | |||
142 | /** | 202 | /** |
143 | * rpcb_register - set or unset a port registration with the local rpcbind svc | 203 | * rpcb_register - set or unset a port registration with the local rpcbind svc |
144 | * @prog: RPC program number to bind | 204 | * @prog: RPC program number to bind |
145 | * @vers: RPC version number to bind | 205 | * @vers: RPC version number to bind |
146 | * @prot: transport protocol to use to make this request | 206 | * @prot: transport protocol to register |
147 | * @port: port value to register | 207 | * @port: port value to register |
148 | * @okay: result code | 208 | * @okay: OUT: result code |
209 | * | ||
210 | * RPC services invoke this function to advertise their contact | ||
211 | * information via the system's rpcbind daemon. RPC services | ||
212 | * invoke this function once for each [program, version, transport] | ||
213 | * tuple they wish to advertise. | ||
214 | * | ||
215 | * Callers may also unregister RPC services that are no longer | ||
216 | * available by setting the passed-in port to zero. This removes | ||
217 | * all registered transports for [program, version] from the local | ||
218 | * rpcbind database. | ||
219 | * | ||
220 | * Returns zero if the registration request was dispatched | ||
221 | * successfully and a reply was received. The rpcbind daemon's | ||
222 | * boolean result code is stored in *okay. | ||
223 | * | ||
224 | * Returns an errno value and sets *result to zero if there was | ||
225 | * some problem that prevented the rpcbind request from being | ||
226 | * dispatched, or if the rpcbind daemon did not respond within | ||
227 | * the timeout. | ||
149 | * | 228 | * |
150 | * port == 0 means unregister, port != 0 means register. | 229 | * This function uses rpcbind protocol version 2 to contact the |
230 | * local rpcbind daemon. | ||
151 | * | 231 | * |
152 | * This routine supports only rpcbind version 2. | 232 | * Registration works over both AF_INET and AF_INET6, and services |
233 | * registered via this function are advertised as available for any | ||
234 | * address. If the local rpcbind daemon is listening on AF_INET6, | ||
235 | * services registered via this function will be advertised on | ||
236 | * IN6ADDR_ANY (ie available for all AF_INET and AF_INET6 | ||
237 | * addresses). | ||
153 | */ | 238 | */ |
154 | int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | 239 | int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) |
155 | { | 240 | { |
156 | struct sockaddr_in sin = { | ||
157 | .sin_family = AF_INET, | ||
158 | .sin_addr.s_addr = htonl(INADDR_LOOPBACK), | ||
159 | }; | ||
160 | struct rpcbind_args map = { | 241 | struct rpcbind_args map = { |
161 | .r_prog = prog, | 242 | .r_prog = prog, |
162 | .r_vers = vers, | 243 | .r_vers = vers, |
@@ -164,32 +245,159 @@ int rpcb_register(u32 prog, u32 vers, int prot, unsigned short port, int *okay) | |||
164 | .r_port = port, | 245 | .r_port = port, |
165 | }; | 246 | }; |
166 | struct rpc_message msg = { | 247 | struct rpc_message msg = { |
167 | .rpc_proc = &rpcb_procedures2[port ? | ||
168 | RPCBPROC_SET : RPCBPROC_UNSET], | ||
169 | .rpc_argp = &map, | 248 | .rpc_argp = &map, |
170 | .rpc_resp = okay, | 249 | .rpc_resp = okay, |
171 | }; | 250 | }; |
172 | struct rpc_clnt *rpcb_clnt; | ||
173 | int error = 0; | ||
174 | 251 | ||
175 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " | 252 | dprintk("RPC: %sregistering (%u, %u, %d, %u) with local " |
176 | "rpcbind\n", (port ? "" : "un"), | 253 | "rpcbind\n", (port ? "" : "un"), |
177 | prog, vers, prot, port); | 254 | prog, vers, prot, port); |
178 | 255 | ||
179 | rpcb_clnt = rpcb_create("localhost", (struct sockaddr *) &sin, | 256 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_UNSET]; |
180 | sizeof(sin), XPRT_TRANSPORT_UDP, 2, 1); | 257 | if (port) |
181 | if (IS_ERR(rpcb_clnt)) | 258 | msg.rpc_proc = &rpcb_procedures2[RPCBPROC_SET]; |
182 | return PTR_ERR(rpcb_clnt); | ||
183 | 259 | ||
184 | error = rpc_call_sync(rpcb_clnt, &msg, 0); | 260 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, |
261 | sizeof(rpcb_inaddr_loopback), | ||
262 | RPCBVERS_2, &msg, okay); | ||
263 | } | ||
185 | 264 | ||
186 | rpc_shutdown_client(rpcb_clnt); | 265 | /* |
187 | if (error < 0) | 266 | * Fill in AF_INET family-specific arguments to register |
188 | printk(KERN_WARNING "RPC: failed to contact local rpcbind " | 267 | */ |
189 | "server (errno %d).\n", -error); | 268 | static int rpcb_register_netid4(struct sockaddr_in *address_to_register, |
190 | dprintk("RPC: registration status %d/%d\n", error, *okay); | 269 | struct rpc_message *msg) |
270 | { | ||
271 | struct rpcbind_args *map = msg->rpc_argp; | ||
272 | unsigned short port = ntohs(address_to_register->sin_port); | ||
273 | char buf[32]; | ||
274 | |||
275 | /* Construct AF_INET universal address */ | ||
276 | snprintf(buf, sizeof(buf), | ||
277 | NIPQUAD_FMT".%u.%u", | ||
278 | NIPQUAD(address_to_register->sin_addr.s_addr), | ||
279 | port >> 8, port & 0xff); | ||
280 | map->r_addr = buf; | ||
281 | |||
282 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | ||
283 | "local rpcbind\n", (port ? "" : "un"), | ||
284 | map->r_prog, map->r_vers, | ||
285 | map->r_addr, map->r_netid); | ||
286 | |||
287 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; | ||
288 | if (port) | ||
289 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | ||
290 | |||
291 | return rpcb_register_call((struct sockaddr *)&rpcb_inaddr_loopback, | ||
292 | sizeof(rpcb_inaddr_loopback), | ||
293 | RPCBVERS_4, msg, msg->rpc_resp); | ||
294 | } | ||
191 | 295 | ||
192 | return error; | 296 | /* |
297 | * Fill in AF_INET6 family-specific arguments to register | ||
298 | */ | ||
299 | static int rpcb_register_netid6(struct sockaddr_in6 *address_to_register, | ||
300 | struct rpc_message *msg) | ||
301 | { | ||
302 | struct rpcbind_args *map = msg->rpc_argp; | ||
303 | unsigned short port = ntohs(address_to_register->sin6_port); | ||
304 | char buf[64]; | ||
305 | |||
306 | /* Construct AF_INET6 universal address */ | ||
307 | snprintf(buf, sizeof(buf), | ||
308 | NIP6_FMT".%u.%u", | ||
309 | NIP6(address_to_register->sin6_addr), | ||
310 | port >> 8, port & 0xff); | ||
311 | map->r_addr = buf; | ||
312 | |||
313 | dprintk("RPC: %sregistering [%u, %u, %s, '%s'] with " | ||
314 | "local rpcbind\n", (port ? "" : "un"), | ||
315 | map->r_prog, map->r_vers, | ||
316 | map->r_addr, map->r_netid); | ||
317 | |||
318 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_UNSET]; | ||
319 | if (port) | ||
320 | msg->rpc_proc = &rpcb_procedures4[RPCBPROC_SET]; | ||
321 | |||
322 | return rpcb_register_call((struct sockaddr *)&rpcb_in6addr_loopback, | ||
323 | sizeof(rpcb_in6addr_loopback), | ||
324 | RPCBVERS_4, msg, msg->rpc_resp); | ||
325 | } | ||
326 | |||
327 | /** | ||
328 | * rpcb_v4_register - set or unset a port registration with the local rpcbind | ||
329 | * @program: RPC program number of service to (un)register | ||
330 | * @version: RPC version number of service to (un)register | ||
331 | * @address: address family, IP address, and port to (un)register | ||
332 | * @netid: netid of transport protocol to (un)register | ||
333 | * @result: result code from rpcbind RPC call | ||
334 | * | ||
335 | * RPC services invoke this function to advertise their contact | ||
336 | * information via the system's rpcbind daemon. RPC services | ||
337 | * invoke this function once for each [program, version, address, | ||
338 | * netid] tuple they wish to advertise. | ||
339 | * | ||
340 | * Callers may also unregister RPC services that are no longer | ||
341 | * available by setting the port number in the passed-in address | ||
342 | * to zero. Callers pass a netid of "" to unregister all | ||
343 | * transport netids associated with [program, version, address]. | ||
344 | * | ||
345 | * Returns zero if the registration request was dispatched | ||
346 | * successfully and a reply was received. The rpcbind daemon's | ||
347 | * result code is stored in *result. | ||
348 | * | ||
349 | * Returns an errno value and sets *result to zero if there was | ||
350 | * some problem that prevented the rpcbind request from being | ||
351 | * dispatched, or if the rpcbind daemon did not respond within | ||
352 | * the timeout. | ||
353 | * | ||
354 | * This function uses rpcbind protocol version 4 to contact the | ||
355 | * local rpcbind daemon. The local rpcbind daemon must support | ||
356 | * version 4 of the rpcbind protocol in order for these functions | ||
357 | * to register a service successfully. | ||
358 | * | ||
359 | * Supported netids include "udp" and "tcp" for UDP and TCP over | ||
360 | * IPv4, and "udp6" and "tcp6" for UDP and TCP over IPv6, | ||
361 | * respectively. | ||
362 | * | ||
363 | * The contents of @address determine the address family and the | ||
364 | * port to be registered. The usual practice is to pass INADDR_ANY | ||
365 | * as the raw address, but specifying a non-zero address is also | ||
366 | * supported by this API if the caller wishes to advertise an RPC | ||
367 | * service on a specific network interface. | ||
368 | * | ||
369 | * Note that passing in INADDR_ANY does not create the same service | ||
370 | * registration as IN6ADDR_ANY. The former advertises an RPC | ||
371 | * service on any IPv4 address, but not on IPv6. The latter | ||
372 | * advertises the service on all IPv4 and IPv6 addresses. | ||
373 | */ | ||
374 | int rpcb_v4_register(const u32 program, const u32 version, | ||
375 | const struct sockaddr *address, const char *netid, | ||
376 | int *result) | ||
377 | { | ||
378 | struct rpcbind_args map = { | ||
379 | .r_prog = program, | ||
380 | .r_vers = version, | ||
381 | .r_netid = netid, | ||
382 | .r_owner = RPCB_OWNER_STRING, | ||
383 | }; | ||
384 | struct rpc_message msg = { | ||
385 | .rpc_argp = &map, | ||
386 | .rpc_resp = result, | ||
387 | }; | ||
388 | |||
389 | *result = 0; | ||
390 | |||
391 | switch (address->sa_family) { | ||
392 | case AF_INET: | ||
393 | return rpcb_register_netid4((struct sockaddr_in *)address, | ||
394 | &msg); | ||
395 | case AF_INET6: | ||
396 | return rpcb_register_netid6((struct sockaddr_in6 *)address, | ||
397 | &msg); | ||
398 | } | ||
399 | |||
400 | return -EAFNOSUPPORT; | ||
193 | } | 401 | } |
194 | 402 | ||
195 | /** | 403 | /** |
@@ -227,7 +435,7 @@ int rpcb_getport_sync(struct sockaddr_in *sin, u32 prog, u32 vers, int prot) | |||
227 | __func__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); | 435 | __func__, NIPQUAD(sin->sin_addr.s_addr), prog, vers, prot); |
228 | 436 | ||
229 | rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin, | 437 | rpcb_clnt = rpcb_create(NULL, (struct sockaddr *)sin, |
230 | sizeof(*sin), prot, 2, 0); | 438 | sizeof(*sin), prot, RPCBVERS_2); |
231 | if (IS_ERR(rpcb_clnt)) | 439 | if (IS_ERR(rpcb_clnt)) |
232 | return PTR_ERR(rpcb_clnt); | 440 | return PTR_ERR(rpcb_clnt); |
233 | 441 | ||
@@ -289,17 +497,16 @@ void rpcb_getport_async(struct rpc_task *task) | |||
289 | /* Autobind on cloned rpc clients is discouraged */ | 497 | /* Autobind on cloned rpc clients is discouraged */ |
290 | BUG_ON(clnt->cl_parent != clnt); | 498 | BUG_ON(clnt->cl_parent != clnt); |
291 | 499 | ||
500 | /* Put self on the wait queue to ensure we get notified if | ||
501 | * some other task is already attempting to bind the port */ | ||
502 | rpc_sleep_on(&xprt->binding, task, NULL); | ||
503 | |||
292 | if (xprt_test_and_set_binding(xprt)) { | 504 | if (xprt_test_and_set_binding(xprt)) { |
293 | status = -EAGAIN; /* tell caller to check again */ | ||
294 | dprintk("RPC: %5u %s: waiting for another binder\n", | 505 | dprintk("RPC: %5u %s: waiting for another binder\n", |
295 | task->tk_pid, __func__); | 506 | task->tk_pid, __func__); |
296 | goto bailout_nowake; | 507 | return; |
297 | } | 508 | } |
298 | 509 | ||
299 | /* Put self on queue before sending rpcbind request, in case | ||
300 | * rpcb_getport_done completes before we return from rpc_run_task */ | ||
301 | rpc_sleep_on(&xprt->binding, task, NULL); | ||
302 | |||
303 | /* Someone else may have bound if we slept */ | 510 | /* Someone else may have bound if we slept */ |
304 | if (xprt_bound(xprt)) { | 511 | if (xprt_bound(xprt)) { |
305 | status = 0; | 512 | status = 0; |
@@ -338,7 +545,7 @@ void rpcb_getport_async(struct rpc_task *task) | |||
338 | task->tk_pid, __func__, bind_version); | 545 | task->tk_pid, __func__, bind_version); |
339 | 546 | ||
340 | rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot, | 547 | rpcb_clnt = rpcb_create(clnt->cl_server, sap, salen, xprt->prot, |
341 | bind_version, 0); | 548 | bind_version); |
342 | if (IS_ERR(rpcb_clnt)) { | 549 | if (IS_ERR(rpcb_clnt)) { |
343 | status = PTR_ERR(rpcb_clnt); | 550 | status = PTR_ERR(rpcb_clnt); |
344 | dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n", | 551 | dprintk("RPC: %5u %s: rpcb_create failed, error %ld\n", |
@@ -361,15 +568,15 @@ void rpcb_getport_async(struct rpc_task *task) | |||
361 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); | 568 | map->r_netid = rpc_peeraddr2str(clnt, RPC_DISPLAY_NETID); |
362 | map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR); | 569 | map->r_addr = rpc_peeraddr2str(rpcb_clnt, RPC_DISPLAY_UNIVERSAL_ADDR); |
363 | map->r_owner = RPCB_OWNER_STRING; /* ignored for GETADDR */ | 570 | map->r_owner = RPCB_OWNER_STRING; /* ignored for GETADDR */ |
571 | map->r_status = -EIO; | ||
364 | 572 | ||
365 | child = rpcb_call_async(rpcb_clnt, map, proc); | 573 | child = rpcb_call_async(rpcb_clnt, map, proc); |
366 | rpc_release_client(rpcb_clnt); | 574 | rpc_release_client(rpcb_clnt); |
367 | if (IS_ERR(child)) { | 575 | if (IS_ERR(child)) { |
368 | status = -EIO; | ||
369 | /* rpcb_map_release() has freed the arguments */ | 576 | /* rpcb_map_release() has freed the arguments */ |
370 | dprintk("RPC: %5u %s: rpc_run_task failed\n", | 577 | dprintk("RPC: %5u %s: rpc_run_task failed\n", |
371 | task->tk_pid, __func__); | 578 | task->tk_pid, __func__); |
372 | goto bailout_nofree; | 579 | return; |
373 | } | 580 | } |
374 | rpc_put_task(child); | 581 | rpc_put_task(child); |
375 | 582 | ||
@@ -378,7 +585,6 @@ void rpcb_getport_async(struct rpc_task *task) | |||
378 | 585 | ||
379 | bailout_nofree: | 586 | bailout_nofree: |
380 | rpcb_wake_rpcbind_waiters(xprt, status); | 587 | rpcb_wake_rpcbind_waiters(xprt, status); |
381 | bailout_nowake: | ||
382 | task->tk_status = status; | 588 | task->tk_status = status; |
383 | } | 589 | } |
384 | EXPORT_SYMBOL_GPL(rpcb_getport_async); | 590 | EXPORT_SYMBOL_GPL(rpcb_getport_async); |
@@ -417,9 +623,13 @@ static void rpcb_getport_done(struct rpc_task *child, void *data) | |||
417 | dprintk("RPC: %5u rpcb_getport_done(status %d, port %u)\n", | 623 | dprintk("RPC: %5u rpcb_getport_done(status %d, port %u)\n", |
418 | child->tk_pid, status, map->r_port); | 624 | child->tk_pid, status, map->r_port); |
419 | 625 | ||
420 | rpcb_wake_rpcbind_waiters(xprt, status); | 626 | map->r_status = status; |
421 | } | 627 | } |
422 | 628 | ||
629 | /* | ||
630 | * XDR functions for rpcbind | ||
631 | */ | ||
632 | |||
423 | static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p, | 633 | static int rpcb_encode_mapping(struct rpc_rqst *req, __be32 *p, |
424 | struct rpcbind_args *rpcb) | 634 | struct rpcbind_args *rpcb) |
425 | { | 635 | { |
@@ -438,7 +648,7 @@ static int rpcb_decode_getport(struct rpc_rqst *req, __be32 *p, | |||
438 | unsigned short *portp) | 648 | unsigned short *portp) |
439 | { | 649 | { |
440 | *portp = (unsigned short) ntohl(*p++); | 650 | *portp = (unsigned short) ntohl(*p++); |
441 | dprintk("RPC: rpcb_decode_getport result %u\n", | 651 | dprintk("RPC: rpcb_decode_getport result %u\n", |
442 | *portp); | 652 | *portp); |
443 | return 0; | 653 | return 0; |
444 | } | 654 | } |
@@ -447,8 +657,8 @@ static int rpcb_decode_set(struct rpc_rqst *req, __be32 *p, | |||
447 | unsigned int *boolp) | 657 | unsigned int *boolp) |
448 | { | 658 | { |
449 | *boolp = (unsigned int) ntohl(*p++); | 659 | *boolp = (unsigned int) ntohl(*p++); |
450 | dprintk("RPC: rpcb_decode_set result %u\n", | 660 | dprintk("RPC: rpcb_decode_set: call %s\n", |
451 | *boolp); | 661 | (*boolp ? "succeeded" : "failed")); |
452 | return 0; | 662 | return 0; |
453 | } | 663 | } |
454 | 664 | ||
@@ -571,52 +781,60 @@ out_err: | |||
571 | static struct rpc_procinfo rpcb_procedures2[] = { | 781 | static struct rpc_procinfo rpcb_procedures2[] = { |
572 | PROC(SET, mapping, set), | 782 | PROC(SET, mapping, set), |
573 | PROC(UNSET, mapping, set), | 783 | PROC(UNSET, mapping, set), |
574 | PROC(GETADDR, mapping, getport), | 784 | PROC(GETPORT, mapping, getport), |
575 | }; | 785 | }; |
576 | 786 | ||
577 | static struct rpc_procinfo rpcb_procedures3[] = { | 787 | static struct rpc_procinfo rpcb_procedures3[] = { |
578 | PROC(SET, mapping, set), | 788 | PROC(SET, getaddr, set), |
579 | PROC(UNSET, mapping, set), | 789 | PROC(UNSET, getaddr, set), |
580 | PROC(GETADDR, getaddr, getaddr), | 790 | PROC(GETADDR, getaddr, getaddr), |
581 | }; | 791 | }; |
582 | 792 | ||
583 | static struct rpc_procinfo rpcb_procedures4[] = { | 793 | static struct rpc_procinfo rpcb_procedures4[] = { |
584 | PROC(SET, mapping, set), | 794 | PROC(SET, getaddr, set), |
585 | PROC(UNSET, mapping, set), | 795 | PROC(UNSET, getaddr, set), |
796 | PROC(GETADDR, getaddr, getaddr), | ||
586 | PROC(GETVERSADDR, getaddr, getaddr), | 797 | PROC(GETVERSADDR, getaddr, getaddr), |
587 | }; | 798 | }; |
588 | 799 | ||
589 | static struct rpcb_info rpcb_next_version[] = { | 800 | static struct rpcb_info rpcb_next_version[] = { |
590 | #ifdef CONFIG_SUNRPC_BIND34 | 801 | { |
591 | { 4, &rpcb_procedures4[RPCBPROC_GETVERSADDR] }, | 802 | .rpc_vers = RPCBVERS_2, |
592 | { 3, &rpcb_procedures3[RPCBPROC_GETADDR] }, | 803 | .rpc_proc = &rpcb_procedures2[RPCBPROC_GETPORT], |
593 | #endif | 804 | }, |
594 | { 2, &rpcb_procedures2[RPCBPROC_GETPORT] }, | 805 | { |
595 | { 0, NULL }, | 806 | .rpc_proc = NULL, |
807 | }, | ||
596 | }; | 808 | }; |
597 | 809 | ||
598 | static struct rpcb_info rpcb_next_version6[] = { | 810 | static struct rpcb_info rpcb_next_version6[] = { |
599 | #ifdef CONFIG_SUNRPC_BIND34 | 811 | { |
600 | { 4, &rpcb_procedures4[RPCBPROC_GETVERSADDR] }, | 812 | .rpc_vers = RPCBVERS_4, |
601 | { 3, &rpcb_procedures3[RPCBPROC_GETADDR] }, | 813 | .rpc_proc = &rpcb_procedures4[RPCBPROC_GETADDR], |
602 | #endif | 814 | }, |
603 | { 0, NULL }, | 815 | { |
816 | .rpc_vers = RPCBVERS_3, | ||
817 | .rpc_proc = &rpcb_procedures3[RPCBPROC_GETADDR], | ||
818 | }, | ||
819 | { | ||
820 | .rpc_proc = NULL, | ||
821 | }, | ||
604 | }; | 822 | }; |
605 | 823 | ||
606 | static struct rpc_version rpcb_version2 = { | 824 | static struct rpc_version rpcb_version2 = { |
607 | .number = 2, | 825 | .number = RPCBVERS_2, |
608 | .nrprocs = RPCB_HIGHPROC_2, | 826 | .nrprocs = RPCB_HIGHPROC_2, |
609 | .procs = rpcb_procedures2 | 827 | .procs = rpcb_procedures2 |
610 | }; | 828 | }; |
611 | 829 | ||
612 | static struct rpc_version rpcb_version3 = { | 830 | static struct rpc_version rpcb_version3 = { |
613 | .number = 3, | 831 | .number = RPCBVERS_3, |
614 | .nrprocs = RPCB_HIGHPROC_3, | 832 | .nrprocs = RPCB_HIGHPROC_3, |
615 | .procs = rpcb_procedures3 | 833 | .procs = rpcb_procedures3 |
616 | }; | 834 | }; |
617 | 835 | ||
618 | static struct rpc_version rpcb_version4 = { | 836 | static struct rpc_version rpcb_version4 = { |
619 | .number = 4, | 837 | .number = RPCBVERS_4, |
620 | .nrprocs = RPCB_HIGHPROC_4, | 838 | .nrprocs = RPCB_HIGHPROC_4, |
621 | .procs = rpcb_procedures4 | 839 | .procs = rpcb_procedures4 |
622 | }; | 840 | }; |
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 6eab9bf94baf..6288af05c20f 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -626,19 +626,15 @@ static void __rpc_execute(struct rpc_task *task) | |||
626 | /* | 626 | /* |
627 | * Execute any pending callback. | 627 | * Execute any pending callback. |
628 | */ | 628 | */ |
629 | if (RPC_DO_CALLBACK(task)) { | 629 | if (task->tk_callback) { |
630 | /* Define a callback save pointer */ | ||
631 | void (*save_callback)(struct rpc_task *); | 630 | void (*save_callback)(struct rpc_task *); |
632 | 631 | ||
633 | /* | 632 | /* |
634 | * If a callback exists, save it, reset it, | 633 | * We set tk_callback to NULL before calling it, |
635 | * call it. | 634 | * in case it sets the tk_callback field itself: |
636 | * The save is needed to stop from resetting | ||
637 | * another callback set within the callback handler | ||
638 | * - Dave | ||
639 | */ | 635 | */ |
640 | save_callback=task->tk_callback; | 636 | save_callback = task->tk_callback; |
641 | task->tk_callback=NULL; | 637 | task->tk_callback = NULL; |
642 | save_callback(task); | 638 | save_callback(task); |
643 | } | 639 | } |
644 | 640 | ||
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index e1770f7ba0b3..99a52aabe332 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c | |||
@@ -690,7 +690,7 @@ static void xprt_connect_status(struct rpc_task *task) | |||
690 | { | 690 | { |
691 | struct rpc_xprt *xprt = task->tk_xprt; | 691 | struct rpc_xprt *xprt = task->tk_xprt; |
692 | 692 | ||
693 | if (task->tk_status >= 0) { | 693 | if (task->tk_status == 0) { |
694 | xprt->stat.connect_count++; | 694 | xprt->stat.connect_count++; |
695 | xprt->stat.connect_time += (long)jiffies - xprt->stat.connect_start; | 695 | xprt->stat.connect_time += (long)jiffies - xprt->stat.connect_start; |
696 | dprintk("RPC: %5u xprt_connect_status: connection established\n", | 696 | dprintk("RPC: %5u xprt_connect_status: connection established\n", |
@@ -699,12 +699,6 @@ static void xprt_connect_status(struct rpc_task *task) | |||
699 | } | 699 | } |
700 | 700 | ||
701 | switch (task->tk_status) { | 701 | switch (task->tk_status) { |
702 | case -ECONNREFUSED: | ||
703 | case -ECONNRESET: | ||
704 | dprintk("RPC: %5u xprt_connect_status: server %s refused " | ||
705 | "connection\n", task->tk_pid, | ||
706 | task->tk_client->cl_server); | ||
707 | break; | ||
708 | case -ENOTCONN: | 702 | case -ENOTCONN: |
709 | dprintk("RPC: %5u xprt_connect_status: connection broken\n", | 703 | dprintk("RPC: %5u xprt_connect_status: connection broken\n", |
710 | task->tk_pid); | 704 | task->tk_pid); |
@@ -878,6 +872,7 @@ void xprt_transmit(struct rpc_task *task) | |||
878 | return; | 872 | return; |
879 | 873 | ||
880 | req->rq_connect_cookie = xprt->connect_cookie; | 874 | req->rq_connect_cookie = xprt->connect_cookie; |
875 | req->rq_xtime = jiffies; | ||
881 | status = xprt->ops->send_request(task); | 876 | status = xprt->ops->send_request(task); |
882 | if (status == 0) { | 877 | if (status == 0) { |
883 | dprintk("RPC: %5u xmit complete\n", task->tk_pid); | 878 | dprintk("RPC: %5u xmit complete\n", task->tk_pid); |
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index ddbe981ab516..4486c59c3aca 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
@@ -579,7 +579,6 @@ static int xs_udp_send_request(struct rpc_task *task) | |||
579 | req->rq_svec->iov_base, | 579 | req->rq_svec->iov_base, |
580 | req->rq_svec->iov_len); | 580 | req->rq_svec->iov_len); |
581 | 581 | ||
582 | req->rq_xtime = jiffies; | ||
583 | status = xs_sendpages(transport->sock, | 582 | status = xs_sendpages(transport->sock, |
584 | xs_addr(xprt), | 583 | xs_addr(xprt), |
585 | xprt->addrlen, xdr, | 584 | xprt->addrlen, xdr, |
@@ -671,7 +670,6 @@ static int xs_tcp_send_request(struct rpc_task *task) | |||
671 | * to cope with writespace callbacks arriving _after_ we have | 670 | * to cope with writespace callbacks arriving _after_ we have |
672 | * called sendmsg(). */ | 671 | * called sendmsg(). */ |
673 | while (1) { | 672 | while (1) { |
674 | req->rq_xtime = jiffies; | ||
675 | status = xs_sendpages(transport->sock, | 673 | status = xs_sendpages(transport->sock, |
676 | NULL, 0, xdr, req->rq_bytes_sent); | 674 | NULL, 0, xdr, req->rq_bytes_sent); |
677 | 675 | ||