From patchwork Mon Feb 5 22:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 197090 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1196253dyb; Mon, 5 Feb 2024 14:58:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEjmzqKcZj05ak+pffB5k7RrjtFXd50BjzZrReWA949Qz523vG4sUsN8w6+siXimONBYhV X-Received: by 2002:a2e:95c5:0:b0:2d0:b6cc:8169 with SMTP id y5-20020a2e95c5000000b002d0b6cc8169mr712070ljh.28.1707173914866; Mon, 05 Feb 2024 14:58:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707173914; cv=pass; d=google.com; s=arc-20160816; b=TARhcyE9tZD137WFFPXT1pdLP+eEZDgtw6mQjelZbHJtI7GqS5ea/fLsak5CWiMhCg jdjS/8641VeGGWhkFdFnRgPyc7EpGwdtfunSDi6DAgJe4veHOrhqXXGzy7NrPtcYc/1K KjfNjY1fRVqvfpzG8UfHi6LG1O5LMZZpmHFzixkED6mmW/ecMYVqyL5rss2YuZdZPKMv rL6y3zGgxEl46iO8jHaLf4fT2a7WUMMcMOyqkAeB4VPsO0fE83f86iaULFBYRH7EM7lb Z5a7FbWvt+NZjiasAUvtdScfaubCFr8/MSKBLoiuHmeMf8tSc8UVs5hTsjQhyQDreZ68 4uVA== 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=9AufEF5BoE2ti1jRANwQA21BYnThNCxSf+Ymoah+TR0=; fh=SB7fG+WvdcXt9FMMrrc3w8JR32HV/xw/kV4HZ2g1yCk=; b=RH3Cl46x9jqdTH5rMf+i9fD/s1QnxM71CPRM5XXq9IAe5VQLDEkA7vrKuWfwMb5Ifr 9fZrA6vpVWVSCgHNCMte1ISUG63xN07KKyjUCZF0Jo0I7PONlxj8Zmr0zMh58Odb1NnR 5jLQIF54ZaD70MSHhkQ+NZ/44eabyW6oI4f1IRNIlt9anpm2Hc/HJAUD/SdY5jnTmNk5 5o1q2YijSaEvG9OXv7vkh4kKFfdJ/75sdM0mQSnBtN6Lfj1KRr/cdGwO892QTKVNQZKi qHHv9LoEo7AbECNdQ+dWF90J/E1I4XjppwFtz/euMkcBJ0ec5R3UgrTZ4KlwTyOIOhlg 48zg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZpgcuVYC; 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-54047-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54047-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUByg8uO6e7do9eloOkXgGLQPGtpnBARHjALWWEUBO9/5JFT21yA8UD3939witeH/j6/t7WRjSZ4AM4SHSyfZMxhRXTLg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bd18-20020a056402207200b0055eaca42c54si344896edb.418.2024.02.05.14.58.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 14:58:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54047-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZpgcuVYC; 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-54047-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54047-ouuuleilei=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 7707D1F2863C for ; Mon, 5 Feb 2024 22:58:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEC3B1C2A8; Mon, 5 Feb 2024 22:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZpgcuVYC" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 770BF249E3 for ; Mon, 5 Feb 2024 22:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707173864; cv=none; b=c9pI3VquXL9aTkhr4FU2v5Xg8ajonpUPF5WP8DMY75A7ngeh/o393pKNQU7x3pDtDl5vaqvJKHuVjokB1FZz7aD0QUS1ITFaeB4dPfyfb5ZvzyQNM1YF7WTc7RrkhBi2pOXK1DzIy/AkeB6ep2QkMyp4on0mbPKb/4T7RpxwrGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707173864; c=relaxed/simple; bh=Agj0gXGUntbTVJaToDnP0jCCebZOHGxchG/pl6AcBHg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bLT5hqjDqBxipcwuYoUdy8scHWYM9rdEzyeuXPrpOLNfeayCJpV9QX1+CPm9S0EvCo2QNtAjr+PkWtH/MB7LAUmaJs5yfgIVbH+6nDiYD4VGgAU9eBssvpkMd+BSuIH2awi6rSkj8AX8qZ9GWOhYHGeluiYCI6buKUXWByEGCqc= 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=ZpgcuVYC; arc=none smtp.client-ip=170.10.129.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=1707173861; 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=9AufEF5BoE2ti1jRANwQA21BYnThNCxSf+Ymoah+TR0=; b=ZpgcuVYCLEO0D+mWmGcRgtT1Xg0a5XShtUByEcfbn+89My8YAn54euJnzvrZzvqpFiV0sP k89hwW3x+KGgCqZ4I+X7ytzuN3GfRBeajPgekQM3nAKK3ORCI/6Lt3xnPEIHQ/O5GAMjWS sduLR2ZyRgO1t1Gxto/mTN3g5xwqyFM= 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-319-6-Z_WH0MMm-tUd2tJ60avA-1; Mon, 05 Feb 2024 17:57:37 -0500 X-MC-Unique: 6-Z_WH0MMm-tUd2tJ60avA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 9D74C8870E2; Mon, 5 Feb 2024 22:57:36 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD0DD492BC6; Mon, 5 Feb 2024 22:57:34 +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 v5 02/12] cifs: Set zero_point in the copy_file_range() and remap_file_range() Date: Mon, 5 Feb 2024 22:57:14 +0000 Message-ID: <20240205225726.3104808-3-dhowells@redhat.com> In-Reply-To: <20240205225726.3104808-1-dhowells@redhat.com> References: <20240205225726.3104808-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790101594781369085 X-GMAIL-MSGID: 1790101594781369085 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 2a4a4e3a8751..41617541d175 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1340,6 +1340,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); @@ -1358,6 +1360,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 @@ -1449,6 +1453,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);