Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp24532ybp; Thu, 3 Oct 2019 09:39:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6WD4eb5w1PwH5x7MxMSh8o/MXmS3+NOEuOpR2N0XXxVLu9yufNkOD+tXuAtZGj2I/ZPLj X-Received: by 2002:a50:d2d4:: with SMTP id q20mr10659243edg.172.1570120786990; Thu, 03 Oct 2019 09:39:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120786; cv=none; d=google.com; s=arc-20160816; b=bzGVITjxjQE6qlL5jU0y48fGGBuHrtyGK54TKM7ID34e8SljdrUWWl4egM5upuZo/f 5MOVZgppzYrGXGE1X+OM2rrUsUAHXsoLO06cKh/SQQlP5Kj6+lyvw5fawvM1hGCU05H7 H3Q7qfbuwbQkLvba17kX4U9aIiXR12Ps36zJqPD4bZoB85Ki9k3ZAYqZkBNmdLVIgUcD yLULQxulfTPo0tOlSlJjlDBP1DtuyjJOt9mw8XMBtRMpwLwRbcbUmeSIala/FEtbkViB rA0tGfa/D2o6N7mU9epDPl+bIkf6DLsRiu7t19Kb04x16GSlY9dMKDLmEhXZlFbQRENU AUGg== 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=hWDvwStM9FTEPkgyeBCGmKvSsdSHQNL260miVcZbi8A=; b=Vog1KDbKZ7UoUx3xzLLsrRd8hRsuY5i/qJ2PXZ1OSK/boBsWWjvCSDE1Y1skj3quTt 8r9gD90ZcyS4qLUrYV1q32x0RJJ9vjdQgNmlVdOYc9ldiP1/fkrP9vcm1wnoFwlucH3t VrWigPs+FLdHiovbdl3mnMYI+LqnSV8a9/unymdtR9rK68kuyRzkorcX2Aut62hHkkIz xdAtCuip7SPkPpaU3NRzb3HEH1mhFeueWHZCJ5eyHC20M8s5cCw3bLIAp/sEAi28L0HI D3PU4sWO1o4bmtGEA7f022F2LIwK0ARB4yVaxK9NyTqTW8tDgBmivfbwz4cHQFgXuLMu KXWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="lLCJ5/gl"; 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 a15si1811032eda.222.2019.10.03.09.39.22; Thu, 03 Oct 2019 09:39:46 -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="lLCJ5/gl"; 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 S2392275AbfJCQhv (ORCPT + 99 others); Thu, 3 Oct 2019 12:37:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:47302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392264AbfJCQhu (ORCPT ); Thu, 3 Oct 2019 12:37:50 -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 5792E2133F; Thu, 3 Oct 2019 16:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120669; bh=01agJby62tuAeRXLk6W4fILSArGI+QScEtBbvEtPdOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lLCJ5/glE4vm1oXI1iXJIthQ//9fSoryumPowcNQk98uQCB9uRADmYfc05WIVYkSg +tBXM3+fhtB/bojaGbqynZ5/VR4exa5w6f5lT1/byjlgxg2zxY4WT25Up7l+NqPy76 24B1TmYFDG67kr2tVwNCap32l+dxytNqEIqJNOQk= 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 5.2 308/313] CIFS: Fix oplock handling for SMB 2.1+ protocols Date: Thu, 3 Oct 2019 17:54:46 +0200 Message-Id: <20191003154603.524398245@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@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 @@ -3254,6 +3254,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");