Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp580376img; Fri, 22 Mar 2019 04:28:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6TmhBkfnmz6bsmvfT8RqH9cd9lTu4gASlDkVuO+LIhlolyFqj1u4HHneTV6QIykK6ypRz X-Received: by 2002:a65:6241:: with SMTP id q1mr8531342pgv.340.1553254110106; Fri, 22 Mar 2019 04:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553254110; cv=none; d=google.com; s=arc-20160816; b=kcY1d45BtxL+1a5DMhdfsiORpwAt5JSvSBHbRryKfYgRw8PLTGv2/jmgiy8nP9LHhC smoaJEdG61Q4x/oiORkP5jDL7WXVIWqsDt/zMlFvRL9bEPYF4alvx9B3ASeLMDG2oPQh TE71ei/VRxnKealNLqUe4AjLEgOi0lM1Q8DuY4anGpL5rqq3Rxx6tbClMiMDVyKh20xB 85qXwAp6e7DrzugPlEmw+AXDBmfQvTrRih4+SFdhGkfxiy94mtiAFRvvtN+5tx7VcV9T IHOEvFs2L/iDem0g3lyV2py4hAwkKaa3HaHM0BS95rvF1CGLCycxVij+ItgDhBBou9+j wmaw== 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=Gk6uOMh7e6ew6RJZgSuc5KAre5Nog79t7AFNUsxxf+c=; b=hHwjbVcWFN7umZnTrUOM2GqgxAd5w7y1XKJGNa0F5x5q01eBrQ7fBf6T1tEH7sxrvo oqTZTg8ANX+kJPaaQJnJP1NKejWCpTjpHyGq10w1h8njX8uh1XXGlsM/s6SG3vfxqTzx w0SY7zRDvEdNWYHBcoOxsIDakwYuaS62m37sPS6kKDXa6W59VZ64q1yUbq3pJwQ3+RXu Le0R8GCZD2N38vpU63mbOAuUVtiQ6RL8mHrOd/c/nlFjl1+bGQNo9Jc9NiJgIf3MqLGi +3QOWz0kk2uJr9uwyYWiAR7ovCKalaQkw6l+UDArt3E+Kl3jKBJpbzFZcSmJ5DYWtgTx JMNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hVEQM09c; 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 c22si6610564pgj.405.2019.03.22.04.28.12; Fri, 22 Mar 2019 04:28: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=hVEQM09c; 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 S1729250AbfCVLZM (ORCPT + 99 others); Fri, 22 Mar 2019 07:25:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:52458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728215AbfCVLZL (ORCPT ); Fri, 22 Mar 2019 07:25:11 -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 65E7D218A2; Fri, 22 Mar 2019 11:25:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253910; bh=jF1VomsOOJ5r90xfa1HfFFyyMujpQdBt0zSvSMWWtk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVEQM09cLI8dlLlvV+QDl1aKNHwg9q4E22lks3cShAu7pW18nNGcJEULx1vZfzfLf C9fQBRRC4noKO7eoYF3+wFDfMjBI4zkTadk5nbqYQPEJCX51qeUTfZjdDDCd0D30M0 R6YEQo2+QW8Ab8agkr31/w+4JMbON+xVfPz4rtbE= 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 3.18 109/134] CIFS: Fix read after write for files with read caching Date: Fri, 22 Mar 2019 12:15:22 +0100 Message-Id: <20190322111218.211259548@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@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 3.18-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 @@ -2772,14 +2772,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; }