From patchwork Wed Nov 28 14:23:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1816691 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 AD7AEDF26F for ; Wed, 28 Nov 2012 14:24:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755046Ab2K1OYD (ORCPT ); Wed, 28 Nov 2012 09:24:03 -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 S1754935Ab2K1OYC (ORCPT ); Wed, 28 Nov 2012 09:24:02 -0500 Received: by mail-lb0-f174.google.com with SMTP id gi11so7620337lbb.19 for ; Wed, 28 Nov 2012 06:24:02 -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=Qtn38YiWgWwQQTPy8ARbOfsf6ft+Luj6gQ/UyK1HSPo=; b=QKgaBtCnC2ZyFRpw10bLZEk0EKVzO6STI0i8LZ6dv+WEVkMIz9pZSIpmlhFnQ7ul/c Oek5hEgz2pGO4D9nXdGQggao/yItIYzxSi0gmBqlsuTaPJmnfwU1SENUiNS2dQcPfnR3 ViQz9Ru6bOu1OVjMgKJAgvbH9e83RlmBs+I5KVygg2GFCZVwVtVm2lNayYndOH6GM5tn fEPh4W7Na4kzRbcaK99tlFBHyvlk1mIhujMrrsaTM4rc1jirUqR393FHrdu3a48q9axd epeowzT/9hTuBQoy11F73UMw0PSDtYat/89R9shl3rErFs0Q8KNQEPiBnb/pX6LZCydL jfew== Received: by 10.152.124.111 with SMTP id mh15mr18243383lab.20.1354112642047; Wed, 28 Nov 2012 06:24:02 -0800 (PST) Received: from localhost.localdomain ([95.84.0.69]) by mx.google.com with ESMTPS id oj5sm8159019lab.8.2012.11.28.06.24.00 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 06:24:00 -0800 (PST) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH v2 3/6] CIFS: Implement cifs_relock_file Date: Wed, 28 Nov 2012 18:23:42 +0400 Message-Id: <1354112625-30315-4-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 that reacquires byte-range locks when a file is reopened. Reviewed-by: Jeff Layton 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; }