mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Linux/vnops: implement STATX_DIOALIGN
This statx(2) mask returns the alignment restrictions for O_DIRECT access on the given file. We're expected to return both memory and IO alignment. For memory, it's always PAGE_SIZE. For IO, we return the current block size for the file, which is the required alignment for an arbitrary block, and for the first block we'll fall back to the ARC when necessary, so it should always work. Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #16972
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Lawrence Livermore National Security, LLC.
|
||||
* Copyright (c) 2015 by Chunwei Chen. All rights reserved.
|
||||
* Copyright (c) 2025, Rob Norris <robn@despairlabs.com>
|
||||
*/
|
||||
|
||||
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <sys/zfs_vnops.h>
|
||||
#include <sys/zfs_znode.h>
|
||||
#include <sys/dmu_objset.h>
|
||||
#include <sys/spa_impl.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <sys/zpl.h>
|
||||
#include <sys/file.h>
|
||||
@@ -490,6 +492,17 @@ zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef STATX_DIOALIGN
|
||||
if (request_mask & STATX_DIOALIGN) {
|
||||
uint64_t align;
|
||||
if (zfs_get_direct_alignment(zp, &align) == 0) {
|
||||
stat->dio_mem_align = PAGE_SIZE;
|
||||
stat->dio_offset_align = align;
|
||||
stat->result_mask |= STATX_DIOALIGN;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef STATX_ATTR_IMMUTABLE
|
||||
if (zp->z_pflags & ZFS_IMMUTABLE)
|
||||
stat->attributes |= STATX_ATTR_IMMUTABLE;
|
||||
|
||||
Reference in New Issue
Block a user