Pull splice updates from Al Viro: "Christoph's assorted splice cleanups" * 'work.splice' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: fs: rename pipe_buf ->steal to ->try_steal fs: make the pipe_buf_operations ->confirm operation optional fs: make the pipe_buf_operations ->steal operation optional trace: remove tracing_pipe_buf_ops pipe: merge anon_pipe_buf*_ops fs: simplify do_splice_from fs: simplify do_splice_to
Showing the changes to include/linux (1 of 8 files). Show all
Unified · Split
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */ | 8 | #define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */ |
| 9 | #define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */ | 9 | #define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */ |
| 10 | #define PIPE_BUF_FLAG_PACKET 0x08 /* read() as a packet */ | 10 | #define PIPE_BUF_FLAG_PACKET 0x08 /* read() as a packet */ |
| 11 | #define PIPE_BUF_FLAG_CAN_MERGE 0x10 /* can merge buffers */ | ||
| 11 | 12 | ||
| 12 | /** | 13 | /** |
| 13 | * struct pipe_buffer - a linux kernel pipe buffer | 14 | * struct pipe_buffer - a linux kernel pipe buffer |
| @@ -69,11 +70,11 @@ struct pipe_inode_info { · 55 unmodified lines | |||
| 69 | * Note on the nesting of these functions: | 70 | * Note on the nesting of these functions: |
| 70 | * | 71 | * |
| 71 | * ->confirm() | 72 | * ->confirm() |
| 72 | * ->steal() | 73 | * ->try_steal() |
| 73 | * | 74 | * |
| 74 | * That is, ->steal() must be called on a confirmed buffer. | 75 | * That is, ->try_steal() must be called on a confirmed buffer. See below for |
| 75 | * See below for the meaning of each operation. Also see kerneldoc | 76 | * the meaning of each operation. Also see the kerneldoc in fs/pipe.c for the |
| 76 | * in fs/pipe.c for the pipe and generic variants of these hooks. | 77 | * pipe and generic variants of these hooks. |
| 77 | */ | 78 | */ |
| 78 | struct pipe_buf_operations { | 79 | struct pipe_buf_operations { |
| 79 | /* | 80 | /* |
| @@ -81,7 +82,7 @@ struct pipe_buf_operations { · 1 unmodified line | |||
| 81 | * and that the contents are good. If the pages in the pipe belong | 82 | * and that the contents are good. If the pages in the pipe belong |
| 82 | * to a file system, we may need to wait for IO completion in this | 83 | * to a file system, we may need to wait for IO completion in this |
| 83 | * hook. Returns 0 for good, or a negative error value in case of | 84 | * hook. Returns 0 for good, or a negative error value in case of |
| 84 | * error. | 85 | * error. If not present all pages are considered good. |
| 85 | */ | 86 | */ |
| 86 | int (*confirm)(struct pipe_inode_info *, struct pipe_buffer *); | 87 | int (*confirm)(struct pipe_inode_info *, struct pipe_buffer *); |
| 87 | 88 | ||
| @@ -93,13 +94,13 @@ struct pipe_buf_operations { · 5 unmodified lines | |||
| 93 | 94 | ||
| 94 | /* | 95 | /* |
| 95 | * Attempt to take ownership of the pipe buffer and its contents. | 96 | * Attempt to take ownership of the pipe buffer and its contents. |
| 96 | * ->steal() returns 0 for success, in which case the contents | 97 | * ->try_steal() returns %true for success, in which case the contents |
| 97 | * of the pipe (the buf->page) is locked and now completely owned | 98 | * of the pipe (the buf->page) is locked and now completely owned by the |
| 98 | * by the caller. The page may then be transferred to a different | 99 | * caller. The page may then be transferred to a different mapping, the |
| 99 | * mapping, the most often used case is insertion into different | 100 | * most often used case is insertion into different file address space |
| 100 | * file address space cache. | 101 | * cache. |
| 101 | */ | 102 | */ |
| 102 | int (*steal)(struct pipe_inode_info *, struct pipe_buffer *); | 103 | bool (*try_steal)(struct pipe_inode_info *, struct pipe_buffer *); |
| 103 | 104 | ||
| 104 | /* | 105 | /* |
| 105 | * Get a reference to the pipe buffer. | 106 | * Get a reference to the pipe buffer. |
| @@ -194,18 +195,22 @@ static inline void pipe_buf_release(struct pipe_inode_info *pipe, · 88 unmodified lines | |||
| 194 | static inline int pipe_buf_confirm(struct pipe_inode_info *pipe, | 195 | static inline int pipe_buf_confirm(struct pipe_inode_info *pipe, |
| 195 | struct pipe_buffer *buf) | 196 | struct pipe_buffer *buf) |
| 196 | { | 197 | { |
| 198 | if (!buf->ops->confirm) | ||
| 199 | return 0; | ||
| 197 | return buf->ops->confirm(pipe, buf); | 200 | return buf->ops->confirm(pipe, buf); |
| 198 | } | 201 | } |
| 199 | 202 | ||
| 200 | /** | 203 | /** |
| 201 | * pipe_buf_steal - attempt to take ownership of a pipe_buffer | 204 | * pipe_buf_try_steal - attempt to take ownership of a pipe_buffer |
| 202 | * @pipe: the pipe that the buffer belongs to | 205 | * @pipe: the pipe that the buffer belongs to |
| 203 | * @buf: the buffer to attempt to steal | 206 | * @buf: the buffer to attempt to steal |
| 204 | */ | 207 | */ |
| 205 | static inline int pipe_buf_steal(struct pipe_inode_info *pipe, | 208 | static inline bool pipe_buf_try_steal(struct pipe_inode_info *pipe, |
| 206 | struct pipe_buffer *buf) | 209 | struct pipe_buffer *buf) |
| 207 | { | 210 | { |
| 208 | return buf->ops->steal(pipe, buf); | 211 | if (!buf->ops->try_steal) |
| 212 | return false; | ||
| 213 | return buf->ops->try_steal(pipe, buf); | ||
| 209 | } | 214 | } |
| 210 | 215 | ||
| 211 | /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual | 216 | /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual |
| @@ -229,11 +234,8 @@ void free_pipe_info(struct pipe_inode_info *); · 17 unmodified lines | |||
| 229 | 234 | ||
| 230 | /* Generic pipe buffer ops functions */ | 235 | /* Generic pipe buffer ops functions */ |
| 231 | bool generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *); | 236 | bool generic_pipe_buf_get(struct pipe_inode_info *, struct pipe_buffer *); |
| 232 | int generic_pipe_buf_confirm(struct pipe_inode_info *, struct pipe_buffer *); | 237 | bool generic_pipe_buf_try_steal(struct pipe_inode_info *, struct pipe_buffer *); |
| 233 | int generic_pipe_buf_steal(struct pipe_inode_info *, struct pipe_buffer *); | ||
| 234 | int generic_pipe_buf_nosteal(struct pipe_inode_info *, struct pipe_buffer *); | ||
| 235 | void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *); | 238 | void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *); |
| 236 | void pipe_buf_mark_unmergeable(struct pipe_buffer *buf); | ||
| 237 | 239 | ||
| 238 | extern const struct pipe_buf_operations nosteal_pipe_buf_ops; | 240 | extern const struct pipe_buf_operations nosteal_pipe_buf_ops; |
| 239 | 241 | ||