Commit 48b10aec authored by Pavel Shilovsky's avatar Pavel Shilovsky

Fixes in 2.6.23

- oplock handling - F_GETLK
parent 425633bc
...@@ -961,9 +961,10 @@ static int cifs_oplock_thread(void *dummyarg) ...@@ -961,9 +961,10 @@ static int cifs_oplock_thread(void *dummyarg)
rc = CIFSSMBLock(0, pTcon, netfid, netpid, rc = CIFSSMBLock(0, pTcon, netfid, netpid,
0 /* len */ , 0 /* offset */, 0, 0 /* len */ , 0 /* offset */, 0,
0, LOCKING_ANDX_OPLOCK_RELEASE, 0, LOCKING_ANDX_OPLOCK_RELEASE,
0 /* wait flag */); 0 /* wait flag */,
cFYI(1, CIFS_I(inode)->clientCanCacheRead ?
("Oplock release rc = %d ", rc)); 1 : 0);
cFYI(1, ("Oplock release rc = %d", rc));
} }
} else } else
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
......
...@@ -281,7 +281,7 @@ extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, ...@@ -281,7 +281,7 @@ extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const __u16 netfid, const __u32 netpid, const __u64 len, const __u16 netfid, const __u32 netpid, const __u64 len,
const __u64 offset, const __u32 numUnlock, const __u64 offset, const __u32 numUnlock,
const __u32 numLock, const __u8 lockType, const __u32 numLock, const __u8 lockType,
const int waitFlag); const int waitFlag, const __u8 oplock_level);
extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const __u32 netpid, const int get_flag, const __u16 smb_file_id, const __u32 netpid, const int get_flag,
const __u64 len, struct file_lock *, const __u64 len, struct file_lock *,
......
...@@ -1694,7 +1694,8 @@ int ...@@ -1694,7 +1694,8 @@ int
CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const __u32 net_pid, const __u64 len, const __u16 smb_file_id, const __u32 net_pid, const __u64 len,
const __u64 offset, const __u32 numUnlock, const __u64 offset, const __u32 numUnlock,
const __u32 numLock, const __u8 lockType, const int waitFlag) const __u32 numLock, const __u8 lockType, const int waitFlag,
const __u8 oplock_level)
{ {
int rc = 0; int rc = 0;
LOCK_REQ *pSMB = NULL; LOCK_REQ *pSMB = NULL;
...@@ -1724,6 +1725,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, ...@@ -1724,6 +1725,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
pSMB->NumberOfLocks = cpu_to_le16(numLock); pSMB->NumberOfLocks = cpu_to_le16(numLock);
pSMB->NumberOfUnlocks = cpu_to_le16(numUnlock); pSMB->NumberOfUnlocks = cpu_to_le16(numUnlock);
pSMB->LockType = lockType; pSMB->LockType = lockType;
pSMB->OplockLevel = oplock_level;
pSMB->AndXCommand = 0xFF; /* none */ pSMB->AndXCommand = 0xFF; /* none */
pSMB->Fid = smb_file_id; /* netfid stays le */ pSMB->Fid = smb_file_id; /* netfid stays le */
......
...@@ -720,12 +720,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -720,12 +720,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
/* BB we could chain these into one lock request BB */ /* BB we could chain these into one lock request BB */
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length, pfLock->fl_start, rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length, pfLock->fl_start,
0, 1, lockType, 0 /* wait flag */ ); 0, 1, lockType, 0 /* wait flag */, 0);
if (rc == 0) { if (rc == 0) {
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length, rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start, 1 /* numUnlock */ , pfLock->fl_start, 1 /* numUnlock */ ,
0 /* numLock */ , lockType, 0 /* numLock */ , lockType,
0 /* wait flag */ ); 0 /* wait flag */, 0);
pfLock->fl_type = F_UNLCK; pfLock->fl_type = F_UNLCK;
if (rc != 0) if (rc != 0)
cERROR(1, ("Error unlocking previously locked " cERROR(1, ("Error unlocking previously locked "
...@@ -734,8 +734,32 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -734,8 +734,32 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
} else { } else {
/* if rc == ERR_SHARING_VIOLATION ? */ /* if rc == ERR_SHARING_VIOLATION ? */
rc = 0; /* do not change lock type to unlock rc = 0;
since range in use */
if (lockType & LOCKING_ANDX_SHARED_LOCK) {
pfLock->fl_type = F_WRLCK;
} else {
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start, 0, 1,
lockType | LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */, 0);
if (rc == 0) {
rc = CIFSSMBLock(xid, pTcon, netfid, netpid,
length, pfLock->fl_start, 1, 0,
lockType |
LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */, 0);
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); FreeXid(xid);
...@@ -769,7 +793,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -769,7 +793,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if (numLock) { if (numLock) {
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length, rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start, pfLock->fl_start,
0, numLock, lockType, wait_flag); 0, numLock, lockType, wait_flag, 0);
if (rc == 0) { if (rc == 0) {
/* For Windows locks we must store them. */ /* For Windows locks we must store them. */
...@@ -791,7 +815,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) ...@@ -791,7 +815,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
stored_rc = CIFSSMBLock(xid, pTcon, stored_rc = CIFSSMBLock(xid, pTcon,
netfid, netpid, netfid, netpid,
li->length, li->offset, li->length, li->offset,
1, 0, li->type, FALSE); 1, 0, li->type, FALSE,
0);
if (stored_rc) if (stored_rc)
rc = stored_rc; rc = stored_rc;
else { else {
......
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