splice: allow direct splicing with chardevs
PATCH 1/1 splice: allow direct splicing with chardevs
The original direct splicing mechanism from Jens required the input to be a regular file because it was avoiding the special socket case. It also recognized blkdevs as being close enough to a regular file. But it forgot about chardevs, which behave the same way and work fine here.
This commit adds the missing S_ISCHR condition so that chardevs such as /dev/urandom can be directly spliced without strangely returning -EINVAL.
--- fs/splice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/splice.c +1 -1
@@ -824,7 +824,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,* piped splicing for that! */ i_mode =file_inode (in)->i_mode; -if (unlikely (!S_ISREG (i_mode) && !S_ISBLK (i_mode))) +if (unlikely (!S_ISREG (i_mode) && !S_ISBLK (i_mode) && !S_ISCHR (i_mode)))return -EINVAL ;/*
Signature · 1 line
2.35.1
Quoted 8 lines · Jason A. Donenfeld
The original direct splicing mechanism from Jens required the input to be a regular file because it was avoiding the special socket case. It also recognized blkdevs as being close enough to a regular file. But it forgot about chardevs, which behave the same way and work fine here.
This commit adds the missing
S_ISCHRcondition so that chardevs such as/dev/urandomcan be directly spliced without strangely returning-EINVAL.
Should be fine to turn this on for char devices:
Signature · 1 line
Jens Axboe
Hey Al,
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Jason A. Donenfeld
The original direct splicing mechanism from Jens required the input to be a regular file because it was avoiding the special socket case. It also recognized blkdevs as being close enough to a regular file. But it forgot about chardevs, which behave the same way and work fine here.
Quoted 8 lines
Quoted 3 lines
This commit adds the missing
S_ISCHRcondition so that chardevs such as/dev/urandomcan be directly spliced without strangely returning-EINVAL.Should be fine to turn this on for char devices:
Reviewed-by Jens Axboe <[email protected]>
Was wondering if this would make 5.19. That'd be nice, as it's the release in which we switch to read_iter().
Jason
Hey again,
Quoted 13 lines · Jason A. Donenfeld
Hey Al,
Quoted 10 lines · Jens Axboe
Quoted 8 lines · Jason A. Donenfeld
The original direct splicing mechanism from Jens required the input to be a regular file because it was avoiding the special socket case. It also recognized blkdevs as being close enough to a regular file. But it forgot about chardevs, which behave the same way and work fine here.
This commit adds the missing
S_ISCHRcondition so that chardevs such as/dev/urandomcan be directly spliced without strangely returning-EINVAL.
Quoted 7 lines
Quoted 4 lines
Should be fine to turn this on for char devices:
Reviewed-by Jens Axboe <[email protected]>Was wondering if this would make 5.19. That'd be nice, as it's the release in which we switch to
read_iter().
Just thought I should ping once more on this. Should probably be queued up somewhat soon for 5.19 if it's to make 5.19, which I would really appreciate.
Jason