Skip to content

Commit b49c021

Browse files
committed
erofs: clarify direct I/O support
Currently, only filesystems backed by block devices support direct I/O. Also remove the unnecessary strict checks that can be supported with iomap. Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20241115074625.2520728-1-hsiangkao@linux.alibaba.com
1 parent bae0854 commit b49c021

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

fs/erofs/data.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,22 +405,9 @@ static ssize_t erofs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
405405
if (IS_DAX(inode))
406406
return dax_iomap_rw(iocb, to, &erofs_iomap_ops);
407407
#endif
408-
if (iocb->ki_flags & IOCB_DIRECT) {
409-
struct block_device *bdev = inode->i_sb->s_bdev;
410-
unsigned int blksize_mask;
411-
412-
if (bdev)
413-
blksize_mask = bdev_logical_block_size(bdev) - 1;
414-
else
415-
blksize_mask = i_blocksize(inode) - 1;
416-
417-
if ((iocb->ki_pos | iov_iter_count(to) |
418-
iov_iter_alignment(to)) & blksize_mask)
419-
return -EINVAL;
420-
408+
if ((iocb->ki_flags & IOCB_DIRECT) && inode->i_sb->s_bdev)
421409
return iomap_dio_rw(iocb, to, &erofs_iomap_ops,
422410
NULL, 0, NULL, 0);
423-
}
424411
return filemap_read(iocb, to, 0);
425412
}
426413

fs/erofs/inode.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
318318
unsigned int query_flags)
319319
{
320320
struct inode *const inode = d_inode(path->dentry);
321+
struct block_device *bdev = inode->i_sb->s_bdev;
321322
bool compressed =
322323
erofs_inode_is_data_compressed(EROFS_I(inode)->datalayout);
323324

@@ -330,15 +331,14 @@ int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
330331
/*
331332
* Return the DIO alignment restrictions if requested.
332333
*
333-
* In EROFS, STATX_DIOALIGN is not supported in ondemand mode and
334-
* compressed files, so in these cases we report no DIO support.
334+
* In EROFS, STATX_DIOALIGN is only supported in bdev-based mode
335+
* and uncompressed inodes, otherwise we report no DIO support.
335336
*/
336337
if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
337338
stat->result_mask |= STATX_DIOALIGN;
338-
if (!erofs_is_fscache_mode(inode->i_sb) && !compressed) {
339-
stat->dio_mem_align =
340-
bdev_logical_block_size(inode->i_sb->s_bdev);
341-
stat->dio_offset_align = stat->dio_mem_align;
339+
if (bdev && !compressed) {
340+
stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
341+
stat->dio_offset_align = bdev_logical_block_size(bdev);
342342
}
343343
}
344344
generic_fillattr(idmap, request_mask, inode, stat);

0 commit comments

Comments
 (0)