Commit 6faf875a authored by Pavel Shilovsky's avatar Pavel Shilovsky

Pull from cifs-2.6 repo for 2.6.32

Implement WINE logic Fix losing locks during fork()
parent ffdeafd1
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define CIFS_MOUNT_DYNPERM 0x1000 /* allow in-memory only mode setting */ #define CIFS_MOUNT_DYNPERM 0x1000 /* allow in-memory only mode setting */
#define CIFS_MOUNT_NOPOSIXBRL 0x2000 /* mandatory not posix byte range lock */ #define CIFS_MOUNT_NOPOSIXBRL 0x2000 /* mandatory not posix byte range lock */
#define CIFS_MOUNT_NOSSYNC 0x4000 /* don't do slow SMBflush on every sync*/ #define CIFS_MOUNT_NOSSYNC 0x4000 /* don't do slow SMBflush on every sync*/
#define CIFS_MOUNT_WINE_MODE 0x8000 /* use pid forwarding for wine apps */
struct cifs_sb_info { struct cifs_sb_info {
struct cifsTconInfo *tcon; /* primary mount */ struct cifsTconInfo *tcon; /* primary mount */
......
...@@ -390,6 +390,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) ...@@ -390,6 +390,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
seq_printf(s, ",nocase"); seq_printf(s, ",nocase");
if (tcon->retry) if (tcon->retry)
seq_printf(s, ",hard"); seq_printf(s, ",hard");
if (tcon->unix_ext)
seq_printf(s, ",unix");
else
seq_printf(s, ",nounix");
if (cifs_sb->prepath) if (cifs_sb->prepath)
seq_printf(s, ",prepath=%s", cifs_sb->prepath); seq_printf(s, ",prepath=%s", cifs_sb->prepath);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
...@@ -398,6 +402,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) ...@@ -398,6 +402,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
seq_printf(s, ",setuids"); seq_printf(s, ",setuids");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
seq_printf(s, ",serverino"); seq_printf(s, ",serverino");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
seq_printf(s, ",wine");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
seq_printf(s, ",forcemand");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
seq_printf(s, ",directio"); seq_printf(s, ",directio");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
...@@ -643,7 +651,7 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, l ...@@ -643,7 +651,7 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, size_t len, l
return -ENOENT; return -ENOENT;
if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead && !posix_locking) { if (!CIFS_I(filp->f_path.dentry->d_inode)->clientCanCacheRead && !posix_locking) {
retval = cifs_lock(filp, F_GETLK, &pfLock); retval = cifs_lock(filp, F_GETLK | CIFS_NOPOSIXBRL_READ, &pfLock);
if (retval < 0) if (retval < 0)
return (ssize_t)retval; return (ssize_t)retval;
if (pfLock.fl_type == F_UNLCK) if (pfLock.fl_type == F_UNLCK)
......
...@@ -318,6 +318,8 @@ struct cifsLockInfo { ...@@ -318,6 +318,8 @@ struct cifsLockInfo {
__u8 type; __u8 type;
}; };
#define CIFS_NOPOSIXBRL_READ 64
/* /*
* One of these for each open instance of a file * One of these for each open instance of a file
*/ */
...@@ -466,6 +468,7 @@ struct oplock_q_entry { ...@@ -466,6 +468,7 @@ struct oplock_q_entry {
struct inode *pinode; struct inode *pinode;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
__u16 netfid; __u16 netfid;
__u32 netpid;
}; };
/* for pending dnotify requests */ /* for pending dnotify requests */
......
...@@ -298,16 +298,16 @@ extern int CIFSSMBFlush(const int xid, struct cifsTconInfo *tcon, ...@@ -298,16 +298,16 @@ extern int CIFSSMBFlush(const int xid, struct cifsTconInfo *tcon,
const int smb_file_id); const int smb_file_id);
extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
const int netfid, unsigned int count, const int netfid, const u32 netpid, unsigned int count,
const __u64 lseek, unsigned int *nbytes, char **buf, const __u64 lseek, unsigned int *nbytes, char **buf,
int *return_buf_type); int *return_buf_type);
extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
const int netfid, const unsigned int count, const int netfid, const u32 netpid,
const __u64 lseek, unsigned int *nbytes, const unsigned int count, const __u64 lseek,
const char *buf, const char __user *ubuf, unsigned int *nbytes, const char *buf,
const int long_op); const char __user *ubuf, const int long_op);
extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
const int netfid, const unsigned int count, const int netfid, u32 netpid, const unsigned int count,
const __u64 offset, unsigned int *nbytes, const __u64 offset, unsigned int *nbytes,
struct kvec *iov, const int nvec, const int long_op); struct kvec *iov, const int nvec, const int long_op);
extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon, extern int CIFSGetSrvInodeNumber(const int xid, struct cifsTconInfo *tcon,
...@@ -318,12 +318,12 @@ extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen, ...@@ -318,12 +318,12 @@ extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen,
const struct nls_table *cp, int mapChars); const struct nls_table *cp, int mapChars);
extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const __u16 netfid, const __u64 len, const __u16 netfid, const __u32 netpid, const __u64 len,
const __u64 offset, const __u32 numUnlock, const __u64 offset, const __u32 numUnlock,
const __u32 numLock, const __u8 lockType, const __u32 numLock, const __u8 lockType,
const bool waitFlag); const bool waitFlag);
extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const int get_flag, const __u16 smb_file_id, const __u32 netpid, const int get_flag,
const __u64 len, struct file_lock *, const __u64 len, struct file_lock *,
const __u16 lock_type, const bool waitFlag); const __u16 lock_type, const bool waitFlag);
extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon); extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
......
...@@ -1319,8 +1319,8 @@ openRetry: ...@@ -1319,8 +1319,8 @@ openRetry:
int int
CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid,
const unsigned int count, const __u64 lseek, unsigned int *nbytes, const u32 netpid, const unsigned int count, const __u64 lseek,
char **buf, int *pbuf_type) unsigned int *nbytes, char **buf, int *pbuf_type)
{ {
int rc = -EACCES; int rc = -EACCES;
READ_REQ *pSMB = NULL; READ_REQ *pSMB = NULL;
...@@ -1346,6 +1346,9 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, ...@@ -1346,6 +1346,9 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid,
if (rc) if (rc)
return rc; return rc;
pSMB->hdr.Pid = cpu_to_le16((__u16)netpid);
pSMB->hdr.PidHigh = cpu_to_le16((__u16)(netpid >> 16));
/* tcon and ses pointer are checked in smb_init */ /* tcon and ses pointer are checked in smb_init */
if (tcon->ses->server == NULL) if (tcon->ses->server == NULL)
return -ECONNABORTED; return -ECONNABORTED;
...@@ -1424,7 +1427,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, ...@@ -1424,7 +1427,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid,
int int
CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
const int netfid, const unsigned int count, const int netfid, const u32 netpid, const unsigned int count,
const __u64 offset, unsigned int *nbytes, const char *buf, const __u64 offset, unsigned int *nbytes, const char *buf,
const char __user *ubuf, const int long_op) const char __user *ubuf, const int long_op)
{ {
...@@ -1453,6 +1456,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, ...@@ -1453,6 +1456,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
(void **) &pSMBr); (void **) &pSMBr);
if (rc) if (rc)
return rc; return rc;
pSMB->hdr.Pid = cpu_to_le16((__u16)netpid);
pSMB->hdr.PidHigh = cpu_to_le16((__u16)(netpid >> 16));
/* tcon and ses pointer are checked in smb_init */ /* tcon and ses pointer are checked in smb_init */
if (tcon->ses->server == NULL) if (tcon->ses->server == NULL)
return -ECONNABORTED; return -ECONNABORTED;
...@@ -1534,7 +1541,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, ...@@ -1534,7 +1541,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
int int
CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
const int netfid, const unsigned int count, const int netfid, const u32 netpid, const unsigned int count,
const __u64 offset, unsigned int *nbytes, struct kvec *iov, const __u64 offset, unsigned int *nbytes, struct kvec *iov,
int n_vec, const int long_op) int n_vec, const int long_op)
{ {
...@@ -1560,6 +1567,10 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, ...@@ -1560,6 +1567,10 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
rc = small_smb_init(SMB_COM_WRITE_ANDX, wct, tcon, (void **) &pSMB); rc = small_smb_init(SMB_COM_WRITE_ANDX, wct, tcon, (void **) &pSMB);
if (rc) if (rc)
return rc; return rc;
pSMB->hdr.Pid = cpu_to_le16((__u16)netpid);
pSMB->hdr.PidHigh = cpu_to_le16((__u16)(netpid >> 16));
/* tcon and ses pointer are checked in smb_init */ /* tcon and ses pointer are checked in smb_init */
if (tcon->ses->server == NULL) if (tcon->ses->server == NULL)
return -ECONNABORTED; return -ECONNABORTED;
...@@ -1627,7 +1638,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, ...@@ -1627,7 +1638,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
int int
CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const __u64 len, const __u16 smb_file_id, const __u32 net_pid, const __u64 len,
const __u64 offset, const __u32 numUnlock, const __u64 offset, const __u32 numUnlock,
const __u32 numLock, const __u8 lockType, const bool waitFlag) const __u32 numLock, const __u8 lockType, const bool waitFlag)
{ {
...@@ -1661,7 +1672,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, ...@@ -1661,7 +1672,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
pSMB->Fid = smb_file_id; /* netfid stays le */ pSMB->Fid = smb_file_id; /* netfid stays le */
if ((numLock != 0) || (numUnlock != 0)) { if ((numLock != 0) || (numUnlock != 0)) {
pSMB->Locks[0].Pid = cpu_to_le16(current->tgid); pSMB->Locks[0].Pid = cpu_to_le16(net_pid);
/* BB where to store pid high? */ /* BB where to store pid high? */
pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len); pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len);
pSMB->Locks[0].LengthHigh = cpu_to_le32((u32)(len>>32)); pSMB->Locks[0].LengthHigh = cpu_to_le32((u32)(len>>32));
...@@ -1695,7 +1706,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, ...@@ -1695,7 +1706,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
int int
CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const int get_flag, const __u64 len, const __u16 smb_file_id, const __u32 net_pid, const int get_flag, const __u64 len,
struct file_lock *pLockData, const __u16 lock_type, struct file_lock *pLockData, const __u16 lock_type,
const bool waitFlag) const bool waitFlag)
{ {
...@@ -1755,7 +1766,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, ...@@ -1755,7 +1766,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
} else } else
pSMB->Timeout = 0; pSMB->Timeout = 0;
parm_data->pid = cpu_to_le32(current->tgid); parm_data->pid = cpu_to_le32(net_pid);
parm_data->start = cpu_to_le64(pLockData->fl_start); parm_data->start = cpu_to_le64(pLockData->fl_start);
parm_data->length = cpu_to_le64(len); /* normalize negative numbers */ parm_data->length = cpu_to_le64(len); /* normalize negative numbers */
......
...@@ -96,6 +96,7 @@ struct smb_vol { ...@@ -96,6 +96,7 @@ struct smb_vol {
bool noblocksnd:1; bool noblocksnd:1;
bool noautotune:1; bool noautotune:1;
bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
bool wine_mode:1;
unsigned int rsize; unsigned int rsize;
unsigned int wsize; unsigned int wsize;
unsigned int sockopt; unsigned int sockopt;
...@@ -1299,6 +1300,10 @@ cifs_parse_mount_options(char *options, const char *devname, ...@@ -1299,6 +1300,10 @@ cifs_parse_mount_options(char *options, const char *devname,
vol->server_ino = 1; vol->server_ino = 1;
} else if (strnicmp(data, "noserverino", 9) == 0) { } else if (strnicmp(data, "noserverino", 9) == 0) {
vol->server_ino = 0; vol->server_ino = 0;
} else if (strnicmp(data, "wine", 4) == 0) {
vol->wine_mode = 1;
vol->mand_lock = 1;
vol->direct_io = 1;
} else if (strnicmp(data, "cifsacl", 7) == 0) { } else if (strnicmp(data, "cifsacl", 7) == 0) {
vol->cifs_acl = 1; vol->cifs_acl = 1;
} else if (strnicmp(data, "nocifsacl", 9) == 0) { } else if (strnicmp(data, "nocifsacl", 9) == 0) {
...@@ -2197,6 +2202,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info, ...@@ -2197,6 +2202,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info,
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC;
if (pvolume_info->mand_lock) if (pvolume_info->mand_lock)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL;
if (pvolume_info->wine_mode)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_WINE_MODE;
if (pvolume_info->cifs_acl) if (pvolume_info->cifs_acl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
if (pvolume_info->override_uid) if (pvolume_info->override_uid)
......
...@@ -570,7 +570,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, ...@@ -570,7 +570,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
pdev->minor = pdev->minor =
cpu_to_le64(MINOR(device_number)); cpu_to_le64(MINOR(device_number));
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
fileHandle, fileHandle, current->tgid,
sizeof(struct win_dev), sizeof(struct win_dev),
0, &bytes_written, (char *)pdev, 0, &bytes_written, (char *)pdev,
NULL, 0); NULL, 0);
...@@ -581,7 +581,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, ...@@ -581,7 +581,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
pdev->minor = pdev->minor =
cpu_to_le64(MINOR(device_number)); cpu_to_le64(MINOR(device_number));
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
fileHandle, fileHandle, current->tgid,
sizeof(struct win_dev), sizeof(struct win_dev),
0, &bytes_written, (char *)pdev, 0, &bytes_written, (char *)pdev,
NULL, 0); NULL, 0);
......
...@@ -748,6 +748,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -748,6 +748,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
bool wait_flag = false; bool wait_flag = false;
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *tcon; struct cifsTconInfo *tcon;
__u32 netpid;
__u16 netfid; __u16 netfid;
__u8 lockType = LOCKING_ANDX_LARGE_FILES; __u8 lockType = LOCKING_ANDX_LARGE_FILES;
bool posix_locking = 0; bool posix_locking = 0;
...@@ -810,6 +811,14 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -810,6 +811,14 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
} }
netfid = ((struct cifsFileInfo *)file->private_data)->netfid; netfid = ((struct cifsFileInfo *)file->private_data)->netfid;
if ((cmd & CIFS_NOPOSIXBRL_READ) &&
(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE))
netpid = ((struct cifsFileInfo *)file->private_data)->pid;
else
netpid = current->tgid;
cmd &= ~CIFS_NOPOSIXBRL_READ;
if ((tcon->ses->capabilities & CAP_UNIX) && if ((tcon->ses->capabilities & CAP_UNIX) &&
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
...@@ -824,7 +833,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -824,7 +833,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
posix_lock_type = CIFS_RDLCK; posix_lock_type = CIFS_RDLCK;
else else
posix_lock_type = CIFS_WRLCK; posix_lock_type = CIFS_WRLCK;
rc = CIFSSMBPosixLock(xid, tcon, netfid, 1 /* get */, rc = CIFSSMBPosixLock(xid, tcon, netfid, netpid, 1 /* get */,
length, pfLock, length, pfLock,
posix_lock_type, wait_flag); posix_lock_type, wait_flag);
FreeXid(xid); FreeXid(xid);
...@@ -832,10 +841,10 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -832,10 +841,10 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
} }
/* BB we could chain these into one lock request BB */ /* BB we could chain these into one lock request BB */
rc = CIFSSMBLock(xid, tcon, netfid, length, pfLock->fl_start, rc = CIFSSMBLock(xid, tcon, netfid, netpid, length, pfLock->fl_start,
0, 1, lockType, 0 /* wait flag */ ); 0, 1, lockType, 0 /* wait flag */ );
if (rc == 0) { if (rc == 0) {
rc = CIFSSMBLock(xid, tcon, netfid, length, rc = CIFSSMBLock(xid, tcon, netfid, netpid, length,
pfLock->fl_start, 1 /* numUnlock */ , pfLock->fl_start, 1 /* numUnlock */ ,
0 /* numLock */ , lockType, 0 /* numLock */ , lockType,
0 /* wait flag */ ); 0 /* wait flag */ );
...@@ -852,13 +861,14 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -852,13 +861,14 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if (lockType & LOCKING_ANDX_SHARED_LOCK) { if (lockType & LOCKING_ANDX_SHARED_LOCK) {
pfLock->fl_type = F_WRLCK; pfLock->fl_type = F_WRLCK;
} else { } else {
rc = CIFSSMBLock(xid, tcon, netfid, length, rc = CIFSSMBLock(xid, tcon, netfid, netpid,
pfLock->fl_start, 0, 1, length, pfLock->fl_start, 0, 1,
lockType | LOCKING_ANDX_SHARED_LOCK, lockType | LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */ ); 0 /* wait flag */ );
if (rc == 0) { if (rc == 0) {
rc = CIFSSMBLock(xid, tcon, netfid, rc = CIFSSMBLock(xid, tcon, netfid,
length, pfLock->fl_start, 1, 0, netpid, length,
pfLock->fl_start, 1, 0,
lockType | lockType |
LOCKING_ANDX_SHARED_LOCK, LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */ ); 0 /* wait flag */ );
...@@ -896,7 +906,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -896,7 +906,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if (numUnlock == 1) if (numUnlock == 1)
posix_lock_type = CIFS_UNLCK; posix_lock_type = CIFS_UNLCK;
rc = CIFSSMBPosixLock(xid, tcon, netfid, 0 /* set */, rc = CIFSSMBPosixLock(xid, tcon, netfid, netpid, 0 /* set */,
length, pfLock, length, pfLock,
posix_lock_type, wait_flag); posix_lock_type, wait_flag);
} else { } else {
...@@ -904,7 +914,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -904,7 +914,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
(struct cifsFileInfo *)file->private_data; (struct cifsFileInfo *)file->private_data;
if (numLock) { if (numLock) {
rc = CIFSSMBLock(xid, tcon, netfid, length, rc = CIFSSMBLock(xid, tcon, netfid, netpid, length,
pfLock->fl_start, pfLock->fl_start,
0, numLock, lockType, wait_flag); 0, numLock, lockType, wait_flag);
...@@ -926,14 +936,15 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -926,14 +936,15 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
(pfLock->fl_start + length) >= (pfLock->fl_start + length) >=
(li->offset + li->length)) { (li->offset + li->length)) {
stored_rc = CIFSSMBLock(xid, tcon, stored_rc = CIFSSMBLock(xid, tcon,
netfid, netfid, netpid,
li->length, li->offset, li->length, li->offset,
1, 0, li->type, false); 1, 0, li->type, false);
if (stored_rc) if (stored_rc)
rc = stored_rc; rc = stored_rc;
else {
list_del(&li->llist); list_del(&li->llist);
kfree(li); kfree(li);
}
} }
} }
mutex_unlock(&fid->lock_mutex); mutex_unlock(&fid->lock_mutex);
...@@ -991,6 +1002,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -991,6 +1002,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
int xid, long_op; int xid, long_op;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode); struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode);
__u32 netpid;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
...@@ -1004,6 +1016,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -1004,6 +1016,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
return -EBADF; return -EBADF;
open_file = (struct cifsFileInfo *) file->private_data; open_file = (struct cifsFileInfo *) file->private_data;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
netpid = open_file->pid;
else
netpid = current->tgid;
rc = generic_write_checks(file, poffset, &write_size, 0); rc = generic_write_checks(file, poffset, &write_size, 0);
if (rc) if (rc)
return rc; return rc;
...@@ -1041,7 +1058,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -1041,7 +1058,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
} }
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
open_file->netfid, open_file->netfid, netpid,
min_t(const int, cifs_sb->wsize, min_t(const int, cifs_sb->wsize,
write_size - total_written), write_size - total_written),
*poffset, &bytes_written, *poffset, &bytes_written,
...@@ -1094,6 +1111,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1094,6 +1111,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
int xid, long_op; int xid, long_op;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode); struct cifsInodeInfo *cifsi = CIFS_I(file->f_path.dentry->d_inode);
__u32 netpid;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
...@@ -1106,6 +1124,11 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1106,6 +1124,11 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
return -EBADF; return -EBADF;
open_file = (struct cifsFileInfo *)file->private_data; open_file = (struct cifsFileInfo *)file->private_data;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
netpid = open_file->pid;
else
netpid = current->tgid;
xid = GetXid(); xid = GetXid();
long_op = cifs_write_timeout(cifsi, *poffset); long_op = cifs_write_timeout(cifsi, *poffset);
...@@ -1152,12 +1175,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1152,12 +1175,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
total_written; total_written;
iov[1].iov_len = len; iov[1].iov_len = len;
rc = CIFSSMBWrite2(xid, pTcon, rc = CIFSSMBWrite2(xid, pTcon,
open_file->netfid, len, open_file->netfid,
*poffset, &bytes_written, netpid, len, *poffset,
iov, 1, long_op); &bytes_written, iov,
1, long_op);
} else } else
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
open_file->netfid, open_file->netfid, netpid,
min_t(const int, cifs_sb->wsize, min_t(const int, cifs_sb->wsize,
write_size - total_written), write_size - total_written),
*poffset, &bytes_written, *poffset, &bytes_written,
...@@ -1393,6 +1417,7 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -1393,6 +1417,7 @@ static int cifs_writepages(struct address_space *mapping,
int rc = 0; int rc = 0;
int scanned = 0; int scanned = 0;
int xid, long_op; int xid, long_op;
__u32 netpid;
cifs_sb = CIFS_SB(mapping->host->i_sb); cifs_sb = CIFS_SB(mapping->host->i_sb);
...@@ -1532,13 +1557,18 @@ retry: ...@@ -1532,13 +1557,18 @@ retry:
* we used to still be valid * we used to still be valid
*/ */
open_file = find_writable_file(CIFS_I(mapping->host)); open_file = find_writable_file(CIFS_I(mapping->host));
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
netpid = open_file->pid;
else
netpid = current->tgid;
if (!open_file) { if (!open_file) {
cERROR(1, ("No writable handles for inode")); cERROR(1, ("No writable handles for inode"));
rc = -EBADF; rc = -EBADF;
} else { } else {
long_op = cifs_write_timeout(cifsi, offset); long_op = cifs_write_timeout(cifsi, offset);
rc = CIFSSMBWrite2(xid, cifs_sb->tcon, rc = CIFSSMBWrite2(xid, cifs_sb->tcon,
open_file->netfid, open_file->netfid, netpid,
bytes_to_write, offset, bytes_to_write, offset,
&bytes_written, iov, n_iov, &bytes_written, iov, n_iov,
long_op); long_op);
...@@ -1783,6 +1813,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1783,6 +1813,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
char *smb_read_data; char *smb_read_data;
char __user *current_offset; char __user *current_offset;
struct smb_com_read_rsp *pSMBr; struct smb_com_read_rsp *pSMBr;
__u32 netpid;
xid = GetXid(); xid = GetXid();
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
...@@ -1795,6 +1826,11 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1795,6 +1826,11 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
} }
open_file = (struct cifsFileInfo *)file->private_data; open_file = (struct cifsFileInfo *)file->private_data;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
netpid = open_file->pid;
else
netpid = current->tgid;
if ((file->f_flags & O_ACCMODE) == O_WRONLY) if ((file->f_flags & O_ACCMODE) == O_WRONLY)
cFYI(1, ("attempting read on write only file instance")); cFYI(1, ("attempting read on write only file instance"));
...@@ -1814,7 +1850,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1814,7 +1850,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
break; break;
} }
rc = CIFSSMBRead(xid, pTcon, rc = CIFSSMBRead(xid, pTcon,
open_file->netfid, open_file->netfid, netpid,
current_read_size, *poffset, current_read_size, *poffset,
&bytes_read, &smb_read_data, &bytes_read, &smb_read_data,
&buf_type); &buf_type);
...@@ -1864,6 +1900,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1864,6 +1900,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
char *current_offset; char *current_offset;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
__u32 netpid;
xid = GetXid(); xid = GetXid();
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
...@@ -1876,6 +1913,11 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1876,6 +1913,11 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
} }
open_file = (struct cifsFileInfo *)file->private_data; open_file = (struct cifsFileInfo *)file->private_data;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
netpid = open_file->pid;
else
netpid = current->tgid;
if ((file->f_flags & O_ACCMODE) == O_WRONLY) if ((file->f_flags & O_ACCMODE) == O_WRONLY)
cFYI(1, ("attempting read on write only file instance")); cFYI(1, ("attempting read on write only file instance"));
...@@ -1900,7 +1942,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1900,7 +1942,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
break; break;
} }
rc = CIFSSMBRead(xid, pTcon, rc = CIFSSMBRead(xid, pTcon,
open_file->netfid, open_file->netfid, netpid,
current_read_size, *poffset, current_read_size, *poffset,
&bytes_read, &current_offset, &bytes_read, &current_offset,
&buf_type); &buf_type);
...@@ -2002,6 +2044,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2002,6 +2044,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
struct pagevec lru_pvec; struct pagevec lru_pvec;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
__u32 netpid;
xid = GetXid(); xid = GetXid();
if (file->private_data == NULL) { if (file->private_data == NULL) {
...@@ -2013,6 +2056,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2013,6 +2056,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_WINE_MODE)
netpid = open_file->pid;
else
netpid = current->tgid;
pagevec_init(&lru_pvec, 0); pagevec_init(&lru_pvec, 0);
cFYI(DBG2, ("rpages: num pages %d", num_pages)); cFYI(DBG2, ("rpages: num pages %d", num_pages));
for (i = 0; i < num_pages; ) { for (i = 0; i < num_pages; ) {
...@@ -2059,10 +2107,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2059,10 +2107,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
} }
rc = CIFSSMBRead(xid, pTcon, rc = CIFSSMBRead(xid, pTcon,
open_file->netfid, open_file->netfid, netpid,
read_size, offset, read_size, offset, &bytes_read,
&bytes_read, &smb_read_data, &smb_read_data, &buf_type);
&buf_type);
/* BB more RC checks ? */ /* BB more RC checks ? */
if (rc == -EAGAIN) { if (rc == -EAGAIN) {
if (smb_read_data) { if (smb_read_data) {
...@@ -2345,8 +2392,9 @@ cifs_oplock_break(struct slow_work *work) ...@@ -2345,8 +2392,9 @@ cifs_oplock_break(struct slow_work *work)
* disconnected since oplock already released by the server * disconnected since oplock already released by the server
*/ */
if (!cfile->closePend && !cfile->oplock_break_cancelled) { if (!cfile->closePend && !cfile->oplock_break_cancelled) {
rc = CIFSSMBLock(0, cifs_sb->tcon, cfile->netfid, 0, 0, 0, 0, rc = CIFSSMBLock(0, cifs_sb->tcon, cfile->netfid, cfile->pid,
LOCKING_ANDX_OPLOCK_RELEASE, false); 0, 0, 0, 0, LOCKING_ANDX_OPLOCK_RELEASE,
false);
cFYI(1, ("Oplock release rc = %d", rc)); cFYI(1, ("Oplock release rc = %d", rc));
} }
} }
......
...@@ -304,7 +304,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path, ...@@ -304,7 +304,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,
if (rc == 0) { if (rc == 0) {
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
/* Read header */ /* Read header */
rc = CIFSSMBRead(xid, pTcon, netfid, rc = CIFSSMBRead(xid, pTcon, netfid, current->tgid,
24 /* length */, 0 /* offset */, 24 /* length */, 0 /* offset */,
&bytes_read, &pbuf, &buf_type); &bytes_read, &pbuf, &buf_type);
if ((rc == 0) && (bytes_read >= 8)) { if ((rc == 0) && (bytes_read >= 8)) {
...@@ -1599,8 +1599,9 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, ...@@ -1599,8 +1599,9 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
cFYI(1, ("SetFSize for attrs rc = %d", rc)); cFYI(1, ("SetFSize for attrs rc = %d", rc));
if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
unsigned int bytes_written; unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, nfid, 0, attrs->ia_size, rc = CIFSSMBWrite(xid, pTcon, nfid, npid,
&bytes_written, NULL, NULL, 1); 0, attrs->ia_size, &bytes_written,
NULL, NULL, 1);
cFYI(1, ("Wrt seteof rc %d", rc)); cFYI(1, ("Wrt seteof rc %d", rc));
} }
} else } else
...@@ -1628,7 +1629,8 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, ...@@ -1628,7 +1629,8 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
CIFS_MOUNT_MAP_SPECIAL_CHR); CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc == 0) { if (rc == 0) {
unsigned int bytes_written; unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, netfid, 0, rc = CIFSSMBWrite(xid, pTcon, netfid,
current->tgid, 0,
attrs->ia_size, attrs->ia_size,
&bytes_written, NULL, &bytes_written, NULL,
NULL, 1); NULL, 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment