Commit f6d70937 authored by Pavel Shilovsky's avatar Pavel Shilovsky

Pull from cifs-2.6 repo for centos52

Implement WINE logic Fix losing locks during fork()
parent 6faf875a
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */ #define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */
#define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */ #define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */
#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_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 */
......
...@@ -348,6 +348,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) ...@@ -348,6 +348,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
seq_printf(s, ",domain=%s", seq_printf(s, ",domain=%s",
cifs_sb->tcon->ses->domainName); cifs_sb->tcon->ses->domainName);
} }
if (cifs_sb->tcon->unix_ext)
seq_printf(s, ",unix");
else
seq_printf(s, ",nounix");
} }
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
seq_printf(s, ",posixpaths"); seq_printf(s, ",posixpaths");
...@@ -357,6 +361,12 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) ...@@ -357,6 +361,12 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) || if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
!(cifs_sb->tcon->unix_ext)) !(cifs_sb->tcon->unix_ext))
seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
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)
seq_printf(s, ",directio");
seq_printf(s, ",rsize=%d", cifs_sb->rsize); seq_printf(s, ",rsize=%d", cifs_sb->rsize);
seq_printf(s, ",wsize=%d", cifs_sb->wsize); seq_printf(s, ",wsize=%d", cifs_sb->wsize);
} }
...@@ -647,7 +657,7 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf, ...@@ -647,7 +657,7 @@ static ssize_t cifs_sync_read(struct file *filp, char __user *buf,
if (!CIFS_I(filp->f_dentry->d_inode)->clientCanCacheRead if (!CIFS_I(filp->f_dentry->d_inode)->clientCanCacheRead
&& !posix_locking) { && !posix_locking) {
#endif #endif
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)
......
...@@ -306,6 +306,8 @@ struct cifsLockInfo { ...@@ -306,6 +306,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
*/ */
......
...@@ -286,16 +286,16 @@ extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon, ...@@ -286,16 +286,16 @@ extern int CIFSSMBClose(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,
......
...@@ -1397,8 +1397,8 @@ openRetry: ...@@ -1397,8 +1397,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;
...@@ -1419,6 +1419,9 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, ...@@ -1419,6 +1419,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;
...@@ -1500,7 +1503,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, ...@@ -1500,7 +1503,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)
{ {
...@@ -1524,6 +1527,10 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, ...@@ -1524,6 +1527,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;
...@@ -1607,7 +1614,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, ...@@ -1607,7 +1614,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)
{ {
...@@ -1626,6 +1633,10 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, ...@@ -1626,6 +1633,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;
......
...@@ -107,6 +107,7 @@ struct smb_vol { ...@@ -107,6 +107,7 @@ struct smb_vol {
unsigned nocase; /* request case insensitive filenames */ unsigned nocase; /* request case insensitive filenames */
unsigned nobrl; /* disable sending byte range locks to srv */ unsigned nobrl; /* disable sending byte range locks to srv */
unsigned mand_lock:1; /* send mandatory not posix byte range lock reqs */ unsigned mand_lock:1; /* send mandatory not posix byte range lock reqs */
bool wine_mode:1;
unsigned int rsize; unsigned int rsize;
unsigned int wsize; unsigned int wsize;
unsigned int sockopt; unsigned int sockopt;
...@@ -1285,6 +1286,10 @@ cifs_parse_mount_options(char *options, const char *devname, ...@@ -1285,6 +1286,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) {
...@@ -2160,6 +2165,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2160,6 +2165,8 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
if (volume_info.mand_lock) if (volume_info.mand_lock)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL;
if (volume_info.wine_mode)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_WINE_MODE;
if (volume_info.cifs_acl) if (volume_info.cifs_acl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
if (volume_info.override_uid) if (volume_info.override_uid)
......
...@@ -443,7 +443,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, int devic ...@@ -443,7 +443,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, int devic
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);
...@@ -454,7 +454,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, int devic ...@@ -454,7 +454,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, int devic
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);
......
...@@ -815,9 +815,16 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -815,9 +815,16 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
FreeXid(xid); FreeXid(xid);
return -EBADF; return -EBADF;
} }
netpid = ((struct cifsFileInfo *)file->private_data)->pid;
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 ((pTcon->ses->capabilities & CAP_UNIX) && if ((pTcon->ses->capabilities & CAP_UNIX) &&
(CIFS_UNIX_FCNTL_CAP & le64_to_cpu(pTcon->fsUnixInfo.Capability)) && (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(pTcon->fsUnixInfo.Capability)) &&
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
...@@ -938,11 +945,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -938,11 +945,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
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);
} }
} }
...@@ -965,6 +973,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -965,6 +973,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
int xid, long_op; int xid, long_op;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
__u32 netpid;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
cifs_sb = CIFS_SB(file->f_dentry->d_sb); cifs_sb = CIFS_SB(file->f_dentry->d_sb);
...@@ -982,6 +991,11 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -982,6 +991,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;
xid = GetXid(); xid = GetXid();
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
...@@ -1023,7 +1037,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data, ...@@ -1023,7 +1037,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,
...@@ -1089,6 +1103,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1089,6 +1103,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
int xid, long_op; int xid, long_op;
struct cifsFileInfo *open_file; struct cifsFileInfo *open_file;
__u32 netpid;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
cifs_sb = CIFS_SB(file->f_dentry->d_sb); cifs_sb = CIFS_SB(file->f_dentry->d_sb);
...@@ -1102,6 +1117,11 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1102,6 +1117,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();
if (*poffset > file->f_dentry->d_inode->i_size) if (*poffset > file->f_dentry->d_inode->i_size)
...@@ -1117,6 +1137,11 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1117,6 +1137,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();
if (*poffset > file->f_path.dentry->d_inode->i_size) if (*poffset > file->f_path.dentry->d_inode->i_size)
...@@ -1168,12 +1193,13 @@ static ssize_t cifs_write(struct file *file, const char *write_data, ...@@ -1168,12 +1193,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,
...@@ -1368,6 +1394,7 @@ static int cifs_writepages(struct address_space *mapping, ...@@ -1368,6 +1394,7 @@ static int cifs_writepages(struct address_space *mapping,
int rc = 0; int rc = 0;
int scanned = 0; int scanned = 0;
int xid; int xid;
__u32 netpid;
cifs_sb = CIFS_SB(mapping->host->i_sb); cifs_sb = CIFS_SB(mapping->host->i_sb);
...@@ -1527,12 +1554,17 @@ retry: ...@@ -1527,12 +1554,17 @@ 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 {
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,
1); 1);
...@@ -1771,6 +1803,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1771,6 +1803,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();
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
...@@ -1786,6 +1819,11 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1786,6 +1819,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"));
} }
...@@ -1805,7 +1843,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data, ...@@ -1805,7 +1843,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);
...@@ -1856,6 +1894,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1856,6 +1894,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();
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
...@@ -1871,6 +1910,11 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1871,6 +1910,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"));
...@@ -1895,7 +1939,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size, ...@@ -1895,7 +1939,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);
...@@ -2001,6 +2045,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2001,6 +2045,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) {
...@@ -2015,6 +2060,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2015,6 +2060,11 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
#endif #endif
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);
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
cFYI(1, ("rpages: num pages %d", num_pages)); cFYI(1, ("rpages: num pages %d", num_pages));
...@@ -2065,10 +2115,9 @@ static int cifs_readpages(struct file *file, struct address_space *mapping, ...@@ -2065,10 +2115,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) {
......
...@@ -263,8 +263,7 @@ static int decode_sfu_inode(struct inode *inode, __u64 size, ...@@ -263,8 +263,7 @@ static int decode_sfu_inode(struct inode *inode, __u64 size,
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, rc = CIFSSMBRead(xid, pTcon, netfid, current->tgid,
netfid,
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)) {
...@@ -1524,8 +1523,8 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1524,8 +1523,8 @@ int cifs_setattr(struct dentry *direntry, 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, rc = CIFSSMBWrite(xid, pTcon, nfid,
nfid, 0, attrs->ia_size, npid, 0, attrs->ia_size,
&bytes_written, NULL, NULL, &bytes_written, NULL, NULL,
1 /* 45 seconds */); 1 /* 45 seconds */);
cFYI(1, ("Wrt seteof rc %d", rc)); cFYI(1, ("Wrt seteof rc %d", rc));
...@@ -1558,7 +1557,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs) ...@@ -1558,7 +1557,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
if (rc == 0) { if (rc == 0) {
unsigned int bytes_written; unsigned int bytes_written;
rc = CIFSSMBWrite(xid, pTcon, rc = CIFSSMBWrite(xid, pTcon,
netfid, 0, netfid, current->tgid, 0,
attrs->ia_size, attrs->ia_size,
&bytes_written, NULL, &bytes_written, NULL,
NULL, 1 /* 45 sec */); NULL, 1 /* 45 sec */);
......
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