44
44
* addition of remove_mapping(). If success is returned, the caller may
45
45
* attempt to reuse this page for another destination.
46
46
*/
47
- static int page_cache_pipe_buf_steal (struct pipe_inode_info * pipe ,
48
- struct pipe_buffer * buf )
47
+ static bool page_cache_pipe_buf_try_steal (struct pipe_inode_info * pipe ,
48
+ struct pipe_buffer * buf )
49
49
{
50
50
struct page * page = buf -> page ;
51
51
struct address_space * mapping ;
@@ -76,7 +76,7 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,
76
76
*/
77
77
if (remove_mapping (mapping , page )) {
78
78
buf -> flags |= PIPE_BUF_FLAG_LRU ;
79
- return 0 ;
79
+ return true ;
80
80
}
81
81
}
82
82
@@ -86,7 +86,7 @@ static int page_cache_pipe_buf_steal(struct pipe_inode_info *pipe,
86
86
*/
87
87
out_unlock :
88
88
unlock_page (page );
89
- return 1 ;
89
+ return false ;
90
90
}
91
91
92
92
static void page_cache_pipe_buf_release (struct pipe_inode_info * pipe ,
@@ -139,27 +139,26 @@ static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe,
139
139
}
140
140
141
141
const struct pipe_buf_operations page_cache_pipe_buf_ops = {
142
- .confirm = page_cache_pipe_buf_confirm ,
143
- .release = page_cache_pipe_buf_release ,
144
- .steal = page_cache_pipe_buf_steal ,
145
- .get = generic_pipe_buf_get ,
142
+ .confirm = page_cache_pipe_buf_confirm ,
143
+ .release = page_cache_pipe_buf_release ,
144
+ .try_steal = page_cache_pipe_buf_try_steal ,
145
+ .get = generic_pipe_buf_get ,
146
146
};
147
147
148
- static int user_page_pipe_buf_steal (struct pipe_inode_info * pipe ,
149
- struct pipe_buffer * buf )
148
+ static bool user_page_pipe_buf_try_steal (struct pipe_inode_info * pipe ,
149
+ struct pipe_buffer * buf )
150
150
{
151
151
if (!(buf -> flags & PIPE_BUF_FLAG_GIFT ))
152
- return 1 ;
152
+ return false ;
153
153
154
154
buf -> flags |= PIPE_BUF_FLAG_LRU ;
155
- return generic_pipe_buf_steal (pipe , buf );
155
+ return generic_pipe_buf_try_steal (pipe , buf );
156
156
}
157
157
158
158
static const struct pipe_buf_operations user_page_pipe_buf_ops = {
159
- .confirm = generic_pipe_buf_confirm ,
160
- .release = page_cache_pipe_buf_release ,
161
- .steal = user_page_pipe_buf_steal ,
162
- .get = generic_pipe_buf_get ,
159
+ .release = page_cache_pipe_buf_release ,
160
+ .try_steal = user_page_pipe_buf_try_steal ,
161
+ .get = generic_pipe_buf_get ,
163
162
};
164
163
165
164
static void wakeup_pipe_readers (struct pipe_inode_info * pipe )
@@ -331,24 +330,15 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos,
331
330
EXPORT_SYMBOL (generic_file_splice_read );
332
331
333
332
const struct pipe_buf_operations default_pipe_buf_ops = {
334
- .confirm = generic_pipe_buf_confirm ,
335
- .release = generic_pipe_buf_release ,
336
- .steal = generic_pipe_buf_steal ,
337
- .get = generic_pipe_buf_get ,
333
+ .release = generic_pipe_buf_release ,
334
+ .try_steal = generic_pipe_buf_try_steal ,
335
+ .get = generic_pipe_buf_get ,
338
336
};
339
337
340
- int generic_pipe_buf_nosteal (struct pipe_inode_info * pipe ,
341
- struct pipe_buffer * buf )
342
- {
343
- return 1 ;
344
- }
345
-
346
338
/* Pipe buffer operations for a socket and similar. */
347
339
const struct pipe_buf_operations nosteal_pipe_buf_ops = {
348
- .confirm = generic_pipe_buf_confirm ,
349
- .release = generic_pipe_buf_release ,
350
- .steal = generic_pipe_buf_nosteal ,
351
- .get = generic_pipe_buf_get ,
340
+ .release = generic_pipe_buf_release ,
341
+ .get = generic_pipe_buf_get ,
352
342
};
353
343
EXPORT_SYMBOL (nosteal_pipe_buf_ops );
354
344
@@ -852,15 +842,9 @@ EXPORT_SYMBOL(generic_splice_sendpage);
852
842
static long do_splice_from (struct pipe_inode_info * pipe , struct file * out ,
853
843
loff_t * ppos , size_t len , unsigned int flags )
854
844
{
855
- ssize_t (* splice_write )(struct pipe_inode_info * , struct file * ,
856
- loff_t * , size_t , unsigned int );
857
-
858
845
if (out -> f_op -> splice_write )
859
- splice_write = out -> f_op -> splice_write ;
860
- else
861
- splice_write = default_file_splice_write ;
862
-
863
- return splice_write (pipe , out , ppos , len , flags );
846
+ return out -> f_op -> splice_write (pipe , out , ppos , len , flags );
847
+ return default_file_splice_write (pipe , out , ppos , len , flags );
864
848
}
865
849
866
850
/*
@@ -870,8 +854,6 @@ static long do_splice_to(struct file *in, loff_t *ppos,
870
854
struct pipe_inode_info * pipe , size_t len ,
871
855
unsigned int flags )
872
856
{
873
- ssize_t (* splice_read )(struct file * , loff_t * ,
874
- struct pipe_inode_info * , size_t , unsigned int );
875
857
int ret ;
876
858
877
859
if (unlikely (!(in -> f_mode & FMODE_READ )))
@@ -885,11 +867,8 @@ static long do_splice_to(struct file *in, loff_t *ppos,
885
867
len = MAX_RW_COUNT ;
886
868
887
869
if (in -> f_op -> splice_read )
888
- splice_read = in -> f_op -> splice_read ;
889
- else
890
- splice_read = default_file_splice_read ;
891
-
892
- return splice_read (in , ppos , pipe , len , flags );
870
+ return in -> f_op -> splice_read (in , ppos , pipe , len , flags );
871
+ return default_file_splice_read (in , ppos , pipe , len , flags );
893
872
}
894
873
895
874
/**
@@ -1626,12 +1605,11 @@ static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
1626
1605
* obuf = * ibuf ;
1627
1606
1628
1607
/*
1629
- * Don't inherit the gift flag , we need to
1608
+ * Don't inherit the gift and merge flags , we need to
1630
1609
* prevent multiple steals of this page.
1631
1610
*/
1632
1611
obuf -> flags &= ~PIPE_BUF_FLAG_GIFT ;
1633
-
1634
- pipe_buf_mark_unmergeable (obuf );
1612
+ obuf -> flags &= ~PIPE_BUF_FLAG_CAN_MERGE ;
1635
1613
1636
1614
obuf -> len = len ;
1637
1615
ibuf -> offset += len ;
@@ -1719,12 +1697,11 @@ static int link_pipe(struct pipe_inode_info *ipipe,
1719
1697
* obuf = * ibuf ;
1720
1698
1721
1699
/*
1722
- * Don't inherit the gift flag, we need to
1723
- * prevent multiple steals of this page.
1700
+ * Don't inherit the gift and merge flag, we need to prevent
1701
+ * multiple steals of this page.
1724
1702
*/
1725
1703
obuf -> flags &= ~PIPE_BUF_FLAG_GIFT ;
1726
-
1727
- pipe_buf_mark_unmergeable (obuf );
1704
+ obuf -> flags &= ~PIPE_BUF_FLAG_CAN_MERGE ;
1728
1705
1729
1706
if (obuf -> len > len )
1730
1707
obuf -> len = len ;
0 commit comments