Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5401469rdb; Wed, 13 Dec 2023 07:42:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IECqJwRYelg/jNBUJY3pnycxRafzv4SBYv6gJzm627mzX9UClach3YphuGLr1iYx0irlzw5 X-Received: by 2002:a17:902:7604:b0:1d0:6ffe:1ea8 with SMTP id k4-20020a170902760400b001d06ffe1ea8mr3702744pll.139.1702482158477; Wed, 13 Dec 2023 07:42:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702482158; cv=none; d=google.com; s=arc-20160816; b=fqPjWPlG6I4wJqTDuSVlVVfq4UvWL8nHfeGZ3u+yxqFGT9XPMIvLXZiSAMhBWD4Eo0 ycXrGzqgRX//belaZ/p1ZWT08UZP1Jz+6kXguZIle40DOt+knCZLoTVlVWBgfFL6e1tz iUvgnaZxvKkVmzXGyAfvRfDRDDYTU8YIz59PJUXtgatywSUNzVo8O5GSCdQETZecYROW qGCVlbP8wpnOYfHZY4BtNjW95BsN1RPJU/hJQDjIN6GuWge7jbPq0lFrELQOj3W240nS zEvh75CjrEmVs7FbkJkx1KUUaogzbBHM9gXyLSbOrAI6sfHk/Pp1BiE9FBer/zRWd2bP 0VVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WWGWFaVybn+Cuwok82Tqy8Z4Nj/F9zUC0bxWKAhhGjQ=; fh=/d04rGhva23/oMvvc+i8J/J8+GzO8KYoVKSGWp4U6JE=; b=KcQJNnZd4jMb6eHGTk4wsvvE+lbRrascyexsxw7GEbBnbfCcS+MY8APJ6W0S2nl5mJ DjR+USMZ1/3hghA8X2NcFclJGiIYpdmR0+7vAdRkoKt8TMgK6/Wu3hJITm7e1DUVz/Nf vIDrAx6IJ22syqC4a7Wt1Y2vDwi4ffzO2QOaFGbxKiKPVkVzQ/F0LDeHVksu39I2sPpO kei+NVO6kefDu3r3A8vfeaFImnOtq7FcyEKyTMH/M+bmWgJLeW11Ro4R30i8weZLMHyT q55bfzLcyStu+VqxAGnpbIec9yaKeqw4gBPok5V88Qb92iiSDv+vHzu4Rc9QpmntPmrU gWyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NfadNnnI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q16-20020a17090311d000b001b8922e82e3si9774096plh.297.2023.12.13.07.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 07:42:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NfadNnnI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0E97980401F5; Wed, 13 Dec 2023 07:42:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442429AbjLMPmI (ORCPT + 99 others); Wed, 13 Dec 2023 10:42:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442221AbjLMPl6 (ORCPT ); Wed, 13 Dec 2023 10:41:58 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943C2EA for ; Wed, 13 Dec 2023 07:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702482123; 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=WWGWFaVybn+Cuwok82Tqy8Z4Nj/F9zUC0bxWKAhhGjQ=; b=NfadNnnIbLU7ROQRYAFK/J6PuTpxqh3+bOJ5Jxw4J/SySAJa23u91B5tIt1/uZuT9xPbrh 09so5R7o/e/aKU+uL1z32t4p4WYBgpD7h+Tbdzz40gu1IjqpGrWX7mXa6Ja8d4cqeayma5 AN+8MLuAJUUXweHOme2nBAh2mRPo9vM= 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-167-NbVZ4rhjNzOCnjEj5MTkAw-1; Wed, 13 Dec 2023 10:42:01 -0500 X-MC-Unique: NbVZ4rhjNzOCnjEj5MTkAw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 A54728350E4; Wed, 13 Dec 2023 15:42:00 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3785492BF0; Wed, 13 Dec 2023 15:41:57 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Christian Brauner , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, 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 v4 04/13] cifs: Set zero_point in the copy_file_range() and remap_file_range() Date: Wed, 13 Dec 2023 15:41:30 +0000 Message-ID: <20231213154139.432922-5-dhowells@redhat.com> In-Reply-To: <20231213154139.432922-1-dhowells@redhat.com> References: <20231213154139.432922-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 07:42:33 -0800 (PST) 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: linux-cachefs@redhat.com 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 078cff36cd2e..ebe04c78a955 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1337,6 +1337,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); @@ -1355,6 +1357,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 @@ -1446,6 +1450,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);