public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Mark Harmstone <[email protected]>,
	[email protected], [email protected]
Subject: Re: [PATCH 2/6] btrfs: store encoded read state in struct btrfs_encoded_read_private
Date: Fri, 6 Sep 2024 16:19:25 +0100	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

On 8/23/24 17:27, Mark Harmstone wrote:
> Move the various stack variables needed for encoded reads into struct
> btrfs_encoded_read_private, so that we can split it into several
> functions.
> 
> Signed-off-by: Mark Harmstone <[email protected]>
> ---
>   fs/btrfs/btrfs_inode.h |  20 ++++-
>   fs/btrfs/inode.c       | 170 +++++++++++++++++++++--------------------
>   fs/btrfs/ioctl.c       |  60 ++++++++-------
>   3 files changed, 135 insertions(+), 115 deletions(-)
> 
> diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
> index affe70929234..5cd4308bd337 100644
...
>   
> -ssize_t btrfs_encoded_read(struct file *file, loff_t offset,
> -			   struct iov_iter *iter,
> -			   struct btrfs_ioctl_encoded_io_args *encoded)
> +ssize_t btrfs_encoded_read(struct btrfs_encoded_read_private *priv)
>   {
> -	struct btrfs_inode *inode = BTRFS_I(file_inode(file));
> +	struct btrfs_inode *inode = BTRFS_I(file_inode(priv->file));
>   	struct btrfs_fs_info *fs_info = inode->root->fs_info;
>   	struct extent_io_tree *io_tree = &inode->io_tree;
>   	ssize_t ret;
> -	size_t count = iov_iter_count(iter);
>   	u64 start, lockend, disk_bytenr, disk_io_size;
> -	struct extent_state *cached_state = NULL;
>   	struct extent_map *em;
>   	bool unlocked = false;
>   
> -	file_accessed(file);
> +	priv->count = iov_iter_count(&priv->iter);
> +
> +	file_accessed(priv->file);
>   
>   	btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);

Request submission should usually be short and not block
on IO or any locks that might wait for IO.

bool nowait = issue_flags & IO_URING_F_NONBLOCK;

btrfs_encoded_read(..., nowait) {
	f = BTRFS_ILOCK_SHARED;
	if (nowait)
		f |= BTRFS_ILOCK_TRY;
	if (btrfs_inode_lock(inode, f))
		return -EAGAIN; // io_uring will retry from a blocking context
}

so it might need sth like this here as well as for
filemap waiting and possibly other places.

>   
> -	if (offset >= inode->vfs_inode.i_size) {
> +	if (priv->args.offset >= inode->vfs_inode.i_size) {
>   		btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
>   		return 0;
>   	}
> -	start = ALIGN_DOWN(offset, fs_info->sectorsize);
> +	start = ALIGN_DOWN(priv->args.offset, fs_info->sectorsize);
>   	/*
> -	 * We don't know how long the extent containing offset is, but if
> -	 * it's compressed we know that it won't be longer than this.
> +	 * We don't know how long the extent containing priv->args.offset is,
> +	 * but if it's compressed we know that it won't be longer than this.
>   	 */
>   	lockend = start + BTRFS_MAX_UNCOMPRESSED - 1;
>   
...

-- 
Pavel Begunkov

  parent reply	other threads:[~2024-09-06 15:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-23 16:27 [PATCH 0/6] btrfs: add io_uring for encoded reads Mark Harmstone
2024-08-23 16:27 ` [PATCH 1/6] btrfs: remove iocb from btrfs_encoded_read Mark Harmstone
2024-08-27  1:12   ` David Sterba
2024-08-23 16:27 ` [PATCH 2/6] btrfs: store encoded read state in struct btrfs_encoded_read_private Mark Harmstone
2024-08-26 15:22   ` David Sterba
2024-08-27  1:03   ` David Sterba
2024-09-06 15:19   ` Pavel Begunkov [this message]
2024-08-23 16:27 ` [PATCH 3/6] btrfs: add btrfs_encoded_read_finish Mark Harmstone
2024-08-23 16:27 ` [PATCH 4/6] btrfs: add btrfs_prepare_encoded_read Mark Harmstone
2024-08-23 16:27 ` [PATCH 5/6] btrfs: move wait out of btrfs_encoded_read Mark Harmstone
2024-09-06 15:11   ` Pavel Begunkov
2024-08-23 16:27 ` [PATCH 6/6] btrfs: add io_uring interface for encoded reads Mark Harmstone
2024-09-06 14:41   ` Pavel Begunkov
2024-09-06 15:33   ` Pavel Begunkov

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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