On Thu, Jun 16, 2022 at 01:15:00PM -0700, Eric Biggers wrote: > +/* Handle STATX_DIOALIGN for block devices. */ > +static inline void handle_bdev_dioalign(struct path *path, u32 request_mask, > + struct kstat *stat) > +{ > +#ifdef CONFIG_BLOCK > + struct inode *inode; > + struct block_device *bdev; > + unsigned int lbs; > + > + if (likely(!(request_mask & STATX_DIOALIGN))) > + return; > + > + inode = d_backing_inode(path->dentry); > + if (!S_ISBLK(inode->i_mode)) > + return; > + > + bdev = blkdev_get_no_open(inode->i_rdev); > + if (!bdev) > + return; > + > + lbs = bdev_logical_block_size(bdev); > + stat->dio_mem_align = lbs; > + stat->dio_offset_align = lbs; > + stat->result_mask |= STATX_DIOALIGN; > + > + blkdev_put_no_open(bdev); > +#endif /* CONFIG_BLOCK */ > +} This helper should go into block/bdev.c with the STATX_DIOALIGN and S_ISBLK checks lifted into the caller. I'd also pass just the inode here. Note that this also needs to account for the reduced memory alignment that landed in the block tree eventually.