Skip to content

Commit 1f0d4ab

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
NFS: add basic STATX_DIOALIGN and STATX_DIO_READ_ALIGN support
NFS doesn't have DIO alignment constraints, so have NFS respond with accommodating DIO alignment attributes (rather than plumb in GETATTR support for STATX_DIOALIGN and STATX_DIO_READ_ALIGN). The most coarse-grained dio_offset_align is the most accommodating (e.g. PAGE_SIZE, in future larger may be supported). Now that NFS has support, NFS reexport will now handle unaligned DIO (NFSD's NFSD_IO_DIRECT support requires the underlying filesystem support STATX_DIOALIGN and/or STATX_DIO_READ_ALIGN). Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent cda9445 commit 1f0d4ab

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fs/nfs/inode.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,21 @@ int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
10731073
if (S_ISDIR(inode->i_mode))
10741074
stat->blksize = NFS_SERVER(inode)->dtsize;
10751075
stat->btime = NFS_I(inode)->btime;
1076+
1077+
/* Special handling for STATX_DIOALIGN and STATX_DIO_READ_ALIGN
1078+
* - NFS doesn't have DIO alignment constraints, avoid getting
1079+
* these DIO attrs from remote and just respond with most
1080+
* accommodating limits (so client will issue supported DIO).
1081+
* - this is unintuitive, but the most coarse-grained
1082+
* dio_offset_align is the most accommodating.
1083+
*/
1084+
if ((request_mask & (STATX_DIOALIGN | STATX_DIO_READ_ALIGN)) &&
1085+
S_ISREG(inode->i_mode)) {
1086+
stat->result_mask |= STATX_DIOALIGN | STATX_DIO_READ_ALIGN;
1087+
stat->dio_mem_align = 4; /* 4-byte alignment */
1088+
stat->dio_offset_align = PAGE_SIZE;
1089+
stat->dio_read_offset_align = stat->dio_offset_align;
1090+
}
10761091
out:
10771092
trace_nfs_getattr_exit(inode, err);
10781093
return err;

0 commit comments

Comments
 (0)