linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kees Bakker <kees@ijzerbout.nl>
To: David Howells <dhowells@redhat.com>,
	Christian Brauner <christian@brauner.io>,
	Steve French <smfrench@gmail.com>,
	Matthew Wilcox <willy@infradead.org>
Cc: 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: Re: [PATCH v4 23/33] afs: Use netfslib for directories
Date: Fri, 15 Nov 2024 21:32:02 +0100	[thread overview]
Message-ID: <17eb79fc-ccd9-4c85-bd23-e08380825c41@ijzerbout.nl> (raw)
In-Reply-To: <20241108173236.1382366-24-dhowells@redhat.com>

Op 08-11-2024 om 18:32 schreef David Howells:
> In the AFS ecosystem, directories are just a special type of file that is
> downloaded and parsed locally.  Download is done by the same mechanism as
> ordinary files and the data can be cached.  There is one important semantic
> restriction on directories over files: the client must download the entire
> directory in one go because, for example, the server could fabricate the
> contents of the blob on the fly with each download and give a different
> image each time.
>
> So that we can cache the directory download, switch AFS directory support
> over to using the netfslib single-object API, thereby allowing directory
> content to be stored in the local cache.
>
> To make this work, the following changes are made:
>
>   (1) A directory's contents are now stored in a folio_queue chain attached
>       to the afs_vnode (inode) struct rather than its associated pagecache,
>       though multipage folios are still used to hold the data.  The folio
>       queue is discarded when the directory inode is evicted.
>
>       This also helps with the phasing out of ITER_XARRAY.
>
>   (2) Various directory operations are made to use and unuse the cache
>       cookie.
>
>   (3) The content checking, content dumping and content iteration are now
>       performed with a standard iov_iter iterator over the contents of the
>       folio queue.
>
>   (4) Iteration and modification must be done with the vnode's validate_lock
>       held.  In conjunction with (1), this means that the iteration can be
>       done without the need to lock pages or take extra refs on them, unlike
>       when accessing ->i_pages.
>
>   (5) Convert to using netfs_read_single() to read data.
>
>   (6) Provide a ->writepages() to call netfs_writeback_single() to save the
>       data to the cache according to the VM's scheduling whilst holding the
>       validate_lock read-locked as (4).
>
>   (7) Change local directory image editing functions:
>
>       (a) Provide a function to get a specific block by number from the
>       	 folio_queue as we can no longer use the i_pages xarray to locate
>       	 folios by index.  This uses a cursor to remember the current
>       	 position as we need to iterate through the directory contents.
>       	 The block is kmapped before being returned.
>
>       (b) Make the function in (a) extend the directory by an extra folio if
>       	 we run out of space.
>
>       (c) Raise the check of the block free space counter, for those blocks
>       	 that have one, higher in the function to eliminate a call to get a
>       	 block.
>
>       (d) Remove the page unlocking and putting done during the editing
>       	 loops.  This is no longer necessary as the folio_queue holds the
>       	 references and the pages are no longer in the pagecache.
>
>       (e) Mark the inode dirty and pin the cache usage till writeback at the
>       	 end of a successful edit.
>
>   (8) Don't set the large_folios flag on the inode as we do the allocation
>       ourselves rather than the VM doing it automatically.
>
>   (9) Mark the inode as being a single object that isn't uploaded to the
>       server.
>
> (10) Enable caching on directories.
>
> (11) Only set the upload key for writeback for regular files.
>
> Notes:
>
>   (*) We keep the ->release_folio(), ->invalidate_folio() and
>       ->migrate_folio() ops as we set the mapping pointer on the folio.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Jeff Layton <jlayton@kernel.org>
> cc: linux-afs@lists.infradead.org
> cc: netfs@lists.linux.dev
> cc: linux-fsdevel@vger.kernel.org
> ---
>   fs/afs/dir.c               | 742 +++++++++++++++++++------------------
>   fs/afs/dir_edit.c          | 183 ++++-----
>   fs/afs/file.c              |   8 +
>   fs/afs/inode.c             |  21 +-
>   fs/afs/internal.h          |  16 +
>   fs/afs/super.c             |   2 +
>   fs/afs/write.c             |   4 +-
>   include/trace/events/afs.h |   6 +-
>   8 files changed, 512 insertions(+), 470 deletions(-)
>
> [...]
> +/*
> + * Iterate through the directory folios under RCU conditions.
> + */
> +static int afs_dir_iterate_contents(struct inode *dir, struct dir_context *ctx)
> +{
> +	struct afs_vnode *dvnode = AFS_FS_I(dir);
> +	struct iov_iter iter;
> +	unsigned long long i_size = i_size_read(dir);
> +	int ret = 0;
>   
> -		do {
> -			dblock = kmap_local_folio(folio, offset);
> -			ret = afs_dir_iterate_block(dvnode, ctx, dblock,
> -						    folio_pos(folio) + offset);
> -			kunmap_local(dblock);
> -			if (ret != 1)
> -				goto out;
> +	/* Round the file position up to the next entry boundary */
> +	ctx->pos = round_up(ctx->pos, sizeof(union afs_xdr_dirent));
>   
> -		} while (offset += sizeof(*dblock), offset < size);
> +	if (i_size <= 0 || ctx->pos >= i_size)
> +		return 0;
>   
> -		ret = 0;
> -	}
> +	iov_iter_folio_queue(&iter, ITER_SOURCE, dvnode->directory, 0, 0, i_size);
> +	iov_iter_advance(&iter, round_down(ctx->pos, AFS_DIR_BLOCK_SIZE));
> +
> +	iterate_folioq(&iter, iov_iter_count(&iter), dvnode, ctx,
> +		       afs_dir_iterate_step);
> +
> +	if (ret == -ESTALE)
This is dead code because `ret` is set to 0 and never changed.
> +		afs_invalidate_dir(dvnode, afs_dir_invalid_iter_stale);
> +	return ret;
> +}
> [...]


  reply	other threads:[~2024-11-15 20:32 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08 17:32 [PATCH v4 00/33] netfs: Read performance improvements and "single-blob" support David Howells
2024-11-08 17:32 ` [PATCH v4 01/33] kheaders: Ignore silly-rename files David Howells
2024-11-08 17:32 ` [PATCH v4 02/33] netfs: Remove call to folio_index() David Howells
2024-11-08 17:32 ` [PATCH v4 03/33] netfs: Fix a few minor bugs in netfs_page_mkwrite() David Howells
2024-11-08 17:32 ` [PATCH v4 04/33] netfs: Remove unnecessary references to pages David Howells
2024-11-08 17:32 ` [PATCH v4 05/33] netfs: Use a folio_queue allocation and free functions David Howells
2024-11-08 17:32 ` [PATCH v4 06/33] netfs: Add a tracepoint to log the lifespan of folio_queue structs David Howells
2024-11-08 17:32 ` [PATCH v4 07/33] netfs: Abstract out a rolling folio buffer implementation David Howells
2024-11-15 20:01   ` Kees Bakker
2024-11-18 16:39   ` David Howells
2024-11-08 17:32 ` [PATCH v4 08/33] netfs: Make netfs_advance_write() return size_t David Howells
2024-11-08 17:32 ` [PATCH v4 09/33] netfs: Split retry code out of fs/netfs/write_collect.c David Howells
2024-11-08 17:32 ` [PATCH v4 10/33] netfs: Drop the error arg from netfs_read_subreq_terminated() David Howells
2024-11-08 17:32 ` [PATCH v4 11/33] netfs: Drop the was_async " David Howells
2024-11-08 17:32 ` [PATCH v4 12/33] netfs: Don't use bh spinlock David Howells
2024-11-08 17:32 ` [PATCH v4 13/33] afs: Don't use mutex for I/O operation lock David Howells
2024-11-08 17:32 ` [PATCH v4 14/33] afs: Fix EEXIST error returned from afs_rmdir() to be ENOTEMPTY David Howells
2024-11-08 17:32 ` [PATCH v4 15/33] afs: Fix directory format encoding struct David Howells
2024-11-08 17:32 ` [PATCH v4 16/33] netfs: Remove some extraneous directory invalidations David Howells
2024-11-08 17:32 ` [PATCH v4 17/33] cachefiles: Add some subrequest tracepoints David Howells
2024-11-08 17:32 ` [PATCH v4 18/33] cachefiles: Add auxiliary data trace David Howells
2024-11-08 17:32 ` [PATCH v4 19/33] afs: Add more tracepoints to do with tracking validity David Howells
2024-11-08 17:32 ` [PATCH v4 20/33] netfs: Add functions to build/clean a buffer in a folio_queue David Howells
2024-11-08 17:32 ` [PATCH v4 21/33] netfs: Add support for caching single monolithic objects such as AFS dirs David Howells
2024-11-08 17:32 ` [PATCH v4 22/33] afs: Make afs_init_request() get a key if not given a file David Howells
2024-11-08 17:32 ` [PATCH v4 23/33] afs: Use netfslib for directories David Howells
2024-11-15 20:32   ` Kees Bakker [this message]
2024-11-18 16:35   ` David Howells
2024-11-08 17:32 ` [PATCH v4 24/33] afs: Use netfslib for symlinks, allowing them to be cached David Howells
2024-11-08 17:32 ` [PATCH v4 25/33] afs: Eliminate afs_read David Howells
2024-11-08 17:32 ` [PATCH v4 26/33] afs: Fix cleanup of immediately failed async calls David Howells
2024-11-08 17:32 ` [PATCH v4 27/33] afs: Make {Y,}FS.FetchData an asynchronous operation David Howells
2024-11-08 17:32 ` [PATCH v4 28/33] netfs: Change the read result collector to only use one work item David Howells
2024-11-14 16:39   ` Nathan Chancellor
2024-11-18 17:20   ` David Howells
2024-11-08 17:32 ` [PATCH v4 29/33] afs: Make afs_mkdir() locally initialise a new directory's content David Howells
2024-11-08 17:32 ` [PATCH v4 30/33] afs: Use the contained hashtable to search a directory David Howells
2024-11-08 17:32 ` [PATCH v4 31/33] afs: Locally initialise the contents of a new symlink on creation David Howells
2024-11-08 17:32 ` [PATCH v4 32/33] afs: Add a tracepoint for afs_read_receive() David Howells
2024-11-08 17:32 ` [PATCH v4 33/33] netfs: Report on NULL folioq in netfs_writeback_unlock_folios() David Howells
2024-11-11  9:12 ` [PATCH v4 00/33] netfs: Read performance improvements and "single-blob" support Christian Brauner

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=17eb79fc-ccd9-4c85-bd23-e08380825c41@ijzerbout.nl \
    --to=kees@ijzerbout.nl \
    --cc=asmadeus@codewreck.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=christian@brauner.io \
    --cc=dhowells@redhat.com \
    --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