From patchwork Fri Nov 8 17:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13868589 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 AB5BFD64070 for ; Fri, 8 Nov 2024 17:36:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38CE0900006; Fri, 8 Nov 2024 12:36:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 315628D0001; Fri, 8 Nov 2024 12:36:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1684C900006; Fri, 8 Nov 2024 12:36:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E48AC8D0001 for ; Fri, 8 Nov 2024 12:36:38 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9503B80EBA for ; Fri, 8 Nov 2024 17:36:38 +0000 (UTC) X-FDA: 82763632140.14.05424FB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 0EFEB40010 for ; Fri, 8 Nov 2024 17:35:58 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Fm7gCSc1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1731087225; a=rsa-sha256; cv=none; b=5QeptIXm40kw1SPKJrY16sv5Hk5fiicOm44Ly09v+eGzQ/7ZMmdYHm2YXTWVxCB93Z2I/k miJ+gohD8nN3OZzTobnh1mE7qsN+P+m9HB1bAJdBSbcfr4Fc+3RH3SMkXgThu6LkHjvhz6 vFTaY0Jq+B28jVFZGd6gN0/tPKMccS8= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Fm7gCSc1; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf27.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=1731087225; 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=IFH4nAXrPrYA9knzNJw2PqNPG2o324dUKCIftg33KNo=; b=ldCKzU7VcV8uHc3pmBQp8rCBgqdKYpCONUQ+UYqNJa4b2cGoniUhZBnGsxXYWPwpZ8j4zH RDQA0h1Jy5uQ6ovKfm+QUGXtkajLAgoWNP+6pgT37wvFO2SAcigplbMopM0dIsA5f2jfMl cAw0FmX7Cj+vzXEK6qRdB7hJYVCqCqw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731087396; 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=IFH4nAXrPrYA9knzNJw2PqNPG2o324dUKCIftg33KNo=; b=Fm7gCSc1GNX6JENkTQarid4xoL7j99CX7eYYaeGLVWqUPsOzHDlpI0njCxj5SKXtGIUic9 r6xht6vN1hTObxWU7gYI5VnEGDjzYrzdBE20Z0edjrRi5A9NsOnI1cIOO+dV4W/K96u+c2 9iV9xinUGmpJURM4ChGoO2mNJ6tm9QA= Received: from mx-prod-mc-01.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-301-zQA4ISPnOveGXnynQdnMAw-1; Fri, 08 Nov 2024 12:36:32 -0500 X-MC-Unique: zQA4ISPnOveGXnynQdnMAw-1 X-Mimecast-MFC-AGG-ID: zQA4ISPnOveGXnynQdnMAw Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 613E619560A6; Fri, 8 Nov 2024 17:36:29 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E600030001A0; Fri, 8 Nov 2024 17:36:23 +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 v4 31/33] afs: Locally initialise the contents of a new symlink on creation Date: Fri, 8 Nov 2024 17:32:32 +0000 Message-ID: <20241108173236.1382366-32-dhowells@redhat.com> In-Reply-To: <20241108173236.1382366-1-dhowells@redhat.com> References: <20241108173236.1382366-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Stat-Signature: diikq9ojdoowrtdc6q465mwcotp1dson X-Rspamd-Queue-Id: 0EFEB40010 X-Rspamd-Server: rspam08 X-Rspam-User: X-HE-Tag: 1731087358-654448 X-HE-Meta: U2FsdGVkX1+yPyuu+WlbnJ4Ckgrez6833I/ZoGiKnHCZyVhFPUSLiQbeH08ZUr/VhI94rY4QF+SPXhmRw/IwHmk077sgQawOKmWBf+XucPWxlAGWKW+bFZuQijRC8BNGpOyFQr5iq3XljrV+OE4HHXEeu1t8q0CswbahH/M2yvFWXRYkDXC5zCFhN5MxEyne6krzk71uQZdl03Yze4s0Ni4sJgs02zOvRZw9MbD883fFm8A/dEaa7froM1N60szCZA8zbYjcWPq7tu0GtQsTKuxjifnxSj2C9NtUhJroolmxuCE/UsD0pDm6A3qPvB64s85ds5CCO3dEM0lk6C+Hwy1JN/4iF5m1XW95SHCQXUt0DHWPnZJk0lqx+UAy3sqMTuDL1kPMsewwC6ZYiAJeU9KICYNTZrW6CnfICicac0StG7FeFvOOf+Z/jsuSavWNl7KCnPtUzlYrsbMekvp8K1cr4JObJ2ph8XmXNAQ5zgM6EkZD4e7lpFx1+mvm3ko3RDmYlsqP/uGnZfY4QxtfxCcxLACLWotQhRi1LPuO5/3A3/0W6eHd8fWzbb8JTYVoNznJuuuSvlxNN7bPXu2DaHJqZe3ZTEyAKIlyC6jTP0sd1a7vSrEzSPAiaVutKk/bTuOdOoJ/mlbYGO7srGAnpF0Rc3T+yeAuKJ/TU3oS5czu+M7ra+e+QDpB8tBPQKjLB4MaXIagrdkObL9CzZXlEeww66XMzKALJIrWg/q/cEmnhj7MWvvnz2UxbqRt1YNPJJjXiJ0sbW5PoaNIWNWeYLZmsOeZBYmyFsK6Eg1W4OcSI5l1sdGh7GKwXvqNhl5wrn3CfvDoTJsa8zLV/u1A9F03bA9ldufuF9XkDdGPKbKl1u8xRER7NYHugeykfmdj4eZ3ac0kN88mSzU2bkHkK4J/vYae2KGX+agNv2qaHnfZ+/LxubrEKeTHdQAPerLRnNy6zS6xtJ0AkJfPjdV H+XKJbWH r+znjoDEpHE0hs9kRmIQm+qGBrePvpraWQdU0Wv82J594iE9QV8etYNRmIYRP3MrByEzE/oaol1XFUqOh86/BMgJtV2ckNvwYl9vtFA9PqsoD+FRcFR5pUiFUanCta3tgYip+3UcvXtt2NXCOAkIQkWCX/5rNcX/WeO1Vr/GeRbhfnM5gdg0+tZY65cXDTvZsqOMl9dOtkniZs2ISf2KBjJAV58uUVWjczzrxEd4SfPrIT80DvdjHJPUiU2mDQKu+kI7RQUIYR1UeH8Klh0N4mjIwI5Fqrdno9gP8wxsLPJ3FnUyKVHorDAxki9y47eK9B8oJk9qqAAzPGacrg+duvOvNOtp0nzfaVJf/c+SrYTuvonwv4ueVAj+8loAB0+YHyaxWLK5aXXH7aRhuxeupC96KWLVMu5VdEjlv/Wkk8owlgTZrLu/kmv8v2dxyAK83E4gq 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 | 46 ++++++++++++++++++++++++++++++++++------ fs/afs/internal.h | 1 + fs/netfs/buffered_read.c | 2 +- fs/netfs/read_single.c | 2 +- 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index d195a42cea1d..b6a202fd9926 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1271,6 +1271,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 0e3c43c40632..e9538e91f848 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -25,6 +25,24 @@ #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); + set_bit(AFS_VNODE_DIR_READ, &vnode->flags); + netfs_single_mark_inode_dirty(&vnode->netfs.inode); +} + static void afs_put_link(void *arg) { struct folio *folio = virt_to_folio(arg); @@ -41,15 +59,31 @@ 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 || - !test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) { - if (!dentry) + if (!dentry) { + /* RCU pathwalk. */ + if (!test_bit(AFS_VNODE_DIR_READ, &vnode->flags) || !afs_check_validity(vnode)) return ERR_PTR(-ECHILD); - ret = afs_read_single(vnode, NULL); - if (ret < 0) - return ERR_PTR(ret); + goto good; } + if (test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) + 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) && + test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) + goto good; + +fetch: + ret = afs_read_single(vnode, NULL); + if (ret < 0) + return ERR_PTR(ret); + set_bit(AFS_VNODE_DIR_READ, &vnode->flags); + +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 b7d02c105340..90f407774a9a 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -1221,6 +1221,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;