From patchwork Tue Nov 27 06:50:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1808961 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 071C3DF254 for ; Tue, 27 Nov 2012 06:50:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757993Ab2K0Gus (ORCPT ); Tue, 27 Nov 2012 01:50:48 -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 S1757842Ab2K0Gur (ORCPT ); Tue, 27 Nov 2012 01:50:47 -0500 Received: by mail-la0-f46.google.com with SMTP id p5so6483184lag.19 for ; Mon, 26 Nov 2012 22:50:47 -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=naakyBBo+L5TO3gGuiR2y/mTVzufPmgUa3olIzhOpM8=; b=EKL9BiQnlGvfnmID1a0JHXD3oxUJwLVD/W09WwmLjmnEBDnoJJzKtHC8Cz03PFiy3j HKG/ZXLkL3N0BnssUYvU4GvTpwHw8Ysc2Z5nGjvEra7VPnSzQAqWZzvAnFtvwoMp4Ipo gmqDOMEaf/NpmWNLBAqxUR6dLe0lw8rE23CBHNlLbi0E8gsCTLOehCr7foauV2sbPqTK +rXK06+RIOTX8AShLpwM/M6PAFv7RC1TDNmwqkZetH6JkV4IaPI6Me0K8QEVf8Sa0Wxn nkqIZe+kPLCR5NQp6A9zNEwTxvrH2/krvtnpZCZQgnD8wt1CLTOwqiFYiZ5rubZrcpIG EDvg== Received: by 10.112.44.135 with SMTP id e7mr1134408lbm.55.1353999047044; Mon, 26 Nov 2012 22:50:47 -0800 (PST) Received: from localhost.localdomain ([95.84.0.69]) by mx.google.com with ESMTPS id bf3sm6547215lbb.16.2012.11.26.22.50.41 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Nov 2012 22:50:45 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 3/5] CIFS: Implement cifs_relock_file Date: Tue, 27 Nov 2012 10:50:26 +0400 Message-Id: <1353999029-3975-4-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 that reacquires byte-range locks when a file is reopened. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index cf67f8f..a18c9eb 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -508,16 +508,36 @@ out: return rc; } +static int cifs_push_posix_locks(struct cifsFileInfo *cfile); + /* * Try to reacquire byte range locks that were released when session - * to server was lost + * to server was lost. */ -static int cifs_relock_file(struct cifsFileInfo *cifsFile) +static int +cifs_relock_file(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; - /* BB list all locks open on this file and relock */ + /* we are going to update can_cache_brlcks here - need a write access */ + down_write(&cinode->lock_sem); + if (cinode->can_cache_brlcks) { + /* can cache locks - no need to push them */ + up_write(&cinode->lock_sem); + return rc; + } + + if (cap_unix(tcon->ses) && + (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && + ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) + rc = cifs_push_posix_locks(cfile); + else + rc = tcon->ses->server->ops->push_mand_locks(cfile); + up_write(&cinode->lock_sem); return rc; }