Skip to content

Commit 9c421ef

Browse files
Hongbo Lihsiangkao
authored andcommitted
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: Hongbo Li <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a3c10be commit 9c421ef

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

fs/erofs/inode.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,29 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
334334
unsigned int query_flags)
335335
{
336336
struct inode *const inode = d_inode(path->dentry);
337+
bool compressed =
338+
erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout);
337339

338-
if (erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout))
340+
if (compressed)
339341
stat->attributes |= STATX_ATTR_COMPRESSED;
340-
341342
stat->attributes |= STATX_ATTR_IMMUTABLE;
342343
stat->attributes_mask |= (STATX_ATTR_COMPRESSED |
343344
STATX_ATTR_IMMUTABLE);
344345

346+
/*
347+
* Return the DIO alignment restrictions if requested.
348+
*
349+
* In EROFS, STATX_DIOALIGN is not supported in ondemand mode and
350+
* compressed files, so in these cases we report no DIO support.
351+
*/
352+
if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
353+
stat->result_mask |= STATX_DIOALIGN;
354+
if (!erofs_is_fscache_mode(inode->i_sb) && !compressed) {
355+
stat->dio_mem_align =
356+
bdev_logical_block_size(inode->i_sb->s_bdev);
357+
stat->dio_offset_align = stat->dio_mem_align;
358+
}
359+
}
345360
generic_fillattr(idmap, request_mask, inode, stat);
346361
return 0;
347362
}

0 commit comments

Comments
 (0)