From patchwork Tue Feb 24 14:37:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 8597 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 n1OEaZvp002332 for ; Tue, 24 Feb 2009 14:36:35 GMT Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 1B92D163CC7 for ; Tue, 24 Feb 2009 14:36:22 +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 696A5163BB6 for ; Tue, 24 Feb 2009 14:35:49 +0000 (GMT) Received: from localhost (as.office.etersoft.ru [192.168.0.10]) by mail.etersoft.ru (Postfix) with ESMTP id 66C182E0735 for ; Tue, 24 Feb 2009 17:36:02 +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 RmltaZKI-l8u for ; Tue, 24 Feb 2009 17:36:01 +0300 (MSK) Message-ID: <49A4060E.3060507@etersoft.ru> Date: Tue, 24 Feb 2009 17:37:02 +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: [linux-cifs-client] [PATCH 2/2] use cifs_lock_storage module operations in file.c 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 int rc, xid; @@ -773,33 +747,12 @@ 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, pTcon, - 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); } } diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 6203609..a8137f5 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" @@ -1049,6 +1050,7 @@ init_cifs(void) memset(Local_System_Name, 0, 15); rwlock_init(&GlobalSMBSeslock); 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 8da903b..7f3ae27 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, @@ -486,8 +487,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; - pSMBFile->closePend = true; if (pTcon) { /* no sense reconnecting to close a file that is @@ -516,15 +515,6 @@ int cifs_close(struct inode *inode, struct file *file) } } - /* 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); @@ -612,22 +602,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) {