* [PATCH] erofs: support STATX_DIOALIGN
@ 2024-07-16 12:45 Hongbo Li
2024-07-17 2:00 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Hongbo Li @ 2024-07-16 12:45 UTC (permalink / raw)
To: xiang, chao, huyue2, jefflexu, dhavale, dhowells
Cc: linux-erofs, netfs, lihongbo22
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);
+
+ stat->dio_mem_align = bsize;
+ stat->dio_offset_align = bsize;
+ }
+ }
+
generic_fillattr(idmap, request_mask, inode, stat);
return 0;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: support STATX_DIOALIGN
2024-07-16 12:45 [PATCH] erofs: support STATX_DIOALIGN Hongbo Li
@ 2024-07-17 2:00 ` Gao Xiang
2024-07-17 6:34 ` Hongbo Li
0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2024-07-17 2:00 UTC (permalink / raw)
To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
Cc: linux-erofs, netfs
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: support STATX_DIOALIGN
2024-07-17 2:00 ` Gao Xiang
@ 2024-07-17 6:34 ` Hongbo Li
2024-07-18 2:41 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Hongbo Li @ 2024-07-17 6:34 UTC (permalink / raw)
To: Gao Xiang, xiang, chao, huyue2, jefflexu, dhavale, dhowells
Cc: linux-erofs, netfs
On 2024/7/17 10:00, Gao Xiang wrote:
> 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.
>
Yeah, only the EROFS_FS_ONDEMAND config is on, the s_bdev can be NULL.
Thanks,
Hongbo
> Otherwise it looks good to me.
>
> Thanks,
> Gao Xiang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: support STATX_DIOALIGN
2024-07-17 6:34 ` Hongbo Li
@ 2024-07-18 2:41 ` Gao Xiang
2024-07-18 3:35 ` Hongbo Li
0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2024-07-18 2:41 UTC (permalink / raw)
To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
Cc: linux-erofs, netfs
On 2024/7/17 14:34, Hongbo Li wrote:
>
>
> On 2024/7/17 10:00, Gao Xiang wrote:
>> 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.
>>
> Yeah, only the EROFS_FS_ONDEMAND config is on, the s_bdev can be NULL.
Would you mind sending a v2 to fix this? At least, s_bdev is always
non-NULL currently.
I could apply this for this cycle.
Thanks,
Gao Xiang
>
> Thanks,
> Hongbo
>
>> Otherwise it looks good to me.
>>
>> Thanks,
>> Gao Xiang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: support STATX_DIOALIGN
2024-07-18 2:41 ` Gao Xiang
@ 2024-07-18 3:35 ` Hongbo Li
2024-07-18 4:35 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Hongbo Li @ 2024-07-18 3:35 UTC (permalink / raw)
To: Gao Xiang, xiang, chao, huyue2, jefflexu, dhavale, dhowells
Cc: linux-erofs, netfs
On 2024/7/18 10:41, Gao Xiang wrote:
>
>
> On 2024/7/17 14:34, Hongbo Li wrote:
>>
>>
>> On 2024/7/17 10:00, Gao Xiang wrote:
>>> 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.
>>>
>> Yeah, only the EROFS_FS_ONDEMAND config is on, the s_bdev can be NULL.
>
> Would you mind sending a v2 to fix this? At least, s_bdev is always
> non-NULL currently.
>
> I could apply this for this cycle.
>
I'm working on ondemand direct io mode. This will affect the
STATX_DIOALIGN result for erofs_is_fscache_mode case (.ie the
dio_mem_align is i_blocksize(inode) in erofs over fscache). Should we
apply this first and then modify it after the direct io is supported in
ondemand erofs?
Thanks,
Hongbo
> Thanks,
> Gao Xiang
>
>>
>> Thanks,
>> Hongbo
>>
>>> Otherwise it looks good to me.
>>>
>>> Thanks,
>>> Gao Xiang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: support STATX_DIOALIGN
2024-07-18 3:35 ` Hongbo Li
@ 2024-07-18 4:35 ` Gao Xiang
0 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2024-07-18 4:35 UTC (permalink / raw)
To: Hongbo Li, xiang, chao, huyue2, jefflexu, dhavale, dhowells
Cc: linux-erofs, netfs
On 2024/7/18 11:35, Hongbo Li wrote:
>
>
> On 2024/7/18 10:41, Gao Xiang wrote:
>>
>>
>> On 2024/7/17 14:34, Hongbo Li wrote:
>>>
>>>
>>> On 2024/7/17 10:00, Gao Xiang wrote:
>>>> 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.
>>>>
>>> Yeah, only the EROFS_FS_ONDEMAND config is on, the s_bdev can be NULL.
>>
>> Would you mind sending a v2 to fix this? At least, s_bdev is always
>> non-NULL currently.
>>
>> I could apply this for this cycle.
>>
> I'm working on ondemand direct io mode. This will affect the STATX_DIOALIGN result for erofs_is_fscache_mode case (.ie the dio_mem_align is i_blocksize(inode) in erofs over fscache). Should we apply this first and then modify it after the direct io is supported in ondemand erofs?
Yes, I prefer that. If you submit a new version
of STATX_DIOALIGN, I'd like to merge this for this
cycle (6.11).
But fscache direct i/o seems that it needs another
cycle tho.
Thanks,
Gao Xiang
>
> Thanks,
> Hongbo
>
>> Thanks,
>> Gao Xiang
>>
>>>
>>> Thanks,
>>> Hongbo
>>>
>>>> Otherwise it looks good to me.
>>>>
>>>> Thanks,
>>>> Gao Xiang
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-18 4:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16 12:45 [PATCH] erofs: support STATX_DIOALIGN Hongbo Li
2024-07-17 2:00 ` Gao Xiang
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox