From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC57BC433E0 for ; Mon, 29 Jun 2020 19:58:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B63882072D for ; Mon, 29 Jun 2020 19:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593460733; bh=y9SKW42hDJ6sb/H0jPIXkNCe/2NAlpnlZuUbBnlatuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=rJuF8ttWZKDYKcClOlSMn6qC336OVKAfVz6BbdPiSpLViLR+BXEsBOmyPBVKb8irR MGedfAJfdsD66T6yCT+yOu9qReVhH6sO4FozzxaDDwPJzjnMOYp3t8ePHNh0eznC2T WkqPs11VAoZuscNRKfmFVA9gDsxxthF3p1GKXPqw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388292AbgF2T6w (ORCPT ); Mon, 29 Jun 2020 15:58:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:47668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387589AbgF2TkR (ORCPT ); Mon, 29 Jun 2020 15:40:17 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1CD0A2487A; Mon, 29 Jun 2020 15:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444376; bh=y9SKW42hDJ6sb/H0jPIXkNCe/2NAlpnlZuUbBnlatuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tytevc6oiXqCZFQ/EwbiWV2sSNkL8MSyn9sXqqVvlecuStF5H+ynd5qb73f3ZPPQh SjudNRkJIQdar4JH0KK7SO6RdofD9EhaRbvKYbp33adOjVJGdjsucdl8jYZogMcnK0 qfjeL1mBjrRCv1de7GnroC/XwO2FZd4B/73mkb5c= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhang Xiaoxu , Hulk Robot , Pavel Shilovsky , Steve French , Greg Kroah-Hartman Subject: [PATCH 5.4 053/178] cifs/smb3: Fix data inconsistent when zero file range Date: Mon, 29 Jun 2020 11:23:18 -0400 Message-Id: <20200629152523.2494198-54-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629152523.2494198-1-sashal@kernel.org> References: <20200629152523.2494198-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.50-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.4.50-rc1 X-KernelTest-Deadline: 2020-07-01T15:25+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Zhang Xiaoxu commit 6b69040247e14b43419a520f841f2b3052833df9 upstream. CIFS implements the fallocate(FALLOC_FL_ZERO_RANGE) with send SMB ioctl(FSCTL_SET_ZERO_DATA) to server. It just set the range of the remote file to zero, but local page cache not update, then the data inconsistent with server, which leads the xfstest generic/008 failed. So we need to remove the local page caches before send SMB ioctl(FSCTL_SET_ZERO_DATA) to server. After next read, it will re-cache it. Fixes: 30175628bf7f5 ("[SMB3] Enable fallocate -z support for SMB3 mounts") Reported-by: Hulk Robot Signed-off-by: Zhang Xiaoxu Reviewed-by: Pavel Shilovsky Cc: stable@vger.kernel.org # v3.17 Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2ops.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index e38f21c44133d..7ccbfc6564787 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2970,6 +2970,11 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, trace_smb3_zero_enter(xid, cfile->fid.persistent_fid, tcon->tid, ses->Suid, offset, len); + /* + * We zero the range through ioctl, so we need remove the page caches + * first, otherwise the data may be inconsistent with the server. + */ + truncate_pagecache_range(inode, offset, offset + len - 1); /* if file not oplocked can't be sure whether asking to extend size */ if (!CIFS_CACHE_READ(cifsi)) -- 2.25.1