From patchwork Thu Mar 28 16:57:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13609177 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 23CA2CD1284 for ; Thu, 28 Mar 2024 17:00:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A518D6B00C2; Thu, 28 Mar 2024 13:00:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A01926B00D1; Thu, 28 Mar 2024 13:00:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C8EC6B00D2; Thu, 28 Mar 2024 13:00:00 -0400 (EDT) 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 6C6CE6B00C2 for ; Thu, 28 Mar 2024 13:00:00 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2BB41C0EE2 for ; Thu, 28 Mar 2024 17:00:00 +0000 (UTC) X-FDA: 81947060160.23.CE742C6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id C195210002F for ; Thu, 28 Mar 2024 16:59:57 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c2mm96yO; spf=pass (imf05.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=1711645197; 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=koZtPsH7hhKYp0dfXQczx6sKrVXjOZT1GIZj0qwvbyc=; b=LIWlR+bM3UCbcN+b7cTUjGu+n0kegYrqaS6rqcwNWQZywdQtm58pN4+/qPAt9VaVNkYqT8 cBDrgsgJ6FKbrjQsdQznAda9R90wf90/v2RcNxWh2Xv1JcVfwuNHEaWOo6o7oKBfvDF/wc l+r54B5IOSFoQ9Zp9iBRCHeakCaLk2g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711645197; a=rsa-sha256; cv=none; b=RBO1D5JmIw0N429vcUU9Tt50wDeBbiZdtUiYk0CI78ejF9lrTgyrfQHw1fbqa/xZ4w/TuH GaeQsFBbRWVvCL5DfncLOk6ixKgfyu7nPL5Gn1Jh/01v5ueZth7bW7N2O3lKA5d9VD15wl Ibc4ilHWxqLZzme0pYcHtswDM9dbFmw= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=c2mm96yO; spf=pass (imf05.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711645197; 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=koZtPsH7hhKYp0dfXQczx6sKrVXjOZT1GIZj0qwvbyc=; b=c2mm96yOjdp/ch4ELAuAG/vEZIUaDWxVP96ngXff3l1kThShe5Fq7QUSPUaaPzBGAlVsKG VfzkXghPnAQxjpc4sgFkkjak9JChfDk1oHJEzcx+vqSb7+EZr4orF58gDo8v/xx8I9Ibe1 B8EX+Y4c16ZCMZj9hQ0SSE1ZngYeBE4= 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-270-x0mgGlrpM3uifVCi1HPq0w-1; Thu, 28 Mar 2024 12:59:55 -0400 X-MC-Unique: x0mgGlrpM3uifVCi1HPq0w-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 F0E5A28EC106; Thu, 28 Mar 2024 16:59:54 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id F01722166B31; Thu, 28 Mar 2024 16:59: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, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Steve French , Shyam Prasad N , Rohith Surabattula Subject: [PATCH v6 07/15] cifs: Set zero_point in the copy_file_range() and remap_file_range() Date: Thu, 28 Mar 2024 16:57:58 +0000 Message-ID: <20240328165845.2782259-8-dhowells@redhat.com> In-Reply-To: <20240328165845.2782259-1-dhowells@redhat.com> References: <20240328165845.2782259-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Rspamd-Queue-Id: C195210002F X-Rspam-User: X-Stat-Signature: j7wxequsqt4hpyuxgeauumkcrutx7p5m X-Rspamd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wJP0ZI/Vyo/+j9IPDK+elnZ4KPhrg/PbNIW32DDr140NH2Df2wmx9g+JZaT0W5nmDbr4sPwpR/jcDC2Um87FVl+TtuOQLtzJdS7OjW6z39naUsXf5wt4Pxxs1L73HuOVmfYALp8+c32WUy0T47cQuWoNr1K/tS4SQ37YQl314brNVpRYe/7dA5XreS51r9WR5VDIMm3jjTAiZtFnZ/5vobuytnQ8wMgNilwNZJm6e83JTNrtSYwTCwKO3VqPszgbx3SkQpm/DNc9pMaFbdiEsuNhFKSzOK1jPk427QiveO4NA5qSW2V+Bf3Ts+nW7r241qPkDjntVxMjUPpynxLLpXggSKeiscHbc718AJam6B8pecSikTXn+v2bSV+tFYnV6tn0uLD26G+Yb/SsXLXGZrk4EEas0EJXqR6wndQX3SpB2E0AkKszaCr+FUoTg7SF71RQGIYrLOvfndK480WRIQ== 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 e01ba9f8706a..2dd29663dab1 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1283,6 +1283,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); @@ -1301,6 +1303,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 @@ -1392,6 +1396,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);