Commit 9c421ef3 authored by Hongbo Li's avatar Hongbo Li Committed by Gao Xiang

erofs: support STATX_DIOALIGN

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: default avatarHongbo Li <lihongbo22@huawei.com>
Reviewed-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240718083243.2485437-1-hsiangkao@linux.alibaba.com
parent a3c10bed
...@@ -334,14 +334,29 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path, ...@@ -334,14 +334,29 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
unsigned int query_flags) unsigned int query_flags)
{ {
struct inode *const inode = d_inode(path->dentry); struct inode *const inode = d_inode(path->dentry);
bool compressed =
erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout);
if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout)) if (compressed)
stat->attributes |= STATX_ATTR_COMPRESSED; stat->attributes |= STATX_ATTR_COMPRESSED;
stat->attributes |= STATX_ATTR_IMMUTABLE; stat->attributes |= STATX_ATTR_IMMUTABLE;
stat->attributes_mask |= (STATX_ATTR_COMPRESSED | stat->attributes_mask |= (STATX_ATTR_COMPRESSED |
STATX_ATTR_IMMUTABLE); STATX_ATTR_IMMUTABLE);
/*
* Return the DIO alignment restrictions if requested.
*
* In EROFS, STATX_DIOALIGN is not supported in ondemand mode and
* compressed files, 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) && !compressed) {
stat->dio_mem_align =
bdev_logical_block_size(inode->i_sb->s_bdev);
stat->dio_offset_align = stat->dio_mem_align;
}
}
generic_fillattr(idmap, request_mask, inode, stat); generic_fillattr(idmap, request_mask, inode, stat);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment