From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCBFCC10F14 for ; Thu, 3 Oct 2019 16:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F59520865 for ; Thu, 3 Oct 2019 16:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118759; bh=Ylw5Xnb5JAPsVmjU+fw+TYuGKV/NrCNuO2yKINxYmx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=buTIhqMmkS35RpC7F01GcDXSr9sDq7HP+sIFnrRTqXzt4+iifo09IePo2sccUeb4m ebzDWyoX7Kv6ZZ3Eqe9rDnqy95eniCm9zrJ/QEpNEMi3coTSDhbW7797m6ngYsLO31 kP3EaE8c2CFR5EkdUX70e669tJlHZPxWj6OcAqSQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731838AbfJCQF6 (ORCPT ); Thu, 3 Oct 2019 12:05:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730923AbfJCQFx (ORCPT ); Thu, 3 Oct 2019 12:05:53 -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 9E0E4215EA; Thu, 3 Oct 2019 16:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570118753; bh=Ylw5Xnb5JAPsVmjU+fw+TYuGKV/NrCNuO2yKINxYmx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YR/yq92lDGa4kqek0a5k3YOQlzTe1tdqLq9hDhCX/2SQjrx9BIClsJs8LA/UpGUcT nnNzYNKMRwbBYiLF1qPrr2yg13/RHH1tB25igPMocqr19Fxe7pyiI+Y20erBFz4Dl/ uFG+Ba9K0NXui09V4F9cRoMZsD/nlGiDh9MV5jgU= 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.9 127/129] CIFS: Fix oplock handling for SMB 2.1+ protocols Date: Thu, 3 Oct 2019 17:54:10 +0200 Message-Id: <20191003154417.046746814@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154318.081116689@linuxfoundation.org> References: <20191003154318.081116689@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 @@ -1419,6 +1419,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");