From patchwork Mon Feb 5 22:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13546376 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 80B2BC4828D for ; Mon, 5 Feb 2024 22:57:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 599B46B0089; Mon, 5 Feb 2024 17:57:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 547606B008A; Mon, 5 Feb 2024 17:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C2EF6B008C; Mon, 5 Feb 2024 17:57:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2804D6B008A for ; Mon, 5 Feb 2024 17:57:44 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 04FABA208A for ; Mon, 5 Feb 2024 22:57:43 +0000 (UTC) X-FDA: 81759264048.21.6C9F2E4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 5E3AF1C0012 for ; Mon, 5 Feb 2024 22:57:41 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fs2+Y2Hu; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1707173861; 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=9AufEF5BoE2ti1jRANwQA21BYnThNCxSf+Ymoah+TR0=; b=PKrMfkNRIzkWN1+jLHvnkshtavHuGt6LMHZ8Qmm/oITkC7HUC1cdE5Jca7h1AUXIVD5AuD zAn7pw62PN+DbKKKy3s1OfmWUuvmPoWzC+3O306JCGNeFSgpfYyzeXDMw1k1hbHmOmKDob cX+XPs/tpjXr8IgYNsjqPIxgPFGT58E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707173861; a=rsa-sha256; cv=none; b=8fO5e8JRe9t+sebSrj3vGxXqKloJjgXnjaCzXS9p2O3FGKOoOWDtBgWuZ/RLqGTeBJxwBx ppneb1yh1boe8+NUfhcrH3HS6MTMO3QKX98sXVjL/zWkOaZVd/DIFprZ0QvvaH7DOGx4du alM4WKO+D2t98fHjdFjT+bxkgZ14tjY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fs2+Y2Hu; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707173860; 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=9AufEF5BoE2ti1jRANwQA21BYnThNCxSf+Ymoah+TR0=; b=fs2+Y2Hu39vvvgdw+IIA7ir35pskaoenKOe3gE5T/o/PyedRqjhaFjs5EvXoiStxwGS/56 GnK5TDIz725HVFFTLIOpw0hbdbEHRWHFaPRTjtnYEw1OKnAhVTqt0TrsYGD64pLGu+ahYv DlvWcO6biDKt7dK8sx7NA88s2HjvHNU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319-6-Z_WH0MMm-tUd2tJ60avA-1; Mon, 05 Feb 2024 17:57:37 -0500 X-MC-Unique: 6-Z_WH0MMm-tUd2tJ60avA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 9D74C8870E2; Mon, 5 Feb 2024 22:57:36 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD0DD492BC6; Mon, 5 Feb 2024 22:57:34 +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, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH v5 02/12] cifs: Set zero_point in the copy_file_range() and remap_file_range() Date: Mon, 5 Feb 2024 22:57:14 +0000 Message-ID: <20240205225726.3104808-3-dhowells@redhat.com> In-Reply-To: <20240205225726.3104808-1-dhowells@redhat.com> References: <20240205225726.3104808-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Stat-Signature: k4978rwwdkg139brgqo58ydpz51pxhn7 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5E3AF1C0012 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D/6KgVtpZw0u710yDYudvg1yTUYTm5e1SkJEtT5x9jUcyU0DAm0J2SIfzw1whWGOCSWtHKH+RgvgZEdUsBfBJamsuYVCE18+KVvNLW6uskbId127V1AqaOrPnL22gLj5f4ahTimUWc9e1uJS45Bl2IdEnFYUuiBQiou6Y43xLWcfHLke6XK5EpSxv3wJ/gUshc+DfWSC1UnSABfE8ukeXAzc/KL18bQcjZX2UnH2MeMb10NCpRQH6BMYnIXb6r3ndE3fECToK4NojaNu5v/MHfZ/jEEriDtOHIcV0qbMBJ5n1fNcEFSl2xOCuJZn0pfVzn/b/22qGbkKwFTRCmfhd2cD1G/tayB2Av+jYAAjM7vgCmcR9wBB/PM9KlQMYNMDbZMysaG4l3jWI2hR+Eyc0mgXW3jdPIJlwnXhBGnbnD+0T8FY2LdvmDtKB9ht04A== 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 2a4a4e3a8751..41617541d175 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1340,6 +1340,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); @@ -1358,6 +1360,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 @@ -1449,6 +1453,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);