Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp580993lqh; Thu, 28 Mar 2024 10:02:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWX2VIf9DnDlP3WXzdawIKM+9T/LE9DW08DXqDDleuzxozpIOKJqz9b4dOybA4z/f0rhyG9lS6l+GT5mvwpQPCBXLKddAGhc0N7rBX4Eg== X-Google-Smtp-Source: AGHT+IFMr5AnT6qCK1tbaRZ80Cw9W76FFK/WyaJseTn6CChB4uU/9Bd14l/hKYzlow1NR9NDFEZU X-Received: by 2002:ac2:5b1e:0:b0:514:2f24:b0b6 with SMTP id v30-20020ac25b1e000000b005142f24b0b6mr8852lfn.67.1711645344443; Thu, 28 Mar 2024 10:02:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711645344; cv=pass; d=google.com; s=arc-20160816; b=A5GENnn1zIi0cRPfaPi+HFQCDskxzko3ChA6asrJFdk/XB/nXIPbr9NplycvDB6DtK 41I5Mv34WhNVSovr/SH+EusqfcD09FfMn2mPWc8UpgT41GCQO8H0EqHk/ZLSa8ek3h27 vsIZ83Vbxl7dBveFSfrMpCNCKy0ggvZrCPxKp/+UsTskqm3t/PlXYl7kZx9Ltg2i53Vg u3EEBtGSHXYY1A8KPRF3T2gM3noIl4tNftq2630y+T3AVsy+JSOoPaFnQ+ZkpLDvYm8S 1BoB4BHPpke5YmXKyvJVJ6iNfMCeVDvQ25WmSsvLbOcAO/m/5HtVNLNO6RzQkeOCRPpf sQvA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=koZtPsH7hhKYp0dfXQczx6sKrVXjOZT1GIZj0qwvbyc=; fh=qGO61KcqD8nwg5doI1799cWr3E7eI1fHmScYq/qreMg=; b=R5k5nWOsglBa/m+ogsvx8BdiWS6LVH7qYgXMWc0KjuYeaJW9MAF1Ud/TgnmJROAQ4x VNcAPM0pYCHhW+T1n+7d3SBpwYbxN8+dcNgxcBXfhtqai5aOGLr4OVmjyWidDPAUjZXZ Rqd4o/KOAhNoYdyYLUXoBuTAQefBEIbFCapxfsdauSCOluyUtRfGXhCa3DjdEWGG/u8x mHMDA1CRtqRdWJcWggtxJqYTYWJWeWihgCouZFHTmMYhxsJD4GNslF8HbUrJVjkTAcVA NTAGSXt2pZM55gviNLnAmr7gublFeY01mkTvE9njtdj4wlcpvtSYKpjAPwSZWhbglIsz 35gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="BsjeLdQ/"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123324-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123324-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lf5-20020a170906ae4500b00a474bdae295si916303ejb.136.2024.03.28.10.02.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 10:02:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123324-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="BsjeLdQ/"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123324-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123324-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CB5C81F27126 for ; Thu, 28 Mar 2024 17:02:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69A08132802; Thu, 28 Mar 2024 17:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BsjeLdQ/" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 170AC1327F8 for ; Thu, 28 Mar 2024 16:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645201; cv=none; b=sHl2rX5LCgpfC/vI8TnNFj3jTMOHWoWVxI8wh/EjbV3+19OyGneZUvr2r236R1jACdmSA0cFzOOYSy6VD6nuR6afCPCYmhIOPu49GgCA7GsgJonG3rzuPl4wkOR64BQWRmhImM0Eb+Douf1tfrGYmH8pWQEUgAnOyaZybL/M1nk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711645201; c=relaxed/simple; bh=lViBTFxW094B27mO0CNb4JcXxIC1M1VJ7XSGfavhzeI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mQ+Xm4l4hdqU639p6PxeToHuEUhXL77vg8quYE+IfkyAJS6ufIamt5h+Mrb3yuqUe/Q3N1RZlma6CUbrXPvU1QyjXJ0+V4leTR9Bi9vlJVH1g4+3s5kbG81w93MnXBYxXMw+d3v9WBk9eEfdTQK14s0VXZARnmAvXiAiKCFlpXY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BsjeLdQ/; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711645199; 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=BsjeLdQ/P3A0lBeDoU+x35AjMBHMQk/JcRaOSkjSQm1rOu1hlDdtscq1SrTCn5WXk53wuq 48Q+V6BZhXBRQEUouTi11oTRqijH3hcbC2P4kSDSlfGDHgad55dKW+aHfpv1TSeSHlKcfT opIm6gyALbVOqfJKoP0v35UJArpD7ig= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 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);