From patchwork Wed Nov 6 12:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13864799 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 8C477D44D54 for ; Wed, 6 Nov 2024 12:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DB318D000D; Wed, 6 Nov 2024 07:40:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 167358D0001; Wed, 6 Nov 2024 07:40:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1F1E8D000D; Wed, 6 Nov 2024 07:40:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CA7308D0001 for ; Wed, 6 Nov 2024 07:40:11 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 640B11A088D for ; Wed, 6 Nov 2024 12:40:11 +0000 (UTC) X-FDA: 82755626982.15.9B52C52 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 37A9E180008 for ; Wed, 6 Nov 2024 12:39:45 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S47X/qCY"; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730896643; 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=XXoKBAczFzEdxforFlZoT0jqB8v2JMkojevHnwPW6bc=; b=xToHC3UeyXhhO0BI88294ulTnxNOiByeT4/7aFvPhovg6zcohdYLUfGzPWzx5LSoV4SJP+ qriFv57d4ts10bL8ISzJaZN9ynpcMAElh2atGwRs6bcvlxEPYAtFk+8ZyX02tWzrZQ0MKn V0XNhKjnAC22dQ9cWkzeWzYE6iSmu2c= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="S47X/qCY"; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730896643; a=rsa-sha256; cv=none; b=qkmJBB4JLNmUrf5LzSbc4zt6J6PQJR+zDt3CwkivIr738+IDk0xk/IMdTkCxL9zk822P8k se1SOo+6DaLboPC6INWxf6s7wWai/DSOrUl29BuuFySElr34llE9Kln9W/pzKF+Tm6gEi3 qZHP5yDrruzrr6YDgYzSXI81Ou9rcd0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730896809; 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=XXoKBAczFzEdxforFlZoT0jqB8v2JMkojevHnwPW6bc=; b=S47X/qCYgDWM5mdgs341JSMJLFODEbCqeNkNCI2/ibHnej43wrHEZ3uGWxglU+UblpcVmZ zwmdM6lunKT7r/WW91iKAc5D6n+LvGXJklJeESKFlV4naMOawuhQq9zF3mBJp14kSe41Y+ UnDhywUHoJKt6qrtUcD1X9XTynHoy6Y= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-lO_jK5jjM1WCcN-ItRvP8g-1; Wed, 06 Nov 2024 07:40:03 -0500 X-MC-Unique: lO_jK5jjM1WCcN-ItRvP8g-1 X-Mimecast-MFC-AGG-ID: lO_jK5jjM1WCcN-ItRvP8g Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CF90719560A2; Wed, 6 Nov 2024 12:40:00 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 268B319560AD; Wed, 6 Nov 2024 12:39:54 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, 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-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 31/33] afs: Locally initialise the contents of a new symlink on creation Date: Wed, 6 Nov 2024 12:35:55 +0000 Message-ID: <20241106123559.724888-32-dhowells@redhat.com> In-Reply-To: <20241106123559.724888-1-dhowells@redhat.com> References: <20241106123559.724888-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 37A9E180008 X-Stat-Signature: rfp97m3kh8ky9yoarrupbo4rytyf9na9 X-Rspam-User: X-HE-Tag: 1730896785-5445 X-HE-Meta: U2FsdGVkX18hQSaoucfRpXdcbos5GcyuZp+3xju4ecjLQSc9GQd3NvVglDXMRFSGiQgZcKO/k0t1D/hATlaZXyQ99lWhdK5ARW4U/fx9T53Xdue8Lle/H8f+J0P2a4Ypg5GY06KVjRx0thLxCR+Y12spa78qeJm8HmKpWJkUquDTSbqVYYqBzOP1lfptuZH3rjTb8kcPewIsz7kUjAREDJEDlLg6B2o8eeTwkdY0d7xN7HHNG6FHofH3OUU/p9NfigJcFOgGnPfZzg+ND1nukgP7EW8l7Y5K4KXvCI8hXzi0ulqS1FN407rB4T7U2vfhVib75CiQU658+l4+1OoA73xVspdTTrYN61rwy0fHw8TuB1XVD0zxIoUO1xZiwVCQTjhDI+foxHJC+ylq8IEPT2EK5v26dVJoi56SeRsOnLHDgzJLBZUrcXBpVmLgOK1n5pC2X5vLdkIbxHGoDZxcHlQ7sNItjZgwSp1HBcTYMgjZk3C5cMeCNwohhV3+pysxmwxxpbAU2CRTClMj9KH/85JZJ5yY043YjGTRprO7DEf+3jYH0nLDbSIGwQjvml5AUtKgz/Lr76DUfRH/qBE6dUmD2Jup0Kv1VZHiek/Jj9/sB6sITF3siGD1l3LrJnhdDRuhuZMhYYo/H0xrcQFdwogyXp9K1VyUCaLjZcklG7ZavK2GoyYt5ccwDMdR98rjMz96noQtaLjgPQJ32+iYVRo02Ll7VQCN21d032+sDn2dA9X/JQxCaA5gsDyZv8bj8cRcwajsq5q3woSsYRUc8C03RupZqHkwcTXDJhyhDAhKRnmLae9rcpF8pa3OzrCc4xo01YFmFoexHxX/Ajdxu7c4o6u6+B3GnsLYzlvC+wfjk3HvjBOfEKa6ahsoxmcP3Gv20BOREEV5BtMlfinSDKhMEfSzH+BSBR9fbZkH6qYE08gfnckH1ylrjpdpVpd774v5AB8SGxW9GFkGkh2 ihbb6otw IeeIJbPbfSLWlCQMU+T3X80KgLRWZyvgXraFGjVh8DEOdsOpc44fCxMA3zDsq8I8YIF/YKOonqU6SVBx9Mu8o8uNaS2a1exrCVHzeH1tAbkzswDMqpQI52lsZyTI4wBU3lTF0oLwYfrheqYYCbCCPdHTPMywwFJaiOgj1pV5oYmicldRi9HYM5b5VPtNxY7br1oXwK5LeAzgsx4+ilb4jQ319Q3rii6qOQjmR6YxU5I516S5NsoEf6H+9B4meMeCAUDITP1ubfyCcNf3DDw4EqkNN/WVPtGXsJTRyHQ85gtOWbI684SOBXOSZmP7zOy+Ei5L7/0HGwfeO0BhCF68bDpACoA9M/VlZVgPNRy2Jo8wqxg7j6cq5KHc1E+pI5nT87YLh7Hu1oIdKDENZUaKlGv/LmyBCK0sNcWUNHzh4++9vDDv0tfVbIO29IbBgDWqGf+1J 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: Since we know what the contents of a symlink will be when we create it on the server, initialise its contents locally too to avoid the need to download it. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 2 ++ fs/afs/inode.c | 44 ++++++++++++++++++++++++++++++++++------ fs/afs/internal.h | 1 + fs/netfs/buffered_read.c | 2 +- fs/netfs/read_single.c | 2 +- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 6a4fc1cffb7e..663a212964d8 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1270,6 +1270,8 @@ static void afs_vnode_new_inode(struct afs_operation *op) set_bit(AFS_VNODE_NEW_CONTENT, &vnode->flags); if (S_ISDIR(inode->i_mode)) afs_mkdir_init_dir(vnode, dvp->vnode); + else if (S_ISLNK(inode->i_mode)) + afs_init_new_symlink(vnode, op); if (!afs_op_error(op)) afs_cache_permit(vnode, op->key, vnode->cb_break, &vp->scb); d_instantiate(op->dentry, inode); diff --git a/fs/afs/inode.c b/fs/afs/inode.c index c3b720fda525..f5618564b3fc 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -25,6 +25,23 @@ #include "internal.h" #include "afs_fs.h" +void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *op) +{ + size_t size = strlen(op->create.symlink) + 1; + size_t dsize = 0; + char *p; + + if (netfs_alloc_folioq_buffer(NULL, &vnode->directory, &dsize, size, + mapping_gfp_mask(vnode->netfs.inode.i_mapping)) < 0) + return; + + vnode->directory_size = dsize; + p = kmap_local_folio(folioq_folio(vnode->directory, 0), 0); + memcpy(p, op->create.symlink, size); + kunmap_local(p); + netfs_single_mark_inode_dirty(&vnode->netfs.inode); +} + static void afs_put_link(void *arg) { struct folio *folio = virt_to_folio(arg); @@ -41,15 +58,30 @@ const char *afs_get_link(struct dentry *dentry, struct inode *inode, char *content; ssize_t ret; - if (atomic64_read(&vnode->cb_expires_at) == AFS_NO_CB_PROMISE || - !vnode->directory) { - if (!dentry) + if (!dentry) { + /* RCU pathwalk. */ + if (!vnode->directory || !afs_check_validity(vnode)) return ERR_PTR(-ECHILD); - ret = afs_read_single(vnode, NULL); - if (ret < 0) - return ERR_PTR(ret); + goto good; } + if (!vnode->directory) + goto fetch; + + ret = afs_validate(vnode, NULL); + if (ret < 0) + return ERR_PTR(ret); + + if (!test_and_clear_bit(AFS_VNODE_ZAP_DATA, &vnode->flags) && + vnode->directory) + goto good; + +fetch: + ret = afs_read_single(vnode, NULL); + if (ret < 0) + return ERR_PTR(ret); + +good: folio = folioq_folio(vnode->directory, 0); folio_get(folio); content = kmap_local_folio(folio, 0); diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 8a2daa75b095..a5da0dd8e9cc 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1220,6 +1220,7 @@ extern void afs_fs_probe_cleanup(struct afs_net *); */ extern const struct afs_operation_ops afs_fetch_status_operation; +void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *op); const char *afs_get_link(struct dentry *dentry, struct inode *inode, struct delayed_call *callback); int afs_readlink(struct dentry *dentry, char __user *buffer, int buflen); diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 7036e9f12b07..65d9dd71f65d 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -210,7 +210,7 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) do { struct netfs_io_subrequest *subreq; - enum netfs_io_source source = NETFS_DOWNLOAD_FROM_SERVER; + enum netfs_io_source source = NETFS_SOURCE_UNKNOWN; ssize_t slice; subreq = netfs_alloc_subrequest(rreq); diff --git a/fs/netfs/read_single.c b/fs/netfs/read_single.c index 14bc61107182..fea0ecdecc53 100644 --- a/fs/netfs/read_single.c +++ b/fs/netfs/read_single.c @@ -97,7 +97,7 @@ static int netfs_single_dispatch_read(struct netfs_io_request *rreq) if (!subreq) return -ENOMEM; - subreq->source = NETFS_DOWNLOAD_FROM_SERVER; + subreq->source = NETFS_SOURCE_UNKNOWN; subreq->start = 0; subreq->len = rreq->len; subreq->io_iter = rreq->buffer.iter;