Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp9933ybp; Thu, 3 Oct 2019 09:27:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwdETaGiwawmNpA7InBWehVfEIVdu8p9rY6lgtRfQ0GU3B9l1SuSkOFih+iaSK2QHJq3OS X-Received: by 2002:a17:906:b804:: with SMTP id dv4mr8337309ejb.243.1570120050984; Thu, 03 Oct 2019 09:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120050; cv=none; d=google.com; s=arc-20160816; b=ovkCBBQApMYGqiwwbvCje2J7EZK2M/K7mNPR7s81peeoY3s9o7pSyne+LluhKfDQ+P 3cCjKi5gblwC/j2IXtaSSZLWhcUbrVQF3Nahzp467ywgoYEnoZFkUixy/qUf4DrRUHu+ Qcf88lrI8fknWg++oy1gdA2TwLH7xZFe1Ljrb0xbLAYAAa2HQE7bDjswR8GTqnp75C4/ NhVN4dzoD+wewp7I10YH0eI3/89kExUlGzpkairmj9+m4qX6S23bPyV7F2xh56xjXAW1 x5g9gvtBs1YmKTvRIw7TX4Pd9I+dqyxl2OxcYZAfBlno/SHdlpSMlRyCNUoo18sEbaZK +Onw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fZ+Njl+I5KSibqx119XICv3Mtj5FrPSEjtrgE3KoHXw=; b=FtzQIeUrEhVAz5O9uziDWHTFddiZsGib+qLPcKwp0WVIinz8dXd4v5kpCmWOQzZ2zy Nc9C12J7509c0s2pYNB43DjpyVVy2VP62+5w8zU3C2Afktl9UXHrSxXnUnsx+KWDQRDG xFU/xZkTohSGZ0BTRtbbgJxQShj3iXb1SpwKi2V9AQVcf9lH+37tW46dscXsG5uZqiP8 mV1hJu5TezhULuX28otR4FRtROFNsg/JQy5CtW8BR0KqeL/cfu7ZCicai/Ngf4O9VfWL T1LPU2JX4rO4HvEWvtfMpWfAjXHCxeE7+VlhdbKtDtMxs/3Q7qRraqRjY6GmI5sNToGc xB5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oEySnqvy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id va9si1499349ejb.126.2019.10.03.09.27.06; Thu, 03 Oct 2019 09:27:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oEySnqvy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390620AbfJCQXq (ORCPT + 99 others); Thu, 3 Oct 2019 12:23:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:52952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389355AbfJCQXo (ORCPT ); Thu, 3 Oct 2019 12:23:44 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27A8E222BE; Thu, 3 Oct 2019 16:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119823; bh=yEB9cdRN152hNcF2m8k+3yw49W/hfQIpYS6OO5hf9nE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEySnqvyPf8LmuruxZ6e1/S8w2ukDwCVqdLwOsknVK+TCrETaoZkVGKrq1HQHXE56 HmHDGSoTg1pHVUi7UpVk+3NasyEnBGFGfXbkDzsyyt2xVCKrRUCCvEkiZOlxj01LMj h1FWcYjAmvu9zwFSvbZ47AY0y1T0VOCG1+wyFEDU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Shilovsky , Steve French , Ronnie Sahlberg Subject: [PATCH 4.19 207/211] CIFS: Fix oplock handling for SMB 2.1+ protocols Date: Thu, 3 Oct 2019 17:54:33 +0200 Message-Id: <20191003154530.440466449@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Shilovsky commit a016e2794fc3a245a91946038dd8f34d65e53cc3 upstream. There may be situations when a server negotiates SMB 2.1 protocol version or higher but responds to a CREATE request with an oplock rather than a lease. Currently the client doesn't handle such a case correctly: when another CREATE comes in the server sends an oplock break to the initial CREATE and the client doesn't send an ack back due to a wrong caching level being set (READ instead of RWH). Missing an oplock break ack makes the server wait until the break times out which dramatically increases the latency of the second CREATE. Fix this by properly detecting oplocks when using SMB 2.1 protocol version and higher. Cc: Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French Reviewed-by: Ronnie Sahlberg Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2398,6 +2398,11 @@ smb21_set_oplock_level(struct cifsInodeI if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE) return; + /* Check if the server granted an oplock rather than a lease */ + if (oplock & SMB2_OPLOCK_LEVEL_EXCLUSIVE) + return smb2_set_oplock_level(cinode, oplock, epoch, + purge_cache); + if (oplock & SMB2_LEASE_READ_CACHING_HE) { new_oplock |= CIFS_CACHE_READ_FLG; strcat(message, "R");