From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.manguebit.org (mx1.manguebit.org [143.255.12.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBEC43BE632; Mon, 28 Sep 2026 20:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=143.255.12.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790626191; cv=none; b=kntwe5nTFEHdEgSrjUdhfX6EiswvvBztgSm0kpUrhb0RucrvDsqxOqr8D0QB7TtbsPCg0eD80I3I1lASBju8d79Kqw08YZ8H27ZdmPz0hh2gA+f60yl0BQ5UbGQvlMwBVJXEudfPxeK3/iUlhVj+GeijcwQKVtYCl/hoBbBztDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790626191; c=relaxed/simple; bh=tNo3RGRl0mHjhYe4yo5R9ghVMANq9TkJNE1Z3AXQgVM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H8WTF0pOQqL9/rlw5BpSwUsFQAvQ/It5A+1qUZjVNILcrtvgFVup0X0RyXSrt+LWpd6uyt2X4FMXA/zUihrRqWFvNIhJWP1rnV3RLJnI6prdEhKu88gqaGmpQrO01YsV2nZ6V+4zZrRhGHRJnEbMv0fQWrYIggyFYNtmCtiX69g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.org; spf=pass smtp.mailfrom=manguebit.org; dkim=pass (2048-bit key) header.d=manguebit.org header.i=@manguebit.org header.b=IVObg1TE; arc=none smtp.client-ip=143.255.12.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manguebit.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manguebit.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manguebit.org header.i=@manguebit.org header.b="IVObg1TE" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=manguebit.org; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Content-Type:Reply-To: Content-ID:Content-Description; bh=rLblEt6nmUNeeLCVb8Trztt/wB1WKTYrddiQDKv0hho=; b=IVObg1TEjWJomTP7BHHI5QBGtD HX5BzBzsHUC8T63loOVadxz0aeTwJnZOZ2eTQBviGORIG/u+CWpIIVJocgYtfAMrNxS15cD3YHSQ3 PuDGxRCdInVifebUgMIESI9+acMY72Y3Jf6hxGfKbWRqGTCz14bIZEBx1KXlE/SWSHWq8stTI5pdd 6rhpcZMzYagL2JrNkuLclNwTXImuvXrjhhL0v+DBuf0rsi3ZA3ijzx+PjgjfQLmY8SgW7Je/lT8wt eAHQ/1rYc/9cX2bm/3IFtyYMCmvVcqJC+S0z6qVYL0aoZuZAO2wufwB4eZAv1+Xu6iwe/EcoxMP5q AWPv9zJQ==; Received: from pc by mx1.manguebit.org with local (Exim 4.99.5) id 1xBHfN-00000002UJW-1VmF; Mon, 28 Sep 2026 17:09:37 -0300 From: Paulo Alcantara To: linux-cifs@vger.kernel.org, netfs@lists.linux.dev Cc: Christian Brauner , David Howells , Matthew Wilcox , Namjae Jeon , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , stable@vger.kernel.org Subject: [PATCH 08/15] smb: client: flush dirty data before zeroing a range Date: Mon, 28 Sep 2026 17:09:27 -0300 Message-ID: <20260928200934.1040189-9-pc@manguebit.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260928200934.1040189-1-pc@manguebit.org> References: <20260928200934.1040189-1-pc@manguebit.org> Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit smb3_zero_range() emulates FALLOC_FL_ZERO_RANGE by invalidating the page cache over the target range with truncate_pagecache_range() and then issuing FSCTL_SET_ZERO_DATA to the server. Dirty data was only flushed conditionally, when the range reached or extended EOF. For a purely interior zero range that does not reach EOF, no flush happened, so a dirty folio overlapping the range could be written back to the server after the FSCTL and refill the range that was just zeroed with stale data. Fix this by unconditionally flushing and waiting for dirty data in the range before invalidating the page cache and issuing FSCTL_SET_ZERO_DATA, exactly as was done for smb3_punch_hole() in commit d7d2adcd022b ("smb/client: flush dirty data before punching a hole"); the two paths are structurally identical here. This is observed as generic/363 randomly reading stale data where a zeroed range is expected against Windows Server. Fixes: 91d1dfae4649 ("cifs: Fix FALLOC_FL_ZERO_RANGE to preflush buffered part of target region") Reviewed-by: David Howells Signed-off-by: Paulo Alcantara Cc: Christian Brauner Cc: Matthew Wilcox Cc: Namjae Jeon Cc: Ronnie Sahlberg Cc: Shyam Prasad N Cc: Tom Talpey Cc: Bharath SM Cc: stable@vger.kernel.org --- fs/smb/client/smb2ops.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index dbab69d1b28a..6e1682dedb87 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3547,13 +3547,11 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, filemap_invalidate_lock(inode->i_mapping); netfs_read_sizes(inode, &i_size, &remote_i_size, &zero_point); - if (offset + len >= remote_i_size && offset < i_size) { - unsigned long long top = umin(offset + len, i_size); - rc = filemap_write_and_wait_range(inode->i_mapping, offset, top - 1); - if (rc < 0) - goto zero_range_exit; - } + rc = filemap_write_and_wait_range(inode->i_mapping, offset, + offset + len - 1); + if (rc < 0) + goto zero_range_exit; /* * We zero the range through ioctl, so we need remove the page caches -- 2.55.0