Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2300813ybl; Thu, 19 Dec 2019 11:13:43 -0800 (PST) X-Google-Smtp-Source: APXvYqzLhQM4b0upchYiV0g8FEGoHvV0V4i1r/rDIr9Mf4aQy5jRLQuGNhJSO15nOJ50OIpG4bYJ X-Received: by 2002:a05:6830:4a7:: with SMTP id l7mr8146866otd.372.1576782823005; Thu, 19 Dec 2019 11:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576782822; cv=none; d=google.com; s=arc-20160816; b=U/L7wPl7GmgKTKyA65oKe9v0K1TuYvpp5RbIIFEq1UU4ulZVoyW+QIxfNrtAS6Zng7 wib3Qlo7hFAH5RL7ejQfO37eWE1mvlC/jTput2XHcGY1y1hiw61pArQS7ipFPMWE3XzG IdTyGZmKa4FVl4AH40gtcEoN2VvUa3Yb2FjcJJhr5HeteT7LV0YYTcw0DnlrxkCZs6sr GcMY60AFuNIYtDY2xaaf2FiXBWeTZUJU+auvG9etgv5GrgJd7WL5mQviogDpr8Re8QHV ejKDeYUJfMksARwNQwL4/zCMn4sWAzpgKubS6bLKwD6Uw28NcgJVZiJUFY8rY/LFVghi X4LQ== 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=YkuoxiL0HNrlYed+wgbJZVAbkfk1Se38jx70iv4wlOI=; b=DSmIQ/xs9B3Fe1HIxMglcdGY5jK27tI+CFadlvC23BLxh47ZlOwBpwsZvfw6i/x0Cr faV7Qih3P3c8uhhsey7DxQaROAniOCBJykSJB3GW4pmXYoD1YHamVVw/IKvAxQgwpxCZ 220tQ0hqVUg5fpd8cq9pIAwGbnZ/jlXXCNcC7/094Lyc9Din2OJ0axs2yiHZl6Mwcwqy z4r22euh8yZmkEXkVZQma7hl6s2ugkdf5nCfvvNxqeQDwqYsg1qmrl4JZbpjdf/+yW2J vm10POh8nTWqnXzWbV8jh38piD9f1xTaJ0ftjGgLLy8MiJnCCdofHeBRexQa0XRHBwY1 nlCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cFhzklpT; 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 s26si3681603otr.38.2019.12.19.11.13.31; Thu, 19 Dec 2019 11:13:42 -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=cFhzklpT; 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 S1727835AbfLSShc (ORCPT + 99 others); Thu, 19 Dec 2019 13:37:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:55162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727824AbfLSSh3 (ORCPT ); Thu, 19 Dec 2019 13:37:29 -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 0765D24679; Thu, 19 Dec 2019 18:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780649; bh=BH8qikRBDt42ngMKoPw5Pib1vwe/elbNsYhbcf3y2MA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cFhzklpTP+HnOT2JnJkwGIwP3uxwvHj6HNNTTnRuVcqRQmZn71/ZNGDJQoysHYbQ4 tgJOj9LU6lXhQJK+wDHxOcdbzXmEBmNs4Du+0dHVAbhbeIp31tdETeZ2nvJ+T5Rr8h aQhl0HU3VTfKqznCtctJ2OwQ7vKzxU2dFzXz/SKM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Shilovsky , Steve French Subject: [PATCH 4.4 059/162] CIFS: Fix SMB2 oplock break processing Date: Thu, 19 Dec 2019 19:32:47 +0100 Message-Id: <20191219183211.467075228@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183150.477687052@linuxfoundation.org> References: <20191219183150.477687052@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 @@ -582,10 +582,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, @@ -597,6 +597,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) && @@ -628,9 +630,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);