summaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorPavel Shilovsky2010-04-05 07:59:14 +0200
committerSteve French2010-04-06 19:24:26 +0200
commitf05337c6ac48d19d354e0640a8eb8fc884f82bcc (patch)
tree7be4407febc50dba022112281f1f6d04eb2a5a22 /fs/cifs/file.c
parentcifs: Fix a kernel BUG with remote OS/2 server (try #3) (diff)
downloadkernel-qcow2-linux-f05337c6ac48d19d354e0640a8eb8fc884f82bcc.tar.gz
kernel-qcow2-linux-f05337c6ac48d19d354e0640a8eb8fc884f82bcc.tar.xz
kernel-qcow2-linux-f05337c6ac48d19d354e0640a8eb8fc884f82bcc.zip
not overwriting file_lock structure after GET_LK
If we have preventing lock, cifs should overwrite file_lock structure with info about preventing lock. If we haven't preventing lock, cifs should leave it unchanged except for the lock type (change it to F_UNLCK). Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com> Reviewed-by: Jeff Layton <jlayton@samba.org> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index ca2ba7a0193c..d9e86504b9d4 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -838,8 +838,32 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
} else {
/* if rc == ERR_SHARING_VIOLATION ? */
- rc = 0; /* do not change lock type to unlock
- since range in use */
+ rc = 0;
+
+ if (lockType & LOCKING_ANDX_SHARED_LOCK) {
+ pfLock->fl_type = F_WRLCK;
+ } else {
+ rc = CIFSSMBLock(xid, tcon, netfid, length,
+ pfLock->fl_start, 0, 1,
+ lockType | LOCKING_ANDX_SHARED_LOCK,
+ 0 /* wait flag */);
+ if (rc == 0) {
+ rc = CIFSSMBLock(xid, tcon, netfid,
+ length, pfLock->fl_start, 1, 0,
+ lockType |
+ LOCKING_ANDX_SHARED_LOCK,
+ 0 /* wait flag */);
+ pfLock->fl_type = F_RDLCK;
+ if (rc != 0)
+ cERROR(1, ("Error unlocking "
+ "previously locked range %d "
+ "during test of lock", rc));
+ rc = 0;
+ } else {
+ pfLock->fl_type = F_WRLCK;
+ rc = 0;
+ }
+ }
}
FreeXid(xid);