From patchwork Wed Dec 13 15:41:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13491482 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 AB797C4332F for ; Wed, 13 Dec 2023 15:42:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F07EC8D0040; Wed, 13 Dec 2023 10:42:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8F008D0035; Wed, 13 Dec 2023 10:42:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C95558D0040; Wed, 13 Dec 2023 10:42:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B02708D0035 for ; Wed, 13 Dec 2023 10:42:08 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5082C1C0D63 for ; Wed, 13 Dec 2023 15:42:08 +0000 (UTC) X-FDA: 81562211136.12.A2B191D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 8AA05100017 for ; Wed, 13 Dec 2023 15:42:06 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O1k9jj8u; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702482126; 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=WWGWFaVybn+Cuwok82Tqy8Z4Nj/F9zUC0bxWKAhhGjQ=; b=llfqzOY94c/6sI5fLZr8pvKK86YWcxnLGfbfFCdpSUP+7rBLDCyQntuldYzRKEyD2VNAp4 odnYhaDA+QkM7Ez59ur+jLbS7eDBRJMo4QeVjobt15SzCTecWSbqAeXq9+DHuxaLRDIAap S9g0TiCGxtdQwr3YQ8OkWUEDDgUa0QM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O1k9jj8u; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702482126; a=rsa-sha256; cv=none; b=ZRZNZT8eRZx928CDgM8ICtT98k5IWnkThKS4gFXedLaMp4XXdAibj39dJKRT8CUQw6w7EG dRBwfleXyDGTHf7woxMmHqJ45AZ+7eJlQdUIEyXHtQmMnkDataS1Qlr80Tb3cKvkBe66q0 IdZ5MXhK6Y8pM7Z/E1oYEbueAAibpWQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702482125; 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=O1k9jj8ur/j+OJhPXnnbv5hA+79UGcejQilEpa2GDpW3NbdfSeg8BQCTITnZEzxDYdH+Wg fpBwNBSWcQlNQHEmCim5eXx1ZqxehWWND2amGASNlqNk2vRW/YnCade7q+/xa77B7w0vb1 MC4nJQhCKU7tgwhQHPw9MlFvKqwRE3s= 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 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Rspamd-Queue-Id: 8AA05100017 X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2q/TTs00CH8GD7QzIpEdtYguQh+CRK6OYWsdIH55qCiXcJg0jZqx87NHRJaGMBJIT5kSu3sgXUBWckXl6PungA53B1I1X6bDo30abFD44vhiyYANMA1zghUnVRmCMtTs9STnfsJXNnS0Hcd3yoLTOiey5SkzkEYxNWmU6t282/T6ch6jpJieZAyL0vbMYSWZG4q+h4LhqZ70JT0e/Ebm8xGPTfO+gwO2P93vXidBt5TwH8POD4MvzLuZoa9KGNFtu8bsFUbd+SwP5eF3u2q+TD2kliz0Omd8fqlXElt+/P3t8Bqpz8TOZ3loviDPDr/LKkcFy5qFlIcJ0nlSwAFPRWhE7Oap2fR7z/mtuj9HEUBufxLev0e5b5wd5Vn2+97yUGN+cwCDO7qyNd9BUiEKUQFMd/YPzNENXQ2N5tugnkbGn6N0OBEkJYS5u2/tTt35qySh3kuLmnbva7oQ6lLXFx/j3lSC1WrsCqIezqmrSj+uiYZZDBJULQ== 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: 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);