From patchwork Wed Nov 28 14:23:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1816671 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 8CE74DF26F for ; Wed, 28 Nov 2012 14:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754826Ab2K1OX7 (ORCPT ); Wed, 28 Nov 2012 09:23:59 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:38988 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754738Ab2K1OX6 (ORCPT ); Wed, 28 Nov 2012 09:23:58 -0500 Received: by mail-lb0-f174.google.com with SMTP id gi11so7620337lbb.19 for ; Wed, 28 Nov 2012 06:23:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=dBVbROCIXR20UB45bsTCqjLmeCEuKVG2+QkJl28TLds=; b=Rey3VxuFYUkYr7ZV8mI6FXFHf0UKIaTqoeOBuMjsmZ1SAxp2v0BZ1dISkGeOFvzjfA J7E2i3DvfQcaauzLryoNzxxaWVJHjGd/pAW1AliEt4Sfx3VmW26CRkmKCEUbPYuWbheB FJ1exLVxh6eUQM9WTwR/SrNeN0c3oAlQoJAp3YXwHBjrD+vLJ+QRDMwY1Ouhc5ld/ZC/ lJ5AoqY6VGZBpKeLTjg7t4F54y55yAy8bmf+e7w0VRsljERJ0Wrd8sAfGKDQRK+MYOLO iww+PDi0bbV3VC3zvMN01wtBmrpWVcf+lzD+FVIi2y2dCclTHst0Rkn/dW4c10KD8FLQ Lkow== Received: by 10.152.124.83 with SMTP id mg19mr18335831lab.6.1354112638044; Wed, 28 Nov 2012 06:23:58 -0800 (PST) Received: from localhost.localdomain ([95.84.0.69]) by mx.google.com with ESMTPS id oj5sm8159019lab.8.2012.11.28.06.23.56 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 06:23:57 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 1/6] CIFS: Separate pushing posix locks and lock_sem handling Date: Wed, 28 Nov 2012 18:23:40 +0400 Message-Id: <1354112625-30315-2-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1354112625-30315-1-git-send-email-piastry@etersoft.ru> References: <1354112625-30315-1-git-send-email-piastry@etersoft.ru> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Reviewed-by: Jeff Layton Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index be0c3ea..54541a6 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1047,9 +1047,8 @@ struct lock_to_push { }; static int -cifs_push_posix_locks(struct cifsFileInfo *cfile) +cifs_push_posix_locks_locked(struct cifsFileInfo *cfile) { - struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); struct file_lock *flock, **before; unsigned int count = 0, i = 0; @@ -1060,14 +1059,6 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) xid = get_xid(); - /* we are going to update can_cache_brlcks here - need a write access */ - down_write(&cinode->lock_sem); - if (!cinode->can_cache_brlcks) { - up_write(&cinode->lock_sem); - free_xid(xid); - return rc; - } - lock_flocks(); cifs_for_each_lock(cfile->dentry->d_inode, before) { if ((*before)->fl_flags & FL_POSIX) @@ -1133,9 +1124,6 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) } out: - cinode->can_cache_brlcks = false; - up_write(&cinode->lock_sem); - free_xid(xid); return rc; err_out: @@ -1147,6 +1135,24 @@ err_out: } static int +cifs_push_posix_locks(struct cifsFileInfo *cfile) +{ + struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); + int rc = 0; + + /* we are going to update can_cache_brlcks here - need a write access */ + down_write(&cinode->lock_sem); + if (!cinode->can_cache_brlcks) { + up_write(&cinode->lock_sem); + return rc; + } + rc = cifs_push_posix_locks_locked(cfile); + cinode->can_cache_brlcks = false; + up_write(&cinode->lock_sem); + return rc; +} + +static int cifs_push_locks(struct cifsFileInfo *cfile) { struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);