Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2065941lqa; Tue, 30 Apr 2024 07:22:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUw0CvvW1HzLjFXFa2IjU1SYdeTvsEc93Ugn0syCojycPuC+JOoMMnE6fY7IaMueExfbo0PdtOH63L51ECr7qXhkWpUIGKJA4AbLYlFMw== X-Google-Smtp-Source: AGHT+IGJM/pdxHszZjtiCvRYZ4dBBGb+MhEW1RqXHuAfiDCOSiAZImmsEMJqcctmKR8IBj3UUJaf X-Received: by 2002:a17:906:40c6:b0:a58:d41f:9310 with SMTP id a6-20020a17090640c600b00a58d41f9310mr2384562ejk.21.1714486948398; Tue, 30 Apr 2024 07:22:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714486948; cv=pass; d=google.com; s=arc-20160816; b=03MqHBfr+voLyn28LjTg9JqxFLz8mXiCgmTcvJiNF3epCE1m9eHvyE4mrAT4kdrP++ kNOa6QXyjNiQT0UNc8daKHd1+wMz3pDKQUdSWZcsSgJ+Aire7ldazHAvw1jpx9EhBdKk Dg9S/72I4HtgM9gaKyhIejOWCDXH7zLscTcixc2dKbNU4f1pnnGWZWqQRkBH7fQlDioN OBa2pHOsJdb2pAGml24a0uNv0XfDZEaR/lWVDrYzHrBlz+QROeNUXMN3wYKVtjS25ovL rqFJ21J7aySfJMqsI+Ibo2bUrEQtoClWaudzJz/BFnFRusvkSJbLt2KDj3msmztPKhDF Jxww== 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=6Ss/QoG4KZAnvVRZnfoKEIruxchZiLNdPXpNAK6SDko=; fh=YE7ofT3RvMl8X7BAHep3VPXZdXRMpsNOuSwI9MYxxVI=; b=d1wdmweaQht6gUY5loTySjJLdHs1J4VgNb0VCSwFc4d6Zx0hrndUMpe/V61z+sPSCf qq7x0YKyNbqhp/+jd8h+Y3PPhv6wpO72MpUbYRjpNlGHGATYVmzO+oEb14Q566thJw/i jIc7UXGhkgOh4dnla2sF1774rEbXjOn1pqr/ADfQc3cdnehEH6TBx5mZ3qAHlsaISwLS Kv/eSGl5Wah40AtDTIwVhlH4QaS44OrmdnK7RGG92vwj3pfyVRZTz4SPKIUrIbGHTE7O /dBx8pYKVSN4gDlDTJSW/zj2bn9AWw2Wza4pj2xgnlHX8bZlhqku9shsSgkJYUbyx/U3 55AQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=de2Cr5uO; 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-164106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164106-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 ku3-20020a170907788300b00a58b2f078d6si6278985ejc.14.2024.04.30.07.22.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 07:22:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164106-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=de2Cr5uO; 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-164106-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164106-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 ECA9A1F225DA for ; Tue, 30 Apr 2024 14:22:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 426DC184134; Tue, 30 Apr 2024 14:10:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="de2Cr5uO" 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 CE54E181D13 for ; Tue, 30 Apr 2024 14:10:00 +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=1714486202; cv=none; b=aYr1VGfT8mND0HYkjTJ+61L5iAnchm1OVzVpdFUAnZpSW1XdIdf2opSaHxzqdNUu7+HTzgC4EB3TZCu+M7zcNJ1ngpK/j5UtvK2X7Hhaj20ShF5dvxSNV3inS6x7k9enycA2d8Stw4VKSgoVBjHOLjwmLzQ2NADjTvA9uBX9ybI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714486202; c=relaxed/simple; bh=tWy7mnmCjdlXVrRrzw9jzbJD/G8nxnuHEkiXp7xyO/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PPpbMzt7sK+/ANtH0MteIcfQ7V1+Cf7fLR7Xo/J4U6xXjki6MiKLZ0o5Ko0v53nvvmEFYJnOdfDauLdtZ96ivcerWyqIKmrZeIkLFc1T3cIPh/pbjKnpj/2D72jqmn1MmfBwa1rwMmkMAhHlA0z5+l7OVw5HC2NMZS0gDXwRen0= 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=de2Cr5uO; 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=1714486199; 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=de2Cr5uO7XWI5rqsOT0PXkP60ToK3go/vCFT5HZTGm8gCgh+yqzRmk3vxdKJVbqXFURvI/ KuJ8VB5SyzfS/EPEpjNgkdJ//dTpOWDzL+HZVpqzOkZO2mv0IB+IqCXj0uhe0DHFiB2V8g 8a3ZK32emLPe+MsnZ+2PJA659CEpONg= 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> 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.1 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);