diff options
author | Eric Biggers <ebiggers@google.com> | 2022-08-27 09:58:50 +0300 |
---|---|---|
committer | Eric Biggers <ebiggers@google.com> | 2022-09-12 03:47:12 +0300 |
commit | c8c02272a9f74bcba4a930a496b2a0c661873c35 (patch) | |
tree | 8a207d5c01d87fcedcd7826b2636d70d11962911 /fs/f2fs/file.c | |
parent | bd3673293175288d71bce48e46e58e3bcc19829e (diff) | |
download | linux-c8c02272a9f74bcba4a930a496b2a0c661873c35.tar.xz |
f2fs: support STATX_DIOALIGN
Add support for STATX_DIOALIGN to f2fs, so that direct I/O alignment
restrictions are exposed to userspace in a generic way.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Jaegeuk Kim <jaegeuk@kernel.org>
Link: https://lore.kernel.org/r/20220827065851.135710-8-ebiggers@kernel.org
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r-- | fs/f2fs/file.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 8e11311db210..791770507328 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -847,6 +847,24 @@ int f2fs_getattr(struct user_namespace *mnt_userns, const struct path *path, stat->btime.tv_nsec = fi->i_crtime.tv_nsec; } + /* + * Return the DIO alignment restrictions if requested. We only return + * this information when requested, since on encrypted files it might + * take a fair bit of work to get if the file wasn't opened recently. + * + * f2fs sometimes supports DIO reads but not DIO writes. STATX_DIOALIGN + * cannot represent that, so in that case we report no DIO support. + */ + if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) { + unsigned int bsize = i_blocksize(inode); + + stat->result_mask |= STATX_DIOALIGN; + if (!f2fs_force_buffered_io(inode, WRITE)) { + stat->dio_mem_align = bsize; + stat->dio_offset_align = bsize; + } + } + flags = fi->i_flags; if (flags & F2FS_COMPR_FL) stat->attributes |= STATX_ATTR_COMPRESSED; |