Skip to content

Commit 9592442

Browse files
Hongbo LiKent Overstreet
authored andcommitted
bcachefs: support STATX_DIOALIGN for statx file
Add support for STATX_DIOALIGN to bcachefs, so that direct I/O alignment restrictions are exposed to userspace in a generic way. [Before] ``` ./statx_test /mnt/bcachefs/test statx(/mnt/bcachefs/test) = 0 dio mem align:0 dio offset align:0 ``` [After] ``` ./statx_test /mnt/bcachefs/test statx(/mnt/bcachefs/test) = 0 dio mem align:1 dio offset align:512 ``` Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 7aa7183 commit 9592442

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

fs/bcachefs/fs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,16 @@ static int bch2_getattr(struct mnt_idmap *idmap,
895895
stat->subvol = inode->ei_subvol;
896896
stat->result_mask |= STATX_SUBVOL;
897897

898+
if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->v.i_mode)) {
899+
stat->result_mask |= STATX_DIOALIGN;
900+
/*
901+
* this is incorrect; we should be tracking this in superblock,
902+
* and checking the alignment of open devices
903+
*/
904+
stat->dio_mem_align = SECTOR_SIZE;
905+
stat->dio_offset_align = block_bytes(c);
906+
}
907+
898908
if (request_mask & STATX_BTIME) {
899909
stat->result_mask |= STATX_BTIME;
900910
stat->btime = bch2_time_to_timespec(c, inode->ei_inode.bi_otime);

0 commit comments

Comments
 (0)