@@ -867,12 +867,24 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
867
867
return out -> f_op -> splice_write (pipe , out , ppos , len , flags );
868
868
}
869
869
870
- /*
871
- * Attempt to initiate a splice from a file to a pipe.
870
+ /**
871
+ * vfs_splice_read - Read data from a file and splice it into a pipe
872
+ * @in: File to splice from
873
+ * @ppos: Input file offset
874
+ * @pipe: Pipe to splice to
875
+ * @len: Number of bytes to splice
876
+ * @flags: Splice modifier flags (SPLICE_F_*)
877
+ *
878
+ * Splice the requested amount of data from the input file to the pipe. This
879
+ * is synchronous as the caller must hold the pipe lock across the entire
880
+ * operation.
881
+ *
882
+ * If successful, it returns the amount of data spliced, 0 if it hit the EOF or
883
+ * a hole and a negative error code otherwise.
872
884
*/
873
- static long do_splice_to (struct file * in , loff_t * ppos ,
874
- struct pipe_inode_info * pipe , size_t len ,
875
- unsigned int flags )
885
+ long vfs_splice_read (struct file * in , loff_t * ppos ,
886
+ struct pipe_inode_info * pipe , size_t len ,
887
+ unsigned int flags )
876
888
{
877
889
unsigned int p_space ;
878
890
int ret ;
@@ -895,6 +907,7 @@ static long do_splice_to(struct file *in, loff_t *ppos,
895
907
return warn_unsupported (in , "read" );
896
908
return in -> f_op -> splice_read (in , ppos , pipe , len , flags );
897
909
}
910
+ EXPORT_SYMBOL_GPL (vfs_splice_read );
898
911
899
912
/**
900
913
* splice_direct_to_actor - splices data directly between two non-pipes
@@ -964,7 +977,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
964
977
size_t read_len ;
965
978
loff_t pos = sd -> pos , prev_pos = pos ;
966
979
967
- ret = do_splice_to (in , & pos , pipe , len , flags );
980
+ ret = vfs_splice_read (in , & pos , pipe , len , flags );
968
981
if (unlikely (ret <= 0 ))
969
982
goto out_release ;
970
983
@@ -1112,7 +1125,7 @@ long splice_file_to_pipe(struct file *in,
1112
1125
pipe_lock (opipe );
1113
1126
ret = wait_for_space (opipe , flags );
1114
1127
if (!ret )
1115
- ret = do_splice_to (in , offset , opipe , len , flags );
1128
+ ret = vfs_splice_read (in , offset , opipe , len , flags );
1116
1129
pipe_unlock (opipe );
1117
1130
if (ret > 0 )
1118
1131
wakeup_pipe_readers (opipe );
0 commit comments