From patchwork Tue Nov 27 06:50:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1808941 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A35273FC54 for ; Tue, 27 Nov 2012 06:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756970Ab2K0Gul (ORCPT ); Tue, 27 Nov 2012 01:50:41 -0500 Received: from mail-la0-f46.google.com ([209.85.215.46]:54770 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756732Ab2K0Guk (ORCPT ); Tue, 27 Nov 2012 01:50:40 -0500 Received: by mail-la0-f46.google.com with SMTP id p5so6483184lag.19 for ; Mon, 26 Nov 2012 22:50:40 -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=5DNULVmx+dsbqbaZ19RfexFpyrgLQICptLkAccwrhCM=; b=ocpW9HsHVXqpSCm/jMhXW2s7LaXF2Wd2Hu4lVgt4ZT9EAogT3U93koasZs0OERGahf AfYhDo59KTbPKNZjmETB+v7heyZ3oshC9EdtsWS9+LLbd/SmAk2eGBjDts1p1TMahBhU gYuA8hEOYFmB39Mb8Gpq4MQcSex8Oy7IeKO52ba/ZXweaKp5Awbc8qZWHFC3H/nkbAG4 e8MfjOXeu8yoIuxgN91KIK8BVJxIM+yKDVwRDd/m+7VOt+gSveCd1CrF9vdvm7LVS7Bq RW2ywvy11hBC3jv2OwAwuvachPVxBjhTARG57qFfoOvl7kGXB0Yj8y4eQZfgHyjoiXUj q9oA== Received: by 10.112.13.232 with SMTP id k8mr5953319lbc.90.1353999040025; Mon, 26 Nov 2012 22:50:40 -0800 (PST) Received: from localhost.localdomain ([95.84.0.69]) by mx.google.com with ESMTPS id bf3sm6547215lbb.16.2012.11.26.22.50.37 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 22:50:38 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 1/5] CIFS: Separate pushing posix locks and lock_sem handling Date: Tue, 27 Nov 2012 10:50:24 +0400 Message-Id: <1353999029-3975-2-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1353999029-3975-1-git-send-email-piastry@etersoft.ru> References: <1353999029-3975-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 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);