From patchwork Wed Nov 28 14:23:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1816681 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 94904DF26F for ; Wed, 28 Nov 2012 14:24:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754973Ab2K1OYC (ORCPT ); Wed, 28 Nov 2012 09:24:02 -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 S1754738Ab2K1OYB (ORCPT ); Wed, 28 Nov 2012 09:24:01 -0500 Received: by mail-lb0-f174.google.com with SMTP id gi11so7620337lbb.19 for ; Wed, 28 Nov 2012 06:24:00 -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=5y5MnHFgcBLG/qbEhCvcwVszc14IqW6dXQki9iRKSn8=; b=I4ye1B1UFu2wHV4zQRYUqNIIfyRO68339leoIfw9JcnHmLrm3EKm2RtcMKlSEyAwsH zldBeFaVzOyfl6ZJErnMNvVnhFoAzHPfb/45Cl0aebYGvDRj6liDWMtCCflqE4Aoks+G VoRD4QL0S4ZILkaNuPu2UlyCeSbi6cv+P7fhF2rlK+epzWroIDhRH6Yn+Wrba8tx38ID W8D/ppzi1SRsDPS5Yh5lK7p4Zj9T4mbGgRmSAl3JhaIr7hkFIQgHtQrRxNhbH5J1qvVg J2pKeBUSDPHPpo+Nj+eTwuitDd5XuJfrxJ0Yq7u9QOxCIg+OX+Okq/0OphCaJeBkHLpJ DGYQ== Received: by 10.112.28.98 with SMTP id a2mr8074992lbh.110.1354112640008; Wed, 28 Nov 2012 06:24:00 -0800 (PST) Received: from localhost.localdomain ([95.84.0.69]) by mx.google.com with ESMTPS id oj5sm8159019lab.8.2012.11.28.06.23.58 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 06:23:58 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 2/6] CIFS: Separate pushing mandatory locks and lock_sem handling Date: Wed, 28 Nov 2012 18:23:41 +0400 Message-Id: <1354112625-30315-3-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 | 39 ++++++++++----------------------------- fs/cifs/smb2file.c | 12 ------------ 2 files changed, 10 insertions(+), 41 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 54541a6..cf67f8f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -954,7 +954,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) int rc = 0, stored_rc; struct cifsLockInfo *li, *tmp; struct cifs_tcon *tcon; - struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); unsigned int num, max_num, max_buf; LOCKING_ANDX_RANGE *buf, *cur; int types[] = {LOCKING_ANDX_LARGE_FILES, @@ -964,21 +963,12 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) xid = get_xid(); tcon = tlink_tcon(cfile->tlink); - /* 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; - } - /* * Accessing maxBuf is racy with cifs_reconnect - need to store value * and check it for zero before using. */ max_buf = tcon->ses->server->maxBuf; if (!max_buf) { - up_write(&cinode->lock_sem); free_xid(xid); return -EINVAL; } @@ -987,7 +977,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) sizeof(LOCKING_ANDX_RANGE); buf = kzalloc(max_num * sizeof(LOCKING_ANDX_RANGE), GFP_KERNEL); if (!buf) { - up_write(&cinode->lock_sem); free_xid(xid); return -ENOMEM; } @@ -1024,9 +1013,6 @@ cifs_push_mandatory_locks(struct cifsFileInfo *cfile) } } - cinode->can_cache_brlcks = false; - up_write(&cinode->lock_sem); - kfree(buf); free_xid(xid); return rc; @@ -1047,7 +1033,7 @@ struct lock_to_push { }; static int -cifs_push_posix_locks_locked(struct cifsFileInfo *cfile) +cifs_push_posix_locks(struct cifsFileInfo *cfile) { struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); struct file_lock *flock, **before; @@ -1135,9 +1121,11 @@ err_out: } static int -cifs_push_posix_locks(struct cifsFileInfo *cfile) +cifs_push_locks(struct cifsFileInfo *cfile) { + struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); + struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); int rc = 0; /* we are going to update can_cache_brlcks here - need a write access */ @@ -1146,24 +1134,17 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) 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); - struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); if (cap_unix(tcon->ses) && (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) - return cifs_push_posix_locks(cfile); + rc = cifs_push_posix_locks(cfile); + else + rc = tcon->ses->server->ops->push_mand_locks(cfile); - return tcon->ses->server->ops->push_mand_locks(cfile); + cinode->can_cache_brlcks = false; + up_write(&cinode->lock_sem); + return rc; } static void diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c index bfe22e8..7dfb50c 100644 --- a/fs/cifs/smb2file.c +++ b/fs/cifs/smb2file.c @@ -260,13 +260,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) struct cifs_fid_locks *fdlocks; 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; - } /* * Accessing maxBuf is racy with cifs_reconnect - need to store value @@ -274,7 +267,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) */ max_buf = tlink_tcon(cfile->tlink)->ses->server->maxBuf; if (!max_buf) { - up_write(&cinode->lock_sem); free_xid(xid); return -EINVAL; } @@ -282,7 +274,6 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) max_num = max_buf / sizeof(struct smb2_lock_element); buf = kzalloc(max_num * sizeof(struct smb2_lock_element), GFP_KERNEL); if (!buf) { - up_write(&cinode->lock_sem); free_xid(xid); return -ENOMEM; } @@ -293,10 +284,7 @@ smb2_push_mandatory_locks(struct cifsFileInfo *cfile) rc = stored_rc; } - cinode->can_cache_brlcks = false; kfree(buf); - - up_write(&cinode->lock_sem); free_xid(xid); return rc; }