summaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorLinus Torvalds2010-04-08 20:58:14 +0200
committerLinus Torvalds2010-04-08 20:58:14 +0200
commit9ddd3a31aedcdb55d5509b595c04b187041c8adb (patch)
tree210582aade8b4342b2abfbc3682dd2014456d23b /fs/cifs/file.c
parentMerge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/gi... (diff)
parentnot overwriting file_lock structure after GET_LK (diff)
downloadkernel-qcow2-linux-9ddd3a31aedcdb55d5509b595c04b187041c8adb.tar.gz
kernel-qcow2-linux-9ddd3a31aedcdb55d5509b595c04b187041c8adb.tar.xz
kernel-qcow2-linux-9ddd3a31aedcdb55d5509b595c04b187041c8adb.zip
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6: not overwriting file_lock structure after GET_LK cifs: Fix a kernel BUG with remote OS/2 server (try #3) [CIFS] initialize nbytes at the beginning of CIFSSMBWrite() [CIFS] Add mmap for direct, nobrl cifs mount types
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 058b390d3da8..9b11a8f56f3a 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -839,8 +839,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);