From patchwork Mon Mar 16 18:28: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: 12454 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 n2GITNT4021159 for ; Mon, 16 Mar 2009 18:29:23 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 4BC12163C98 for ; Mon, 16 Mar 2009 18:29:08 +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 A2281163BD3 for ; Mon, 16 Mar 2009 18:28:43 +0000 (GMT) Received: from localhost (as.office.etersoft.ru [192.168.0.10]) by mail.etersoft.ru (Postfix) with ESMTP id DAF202E72FF; Mon, 16 Mar 2009 21:28:57 +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 UGLQu2EDNSD0; Mon, 16 Mar 2009 21:28:56 +0300 (MSK) From: Pavel Shilovsky To: Jeff Layton Subject: Re: [linux-cifs-client] [PATCH 2/2] use cifs_lock_storage module operations in file.c Date: Mon, 16 Mar 2009 21:28:55 +0300 User-Agent: KMail/1.10.3 (Linux/2.6.26-1-686; KDE/4.1.3; i686; ; ) References: <49A4060E.3060507@etersoft.ru> In-Reply-To: <49A4060E.3060507@etersoft.ru> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200903162128.55462.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 -- Best regards, Pavel Shilovsky. diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 13ea532..9701827 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -42,6 +42,7 @@ #include "cifsproto.h" #include "cifs_debug.h" #include "cifs_fs_sb.h" +#include "cifs_lock_storage.h" #include #include #include "dns_resolve.h" @@ -1102,6 +1103,7 @@ init_cifs(void) rwlock_init(&GlobalSMBSeslock); rwlock_init(&cifs_tcp_ses_lock); spin_lock_init(&GlobalMid_Lock); + cifs_lock_storage_init(); if (cifs_max_pending < 2) { cifs_max_pending = 2; diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 81747ac..2d2e3f1 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -38,6 +38,7 @@ #include "cifs_unicode.h" #include "cifs_debug.h" #include "cifs_fs_sb.h" +#include "cifs_lock_storage.h" static inline struct cifsFileInfo *cifs_init_private( struct cifsFileInfo *private_data, struct inode *inode, @@ -640,7 +641,6 @@ int cifs_close(struct inode *inode, struct file *file) cifs_sb = CIFS_SB(inode->i_sb); pTcon = cifs_sb->tcon; if (pSMBFile) { - struct cifsLockInfo *li, *tmp; write_lock(&GlobalSMBSeslock); pSMBFile->closePend = true; if (pTcon) { @@ -674,15 +674,6 @@ int cifs_close(struct inode *inode, struct file *file) } else write_unlock(&GlobalSMBSeslock); - /* Delete any outstanding lock records. - We'll lose them when the file is closed anyway. */ - mutex_lock(&pSMBFile->lock_mutex); - list_for_each_entry_safe(li, tmp, &pSMBFile->llist, llist) { - list_del(&li->llist); - kfree(li); - } - mutex_unlock(&pSMBFile->lock_mutex); - write_lock(&GlobalSMBSeslock); list_del(&pSMBFile->flist); list_del(&pSMBFile->tlist); @@ -773,22 +764,6 @@ int cifs_closedir(struct inode *inode, struct file *file) return rc; } -static int store_file_lock(struct cifsFileInfo *fid, __u64 len, - __u64 offset, __u8 lockType) -{ - struct cifsLockInfo *li = - kmalloc(sizeof(struct cifsLockInfo), GFP_KERNEL); - if (li == NULL) - return -ENOMEM; - li->offset = offset; - li->length = len; - li->type = lockType; - mutex_lock(&fid->lock_mutex); - list_add(&li->llist, &fid->llist); - mutex_unlock(&fid->lock_mutex); - return 0; -} - int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) { int rc, xid; @@ -935,33 +910,14 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) if (rc == 0) { /* For Windows locks we must store them. */ - rc = store_file_lock(fid, length, - pfLock->fl_start, lockType); + rc = cifs_lock_storage_add_lock(fid->pid, fid->pInode->i_ino, + fid->netfid, pfLock->fl_start, length, lockType); } } else if (numUnlock) { /* For each stored lock that this unlock overlaps completely, unlock it. */ - int stored_rc = 0; - struct cifsLockInfo *li, *tmp; - - rc = 0; - mutex_lock(&fid->lock_mutex); - list_for_each_entry_safe(li, tmp, &fid->llist, llist) { - if (pfLock->fl_start <= li->offset && - (pfLock->fl_start + length) >= - (li->offset + li->length)) { - stored_rc = CIFSSMBLock(xid, tcon, - netfid, - li->length, li->offset, - 1, 0, li->type, false); - if (stored_rc) - rc = stored_rc; - - list_del(&li->llist); - kfree(li); - } - } - mutex_unlock(&fid->lock_mutex); + rc = cifs_lock_storage_del_lock(xid, pTcon, fid->pid, fid->pInode->i_ino, + pfLock->fl_start, length, lockType); } }