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 2A1DA373BE8; Wed, 30 Sep 2026 03:28:30 +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=1790738912; cv=none; b=WQUpUKp9aqbZNZxfOWqaXDDaJTp1GZ6F+bbAPWJ98N6L0gOzhGNAQnHWhxDINo00j7VmPoSsnoQUlipsoVZB0UXGlWnlba+PAR835YaUOGnZmxZaYZB+ETmBscJLQlyqUAxfbKqHIn1+wK8YKsDEuNCCY5sQ16V/siJdLNAyCGQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790738912; c=relaxed/simple; bh=VYetu5GlmkBYCupVxCStW4KeCkFuwTmWqXDo/0jIqYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oiURaG0h83mguRGeerPUDNXgQTAXYMpsQszFPyQvrd6qragDOFwuMUdG5HYvw+Cp75kHsRpLecp+Nvh1b9MM6kdzVjelvgFr7wUYO8bFLF5WxaJ+vQuFdIEHBK0o5Pc5zmNQBz9k4bY6j5/ZIXMfzQDxODsdFISOT/9p9FNGBAE= 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=H24gHNUT; 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="H24gHNUT" 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=nigYM/lqtXWmFwckd/9335OFQ7Pfwm1I9E8/VT9wEoc=; b=H24gHNUTZshAMibEipMfFJLNIS RvvAKLVzmzKdTxUGV/Nx3OFo5iuv/95B/R5BLqTy4YknJcbFDic6/fi8H7kJ4Ta5m4xRfnTmlNQdb +H94syuRy+JjY+wufuR76C+lIqiqaArPAE8oKryzFD79pcOayZqWJNsYBiLl7xcZ/wNqe9ZV+71qs NWFeX9Ob1zgHaiwQI5HjFzEJ8tqxejzhlBN8rOWosUG7FPueWeQPH1UNv9iZjuAaQdtjqdkreYOeO JGtVauQb2v4jTycuqfAQnof+7ll8C7BwOaK6VYlFsUaXOmb3h9Qxrfz1IMTfkcxpIeLMOWgqVRUVm YwAaBYTA==; Received: from pc by mx1.manguebit.org with local (Exim 4.99.5) id 1xBkzY-00000002asF-49nU; Wed, 30 Sep 2026 00:28:24 -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 v3 05/15] smb: client: discard post-EOF pagecache when extending a file via clone range Date: Wed, 30 Sep 2026 00:28:12 -0300 Message-ID: <20260930032822.1835287-6-pc@manguebit.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930032822.1835287-1-pc@manguebit.org> References: <20260930032822.1835287-1-pc@manguebit.org> Precedence: bulk X-Mailing-List: netfs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit cifs_remap_file_range() discarded the pagecache only for the folios overlapping the destination region, so when a clone extends the file the folio straddling the old EOF - which may hold data dirtied past EOF through an mmap - was never dropped and became visible as file content once the file was extended. Start the discard at the smaller of fstart and the old EOF. i_size is still old here, so nothing past the old EOF is flushed to the server. Fixes: c54fc3a4f375 ("cifs: Fix flushing, invalidation and file size with FICLONE") Reviewed-by: David Howells Reviewed-by: Namjae Jeon 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/cifsfs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index f1fb4b7b7b7c..6410249f529a 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1467,9 +1467,14 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, i_size = target_inode->i_size; spin_unlock(&target_inode->i_lock); - /* Discard all the folios that overlap the destination region. */ + /* + * Discard all the folios that overlap the destination region. Start at + * the old EOF when extending so the folio straddling it, which may hold + * data written past EOF through an mmap, is dropped too. + */ cifs_dbg(FYI, "about to discard pages %llx-%llx\n", fstart, fend); - truncate_inode_pages_range(&target_inode->i_data, fstart, fend); + truncate_inode_pages_range(&target_inode->i_data, + min(fstart, i_size), fend); fscache_invalidate(cifs_inode_cookie(target_inode), NULL, i_size, 0); -- 2.55.0