public inbox for linux-mm@kvack.org
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: Christian Brauner <christian@brauner.io>,
	Steve French <smfrench@gmail.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: David Howells <dhowells@redhat.com>,
	Jeff Layton <jlayton@kernel.org>,
	Gao Xiang <hsiangkao@linux.alibaba.com>,
	Dominique Martinet <asmadeus@codewreck.org>,
	Marc Dionne <marc.dionne@auristor.com>,
	Paulo Alcantara <pc@manguebit.com>,
	Shyam Prasad N <sprasad@microsoft.com>,
	Tom Talpey <tom@talpey.com>,
	Eric Van Hensbergen <ericvh@kernel.org>,
	Ilya Dryomov <idryomov@gmail.com>,
	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 v5 30/32] afs: Locally initialise the contents of a new symlink on creation
Date: Mon, 16 Dec 2024 20:41:20 +0000	[thread overview]
Message-ID: <20241216204124.3752367-31-dhowells@redhat.com> (raw)
In-Reply-To: <20241216204124.3752367-1-dhowells@redhat.com>

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 <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
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 dd0c98d25270..a843c36fc471 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -1276,6 +1276,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 0245943d974d..f761d44b3436 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;



  parent reply	other threads:[~2024-12-16 20:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-16 20:40 [PATCH v5 00/32] netfs: Read performance improvements and "single-blob" support David Howells
2024-12-16 20:40 ` [PATCH v5 01/32] netfs: Clean up some whitespace in trace header David Howells
2024-12-16 20:40 ` [PATCH v5 02/32] cachefiles: " David Howells
2024-12-16 20:40 ` [PATCH v5 03/32] netfs: Use a folio_queue allocation and free functions David Howells
2024-12-16 20:40 ` [PATCH v5 04/32] netfs: Add a tracepoint to log the lifespan of folio_queue structs David Howells
2024-12-16 20:40 ` [PATCH v5 05/32] netfs: Abstract out a rolling folio buffer implementation David Howells
2024-12-16 20:40 ` [PATCH v5 06/32] netfs: Make netfs_advance_write() return size_t David Howells
2024-12-16 20:40 ` [PATCH v5 07/32] netfs: Split retry code out of fs/netfs/write_collect.c David Howells
2024-12-16 20:40 ` [PATCH v5 08/32] netfs: Drop the error arg from netfs_read_subreq_terminated() David Howells
2024-12-16 20:40 ` [PATCH v5 09/32] netfs: Drop the was_async " David Howells
2024-12-16 20:41 ` [PATCH v5 10/32] netfs: Don't use bh spinlock David Howells
2024-12-16 20:41 ` [PATCH v5 11/32] afs: Don't use mutex for I/O operation lock David Howells
2024-12-16 20:41 ` [PATCH v5 12/32] afs: Fix EEXIST error returned from afs_rmdir() to be ENOTEMPTY David Howells
2024-12-16 20:41 ` [PATCH v5 13/32] afs: Fix directory format encoding struct David Howells
2024-12-16 20:41 ` [PATCH v5 14/32] netfs: Remove some extraneous directory invalidations David Howells
2024-12-16 20:41 ` [PATCH v5 15/32] cachefiles: Add some subrequest tracepoints David Howells
2024-12-16 20:41 ` [PATCH v5 16/32] cachefiles: Add auxiliary data trace David Howells
2024-12-16 20:41 ` [PATCH v5 17/32] afs: Add more tracepoints to do with tracking validity David Howells
2024-12-16 20:41 ` [PATCH v5 18/32] netfs: Add functions to build/clean a buffer in a folio_queue David Howells
2024-12-16 20:41 ` [PATCH v5 19/32] netfs: Add support for caching single monolithic objects such as AFS dirs David Howells
2024-12-16 20:41 ` [PATCH v5 20/32] afs: Make afs_init_request() get a key if not given a file David Howells
2024-12-16 20:41 ` [PATCH v5 21/32] afs: Use netfslib for directories David Howells
2024-12-16 20:41 ` [PATCH v5 22/32] afs: Use netfslib for symlinks, allowing them to be cached David Howells
2024-12-16 20:41 ` [PATCH v5 23/32] afs: Eliminate afs_read David Howells
2024-12-16 20:41 ` [PATCH v5 24/32] afs: Fix cleanup of immediately failed async calls David Howells
2024-12-16 20:41 ` [PATCH v5 25/32] afs: Make {Y,}FS.FetchData an asynchronous operation David Howells
2024-12-16 20:41 ` [PATCH v5 26/32] Display waited-on page index after 1min of waiting David Howells
2024-12-16 20:41 ` [PATCH v5 27/32] netfs: Change the read result collector to only use one work item David Howells
2025-01-24 17:59   ` Ihor Solodrai
2025-01-24 18:21     ` Marc Dionne
2025-01-24 18:46       ` Ihor Solodrai
2025-01-24 19:07         ` Marc Dionne
2025-01-24 19:54           ` Ihor Solodrai
2024-12-16 20:41 ` [PATCH v5 28/32] afs: Make afs_mkdir() locally initialise a new directory's content David Howells
2024-12-16 20:41 ` [PATCH v5 29/32] afs: Use the contained hashtable to search a directory David Howells
2024-12-16 20:41 ` David Howells [this message]
2024-12-16 20:41 ` [PATCH v5 31/32] afs: Add a tracepoint for afs_read_receive() David Howells
2024-12-16 20:41 ` [PATCH v5 32/32] netfs: Report on NULL folioq in netfs_writeback_unlock_folios() David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241216204124.3752367-31-dhowells@redhat.com \
    --to=dhowells@redhat.com \
    --cc=asmadeus@codewreck.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=christian@brauner.io \
    --cc=ericvh@kernel.org \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    --cc=pc@manguebit.com \
    --cc=smfrench@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=v9fs@lists.linux.dev \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox