aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2007-02-13 23:42:51 -0500
committerSteve French <sfrench@us.ibm.com>2007-02-13 23:42:51 -0500
commit8af18971584d1e05770560206cfdfd1d6ba8a17f (patch)
tree5720ee5fa4de18eebc64d41b761e2f890d99b35e /fs
parent7ba526316ae122e60c0c7a40793491f71b9ec590 (diff)
[CIFS] on reconnect to Samba - reset the unix capabilities
After temporary server or network failure and reconneciton, we were not resending the unix capabilities via SetFSInfo - which confused Samba posix byte range locking code. Discovered by jra Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/Kconfig29
-rw-r--r--fs/cifs/CHANGES7
-rw-r--r--fs/cifs/TODO8
-rw-r--r--fs/cifs/cifsfs.h2
-rw-r--r--fs/cifs/cifspdu.h2
-rw-r--r--fs/cifs/cifsproto.h3
-rw-r--r--fs/cifs/cifssmb.c16
-rw-r--r--fs/cifs/connect.c130
8 files changed, 130 insertions, 67 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index 8cd2417a14db..d57f363ea1ab 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -1871,20 +1871,14 @@ config CIFS
1871 file servers such as Windows 2000 (including Windows 2003, NT 4 1871 file servers such as Windows 2000 (including Windows 2003, NT 4
1872 and Windows XP) as well by Samba (which provides excellent CIFS 1872 and Windows XP) as well by Samba (which provides excellent CIFS
1873 server support for Linux and many other operating systems). Limited 1873 server support for Linux and many other operating systems). Limited
1874 support for Windows ME and similar servers is provided as well. 1874 support for OS/2 and Windows ME and similar servers is provided as well.
1875 You must use the smbfs client filesystem to access older SMB servers
1876 such as OS/2 and DOS.
1877 1875
1878 The intent of the cifs module is to provide an advanced 1876 The intent of the cifs module is to provide an advanced
1879 network file system client for mounting to CIFS compliant servers, 1877 network file system client for mounting to CIFS compliant servers,
1880 including support for dfs (hierarchical name space), secure per-user 1878 including support for dfs (hierarchical name space), secure per-user
1881 session establishment, safe distributed caching (oplock), optional 1879 session establishment, safe distributed caching (oplock), optional
1882 packet signing, Unicode and other internationalization improvements, 1880 packet signing, Unicode and other internationalization improvements.
1883 and optional Winbind (nsswitch) integration. You do not need to enable 1881 If you need to mount to Samba or Windows from this machine, say Y.
1884 cifs if running only a (Samba) server. It is possible to enable both
1885 smbfs and cifs (e.g. if you are using CIFS for accessing Windows 2003
1886 and Samba 3 servers, and smbfs for accessing old servers). If you need
1887 to mount to Samba or Windows from this machine, say Y.
1888 1882
1889config CIFS_STATS 1883config CIFS_STATS
1890 bool "CIFS statistics" 1884 bool "CIFS statistics"
@@ -1977,14 +1971,13 @@ config CIFS_EXPERIMENTAL
1977 depends on CIFS && EXPERIMENTAL 1971 depends on CIFS && EXPERIMENTAL
1978 help 1972 help
1979 Enables cifs features under testing. These features are 1973 Enables cifs features under testing. These features are
1980 experimental and currently include support for writepages 1974 experimental and currently include DFS support and directory
1981 (multipage writebehind performance improvements) and directory 1975 change notification ie fcntl(F_DNOTIFY), as well as the upcall
1982 change notification ie fcntl(F_DNOTIFY) as well as some security 1976 mechanism which will be used for Kerberos session negotiation
1983 improvements. Some also depend on setting at runtime the 1977 and uid remapping. Some of these features also may depend on
1984 pseudo-file /proc/fs/cifs/Experimental (which is disabled by 1978 setting a value of 1 to the pseudo-file /proc/fs/cifs/Experimental
1985 default). See the file fs/cifs/README for more details. 1979 (which is disabled by default). See the file fs/cifs/README
1986 1980 for more details. If unsure, say N.
1987 If unsure, say N.
1988 1981
1989config CIFS_UPCALL 1982config CIFS_UPCALL
1990 bool "Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)" 1983 bool "Kerberos/SPNEGO advanced session setup (EXPERIMENTAL)"
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index a1fb03f19637..5fe13593b57f 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -4,7 +4,12 @@ Fix oops in list_del during mount caused by unaligned string.
4Fix file corruption which could occur on some large file 4Fix file corruption which could occur on some large file
5copies caused by writepages page i/o completion bug. 5copies caused by writepages page i/o completion bug.
6Seek to SEEK_END forces check for update of file size for non-cached 6Seek to SEEK_END forces check for update of file size for non-cached
7files. 7files. Allow file size to be updated on remote extend of locally open,
8non-cached file. Fix reconnect to newer Samba servers (or other servers
9which support the CIFS Unix/POSIX extensions) so that we again tell the
10server the Unix/POSIX cifs capabilities which we support (SetFSInfo).
11Add experimental support for new POSIX Open/Mkdir (which returns
12stat information on the open, and allows setting the mode).
8 13
9Version 1.46 14Version 1.46
10------------ 15------------
diff --git a/fs/cifs/TODO b/fs/cifs/TODO
index fc34c74ec4be..68372946dc92 100644
--- a/fs/cifs/TODO
+++ b/fs/cifs/TODO
@@ -128,3 +128,11 @@ negotiated size) and send larger write sizes to modern servers.
128 128
1294) More exhaustively test against less common servers. More testing 1294) More exhaustively test against less common servers. More testing
130against Windows 9x, Windows ME servers. 130against Windows 9x, Windows ME servers.
131
132DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too)
133
134mount check for unmatched uids - and uid override
135
136Add mount option for Linux extension disable per mount, and partial disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?)
137
138Free threads at umount --force that are stuck on the sesSem
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 8aa66dcf13bd..e36b0d43e909 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -100,5 +100,5 @@ extern ssize_t cifs_getxattr(struct dentry *, const char *, void *, size_t);
100extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); 100extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
101extern int cifs_ioctl (struct inode * inode, struct file * filep, 101extern int cifs_ioctl (struct inode * inode, struct file * filep,
102 unsigned int command, unsigned long arg); 102 unsigned int command, unsigned long arg);
103#define CIFS_VERSION "1.47" 103#define CIFS_VERSION "1.48"
104#endif /* _CIFSFS_H */ 104#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 529a000bee46..7d9505491b16 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -2108,7 +2108,7 @@ typedef struct {
2108 2108
2109typedef struct { 2109typedef struct {
2110 /* reply varies based on requested level */ 2110 /* reply varies based on requested level */
2111} __atribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */ 2111} __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
2112 2112
2113 2113
2114struct file_internal_info { 2114struct file_internal_info {
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 1108f17bf550..6148b82170c4 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -23,6 +23,7 @@
23#include <linux/nls.h> 23#include <linux/nls.h>
24 24
25struct statfs; 25struct statfs;
26struct smb_vol;
26 27
27/* 28/*
28 ***************************************************************** 29 *****************************************************************
@@ -147,6 +148,8 @@ extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
147 unsigned int *pnum_referrals, 148 unsigned int *pnum_referrals,
148 unsigned char ** preferrals, 149 unsigned char ** preferrals,
149 int remap); 150 int remap);
151extern void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon,
152 struct super_block * sb, struct smb_vol * vol);
150extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, 153extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon,
151 struct kstatfs *FSData); 154 struct kstatfs *FSData);
152extern int SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, 155extern int SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon,
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 472e33e0f3cf..b8e91470c27f 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -158,9 +158,15 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
158 nls_codepage); 158 nls_codepage);
159 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) { 159 if(!rc && (tcon->tidStatus == CifsNeedReconnect)) {
160 mark_open_files_invalid(tcon); 160 mark_open_files_invalid(tcon);
161 rc = CIFSTCon(0, tcon->ses, tcon->treeName, tcon 161 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
162 , nls_codepage); 162 tcon, nls_codepage);
163 up(&tcon->ses->sesSem); 163 up(&tcon->ses->sesSem);
164 /* tell server which Unix caps we support */
165 if (tcon->ses->capabilities & CAP_UNIX)
166 reset_cifs_unix_caps(0 /* no xid */,
167 tcon,
168 NULL /* we do not know sb */,
169 NULL /* no vol info */);
164 /* BB FIXME add code to check if wsize needs 170 /* BB FIXME add code to check if wsize needs
165 update due to negotiated smb buffer size 171 update due to negotiated smb buffer size
166 shrinking */ 172 shrinking */
@@ -298,6 +304,12 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
298 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 304 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
299 tcon, nls_codepage); 305 tcon, nls_codepage);
300 up(&tcon->ses->sesSem); 306 up(&tcon->ses->sesSem);
307 /* tell server which Unix caps we support */
308 if (tcon->ses->capabilities & CAP_UNIX)
309 reset_cifs_unix_caps(0 /* no xid */,
310 tcon,
311 NULL /* do not know sb */,
312 NULL /* no vol info */);
301 /* BB FIXME add code to check if wsize needs 313 /* BB FIXME add code to check if wsize needs
302 update due to negotiated smb buffer size 314 update due to negotiated smb buffer size
303 shrinking */ 315 shrinking */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 2caca06b4bae..20ba7dcc9959 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -1613,6 +1613,76 @@ ipv6_connect(struct sockaddr_in6 *psin_server, struct socket **csocket)
1613 return rc; 1613 return rc;
1614} 1614}
1615 1615
1616void reset_cifs_unix_caps(int xid, struct cifsTconInfo * tcon,
1617 struct super_block * sb, struct smb_vol * vol_info)
1618{
1619 /* if we are reconnecting then should we check to see if
1620 * any requested capabilities changed locally e.g. via
1621 * remount but we can not do much about it here
1622 * if they have (even if we could detect it by the following)
1623 * Perhaps we could add a backpointer to array of sb from tcon
1624 * or if we change to make all sb to same share the same
1625 * sb as NFS - then we only have one backpointer to sb.
1626 * What if we wanted to mount the server share twice once with
1627 * and once without posixacls or posix paths? */
1628 __u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
1629
1630
1631 if(!CIFSSMBQFSUnixInfo(xid, tcon)) {
1632 __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
1633
1634 /* check for reconnect case in which we do not
1635 want to change the mount behavior if we can avoid it */
1636 if(vol_info == NULL) {
1637 /* turn off POSIX ACL and PATHNAMES if not set
1638 originally at mount time */
1639 if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0)
1640 cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
1641 if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0)
1642 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
1643
1644
1645
1646
1647 }
1648
1649 cap &= CIFS_UNIX_CAP_MASK;
1650 if(vol_info && vol_info->no_psx_acl)
1651 cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
1652 else if(CIFS_UNIX_POSIX_ACL_CAP & cap) {
1653 cFYI(1,("negotiated posix acl support"));
1654 if(sb)
1655 sb->s_flags |= MS_POSIXACL;
1656 }
1657
1658 if(vol_info && vol_info->posix_paths == 0)
1659 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
1660 else if(cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
1661 cFYI(1,("negotiate posix pathnames"));
1662 if(sb)
1663 CIFS_SB(sb)->mnt_cifs_flags |=
1664 CIFS_MOUNT_POSIX_PATHS;
1665 }
1666
1667 cFYI(1,("Negotiate caps 0x%x",(int)cap));
1668#ifdef CONFIG_CIFS_DEBUG2
1669 if(cap & CIFS_UNIX_FCNTL_CAP)
1670 cFYI(1,("FCNTL cap"));
1671 if(cap & CIFS_UNIX_EXTATTR_CAP)
1672 cFYI(1,("EXTATTR cap"));
1673 if(cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
1674 cFYI(1,("POSIX path cap"));
1675 if(cap & CIFS_UNIX_XATTR_CAP)
1676 cFYI(1,("XATTR cap"));
1677 if(cap & CIFS_UNIX_POSIX_ACL_CAP)
1678 cFYI(1,("POSIX ACL cap"));
1679#endif /* CIFS_DEBUG2 */
1680 if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) {
1681 cFYI(1,("setting capabilities failed"));
1682 }
1683 }
1684}
1685
1616int 1686int
1617cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, 1687cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1618 char *mount_data, const char *devname) 1688 char *mount_data, const char *devname)
@@ -1928,20 +1998,25 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1928 if (tcon == NULL) 1998 if (tcon == NULL)
1929 rc = -ENOMEM; 1999 rc = -ENOMEM;
1930 else { 2000 else {
1931 /* check for null share name ie connect to dfs root */ 2001 /* check for null share name ie connecting to
2002 * dfs root */
1932 2003
1933 /* BB check if this works for exactly length three strings */ 2004 /* BB check if this works for exactly length
2005 * three strings */
1934 if ((strchr(volume_info.UNC + 3, '\\') == NULL) 2006 if ((strchr(volume_info.UNC + 3, '\\') == NULL)
1935 && (strchr(volume_info.UNC + 3, '/') == 2007 && (strchr(volume_info.UNC + 3, '/') ==
1936 NULL)) { 2008 NULL)) {
1937 rc = connect_to_dfs_path(xid, pSesInfo, 2009 rc = connect_to_dfs_path(xid, pSesInfo,
1938 "", cifs_sb->local_nls, 2010 "", cifs_sb->local_nls,
1939 cifs_sb->mnt_cifs_flags & 2011 cifs_sb->mnt_cifs_flags &
1940 CIFS_MOUNT_MAP_SPECIAL_CHR); 2012 CIFS_MOUNT_MAP_SPECIAL_CHR);
1941 kfree(volume_info.UNC); 2013 kfree(volume_info.UNC);
1942 FreeXid(xid); 2014 FreeXid(xid);
1943 return -ENODEV; 2015 return -ENODEV;
1944 } else { 2016 } else {
2017 /* BB Do we need to wrap sesSem around
2018 * this TCon call and Unix SetFS as
2019 * we do on SessSetup and reconnect? */
1945 rc = CIFSTCon(xid, pSesInfo, 2020 rc = CIFSTCon(xid, pSesInfo,
1946 volume_info.UNC, 2021 volume_info.UNC,
1947 tcon, cifs_sb->local_nls); 2022 tcon, cifs_sb->local_nls);
@@ -1962,6 +2037,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1962 sb->s_maxbytes = (u64) 1 << 31; /* 2 GB */ 2037 sb->s_maxbytes = (u64) 1 << 31; /* 2 GB */
1963 } 2038 }
1964 2039
2040 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
1965 sb->s_time_gran = 100; 2041 sb->s_time_gran = 100;
1966 2042
1967/* on error free sesinfo and tcon struct if needed */ 2043/* on error free sesinfo and tcon struct if needed */
@@ -2006,45 +2082,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2006 /* do not care if following two calls succeed - informational */ 2082 /* do not care if following two calls succeed - informational */
2007 CIFSSMBQFSDeviceInfo(xid, tcon); 2083 CIFSSMBQFSDeviceInfo(xid, tcon);
2008 CIFSSMBQFSAttributeInfo(xid, tcon); 2084 CIFSSMBQFSAttributeInfo(xid, tcon);
2009 2085
2010 if (tcon->ses->capabilities & CAP_UNIX) { 2086 /* tell server which Unix caps we support */
2011 if(!CIFSSMBQFSUnixInfo(xid, tcon)) { 2087 if (tcon->ses->capabilities & CAP_UNIX)
2012 __u64 cap = 2088 reset_cifs_unix_caps(xid, tcon, sb, &volume_info);
2013 le64_to_cpu(tcon->fsUnixInfo.Capability); 2089
2014 cap &= CIFS_UNIX_CAP_MASK;
2015 if(volume_info.no_psx_acl)
2016 cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
2017 else if(CIFS_UNIX_POSIX_ACL_CAP & cap) {
2018 cFYI(1,("negotiated posix acl support"));
2019 sb->s_flags |= MS_POSIXACL;
2020 }
2021
2022 if(volume_info.posix_paths == 0)
2023 cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
2024 else if(cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
2025 cFYI(1,("negotiate posix pathnames"));
2026 cifs_sb->mnt_cifs_flags |=
2027 CIFS_MOUNT_POSIX_PATHS;
2028 }
2029
2030 cFYI(1,("Negotiate caps 0x%x",(int)cap));
2031#ifdef CONFIG_CIFS_DEBUG2
2032 if(cap & CIFS_UNIX_FCNTL_CAP)
2033 cFYI(1,("FCNTL cap"));
2034 if(cap & CIFS_UNIX_EXTATTR_CAP)
2035 cFYI(1,("EXTATTR cap"));
2036 if(cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
2037 cFYI(1,("POSIX path cap"));
2038 if(cap & CIFS_UNIX_XATTR_CAP)
2039 cFYI(1,("XATTR cap"));
2040 if(cap & CIFS_UNIX_POSIX_ACL_CAP)
2041 cFYI(1,("POSIX ACL cap"));
2042#endif /* CIFS_DEBUG2 */
2043 if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) {
2044 cFYI(1,("setting capabilities failed"));
2045 }
2046 }
2047 }
2048 if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X)) 2090 if (!(tcon->ses->capabilities & CAP_LARGE_WRITE_X))
2049 cifs_sb->wsize = min(cifs_sb->wsize, 2091 cifs_sb->wsize = min(cifs_sb->wsize,
2050 (tcon->ses->server->maxBuf - 2092 (tcon->ses->server->maxBuf -