diff options
author | Pavel Shilovsky <piastryyy@gmail.com> | 2010-04-05 01:59:14 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-04-06 13:24:26 -0400 |
commit | f05337c6ac48d19d354e0640a8eb8fc884f82bcc (patch) | |
tree | 7be4407febc50dba022112281f1f6d04eb2a5a22 /fs/cifs | |
parent | 6513a81e9325d712f1bfb9a1d7b750134e49ff18 (diff) |
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')
-rw-r--r-- | fs/cifs/cifssmb.c | 15 | ||||
-rw-r--r-- | fs/cifs/file.c | 28 |
2 files changed, 40 insertions, 3 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index f213b8ae43c1..184a399749a6 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1810,8 +1810,21 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, | |||
1810 | } | 1810 | } |
1811 | parm_data = (struct cifs_posix_lock *) | 1811 | parm_data = (struct cifs_posix_lock *) |
1812 | ((char *)&pSMBr->hdr.Protocol + data_offset); | 1812 | ((char *)&pSMBr->hdr.Protocol + data_offset); |
1813 | if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK)) | 1813 | if (parm_data->lock_type == __constant_cpu_to_le16(CIFS_UNLCK)) |
1814 | pLockData->fl_type = F_UNLCK; | 1814 | pLockData->fl_type = F_UNLCK; |
1815 | else { | ||
1816 | if (parm_data->lock_type == | ||
1817 | __constant_cpu_to_le16(CIFS_RDLCK)) | ||
1818 | pLockData->fl_type = F_RDLCK; | ||
1819 | else if (parm_data->lock_type == | ||
1820 | __constant_cpu_to_le16(CIFS_WRLCK)) | ||
1821 | pLockData->fl_type = F_WRLCK; | ||
1822 | |||
1823 | pLockData->fl_start = parm_data->start; | ||
1824 | pLockData->fl_end = parm_data->start + | ||
1825 | parm_data->length - 1; | ||
1826 | pLockData->fl_pid = parm_data->pid; | ||
1827 | } | ||
1815 | } | 1828 | } |
1816 | 1829 | ||
1817 | plk_err_exit: | 1830 | plk_err_exit: |
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) | |||
838 | 838 | ||
839 | } else { | 839 | } else { |
840 | /* if rc == ERR_SHARING_VIOLATION ? */ | 840 | /* if rc == ERR_SHARING_VIOLATION ? */ |
841 | rc = 0; /* do not change lock type to unlock | 841 | rc = 0; |
842 | since range in use */ | 842 | |
843 | if (lockType & LOCKING_ANDX_SHARED_LOCK) { | ||
844 | pfLock->fl_type = F_WRLCK; | ||
845 | } else { | ||
846 | rc = CIFSSMBLock(xid, tcon, netfid, length, | ||
847 | pfLock->fl_start, 0, 1, | ||
848 | lockType | LOCKING_ANDX_SHARED_LOCK, | ||
849 | 0 /* wait flag */); | ||
850 | if (rc == 0) { | ||
851 | rc = CIFSSMBLock(xid, tcon, netfid, | ||
852 | length, pfLock->fl_start, 1, 0, | ||
853 | lockType | | ||
854 | LOCKING_ANDX_SHARED_LOCK, | ||
855 | 0 /* wait flag */); | ||
856 | pfLock->fl_type = F_RDLCK; | ||
857 | if (rc != 0) | ||
858 | cERROR(1, ("Error unlocking " | ||
859 | "previously locked range %d " | ||
860 | "during test of lock", rc)); | ||
861 | rc = 0; | ||
862 | } else { | ||
863 | pfLock->fl_type = F_WRLCK; | ||
864 | rc = 0; | ||
865 | } | ||
866 | } | ||
843 | } | 867 | } |
844 | 868 | ||
845 | FreeXid(xid); | 869 | FreeXid(xid); |