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 | 8 | #define PIPE_BUF_FLAG_ATOMIC 0x02 /* was atomically mapped */ |
| 9 | 9 | #define PIPE_BUF_FLAG_GIFT 0x04 /* page is a gift */ |
| 10 | 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 | 14 | * struct pipe_buffer - a linux kernel pipe buffer |
| @@ -69,11 +70,11 @@ struct pipe_inode_info { · 55 unmodified lines | ||
| 69 | 70 | * Note on the nesting of these functions: |
| 70 | 71 | * |
| 71 | 72 | * ->confirm() |
| 72 | − * ->steal() | |
| 73 | + * ->try_steal() | |
| 73 | 74 | * |
| 74 | − * That is, ->steal() must be called on a confirmed buffer. | |
| 75 | − * See below for the meaning of each operation. Also see kerneldoc | |
| 76 | − * in fs/pipe.c for the pipe and generic variants of these hooks. | |
| 75 | + * That is, ->try_steal() must be called on a confirmed buffer. See below for | |
| 76 | + * the meaning of each operation. Also see the kerneldoc in fs/pipe.c for the | |
| 77 | + * pipe and generic variants of these hooks. | |
| 77 | 78 | */ |
| 78 | 79 | struct pipe_buf_operations { |
| 79 | 80 | /* |
| @@ -81,7 +82,7 @@ struct pipe_buf_operations { · 1 unmodified line | ||
| 81 | 82 | * and that the contents are good. If the pages in the pipe belong |
| 82 | 83 | * to a file system, we may need to wait for IO completion in this |
| 83 | 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 | 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 | 96 | * Attempt to take ownership of the pipe buffer and its contents. |
| 96 | − * ->steal() returns 0 for success, in which case the contents | |
| 97 | − * of the pipe (the buf->page) is locked and now completely owned | |
| 98 | − * by the caller. The page may then be transferred to a different | |
| 99 | − * mapping, the most often used case is insertion into different | |
| 100 | − * file address space cache. | |
| 97 | + * ->try_steal() returns %true for success, in which case the contents | |
| 98 | + * of the pipe (the buf->page) is locked and now completely owned by the | |
| 99 | + * caller. The page may then be transferred to a different mapping, the | |
| 100 | + * most often used case is insertion into different file address space | |
| 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 | 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 | 195 | static inline int pipe_buf_confirm(struct pipe_inode_info *pipe, |
| 195 | 196 | struct pipe_buffer *buf) |
| 196 | 197 | { |
| 198 | + if (!buf->ops->confirm) | |
| 199 | + return 0; | |
| 197 | 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 | 205 | * @pipe: the pipe that the buffer belongs to |
| 203 | 206 | * @buf: the buffer to attempt to steal |
| 204 | 207 | */ |
| 205 | −static inline int pipe_buf_steal(struct pipe_inode_info *pipe, | |
| 206 | − struct pipe_buffer *buf) | |
| 208 | +static inline bool pipe_buf_try_steal(struct pipe_inode_info *pipe, | |
| 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 | 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 | 235 | /* Generic pipe buffer ops functions */ |
| 231 | 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 *); | |
| 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 *); | |
| 237 | +bool generic_pipe_buf_try_steal(struct pipe_inode_info *, struct pipe_buffer *); | |
| 235 | 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 | 240 | extern const struct pipe_buf_operations nosteal_pipe_buf_ops; |
| 239 | 241 | |