@@ -231,48 +231,13 @@ void generic_pipe_buf_release(struct pipe_inode_info *pipe,
231
231
}
232
232
EXPORT_SYMBOL (generic_pipe_buf_release );
233
233
234
- /* New data written to a pipe may be appended to a buffer with this type. */
235
234
static const struct pipe_buf_operations anon_pipe_buf_ops = {
236
235
.confirm = generic_pipe_buf_confirm ,
237
236
.release = anon_pipe_buf_release ,
238
237
.steal = anon_pipe_buf_steal ,
239
238
.get = generic_pipe_buf_get ,
240
239
};
241
240
242
- static const struct pipe_buf_operations anon_pipe_buf_nomerge_ops = {
243
- .confirm = generic_pipe_buf_confirm ,
244
- .release = anon_pipe_buf_release ,
245
- .steal = anon_pipe_buf_steal ,
246
- .get = generic_pipe_buf_get ,
247
- };
248
-
249
- static const struct pipe_buf_operations packet_pipe_buf_ops = {
250
- .confirm = generic_pipe_buf_confirm ,
251
- .release = anon_pipe_buf_release ,
252
- .steal = anon_pipe_buf_steal ,
253
- .get = generic_pipe_buf_get ,
254
- };
255
-
256
- /**
257
- * pipe_buf_mark_unmergeable - mark a &struct pipe_buffer as unmergeable
258
- * @buf: the buffer to mark
259
- *
260
- * Description:
261
- * This function ensures that no future writes will be merged into the
262
- * given &struct pipe_buffer. This is necessary when multiple pipe buffers
263
- * share the same backing page.
264
- */
265
- void pipe_buf_mark_unmergeable (struct pipe_buffer * buf )
266
- {
267
- if (buf -> ops == & anon_pipe_buf_ops )
268
- buf -> ops = & anon_pipe_buf_nomerge_ops ;
269
- }
270
-
271
- static bool pipe_buf_can_merge (struct pipe_buffer * buf )
272
- {
273
- return buf -> ops == & anon_pipe_buf_ops ;
274
- }
275
-
276
241
/* Done while waiting without holding the pipe lock - thus the READ_ONCE() */
277
242
static inline bool pipe_readable (const struct pipe_inode_info * pipe )
278
243
{
@@ -478,7 +443,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
478
443
struct pipe_buffer * buf = & pipe -> bufs [(head - 1 ) & mask ];
479
444
int offset = buf -> offset + buf -> len ;
480
445
481
- if (pipe_buf_can_merge (buf ) && offset + chars <= PAGE_SIZE ) {
446
+ if ((buf -> flags & PIPE_BUF_FLAG_CAN_MERGE ) &&
447
+ offset + chars <= PAGE_SIZE ) {
482
448
ret = pipe_buf_confirm (pipe , buf );
483
449
if (ret )
484
450
goto out ;
@@ -541,11 +507,10 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
541
507
buf -> ops = & anon_pipe_buf_ops ;
542
508
buf -> offset = 0 ;
543
509
buf -> len = 0 ;
544
- buf -> flags = 0 ;
545
- if (is_packetized (filp )) {
546
- buf -> ops = & packet_pipe_buf_ops ;
510
+ if (is_packetized (filp ))
547
511
buf -> flags = PIPE_BUF_FLAG_PACKET ;
548
- }
512
+ else
513
+ buf -> flags = PIPE_BUF_FLAG_CAN_MERGE ;
549
514
pipe -> tmp_page = NULL ;
550
515
551
516
copied = copy_page_from_iter (page , 0 , PAGE_SIZE , from );
0 commit comments