@@ -4367,22 +4367,23 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
4367
4367
return ret ;
4368
4368
}
4369
4369
4370
- static void f2fs_trace_rw_file_path (struct kiocb * iocb , size_t count , int rw )
4370
+ static void f2fs_trace_rw_file_path (struct file * file , loff_t pos , size_t count ,
4371
+ int rw )
4371
4372
{
4372
- struct inode * inode = file_inode (iocb -> ki_filp );
4373
+ struct inode * inode = file_inode (file );
4373
4374
char * buf , * path ;
4374
4375
4375
4376
buf = f2fs_getname (F2FS_I_SB (inode ));
4376
4377
if (!buf )
4377
4378
return ;
4378
- path = dentry_path_raw (file_dentry (iocb -> ki_filp ), buf , PATH_MAX );
4379
+ path = dentry_path_raw (file_dentry (file ), buf , PATH_MAX );
4379
4380
if (IS_ERR (path ))
4380
4381
goto free_buf ;
4381
4382
if (rw == WRITE )
4382
- trace_f2fs_datawrite_start (inode , iocb -> ki_pos , count ,
4383
+ trace_f2fs_datawrite_start (inode , pos , count ,
4383
4384
current -> pid , path , current -> comm );
4384
4385
else
4385
- trace_f2fs_dataread_start (inode , iocb -> ki_pos , count ,
4386
+ trace_f2fs_dataread_start (inode , pos , count ,
4386
4387
current -> pid , path , current -> comm );
4387
4388
free_buf :
4388
4389
f2fs_putname (buf );
@@ -4398,7 +4399,8 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
4398
4399
return - EOPNOTSUPP ;
4399
4400
4400
4401
if (trace_f2fs_dataread_start_enabled ())
4401
- f2fs_trace_rw_file_path (iocb , iov_iter_count (to ), READ );
4402
+ f2fs_trace_rw_file_path (iocb -> ki_filp , iocb -> ki_pos ,
4403
+ iov_iter_count (to ), READ );
4402
4404
4403
4405
if (f2fs_should_use_dio (inode , iocb , to )) {
4404
4406
ret = f2fs_dio_read_iter (iocb , to );
@@ -4413,6 +4415,30 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
4413
4415
return ret ;
4414
4416
}
4415
4417
4418
+ static ssize_t f2fs_file_splice_read (struct file * in , loff_t * ppos ,
4419
+ struct pipe_inode_info * pipe ,
4420
+ size_t len , unsigned int flags )
4421
+ {
4422
+ struct inode * inode = file_inode (in );
4423
+ const loff_t pos = * ppos ;
4424
+ ssize_t ret ;
4425
+
4426
+ if (!f2fs_is_compress_backend_ready (inode ))
4427
+ return - EOPNOTSUPP ;
4428
+
4429
+ if (trace_f2fs_dataread_start_enabled ())
4430
+ f2fs_trace_rw_file_path (in , pos , len , READ );
4431
+
4432
+ ret = filemap_splice_read (in , ppos , pipe , len , flags );
4433
+ if (ret > 0 )
4434
+ f2fs_update_iostat (F2FS_I_SB (inode ), inode ,
4435
+ APP_BUFFERED_READ_IO , ret );
4436
+
4437
+ if (trace_f2fs_dataread_end_enabled ())
4438
+ trace_f2fs_dataread_end (inode , pos , ret );
4439
+ return ret ;
4440
+ }
4441
+
4416
4442
static ssize_t f2fs_write_checks (struct kiocb * iocb , struct iov_iter * from )
4417
4443
{
4418
4444
struct file * file = iocb -> ki_filp ;
@@ -4714,7 +4740,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
4714
4740
ret = preallocated ;
4715
4741
} else {
4716
4742
if (trace_f2fs_datawrite_start_enabled ())
4717
- f2fs_trace_rw_file_path (iocb , orig_count , WRITE );
4743
+ f2fs_trace_rw_file_path (iocb -> ki_filp , iocb -> ki_pos ,
4744
+ orig_count , WRITE );
4718
4745
4719
4746
/* Do the actual write. */
4720
4747
ret = dio ?
@@ -4919,7 +4946,7 @@ const struct file_operations f2fs_file_operations = {
4919
4946
#ifdef CONFIG_COMPAT
4920
4947
.compat_ioctl = f2fs_compat_ioctl ,
4921
4948
#endif
4922
- .splice_read = generic_file_splice_read ,
4949
+ .splice_read = f2fs_file_splice_read ,
4923
4950
.splice_write = iter_file_splice_write ,
4924
4951
.fadvise = f2fs_file_fadvise ,
4925
4952
};
0 commit comments