From patchwork Thu Jul 11 12:47:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 2826316 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 351A5C0AB2 for ; Thu, 11 Jul 2013 12:47:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0D20A2016D for ; Thu, 11 Jul 2013 12:47:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FA4C20169 for ; Thu, 11 Jul 2013 12:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932251Ab3GKMrU (ORCPT ); Thu, 11 Jul 2013 08:47:20 -0400 Received: from mail-la0-f41.google.com ([209.85.215.41]:64432 "EHLO mail-la0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932100Ab3GKMrT (ORCPT ); Thu, 11 Jul 2013 08:47:19 -0400 Received: by mail-la0-f41.google.com with SMTP id fn20so6776372lab.0 for ; Thu, 11 Jul 2013 05:47:17 -0700 (PDT) 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=cb0Rqf7WIy8F481896krd1oJu9wrVbSfi+Wc5mx7K5g=; b=mrakUat9P+FjI2+0aMG528EaREsaSanSvUJUjkeDwzSzpcIn7U93J+xbgp8iqXTZ1I 5dfz8KDlMj7aei7CRdPZ6HRDIc1zSjEsblPprdmJ07TXcGDClxL+gzdsPWbkfvoQF2Oo /T+c2mNvw3pivtmN02MMUaOCbaPmA5iQuwZiMB8u1rMKQ9XaobPkl3LC86WWkbeTndmN 4bvgiuKGgt59qwXjgXgWLYuKrh6e9g1FO+GaciA4TMERT6tbKUXgT9eKk3ZWuTRq7akE CG6oKxHFbJcodFCefvBBPMf6fYfM4x+fNVdpP95M9K6vV+C3K5tPqm3/17nkrAlIfP1D Zppg== X-Received: by 10.152.3.74 with SMTP id a10mr17370747laa.74.1373546837656; Thu, 11 Jul 2013 05:47:17 -0700 (PDT) Received: from localhost.localdomain (PPPoE-78-29-83-145.san.ru. [78.29.83.145]) by mx.google.com with ESMTPSA id q6sm12310597lbv.14.2013.07.11.05.47.15 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Jul 2013 05:47:16 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH] CIFS: Reopen the file if reconnect durable handle failed Date: Thu, 11 Jul 2013 16:47:09 +0400 Message-Id: <1373546829-4925-1-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373450401-4135-9-git-send-email-pshilovsky@samba.org> References: <1373450401-4135-9-git-send-email-pshilovsky@samba.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 2cd4a7c..b149ae4 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -681,6 +681,13 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) * not dirty locally we could do this. */ rc = server->ops->open(xid, &oparms, &oplock, NULL); + if (rc == -ENOENT && oparms.reconnect == false) { + /* durable handle timeout is expired - open the file again */ + rc = server->ops->open(xid, &oparms, &oplock, NULL); + /* indicate that we need to relock the file */ + oparms.reconnect = true; + } + if (rc) { mutex_unlock(&cfile->fh_mutex); cifs_dbg(FYI, "cifs_reopen returned 0x%x\n", rc); @@ -1509,7 +1516,6 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, if (!rc) goto out; - /* * Windows 7 server can delay breaking lease from read to None * if we set a byte-range lock on a file - break it explicitly