CIFS: Add rwpidforward mount option (try #2)
Subsystems (2)
PATCH 1/1 CIFS: Add rwpidforward mount option (try #2)
Add rwpidforward mount option that switches on a mode when we forward pid of a process who opened a file to any read and write operation.
This can prevent applications like WINE from failing on read or write operation on a previously locked file region from the same netfd from another process if we use mandatory brlock style.
It is actual for WINE because during a run of WINE program two processes work on the same netfd - share the same file struct between several VFS fds:
1) WINE-server does open and lock;
2) WINE-application does read and write.
--- fs/cifs/README | 3 ++ fs/cifs/cifs_fs_sb.h | 1 + fs/cifs/cifsfs.c | 8 ++++++ fs/cifs/cifsproto.h | 21 ++++++++------- fs/cifs/cifssmb.c | 31 +++++++++++++++------- fs/cifs/connect.c | 5 +++ fs/cifs/dir.c | 4 +- fs/cifs/file.c | 69 ++++++++++++++++++++++++++++++++++++++----------- fs/cifs/inode.c | 10 ++++--- fs/cifs/link.c | 6 ++-- 10 files changed, 113 insertions(+), 45 deletions(-)
fs/cifs/README +3 -0
@@ -457,6 +457,9 @@ A partial list of the supported mount options follows: otherwise - read from the server. All written data are stored in the cache, but if the client doesn't have Exclusive Oplock, it writes the data to the server. + rwpidforward Forward pid of a process who opened a file to any read or write + operation on that file. This revent application like WINE + from failing on read and write if we use mandatory brlock style. acl Allow setfacl and getfacl to manage posix ACLs if server supports them. (default) noacl Do not allow setfacl and getfacl calls on this mount
fs/cifs/cifs_fs_sb.h +1 -0
@@ -43,6 +43,7 @@#define CIFS_MOUNT_MF_SYMLINKS 0x10000/* Minshall+French Symlinks enabled */ #define CIFS_MOUNT_MULTIUSER 0x20000/* multiuser mount */ #define CIFS_MOUNT_STRICT_IO 0x40000/* strict cache mode */ +#define CIFS_MOUNT_RWPIDFORWARD 0x80000/* use pid forwarding for rw */ struct cifs_sb_info {struct rb_root tlink_tree;
fs/cifs/cifsfs.c +8 -0
@@ -460,6 +460,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)seq_printf (s,",nocase" );if (tcon->retry)seq_printf (s,",hard" ); +if (tcon->unix_ext) +seq_printf (s,",unix" ); +else +seq_printf (s,",nounix" );if (cifs_sb->prepath)seq_printf (s,",prepath=%s" , cifs_sb->prepath);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS )
@@ -468,6 +472,10 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)seq_printf (s,",setuids" );if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM )seq_printf (s,",serverino" ); +if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_RWPIDFORWARD ) +seq_printf (s,",rwpidforward" ); +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" );if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR )
fs/cifs/cifsproto.h +11 -10
@@ -335,18 +335,19 @@ extern int CIFSSMBFlush(const int xid, struct cifs_tcon *tcon, const int smb_file_id);extern int CIFSSMBRead (const int xid,struct cifs_tcon *tcon, -const int netfid,unsigned int count, -const __u64 lseek,unsigned int *nbytes,char **buf, -int *return_buf_type); +const int netfid,const __u32 netpid, +unsigned int count,const __u64 lseek, +unsigned int *nbytes,char **buf,int *return_buf_type);extern int CIFSSMBWrite (const int xid,struct cifs_tcon *tcon, -const int netfid,const unsigned int count, -const __u64 lseek,unsigned int *nbytes, -const char *buf,const char __user *ubuf, -const int long_op); +const int netfid,const __u32 netpid, +const unsigned int count,const __u64 lseek, +unsigned int *nbytes,const char *buf, +const char __user *ubuf,const int long_op);extern int CIFSSMBWrite2 (const int xid,struct cifs_tcon *tcon, -const int netfid,const unsigned int count, -const __u64 offset,unsigned int *nbytes, -struct kvec *iov,const int nvec,const int long_op); +const int netfid,const __u32 netpid, +const unsigned int count,const __u64 offset, +unsigned int *nbytes,struct kvec *iov,const int nvec, +const int long_op); extern int CIFSGetSrvInodeNumber(const int xid, struct cifs_tcon *tcon, const unsigned char *searchName, __u64 *inode_number, const struct nls_table *nls_codepage,
fs/cifs/cifssmb.c +21 -10
@@ -1380,8 +1380,8 @@ openRetry:int CIFSSMBRead (const int xid,struct cifs_tcon *tcon,const int netfid, -const unsigned int count,const __u64 lseek,unsigned int *nbytes, -char **buf,int *pbuf_type) +const __u32 netpid,const unsigned int count,const __u64 lseek, +unsigned int *nbytes,char **buf,int *pbuf_type) {int rc = -EACCES ;READ_REQ *pSMB =NULL ;
@@ -1407,6 +1407,9 @@ CIFSSMBRead(const int xid, struct cifs_tcon *tcon, const int netfid,if (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 */ if (tcon->ses->server ==NULL )return -ECONNABORTED ;
@@ -1484,10 +1487,10 @@ CIFSSMBRead(const int xid, struct cifs_tcon *tcon, const int netfid,int -CIFSSMBWrite (const int xid,struct cifs_tcon *tcon, -const int netfid,const unsigned int count, -const __u64 offset,unsigned int *nbytes,const char *buf, -const char __user *ubuf,const int long_op) +CIFSSMBWrite (const int xid,struct cifs_tcon *tcon,const int netfid, +const __u32 netpid,const unsigned int count,const __u64 offset, +unsigned int *nbytes,const char *buf,const char __user *ubuf, +const int long_op) {int rc = -EACCES ;WRITE_REQ *pSMB =NULL ;
@@ -1516,6 +1519,10 @@ CIFSSMBWrite(const int xid, struct cifs_tcon *tcon, (void **) &pSMBr);if (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 */ if (tcon->ses->server ==NULL )return -ECONNABORTED ;
@@ -1603,10 +1610,10 @@ CIFSSMBWrite(const int xid, struct cifs_tcon *tcon, }int -CIFSSMBWrite2 (const int xid,struct cifs_tcon *tcon, -const int netfid,const unsigned int count, -const __u64 offset,unsigned int *nbytes,struct kvec *iov, -int n_vec,const int long_op) +CIFSSMBWrite2 (const int xid,struct cifs_tcon *tcon,const int netfid, +const __u32 netpid,const unsigned int count,const __u64 offset, +unsigned int *nbytes,struct kvec *iov,int n_vec, +const int long_op) {int rc = -EACCES ;WRITE_REQ *pSMB =NULL ;
@@ -1630,6 +1637,10 @@ CIFSSMBWrite2(const int xid, struct cifs_tcon *tcon, rc =small_smb_init (SMB_COM_WRITE_ANDX , wct, tcon, (void **) &pSMB);if (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 */ if (tcon->ses->server ==NULL )return -ECONNABORTED ;
fs/cifs/connect.c +5 -0
@@ -103,6 +103,7 @@ struct smb_vol { bool noautotune:1; bool nostrictsync:1; /* do not force expensive SMBflush on every sync */ bool fsc:1; /* enable fscache */ + bool rwpidforward:1; /* pid forward for rw */ bool mfsymlinks:1; /* use Minshall+French Symlinks */ bool multiuser:1; bool use_smb2:1; /* force smb2 use on mount instead of cifs */
@@ -1362,6 +1363,8 @@ cifs_parse_mount_options(char *options, const char *devname, vol->server_ino =1 ; }else if (strnicmp (data,"noserverino" ,9 ) ==0 ) { vol->server_ino =0 ; + }else if (strnicmp (data,"rwpidforward" ,4 ) ==0 ) { + vol->rwpidforward =1 ; }else if (strnicmp (data,"cifsacl" ,7 ) ==0 ) { vol->cifs_acl =1 ; }else if (strnicmp (data,"nocifsacl" ,9 ) ==0 ) {
@@ -2643,6 +2646,8 @@ static void setup_cifs_sb(struct smb_vol *pvolume_info, cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_NOSSYNC ;if (pvolume_info->mand_lock) cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_NOPOSIXBRL ; +if (pvolume_info->rwpidforward) + cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_RWPIDFORWARD ;if (pvolume_info->cifs_acl) cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_CIFS_ACL ;if (pvolume_info->override_uid)
fs/cifs/dir.c +2 -2
@@ -446,7 +446,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, pdev->minor =cpu_to_le64 (MINOR (device_number)); rc =CIFSSMBWrite (xid, pTcon, - fileHandle, + fileHandle, current->tgid,sizeof (struct win_dev ),0 , &bytes_written, (char *)pdev,NULL ,0 );
@@ -457,7 +457,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, pdev->minor =cpu_to_le64 (MINOR (device_number)); rc =CIFSSMBWrite (xid, pTcon, - fileHandle, + fileHandle, current->tgid,sizeof (struct win_dev ),0 , &bytes_written, (char *)pdev,NULL ,0 );
fs/cifs/file.c +53 -16
184 lines not on this page · raw message
fs/cifs/inode.c +6 -4
@@ -405,7 +405,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const unsigned char *path,if (rc ==0 ) {int buf_type =CIFS_NO_BUFFER ;/* Read header */ - rc =CIFSSMBRead (xid, tcon, netfid, + rc =CIFSSMBRead (xid, tcon, netfid, current->tgid,24 /* length */ ,0 /* offset */ , &bytes_read, &pbuf, &buf_type);if ((rc ==0 ) && (bytes_read >=8 )) {
@@ -1859,8 +1859,9 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,cFYI (1 ,"SetFSize for attrs rc = %d" , rc);if ((rc == -EINVAL ) || (rc == -EOPNOTSUPP )) {unsigned int bytes_written; - rc =CIFSSMBWrite (xid, pTcon, nfid,0 , attrs->ia_size, - &bytes_written,NULL ,NULL ,1 ); + rc =CIFSSMBWrite (xid, pTcon, nfid, npid, +0 , attrs->ia_size, &bytes_written, +NULL ,NULL ,1 );cFYI (1 ,"Wrt seteof rc %d" , rc); } }else
@@ -1895,7 +1896,8 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, CIFS_MOUNT_MAP_SPECIAL_CHR);if (rc ==0 ) {unsigned int bytes_written; - rc =CIFSSMBWrite (xid, pTcon, netfid,0 , + rc =CIFSSMBWrite (xid, pTcon, netfid, + current->tgid,0 , attrs->ia_size, &bytes_written,NULL ,NULL ,1 );
fs/cifs/link.c +3 -3
@@ -203,7 +203,7 @@ CIFSCreateMFSymLink(const int xid, struct cifs_tcon *tcon,return rc; } - rc =CIFSSMBWrite (xid, tcon, netfid, + rc =CIFSSMBWrite (xid, tcon, netfid, current->tgid,CIFS_MF_SYMLINK_FILE_SIZE /* length */ ,0 /* offset */ , &bytes_written, buf,NULL ,0 );
@@ -250,7 +250,7 @@ CIFSQueryMFSymLink(const int xid, struct cifs_tcon *tcon,return -ENOMEM ; pbuf = buf; - rc =CIFSSMBRead (xid, tcon, netfid, + rc =CIFSSMBRead (xid, tcon, netfid, current->tgid,CIFS_MF_SYMLINK_FILE_SIZE /* length */ ,0 /* offset */ , &bytes_read, &pbuf, &buf_type);
@@ -329,7 +329,7 @@ CIFSCheckMFSymlink(struct cifs_fattr *fattr, } pbuf = buf; - rc =CIFSSMBRead (xid, pTcon, netfid, + rc =CIFSSMBRead (xid, pTcon, netfid, current->tgid,CIFS_MF_SYMLINK_FILE_SIZE /* length */ ,0 /* offset */ , &bytes_read, &pbuf, &buf_type);
Signature · 1 line
1.7.1
Quoted 31 lines · On Mon, 18 Apr 2011 16:20:52 +0400 Pavel Shilovsky…
Add rwpidforward mount option that switches on a mode when we forward pid of a process who opened a file to any read and write operation.
This can prevent applications like WINE from failing on read or write operation on a previously locked file region from the same netfd from another process if we use mandatory brlock style.
It is actual for WINE because during a run of WINE program two processes work on the same netfd - share the same file struct between several VFS fds:
1) WINE-server does open and lock;
2) WINE-application does read and write.Signed-off-by Pavel Shilovsky <[email protected]>--- fs/cifs/README | 3 ++ fs/cifs/cifs_fs_sb.h | 1 + fs/cifs/cifsfs.c | 8 ++++++ fs/cifs/cifsproto.h | 21 ++++++++------- fs/cifs/cifssmb.c | 31 +++++++++++++++------- fs/cifs/connect.c | 5 +++ fs/cifs/dir.c | 4 +- fs/cifs/file.c | 69 ++++++++++++++++++++++++++++++++++++++----------- fs/cifs/inode.c | 10 ++++--- fs/cifs/link.c | 6 ++-- 10 files changed, 113 insertions(+), 45 deletions(-)fs/cifs/README +0
-0
fs/cifs/README A partial list of the supported mount options follows: · line 461
Quoted 5 lines
fs/cifs/README +2
-0@@ -457,6 +457,9 @@ A partial list of the supported mount options follows: otherwise - read from the server. All written data are stored in the cache, but if the client doesn't have Exclusive Oplock, it writes the data to the server. + rwpidforward Forward pid of a process who opened a file to any read or write + operation on that file. This revent application like WINE
^^^^^^ "prevents applications"
Quoted 4 lines
fs/cifs/README +1
-0+ from failing on read and write if we use mandatory brlock style. acl Allow setfacl and getfacl to manage posix ACLs if server supports them. (default) noacl Do not allow setfacl and getfacl calls on this mount
[...]
Quoted 17 lines
fs/cifs/README +6
-0@@ -1112,6 +1119,7 @@ static int cifs_writepages(struct address_space *mapping, struct pagevec pvec; int rc = 0; int scanned = 0; + __u32 netpid; int xid; cifs_sb = CIFS_SB(mapping->host->i_sb);@@ -1251,10 +1259,15 @@ retry_write: cERROR(1, "No writable handles for inode"); rc = -EBADF; } else { + if (cifs_sb->mnt_cifs_flags & + CIFS_MOUNT_RWPIDFORWARD) + netpid = open_file->pid; + else + netpid = current->tgid;
fs/cifs/README retry_write: · line 1273
Quoted 10 lines
fs/cifs/README +3
-3rc = CIFSSMBWrite2(xid, tcon, open_file->netfid, - bytes_to_write, offset, - &bytes_written, iov, n_iov, - 0); + netpid, bytes_to_write, + offset, &bytes_written, + iov, n_iov, 0); cifsFileInfo_put(open_file); }
^^^^^^^^^^^^^^^
When flushing data for writeback (writepage or writepages), I don't think we should care if a lock is held or by whom. The kernel has memory that needs to be freed and it wants to perform writes to make that happen.
I don't think these codepaths ought to care about the RWPIDFORWARD flag at all. I think you ought to try to make sure that writes in those cases use whatever pid will allow the writes to succeed.
Also, we should probably get Steve to comment on which patchset he intends to commit first. This one or the async writepages one. One of them will need to be respun on top of the other.
Signature · 1 line
Jeff Layton <[email protected]>
2011/4/18 Jeff Layton <[email protected]>:
Quoted 29 lines
Quoted 26 lines · On Mon, 18 Apr 2011 16:20:52 +0400 Pavel Shilovsky…
Add rwpidforward mount option that switches on a mode when we forward pid of a process who opened a file to any read and write operation.
This can prevent applications like WINE from failing on read or write operation on a previously locked file region from the same netfd from another process if we use mandatory brlock style.
It is actual for WINE because during a run of WINE program two processes work on the same netfd - share the same file struct between several VFS fds:
1) WINE-server does open and lock;
2) WINE-application does read and write.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/README | 3 ++fs/cifs/cifs_fs_sb.h| 1 +fs/cifs/cifsfs.c| 8 ++++++fs/cifs/cifsproto.h| 21 ++++++++-------fs/cifs/cifssmb.c| 31 +++++++++++++++-------fs/cifs/connect.c| 5 +++fs/cifs/dir.c| 4 +-fs/cifs/file.c | 69 ++++++++++++++++++++++++++++++++++++++----------- fs/cifs/inode.c | 10 ++++--- fs/cifs/link.c | 6 ++-- 10 files changed, 113 insertions(+), 45 deletions(-)
Quoted 12 lines
Quoted 10 lines
fs/cifs/README +0
-0@@ -457,6 +457,9 @@ A partial list of the supported mount options follows:otherwise - read from the server. All written data are stored in the cache, but if the client doesn't have Exclusive Oplock, it writes the data to the server.
+ rwpidforward Forward pid of a process who opened a file to any read or write
+ operation on that file. This revent application like WINE^^^^^^ "prevents applications"
Ok, thanks, will fix it.
Quoted 41 lines
Quoted 5 lines
+ from failing on read and write if we use mandatory brlock style. acl Allow setfacl and getfacl to manage posix ACLs if server supports them. (default)
noacl Do not allow setfacl and getfacl calls on this mount[...]
Quoted 17 lines
fs/cifs/README +6
-0@@ -1112,6 +1119,7 @@ static int cifs_writepages(struct address_space *mapping, struct pagevec pvec; int rc = 0; int scanned = 0; + __u32 netpid; int xid; cifs_sb = CIFS_SB(mapping->host->i_sb);@@ -1251,10 +1259,15 @@ retry_write: cERROR(1, "No writable handles for inode"); rc = -EBADF; } else { + if (cifs_sb->mnt_cifs_flags & + CIFS_MOUNT_RWPIDFORWARD) + netpid = open_file->pid; + else + netpid = current->tgid;fs/cifs/README retry_write: · line 1273
Quoted 10 lines
fs/cifs/README +3
-3rc = CIFSSMBWrite2(xid, tcon, open_file->netfid, - bytes_to_write, offset, - &bytes_written, iov, n_iov, - 0); + netpid, bytes_to_write, + offset, &bytes_written, + iov, n_iov, 0); cifsFileInfo_put(open_file); }^^^^^^^^^^^^^^^
When flushing data for writeback (writepage or writepages), I don't think we should care if a lock is held or by whom. The kernel has memory that needs to be freed and it wants to perform writes to make that happen.
Quoted 3 lines
I don't think these codepaths ought to care about the RWPIDFORWARD flag at all. I think you ought to try to make sure that writes in those cases use whatever pid will allow the writes to succeed.
Ok, we have an oplock, set brlock and do write - it succeed (stored in cache). Then we close a file, do flushing, and failes (because of wrong pid). Why not to forward a pid in this situation?
Signature · 2 lines
Best regards, Pavel Shilovsky.
Quoted 86 lines · On Mon, 18 Apr 2011 16:58:09 +0400 Pavel Shilovsky…
2011/4/18 Jeff Layton <[email protected]>:
Quoted 29 lines
Quoted 26 lines · On Mon, 18 Apr 2011 16:20:52 +0400 Pavel Shilovsky…
Add rwpidforward mount option that switches on a mode when we forward pid of a process who opened a file to any read and write operation.
This can prevent applications like WINE from failing on read or write operation on a previously locked file region from the same netfd from another process if we use mandatory brlock style.
It is actual for WINE because during a run of WINE program two processes work on the same netfd - share the same file struct between several VFS fds:
1) WINE-server does open and lock;
2) WINE-application does read and write.Signed-off-by Pavel Shilovsky <[email protected]>---
fs/cifs/README | 3 ++fs/cifs/cifs_fs_sb.h| 1 +fs/cifs/cifsfs.c| 8 ++++++fs/cifs/cifsproto.h| 21 ++++++++-------fs/cifs/cifssmb.c| 31 +++++++++++++++-------fs/cifs/connect.c| 5 +++fs/cifs/dir.c| 4 +-fs/cifs/file.c | 69 ++++++++++++++++++++++++++++++++++++++----------- fs/cifs/inode.c | 10 ++++--- fs/cifs/link.c | 6 ++-- 10 files changed, 113 insertions(+), 45 deletions(-)Quoted 12 lines
Quoted 10 lines
fs/cifs/README +0
-0@@ -457,6 +457,9 @@ A partial list of the supported mount options follows:otherwise - read from the server. All written data are stored in the cache, but if the client doesn't have Exclusive Oplock, it writes the data to the server.
+ rwpidforward Forward pid of a process who opened a file to any read or write
+ operation on that file. This revent application like WINE^^^^^^ "prevents applications"
Ok, thanks, will fix it.
Quoted 41 lines
Quoted 5 lines
+ from failing on read and write if we use mandatory brlock style. acl Allow setfacl and getfacl to manage posix ACLs if server supports them. (default)
noacl Do not allow setfacl and getfacl calls on this mount[...]
Quoted 17 lines
fs/cifs/README +6
-0@@ -1112,6 +1119,7 @@ static int cifs_writepages(struct address_space *mapping, struct pagevec pvec; int rc = 0; int scanned = 0; + __u32 netpid; int xid; cifs_sb = CIFS_SB(mapping->host->i_sb);@@ -1251,10 +1259,15 @@ retry_write: cERROR(1, "No writable handles for inode"); rc = -EBADF; } else { + if (cifs_sb->mnt_cifs_flags & + CIFS_MOUNT_RWPIDFORWARD) + netpid = open_file->pid; + else + netpid = current->tgid;fs/cifs/README retry_write: · line 1273
Quoted 10 lines
fs/cifs/README +3
-3rc = CIFSSMBWrite2(xid, tcon, open_file->netfid, - bytes_to_write, offset, - &bytes_written, iov, n_iov, - 0); + netpid, bytes_to_write, + offset, &bytes_written, + iov, n_iov, 0); cifsFileInfo_put(open_file); }^^^^^^^^^^^^^^^
When flushing data for writeback (writepage or writepages), I don't think we should care if a lock is held or by whom. The kernel has memory that needs to be freed and it wants to perform writes to make that happen.
Quoted 8 lines
Quoted 3 lines
I don't think these codepaths ought to care about the RWPIDFORWARD flag at all. I think you ought to try to make sure that writes in those cases use whatever pid will allow the writes to succeed.
Ok, we have an oplock, set brlock and do write - it succeed (stored in cache). Then we close a file, do flushing, and failes (because of wrong pid). Why not to forward a pid in this situation?
I think we should do whatever is necessary for that write to succeed. If that means forwarding the pid then that's fine. I just don't see why the RWPIDFORWARD flag should matter at all in that case.
Signature · 1 line
Jeff Layton <[email protected]>
2011/4/18 Jeff Layton <[email protected]>:
Quoted 4 lines
I think we should do whatever is necessary for that write to succeed. If that means forwarding the pid then that's fine. I just don't see why the RWPIDFORWARD flag should matter at all in that case.
Ok, I got it and absolutely agree that we should do it for writepages every time. We still have a problem when we negotiate mandatory locking style and a child succeeds doing writepages on a locked file region but I don't think it is a big problem.
Signature · 2 lines
Best regards, Pavel Shilovsky.
Pavel Shilovsky <piastry@...> writes:
Hi Pavel,
Quoted 4 lines
Add rwpidforward mount option that switches on a mode when we forward pid of a process who opened a file to any read and write operation.
Quoted 8 lines
This can prevent applications like WINE from failing on read or write operation on a previously locked file region from the same netfd from another process if we use mandatory brlock style.
It is actual for WINE because during a run of WINE program two processes work on the same netfd - share the same file struct between several VFS fds:
1) WINE-server does open and lock;
2) WINE-application does read and write.
I'm not sure I fully understand what problem you're trying to solve here. The Wine server should take care of all the locking-related operations and make sure the application process should have access to the file. I'm not familiar with exactly how this happens, but I'm not sure how this would be any different for CIFS-based file systems opposed to local file systems. I'm pretty sure it works fine for local file systems.
Can you elaborate what problem you're seeing that your patches fix?
Cheers,
Kai
PS: I'm not subscribed to this list, so please CC me :)
2011/5/2 Kai Blin <[email protected]>:
Quoted 24 lines
Pavel Shilovsky <piastry@...> writes:
Hi Pavel,
Quoted 4 lines
Add rwpidforward mount option that switches on a mode when we forward pid of a process who opened a file to any read and write operation.
Quoted 8 lines
This can prevent applications like WINE from failing on read or write operation on a previously locked file region from the same netfd from another process if we use mandatory brlock style.
It is actual for WINE because during a run of WINE program two processes work on the same netfd - share the same file struct between several VFS fds:
1) WINE-server does open and lock;
2) WINE-application does read and write.I'm not sure I fully understand what problem you're trying to solve here. The Wine server should take care of all the locking-related operations and make sure the application process should have access to the file. I'm not familiar with exactly how this happens, but I'm not sure how this would be any different for CIFS-based file systems opposed to local file systems. I'm pretty sure it works fine for local file systems.
Quoted 7 lines
Can you elaborate what problem you're seeing that your patches fix?
Cheers,
KaiPS: I'm not subscribed to this list, so please CC me :)
You are right - wineserver takes care about all these things if we work on local filesystem. But if we work on CIFS share the situation changes. When we negotiate mandatory locking style CIFS server compares pid of process who tries to do read/write with file with pid of byte-range lock (if one exists) on this area of the file. If pids don't match it fails operation. So, that's why I did this change - to do read and write operations with the pid of process who sets byte-range locks (wineserver). As the result, with this patch (I splited it into two) we do lock, write and read with the same pid and it works good.
Signature · 2 lines
Best regards, Pavel Shilovsky.