diff options
author | Steve French <sfrench@us.ibm.com> | 2007-02-13 23:42:51 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-02-13 23:42:51 -0500 |
commit | 8af18971584d1e05770560206cfdfd1d6ba8a17f (patch) | |
tree | 5720ee5fa4de18eebc64d41b761e2f890d99b35e /fs/cifs | |
parent | 7ba526316ae122e60c0c7a40793491f71b9ec590 (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/cifs')
-rw-r--r-- | fs/cifs/CHANGES | 7 | ||||
-rw-r--r-- | fs/cifs/TODO | 8 | ||||
-rw-r--r-- | fs/cifs/cifsfs.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifspdu.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 3 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 16 | ||||
-rw-r--r-- | fs/cifs/connect.c | 130 |
7 files changed, 119 insertions, 49 deletions
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. | |||
4 | Fix file corruption which could occur on some large file | 4 | Fix file corruption which could occur on some large file |
5 | copies caused by writepages page i/o completion bug. | 5 | copies caused by writepages page i/o completion bug. |
6 | Seek to SEEK_END forces check for update of file size for non-cached | 6 | Seek to SEEK_END forces check for update of file size for non-cached |
7 | files. | 7 | files. Allow file size to be updated on remote extend of locally open, |
8 | non-cached file. Fix reconnect to newer Samba servers (or other servers | ||
9 | which support the CIFS Unix/POSIX extensions) so that we again tell the | ||
10 | server the Unix/POSIX cifs capabilities which we support (SetFSInfo). | ||
11 | Add experimental support for new POSIX Open/Mkdir (which returns | ||
12 | stat information on the open, and allows setting the mode). | ||
8 | 13 | ||
9 | Version 1.46 | 14 | Version 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 | ||
129 | 4) More exhaustively test against less common servers. More testing | 129 | 4) More exhaustively test against less common servers. More testing |
130 | against Windows 9x, Windows ME servers. | 130 | against Windows 9x, Windows ME servers. |
131 | |||
132 | DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too) | ||
133 | |||
134 | mount check for unmatched uids - and uid override | ||
135 | |||
136 | Add 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 | |||
138 | Free 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); | |||
100 | extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); | 100 | extern ssize_t cifs_listxattr(struct dentry *, char *, size_t); |
101 | extern int cifs_ioctl (struct inode * inode, struct file * filep, | 101 | extern 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 | ||
2109 | typedef struct { | 2109 | typedef 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 | ||
2114 | struct file_internal_info { | 2114 | struct 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 | ||
25 | struct statfs; | 25 | struct statfs; |
26 | struct 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); |
151 | extern void reset_cifs_unix_caps(int xid, struct cifsTconInfo *tcon, | ||
152 | struct super_block * sb, struct smb_vol * vol); | ||
150 | extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, | 153 | extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon, |
151 | struct kstatfs *FSData); | 154 | struct kstatfs *FSData); |
152 | extern int SMBOldQFSInfo(const int xid, struct cifsTconInfo *tcon, | 155 | extern 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 | ||
1616 | void 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 | |||
1616 | int | 1686 | int |
1617 | cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | 1687 | cifs_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 - |