Skip to content

Commit

Permalink
bcachefs: support STATX_DIOALIGN for statx file
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
Hongbo Li authored and Kent Overstreet committed Jun 20, 2024
1 parent dab4ef2 commit f94aa52
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions fs/bcachefs/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,12 @@ static int bch2_getattr(struct mnt_idmap *idmap,
stat->subvol = inode->ei_subvol;
stat->result_mask |= STATX_SUBVOL;

if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->v.i_mode)) {
stat->result_mask |= STATX_DIOALIGN;
stat->dio_mem_align = 1;
stat->dio_offset_align = SECTOR_SIZE;
}

if (request_mask & STATX_BTIME) {
stat->result_mask |= STATX_BTIME;
stat->btime = bch2_time_to_timespec(c, inode->ei_inode.bi_otime);
Expand Down

0 comments on commit f94aa52

Please sign in to comment.