Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp649214img; Fri, 22 Mar 2019 05:55:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz7AgS0Oju9eKNxoRQhfwx0NePeBpomIGxGzBkM02Dfqv4Jtrh03k49w4lF3mgfHnk5KvFh X-Received: by 2002:a63:5a1d:: with SMTP id o29mr3842245pgb.320.1553259330548; Fri, 22 Mar 2019 05:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553259330; cv=none; d=google.com; s=arc-20160816; b=w7p8RB/4n6OXzyzKIGAc5F0YumhIHP3Yp+EONmIPt4toe/OVl93C5/nYnX/psXHsMG 67NALmvrG0hMCq1NBTO3hx0WuUJggwGKUc5t/m+6QOl/8Jtp8RM6yUbJGVQtMLWj95N7 A5yu9ph2UPx4kuRk3/gyZzDicoOSYL8RQccRcCY11cw7/O+iNvPr0zOt4kbyTrQDNTPk 3POn6ijbgQZ1ZBsdY7yqom4mO0fiVCEbZyKIe5PvvKoTnVcymCJP5NxWhW4IK5tksSsw bu0OLGaZz83mXPjIuLW5Jo0bPuJdOKp5s8l/Muixsp5+IVEN+9VU1vHCmTRWbn93ia3I elOA== 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=x4jDnN3RiGX6K/W1S8t/RZHGvJ2BbPNXAFZ+PVYW7RU=; b=La1ur8UJhtGEJIgyfF0wkCDQ/BT3+p+VOhfCWELYmyE/bGA08hes8DtKHnzXidXZ1U HNDLc+6r5sPd43gOPEQvVbcRROWrJFSLNM5QF0osPfff1PghTwoTz7d5D+K4Lak6x1Xg emBP6fFOd2aSlxBqSKzDaTa2rWSV6CQ5XvoR0MYnpOzFwaxEzYsuTcDl2Za2PKXmj4o5 oGpT2Y6MVmUkmbrNBjQAqqBXMUIScuwm0oUVRl30WhOIphcOa5qyca3ChMcoCpxiwIoL zZFc6F1/HnoYFM9E9QPcBQ9AyvL8zUyys7Ho8VhST0LNQ6H16v7wOhstekRfGqslDUsX qHHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QgREu7fu; 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 l11si6693545pgc.473.2019.03.22.05.55.12; Fri, 22 Mar 2019 05:55: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=QgREu7fu; 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 S1732950AbfCVMyU (ORCPT + 99 others); Fri, 22 Mar 2019 08:54:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54934 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732324AbfCVLvD (ORCPT ); Fri, 22 Mar 2019 07:51:03 -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 6415B20693; Fri, 22 Mar 2019 11:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255462; bh=wYnfzGMCqjjh7zrpw0uWw8PskoMd051QuLKgxPPCl8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QgREu7fudUlSutAw2s7+Y657abhRi5zOl2zIadXubDKTvEjtj//JYuVU9eIWjjL6Z /qhrNEHhLpcdFrqdmwsH3BnhfRqaDhLeN0tF+kBbzC4hfimteWVmcgLvTPZy6kEiXb 2QKPpNKISngO6Nnw4ZzbdVf1RrZzZRwyu7uuN+NY= 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.14 080/183] CIFS: Fix read after write for files with read caching Date: Fri, 22 Mar 2019 12:15:08 +0100 Message-Id: <20190322111247.524556102@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pavel Shilovsky commit 6dfbd84684700cb58b34e8602c01c12f3d2595c8 upstream. When we have a READ lease for a file and have just issued a write operation to the server we need to purge the cache and set oplock/lease level to NONE to avoid reading stale data. Currently we do that only if a write operation succedeed thus not covering cases when a request was sent to the server but a negative error code was returned later for some other reasons (e.g. -EIOCBQUEUED or -EINTR). Fix this by turning off caching regardless of the error code being returned. The patches fixes generic tests 075 and 112 from the xfs-tests. Cc: Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French Reviewed-by: Ronnie Sahlberg Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2889,14 +2889,16 @@ cifs_strict_writev(struct kiocb *iocb, s * these pages but not on the region from pos to ppos+len-1. */ written = cifs_user_writev(iocb, from); - if (written > 0 && CIFS_CACHE_READ(cinode)) { + if (CIFS_CACHE_READ(cinode)) { /* - * Windows 7 server can delay breaking level2 oplock if a write - * request comes - break it on the client to prevent reading - * an old data. + * We have read level caching and we have just sent a write + * request to the server thus making data in the cache stale. + * Zap the cache and set oplock/lease level to NONE to avoid + * reading stale data from the cache. All subsequent read + * operations will read new data from the server. */ cifs_zap_mapping(inode); - cifs_dbg(FYI, "Set no oplock for inode=%p after a write operation\n", + cifs_dbg(FYI, "Set Oplock/Lease to NONE for inode=%p after write\n", inode); cinode->oplock = 0; }