From nobody Sun Nov 24 01:21:04 2024 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 23A0021D23D for ; Fri, 8 Nov 2024 17:36:36 +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=1731087397; cv=none; b=sTQYXhKxjrm4zTViVzai/LF73lN6UNi2Eszp+8w7teXSmhNtXJjimboL/GV5CDiqRF+41JajneU8wiLeXKyagNaOLXXxW6eRVKuAa7piw8N2idfS1ETPbh1RoBspGuo9uswThpqi1GY++iSym6MunazPUkyb5AvuFUL0GbuhDZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731087397; c=relaxed/simple; bh=I4L3md35rvmc1C72E1lOWwx2AoRius+PP3b8FWLJ+aQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B4+56My/NxO3jDw63ZEdmS4K1FjXhrCIvp49xSIQmHOMOHoArnC3PwVu/eNMegHwBwenzQOKmbxYrxAPMMzPiMwrPoWZOjD81Jc4+h95xEiFrZwcw3rUt0vh7On2/OMfjjYPi3+7yMW4kCsJBrp6741Rio6CIpKaXSxRt7zEBPY= 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=iMrdnGNQ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iMrdnGNQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731087395; 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=iMrdnGNQ8UpR9qooa5r3Wgqv4sjaj5Q6uz4JWhj2bNL5MS2eKofbsSjScHnMEmFLVDJ1UW wg4qCja5C57keyrHLXOA3BMF/Q1noPbby8NHuOFurYw82PIJz6SZQDToM6xzPbGZeQqr3d k93v6+yoft/UCl7303N9D8uiRKkQjKo= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" 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" =20 +void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *o= p) +{ + size_t size =3D strlen(op->create.symlink) + 1; + size_t dsize =3D 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 =3D dsize; + p =3D 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 =3D virt_to_folio(arg); @@ -41,15 +59,31 @@ const char *afs_get_link(struct dentry *dentry, struct = inode *inode, char *content; ssize_t ret; =20 - if (atomic64_read(&vnode->cb_expires_at) =3D=3D 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 =3D afs_read_single(vnode, NULL); - if (ret < 0) - return ERR_PTR(ret); + goto good; } =20 + if (test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) + goto fetch; + + ret =3D 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 =3D afs_read_single(vnode, NULL); + if (ret < 0) + return ERR_PTR(ret); + set_bit(AFS_VNODE_DIR_READ, &vnode->flags); + +good: folio =3D folioq_folio(vnode->directory, 0); folio_get(folio); content =3D 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; =20 +void afs_init_new_symlink(struct afs_vnode *vnode, struct afs_operation *o= p); 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_req= uest *rreq) =20 do { struct netfs_io_subrequest *subreq; - enum netfs_io_source source =3D NETFS_DOWNLOAD_FROM_SERVER; + enum netfs_io_source source =3D NETFS_SOURCE_UNKNOWN; ssize_t slice; =20 subreq =3D 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_req= uest *rreq) if (!subreq) return -ENOMEM; =20 - subreq->source =3D NETFS_DOWNLOAD_FROM_SERVER; + subreq->source =3D NETFS_SOURCE_UNKNOWN; subreq->start =3D 0; subreq->len =3D rreq->len; subreq->io_iter =3D rreq->buffer.iter;