Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3021988ybt; Mon, 29 Jun 2020 13:08:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN7UfzdNuosb6+8XLKdYpapOT2O6wvng/KjnAr5bXLlZvP/EXLCfek0/zfBlFzLjjYToue X-Received: by 2002:a17:906:e91:: with SMTP id p17mr7866064ejf.252.1593461317357; Mon, 29 Jun 2020 13:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593461317; cv=none; d=google.com; s=arc-20160816; b=AQpfw2DxkvPyIDtEDRewh+ASPiOuOcdfafDiJj3jU7CzmHTRAWgOdxlf83XIssnrGy VhhlHMI27nqLCSBfFXtgZ6hEwP+aRJVDtGkFasdPZWJUc++863YfdC9icXtJ+ssk6Qej IS4EJg4mc6/0SJNvq2SzyqorvN1odLx65FaQP65Go9rJcSJ86KFJQc7zqGdtqRge154u gNLMO8Ct/gx4Abe1MDqaiTAg3nNvXKaP3loU6EHxuhskmaplmP3DEZjjh1tqdOCxa5sB ANfNAvvaNWgb87JgHHkpTA3xodKN7e0xUNLu9L3SEGohW9SfRnE8Tv128motPmlGfKea 1hvw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=edyS22HAhDc3AVRDcFMedRq1EfWOAOK6F/u+530EWtA=; b=K98GMKzjMuqKevrPV3RRCcp+6aT0v1q5SXzrAP43eVtzDwjitxKz0PrS6claH/0UgW SXvTxQeY1z/47RSlIiemkRvw+yojL3j+6CtKykzdDfACZKHUJNbvoDD5dGw0sLaMC5fC 3J5uPCYrbOyiqHd5KfLz1uQ0CnghPRopMO0Re21Sz6hhnsSlSrY8fW/+oLwjFPmlXFjU u/60HKcigKZYF9l8DK+Q/ypA6uWdRtHj5Bqy5vowIKYwP3nxptxjSkxAowGLaLoV1anq nIO0PeWy3J5Tnw8qb6/dEA5Zh+85eWTzqkFXU/yDQkDmjy+Yte0E03hiyqwNb9OpE1Vy YwNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PnTDbUEq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o10si394469ejn.140.2020.06.29.13.08.14; Mon, 29 Jun 2020 13:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PnTDbUEq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388892AbgF2UHa (ORCPT + 99 others); Mon, 29 Jun 2020 16:07:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:40564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732946AbgF2TaY (ORCPT ); Mon, 29 Jun 2020 15:30:24 -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 3BCA125248; Mon, 29 Jun 2020 15:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444962; bh=3rNnnkQvxgqmhcMErzisHMd6/5gUFMS/6cR9myII+UM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PnTDbUEqlLY0LOg9f1pIYC/OG4uTP9CuZfT5BxHyFH1hn3glkqp7eeHqpILWwoEAC +IQHVv4r9Iyd7BHJO5CHVFt5KPx3FWb+/g14BJsWfSYbSJu3FRXY8zkvXBjkNWKdz6 /RqSvA2A36g1x9uGgbyEM/fETfJ6inuru5A7Jk3Y= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhang Xiaoxu , Hulk Robot , Pavel Shilovsky , Steve French , Sasha Levin Subject: [PATCH 4.19 060/131] cifs/smb3: Fix data inconsistent when zero file range Date: Mon, 29 Jun 2020 11:33:51 -0400 Message-Id: <20200629153502.2494656-61-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629153502.2494656-1-sashal@kernel.org> References: <20200629153502.2494656-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.131-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.131-rc1 X-KernelTest-Deadline: 2020-07-01T15:34+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Xiaoxu [ Upstream commit 6b69040247e14b43419a520f841f2b3052833df9 ] 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: Sasha Levin --- fs/cifs/smb2ops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 0b830ac8a9e72..2a523139a05fb 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2180,6 +2180,12 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, inode = d_inode(cfile->dentry); cifsi = CIFS_I(inode); + /* + * 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)) if (keep_size == false) { -- 2.25.1