Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp822170ybl; Wed, 11 Dec 2019 08:02:58 -0800 (PST) X-Google-Smtp-Source: APXvYqyc6aNcVEnlJ+gHlH2NQJK7Ydu59O5s80E6SOaZ0B5Ov99SdnKMXmVXZXlYioCj1zZcOfXb X-Received: by 2002:a9d:4789:: with SMTP id b9mr2600393otf.247.1576080177803; Wed, 11 Dec 2019 08:02:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080177; cv=none; d=google.com; s=arc-20160816; b=vlCZdXzG4+68xnUKlOmIPKlQDr8Kjfq0jH+4UBKtWbumsA8U69DPJuzGoTCeYvUuOB FcQtt9Hyg1EXHOr8oJ9Ybe5rMi1IO8EDJaV7i+M8UAxf053XDKpc8DZDO0r3ybi0/KIx NkbtC1QGXdB/uqPP1QqfsReIFQd7rXw59hTVbzn3xGW6GbUEsgLxlqoUz+o4WPJfC/co i+iMGLrQzaHTa9b/eCq6pfhM8GwRpY95NfYk6rVBb5pyPw/aepgSH22mpOhmiJInW+Ol 0rhw1Wi/IySdDc8p7Pk7j6pIH+gGJrQ2MXR6k9op+4e3k4jtHvd4AyJkk3TEJVGhCnce WquA== 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=DZxsHnADgpe6ek5bIgkAEnkh0VaQVzZ7tsd3TE5SJbs=; b=sJWyFIQYjcaIf83mBF+bw4DE8lE+temMB3vXGTz4zcdi2N7my6okAXY42ebojN0WMJ snucPQ5u6EUC1l1yvJdIc17a0O6FbfF3r7hW+jyIIMctqBn0WJNO2LOcwSM2Gir6D8VA jbHTiwjMt6nNfpq/oNWNhe8Ojma7wYvdr0/jjHN1ZxXRRY5Lwu7XuTNVBWmWOWHB6jFf n6RSLSlV92Ilro1EV6B9Q06idvG5PrNebYohlZ1mFCXEj8M9eXoQcjdSDeK+Cf2+h7Ic 5nvcwBXdlww3SG9cjgNcr3C4IuFJg4MtHT5CBZCM6kqgjFavWSiI6FGC58ZMeJa8uJrr UI2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wRC0lB/H"; 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 j23si1200175otr.48.2019.12.11.08.02.39; Wed, 11 Dec 2019 08:02:57 -0800 (PST) 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="wRC0lB/H"; 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 S1733038AbfLKQAW (ORCPT + 99 others); Wed, 11 Dec 2019 11:00:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:37846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730660AbfLKPNs (ORCPT ); Wed, 11 Dec 2019 10:13:48 -0500 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 E2C792465C; Wed, 11 Dec 2019 15:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077228; bh=yNEKqnYFfGAB5VCK7Vas/fD9z/qwhU9RBGBWkm0MGc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wRC0lB/HfM4Ires92KpnwGSsP3X09b2J/2Od0PpgY9VdBpp31yThvgb/MInfgU+W1 4+zXTrYhNFGcK3kIujdF3VT+9u/z+zvfCNMon8ppHzebbl+JAFyIg4OGesodQjl7wF Hfr9T/CX6XrYK8/YaA1iqwzQY4kiySvI9/2S93mA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Shilovsky , Steve French Subject: [PATCH 5.3 065/105] CIFS: Fix SMB2 oplock break processing Date: Wed, 11 Dec 2019 16:05:54 +0100 Message-Id: <20191211150247.522356509@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@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 fa9c2362497fbd64788063288dc4e74daf977ebb upstream. Even when mounting modern protocol version the server may be configured without supporting SMB2.1 leases and the client uses SMB2 oplock to optimize IO performance through local caching. However there is a problem in oplock break handling that leads to missing a break notification on the client who has a file opened. It latter causes big latencies to other clients that are trying to open the same file. The problem reproduces when there are multiple shares from the same server mounted on the client. The processing code tries to match persistent and volatile file ids from the break notification with an open file but it skips all share besides the first one. Fix this by looking up in all shares belonging to the server that issued the oplock break. Cc: Stable Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2misc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -673,10 +673,10 @@ smb2_is_valid_oplock_break(char *buffer, spin_lock(&cifs_tcp_ses_lock); list_for_each(tmp, &server->smb_ses_list) { ses = list_entry(tmp, struct cifs_ses, smb_ses_list); + list_for_each(tmp1, &ses->tcon_list) { tcon = list_entry(tmp1, struct cifs_tcon, tcon_list); - cifs_stats_inc(&tcon->stats.cifs_stats.num_oplock_brks); spin_lock(&tcon->open_file_lock); list_for_each(tmp2, &tcon->openFileList) { cfile = list_entry(tmp2, struct cifsFileInfo, @@ -688,6 +688,8 @@ smb2_is_valid_oplock_break(char *buffer, continue; cifs_dbg(FYI, "file id match, oplock break\n"); + cifs_stats_inc( + &tcon->stats.cifs_stats.num_oplock_brks); cinode = CIFS_I(d_inode(cfile->dentry)); spin_lock(&cfile->file_info_lock); if (!CIFS_CACHE_WRITE(cinode) && @@ -720,9 +722,6 @@ smb2_is_valid_oplock_break(char *buffer, return true; } spin_unlock(&tcon->open_file_lock); - spin_unlock(&cifs_tcp_ses_lock); - cifs_dbg(FYI, "No matching file for oplock break\n"); - return true; } } spin_unlock(&cifs_tcp_ses_lock);