Linux network filesystem support library
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Hongbo Li <lihongbo22@huawei.com>,
	xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com,
	jefflexu@linux.alibaba.com, dhavale@google.com,
	dhowells@redhat.com
Cc: linux-erofs@lists.ozlabs.org, netfs@lists.linux.dev
Subject: Re: [PATCH] erofs: support STATX_DIOALIGN
Date: Wed, 17 Jul 2024 10:00:48 +0800	[thread overview]
Message-ID: <afe7b51b-b235-4ad5-80a5-16e0e61e149e@linux.alibaba.com> (raw)
In-Reply-To: <20240716124534.2358151-1-lihongbo22@huawei.com>

Hi,

On 2024/7/16 20:45, Hongbo Li wrote:
> Add support for STATX_DIOALIGN to erofs, so that direct I/O
> alignment restrictions are exposed to userspace in a generic
> way.
> 
> [Before]
> ```
> ./statx_test /mnt/erofs/testfile
> statx(/mnt/erofs/testfile) = 0
> dio mem align:0
> dio offset align:0
> ```
> 
> [After]
> ```
> ./statx_test /mnt/erofs/testfile
> statx(/mnt/erofs/testfile) = 0
> dio mem align:512
> dio offset align:512
> ```
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>   fs/erofs/inode.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index 5f6439a63af7..9325a6f0058a 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -342,6 +342,25 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
>   	stat->attributes_mask |= (STATX_ATTR_COMPRESSED |
>   				  STATX_ATTR_IMMUTABLE);
>   
> +	/*
> +	 * Return the DIO alignment restrictions if requested.
> +	 *
> +	 * In erofs, STATX_DIOALIGN is not supported in ondemand mode and
> +	 * the compressed file, so in these cases we report no DIO support.
> +	 */
> +	if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
> +		stat->result_mask |= STATX_DIOALIGN;
> +		if (!erofs_is_fscache_mode(inode->i_sb) &&
> +			!erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) {
> +			struct block_device *bdev = inode->i_sb->s_bdev;
> +			unsigned int bsize = (bdev) ? bdev_logical_block_size(bdev) :
> +						i_blocksize(inode);

I guess in this way you could always use
			stat->dio_mem_align = bdev_logical_block_size(bdev);
			stat->dio_offset_align = stat->dio_mem_align;
? since bdev won't be NULL.

Otherwise it looks good to me.

Thanks,
Gao Xiang

  reply	other threads:[~2024-07-17  2:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16 12:45 [PATCH] erofs: support STATX_DIOALIGN Hongbo Li
2024-07-17  2:00 ` Gao Xiang [this message]
2024-07-17  6:34   ` Hongbo Li
2024-07-18  2:41     ` Gao Xiang
2024-07-18  3:35       ` Hongbo Li
2024-07-18  4:35         ` Gao Xiang

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=afe7b51b-b235-4ad5-80a5-16e0e61e149e@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=chao@kernel.org \
    --cc=dhavale@google.com \
    --cc=dhowells@redhat.com \
    --cc=huyue2@coolpad.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=lihongbo22@huawei.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=netfs@lists.linux.dev \
    --cc=xiang@kernel.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