From patchwork Sun Mar 29 18:03:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 15032 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 n2TI4UoY010475 for ; Sun, 29 Mar 2009 18:04:30 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id C5D1A163CC7 for ; Sun, 29 Mar 2009 18:04:12 +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=-1.3 required=3.8 tests=AWL,BAYES_00, FORGED_RCVD_HELO,RCVD_IN_SORBS_WEB autolearn=no 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 58351163BDE for ; Sun, 29 Mar 2009 18:03:53 +0000 (GMT) Received: from localhost (as.office.etersoft.ru [192.168.0.10]) by mail.etersoft.ru (Postfix) with ESMTP id 85B3720F908; Sun, 29 Mar 2009 22:04:08 +0400 (MSD) 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 0yww6f+XHGyh; Sun, 29 Mar 2009 22:04:03 +0400 (MSD) Received: from homestation.localnet (pppoe-88-147-209-216.san.ru [88.147.209.216]) by mail.etersoft.ru (Postfix) with ESMTP id A591F20DD2F; Sun, 29 Mar 2009 22:04:03 +0400 (MSD) From: Pavel Shilovsky To: Jeff Layton Subject: Re: [linux-cifs-client] [PATCH] F_GETLK request - returning value Date: Sun, 29 Mar 2009 22:03:55 +0400 User-Agent: KMail/1.10.3 (Linux/2.6.26-1-686; KDE/4.1.3; i686; ; ) MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200903292204.02755.piastry@etersoft.ru> Cc: linux-cifs-client@lists.samba.org 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 Ok, This is final version. Signed-off-by: Pavel Shilovsky Acked-by: Jeff Layton diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 8f0f86d..54a6a7f 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1880,8 +1880,21 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? parm_data = (struct cifs_posix_lock *) ? ? ? ? ? ? ? ? ? ? ? ? ((char *)&pSMBr->hdr.Protocol + data_offset); - ? ? ? ? ? ? ? if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK)) + ? ? ? ? ? ? ? if (parm_data->lock_type == __constant_cpu_to_le16(CIFS_UNLCK)) ? ? ? ? ? ? ? ? ? ? ? ? pLockData->fl_type = F_UNLCK; + ? ? ? ? ? ? ? else { + ? ? ? ? ? ? ? ? ? ? ? if (parm_data->lock_type == + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __constant_cpu_to_le16(CIFS_RDLCK)) + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? pLockData->fl_type = F_RDLCK; + ? ? ? ? ? ? ? ? ? ? ? else if (parm_data->lock_type == + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __constant_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..f8fefab 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -896,8 +896,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, 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, 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);