Commit c371b0c4 authored by Evgeny Sinelnikov's avatar Evgeny Sinelnikov

Fixed fd duplicate problem with locks for 2.6.25

parent d29fe4e6
......@@ -891,6 +891,7 @@ static int cifs_oplock_thread(void *dummyarg)
struct cifsTconInfo *pTcon;
struct inode *inode;
__u16 netfid;
__u32 netpid;
int rc, waitrc = 0;
set_freezable();
......@@ -911,6 +912,7 @@ static int cifs_oplock_thread(void *dummyarg)
pTcon = oplock_item->tcon;
inode = oplock_item->pinode;
netfid = oplock_item->netfid;
netpid = oplock_item->netpid;
spin_unlock(&GlobalMid_Lock);
DeleteOplockQEntry(oplock_item);
/* can not grab inode sem here since it would
......@@ -943,7 +945,7 @@ static int cifs_oplock_thread(void *dummyarg)
to server still is disconnected since oplock
already released by the server in that case */
if (pTcon->tidStatus != CifsNeedReconnect) {
rc = CIFSSMBLock(0, pTcon, netfid,
rc = CIFSSMBLock(0, pTcon, netfid, netpid,
0 /* len */ , 0 /* offset */, 0,
0, LOCKING_ANDX_OPLOCK_RELEASE,
0 /* wait flag */);
......
......@@ -437,6 +437,7 @@ struct oplock_q_entry {
struct inode *pinode;
struct cifsTconInfo *tcon;
__u16 netfid;
__u32 netpid;
};
/* for pending dnotify requests */
......
......@@ -81,7 +81,7 @@ extern int CIFS_SessSetup(unsigned int xid, struct cifsSesInfo *ses,
const int stage,
const struct nls_table *nls_cp);
extern __u16 GetNextMid(struct TCP_Server_Info *server);
extern struct oplock_q_entry *AllocOplockQEntry(struct inode *, u16,
extern struct oplock_q_entry *AllocOplockQEntry(struct inode *, u16, __u32,
struct cifsTconInfo *);
extern void DeleteOplockQEntry(struct oplock_q_entry *);
extern struct timespec cifs_NTtimeToUnix(u64 utc_nanoseconds_since_1601);
......@@ -293,12 +293,12 @@ extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen,
const struct nls_table *cp, int mapChars);
extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const __u16 netfid, const __u64 len,
const __u16 netfid, const __u32 netpid, const __u64 len,
const __u64 offset, const __u32 numUnlock,
const __u32 numLock, const __u8 lockType,
const int waitFlag);
extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const int get_flag,
const __u16 smb_file_id, const __u32 netpid, const int get_flag,
const __u64 len, struct file_lock *,
const __u16 lock_type, const int waitFlag);
extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
......
......@@ -1685,7 +1685,7 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
int
CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const __u64 len,
const __u16 smb_file_id, const __u32 net_pid, const __u64 len,
const __u64 offset, const __u32 numUnlock,
const __u32 numLock, const __u8 lockType, const int waitFlag)
{
......@@ -1721,7 +1721,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
pSMB->Fid = smb_file_id; /* netfid stays le */
if ((numLock != 0) || (numUnlock != 0)) {
pSMB->Locks[0].Pid = cpu_to_le16(current->tgid);
pSMB->Locks[0].Pid = cpu_to_le16(net_pid);
/* BB where to store pid high? */
pSMB->Locks[0].LengthLow = cpu_to_le32((u32)len);
pSMB->Locks[0].LengthHigh = cpu_to_le32((u32)(len>>32));
......@@ -1755,7 +1755,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
int
CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
const __u16 smb_file_id, const int get_flag, const __u64 len,
const __u16 smb_file_id, const __u32 net_pid, const int get_flag, const __u64 len,
struct file_lock *pLockData, const __u16 lock_type,
const int waitFlag)
{
......@@ -1815,7 +1815,7 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
} else
pSMB->Timeout = 0;
parm_data->pid = cpu_to_le32(current->tgid);
parm_data->pid = cpu_to_le32(net_pid);
parm_data->start = cpu_to_le64(pLockData->fl_start);
parm_data->length = cpu_to_le64(len); /* normalize negative numbers */
......
......@@ -648,6 +648,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
int wait_flag = FALSE;
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon;
__u32 netpid;
__u16 netfid;
__u8 lockType = LOCKING_ANDX_LARGE_FILES;
int posix_locking = 0;
......@@ -707,6 +708,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
FreeXid(xid);
return -EBADF;
}
netpid = ((struct cifsFileInfo *)file->private_data)->pid;
netfid = ((struct cifsFileInfo *)file->private_data)->netfid;
if ((pTcon->ses->capabilities & CAP_UNIX) &&
......@@ -724,7 +726,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
posix_lock_type = CIFS_RDLCK;
else
posix_lock_type = CIFS_WRLCK;
rc = CIFSSMBPosixLock(xid, pTcon, netfid, 1 /* get */,
rc = CIFSSMBPosixLock(xid, pTcon, netfid, netpid, 1 /* get */,
length, pfLock,
posix_lock_type, wait_flag);
FreeXid(xid);
......@@ -732,10 +734,10 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
}
/* BB we could chain these into one lock request BB */
rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start,
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length, pfLock->fl_start,
0, 1, lockType, 0 /* wait flag */ );
if (rc == 0) {
rc = CIFSSMBLock(xid, pTcon, netfid, length,
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start, 1 /* numUnlock */ ,
0 /* numLock */ , lockType,
0 /* wait flag */ );
......@@ -752,12 +754,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if (lockType & LOCKING_ANDX_SHARED_LOCK) {
pfLock->fl_type = F_WRLCK;
} else {
rc = CIFSSMBLock(xid, pTcon, netfid, length,
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start, 0, 1,
lockType | LOCKING_ANDX_SHARED_LOCK,
0 /* wait flag */ );
if (rc == 0) {
rc = CIFSSMBLock(xid, pTcon, netfid,
rc = CIFSSMBLock(xid, pTcon, netfid, netpid,
length, pfLock->fl_start, 1, 0,
lockType |
LOCKING_ANDX_SHARED_LOCK,
......@@ -796,7 +798,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
if (numUnlock == 1)
posix_lock_type = CIFS_UNLCK;
rc = CIFSSMBPosixLock(xid, pTcon, netfid, 0 /* set */,
rc = CIFSSMBPosixLock(xid, pTcon, netfid, netpid, 0 /* set */,
length, pfLock,
posix_lock_type, wait_flag);
} else {
......@@ -804,7 +806,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
(struct cifsFileInfo *)file->private_data;
if (numLock) {
rc = CIFSSMBLock(xid, pTcon, netfid, length,
rc = CIFSSMBLock(xid, pTcon, netfid, netpid, length,
pfLock->fl_start,
0, numLock, lockType, wait_flag);
......@@ -826,7 +828,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
(pfLock->fl_start + length) >=
(li->offset + li->length)) {
stored_rc = CIFSSMBLock(xid, pTcon,
netfid,
netfid, netpid,
li->length, li->offset,
1, 0, li->type, FALSE);
if (stored_rc)
......
......@@ -580,6 +580,7 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
pCifsInode->oplockPending = TRUE;
AllocOplockQEntry(netfile->pInode,
netfile->netfid,
netfile->pid,
tcon);
cFYI(1,
("about to wake up oplock thread"));
......
......@@ -110,7 +110,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
}
struct oplock_q_entry *
AllocOplockQEntry(struct inode *pinode, __u16 fid, struct cifsTconInfo *tcon)
AllocOplockQEntry(struct inode *pinode, __u16 fid, __u32 pid, struct cifsTconInfo *tcon)
{
struct oplock_q_entry *temp;
if ((pinode == NULL) || (tcon == NULL)) {
......@@ -125,6 +125,7 @@ AllocOplockQEntry(struct inode *pinode, __u16 fid, struct cifsTconInfo *tcon)
temp->pinode = pinode;
temp->tcon = tcon;
temp->netfid = fid;
temp->netpid = pid;
spin_lock(&GlobalMid_Lock);
list_add_tail(&temp->qhead, &GlobalOplock_Q);
spin_unlock(&GlobalMid_Lock);
......
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