Skip to content

Commit 7116c0a

Browse files
reubenhwkbrauner
authored andcommitted
vfs: fix readahead(2) on block devices
Readahead was factored to call generic_fadvise. That refactor added an S_ISREG restriction which broke readahead on block devices. In addition to S_ISREG, this change checks S_ISBLK to fix block device readahead. There is no change in behavior with any file type besides block devices in this change. Fixes: 3d8f761 ("vfs: implement readahead(2) using POSIX_FADV_WILLNEED") Signed-off-by: Reuben Hawkins <reubenhwk@gmail.com> Link: https://lore.kernel.org/r/20231003015704.2415-1-reubenhwk@gmail.com Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 50d910d commit 7116c0a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mm/readahead.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count)
735735
*/
736736
ret = -EINVAL;
737737
if (!f.file->f_mapping || !f.file->f_mapping->a_ops ||
738-
!S_ISREG(file_inode(f.file)->i_mode))
738+
(!S_ISREG(file_inode(f.file)->i_mode) &&
739+
!S_ISBLK(file_inode(f.file)->i_mode)))
739740
goto out;
740741

741742
ret = vfs_fadvise(f.file, offset, count, POSIX_FADV_WILLNEED);

0 commit comments

Comments
 (0)