From patchwork Tue Apr 30 14:09:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13649306 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36FE4C4345F for ; Tue, 30 Apr 2024 14:10:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8DE16B00CF; Tue, 30 Apr 2024 10:10:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3DED6B00D1; Tue, 30 Apr 2024 10:10:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DE6A6B00D2; Tue, 30 Apr 2024 10:10:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7E1376B00CF for ; Tue, 30 Apr 2024 10:10:05 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 40DE9A1458 for ; Tue, 30 Apr 2024 14:10:05 +0000 (UTC) X-FDA: 82066382370.11.9DE84C1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 7FE434001C for ; Tue, 30 Apr 2024 14:10:03 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dm0k2xiA; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714486203; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6Ss/QoG4KZAnvVRZnfoKEIruxchZiLNdPXpNAK6SDko=; b=EGPfolN8h3Ap0KLxOLSWgSo3lgNw5ejXZsFi+vbRUvUE0N1mT2p8a5iBsRCVtFaQodRer8 wtPd91K0M2oVqYJCGgaR0oIEMvZFSedRwhQARpuUOj8mFdrTZuoBgb2f7yYuUlOWa2c3Wb QWGzEvoqrzM29NXP7Ca/t77uQJFrLRk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dm0k2xiA; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714486203; a=rsa-sha256; cv=none; b=Enrkk5nuFAPBQyAKV4ebSZjD3pKr/zOJ8cx2gmuD29blhFp+Clu3nMKiatV+PBXWwTM7lA 69rQIT8m7rPfoOZi9uKQGUyKREV18xXJTBFvw7/so2XBK+4BbK9fj7hVY9LLWlHYl4umro NfK/GEoj3HL4CpnXb9tZwr2pwRjewU8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714486202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Ss/QoG4KZAnvVRZnfoKEIruxchZiLNdPXpNAK6SDko=; b=dm0k2xiAZLicHBVcRuwL3w3WE3Fmwwcz7reF2rg7cuyua3lQxLbRCUHG79nTu7sfz85foE ZjgfGs5o+o7zEvoJIg6pbcrOzoyHcrgKKHIbQmKlq+SUOecCQdFHNUraDajppi0s15e+D0 +6OmmM6OYBK4PgrH4iLmMWT2ECg2aoA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-PuhxhG2pOZG572pAbBk4lw-1; Tue, 30 Apr 2024 10:09:57 -0400 X-MC-Unique: PuhxhG2pOZG572pAbBk4lw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED8C629AC013; Tue, 30 Apr 2024 14:09:54 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A007581CB; Tue, 30 Apr 2024 14:09:52 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Jeff Layton , Matthew Wilcox , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Christian Brauner , netfs@lists.linux.dev, linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH v7 08/16] cifs: Set zero_point in the copy_file_range() and remap_file_range() Date: Tue, 30 Apr 2024 15:09:20 +0100 Message-ID: <20240430140930.262762-9-dhowells@redhat.com> In-Reply-To: <20240430140930.262762-1-dhowells@redhat.com> References: <20240430140930.262762-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Stat-Signature: gqwd59kaq7td6doux8e7xhzwbx43tr8t X-Rspamd-Queue-Id: 7FE434001C X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1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UqL/CtnfWUHlG7yXkk/zYWqsm2pNGQvTNVf8cgC+Qz2+v/3APCE9KsyrTY+W9gOs+csDhBkIZZ39f3N975wyJQszVc/ZUgWcyt5CeiD9GbAT3IEebacO4zulE6jagjkt+KoomfotqiTEcI5hVf0hr7z8rXfJetUKsSSEC6ehc43DpflgwqNAbRyBjJEgdUsDCtbwodUsNWnfM+o4FM5FZN8+cCOP7b47P5/vT0oGI3YVB6TxWmTloqSQMZkpDeL4beOG0acubdzjj8JA261NgC8caATH6ly9vjVB3SCLn3GnrqsGWpkL1m33DXbKizGKE/z6lQLedMjDB63cpJX+qyKF64XzUSmWpTdecXI7Kd0xcq6LDUJ+rzB/7oi3fuVy5XvQI3Mjm8DqtRlOEEwTxG3g4TPTpoLkvxGiUdFzjwyJL5oCBEdSCvozg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Set zero_point in the copy_file_range() and remap_file_range() implementations so that we don't skip reading data modified on a server-side copy. Signed-off-by: David Howells cc: Steve French cc: Shyam Prasad N cc: Rohith Surabattula cc: Jeff Layton cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/smb/client/cifsfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 847df5152835..9d656a08f617 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1287,6 +1287,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, rc = cifs_flush_folio(target_inode, destend, &fstart, &fend, false); if (rc) goto unlock; + if (fend > target_cifsi->netfs.zero_point) + target_cifsi->netfs.zero_point = fend + 1; /* Discard all the folios that overlap the destination region. */ cifs_dbg(FYI, "about to discard pages %llx-%llx\n", fstart, fend); @@ -1305,6 +1307,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, fscache_resize_cookie(cifs_inode_cookie(target_inode), new_size); } + if (rc == 0 && new_size > target_cifsi->netfs.zero_point) + target_cifsi->netfs.zero_point = new_size; } /* force revalidate of size and timestamps of target file now @@ -1396,6 +1400,8 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, rc = cifs_flush_folio(target_inode, destend, &fstart, &fend, false); if (rc) goto unlock; + if (fend > target_cifsi->netfs.zero_point) + target_cifsi->netfs.zero_point = fend + 1; /* Discard all the folios that overlap the destination region. */ truncate_inode_pages_range(&target_inode->i_data, fstart, fend);