From patchwork Sat Mar 28 11:27:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 14873 Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2SBRXQN027526 for ; Sat, 28 Mar 2009 11:27:34 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id DEF56163C6F for ; Sat, 28 Mar 2009 11:27:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.8 tests=AWL, BAYES_00 autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mail.etersoft.ru (mail.etersoft.ru [87.249.47.46]) by lists.samba.org (Postfix) with ESMTP id A0227163B99 for ; Sat, 28 Mar 2009 11:26:56 +0000 (GMT) Received: from localhost (as.office.etersoft.ru [192.168.0.10]) by mail.etersoft.ru (Postfix) with ESMTP id F23F53035F2 for ; Sat, 28 Mar 2009 14:27:11 +0300 (MSK) X-Virus-Scanned: amavisd-new at office.etersoft.ru Received: from mail.etersoft.ru ([192.168.0.1]) by localhost (as.office.etersoft.ru [192.168.0.10]) (amavisd-new, port 10024) with LMTP id vWpWuGv+84sS for ; Sat, 28 Mar 2009 14:27:10 +0300 (MSK) Message-ID: <49CE098F.4070606@etersoft.ru> Date: Sat, 28 Mar 2009 14:27:11 +0300 From: Pavel Shilovsky User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: linux-cifs-client@lists.samba.org Subject: Re: [linux-cifs-client] [PATCH] F_GETLK request - returning value References: <49CB77EE.6090608@etersoft.ru> In-Reply-To: <49CB77EE.6090608@etersoft.ru> X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Errors-To: linux-cifs-client-bounces+patchwork-cifs-client=patchwork.kernel.org@lists.samba.org Previous patch only added right behaviour without option forcemand. Here is another path that works right with forcemand and without it. + } } FreeXid(xid); Signed-off-by: Pavel Shilovsky --- Best regards, Pavel Shilovsky. diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 8f0f86d..aa26a3a 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1882,6 +1882,16 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, ((char *)&pSMBr->hdr.Protocol + data_offset); if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK)) pLockData->fl_type = F_UNLCK; + else { + if (parm_data->lock_type == cpu_to_le16(CIFS_RDLCK)) + pLockData->fl_type = F_RDLCK; + else if (parm_data->lock_type == cpu_to_le16(CIFS_WRLCK)) + pLockData->fl_type = F_WRLCK; + + pLockData->fl_start = parm_data->start; + pLockData->fl_end = parm_data->start + parm_data->length - 1; + pLockData->fl_pid = parm_data->pid; + } } plk_err_exit: diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 6851043..7e333c2 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -898,6 +898,25 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) /* if rc == ERR_SHARING_VIOLATION ? */ rc = 0; /* do not change lock type to unlock since range in use */ + if (lockType | LOCKING_ANDX_SHARED_LOCK) { + pfLock->fl_type = F_WRLCK; + } else { + rc = CIFSSMBLock(xid, pTcon, netfid, length, pfLock->fl_start, + 0, 1, lockType | LOCKING_ANDX_SHARED_LOCK, 0 /* wait flag */ ); + if (rc == 0) { + rc = CIFSSMBLock(xid, pTcon, netfid, length, + pfLock->fl_start, 1 /* numUnlock */ , + 0 /* numLock */ , 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; + }