.. | .. |
---|
1 | 1 | /* |
---|
2 | 2 | * Public API and common code for kernel->userspace relay file support. |
---|
3 | 3 | * |
---|
4 | | - * See Documentation/filesystems/relay.txt for an overview. |
---|
| 4 | + * See Documentation/filesystems/relay.rst for an overview. |
---|
5 | 5 | * |
---|
6 | 6 | * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp |
---|
7 | 7 | * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com) |
---|
.. | .. |
---|
91 | 91 | * |
---|
92 | 92 | * Returns 0 if ok, negative on error |
---|
93 | 93 | * |
---|
94 | | - * Caller should already have grabbed mmap_sem. |
---|
| 94 | + * Caller should already have grabbed mmap_lock. |
---|
95 | 95 | */ |
---|
96 | 96 | static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma) |
---|
97 | 97 | { |
---|
.. | .. |
---|
163 | 163 | { |
---|
164 | 164 | struct rchan_buf *buf; |
---|
165 | 165 | |
---|
166 | | - if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t *)) |
---|
| 166 | + if (chan->n_subbufs > KMALLOC_MAX_SIZE / sizeof(size_t)) |
---|
167 | 167 | return NULL; |
---|
168 | 168 | |
---|
169 | 169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); |
---|
170 | 170 | if (!buf) |
---|
171 | 171 | return NULL; |
---|
172 | | - buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *), |
---|
| 172 | + buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t), |
---|
173 | 173 | GFP_KERNEL); |
---|
174 | 174 | if (!buf->padding) |
---|
175 | 175 | goto free_buf; |
---|
.. | .. |
---|
997 | 997 | /* |
---|
998 | 998 | * relay_file_read_avail - boolean, are there unconsumed bytes available? |
---|
999 | 999 | */ |
---|
1000 | | -static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos) |
---|
| 1000 | +static int relay_file_read_avail(struct rchan_buf *buf) |
---|
1001 | 1001 | { |
---|
1002 | 1002 | size_t subbuf_size = buf->chan->subbuf_size; |
---|
1003 | 1003 | size_t n_subbufs = buf->chan->n_subbufs; |
---|
1004 | 1004 | size_t produced = buf->subbufs_produced; |
---|
1005 | | - size_t consumed = buf->subbufs_consumed; |
---|
| 1005 | + size_t consumed; |
---|
1006 | 1006 | |
---|
1007 | | - relay_file_read_consume(buf, read_pos, 0); |
---|
| 1007 | + relay_file_read_consume(buf, 0, 0); |
---|
1008 | 1008 | |
---|
1009 | 1009 | consumed = buf->subbufs_consumed; |
---|
1010 | 1010 | |
---|
.. | .. |
---|
1065 | 1065 | |
---|
1066 | 1066 | /** |
---|
1067 | 1067 | * relay_file_read_start_pos - find the first available byte to read |
---|
1068 | | - * @read_pos: file read position |
---|
1069 | 1068 | * @buf: relay channel buffer |
---|
1070 | 1069 | * |
---|
1071 | | - * If the @read_pos is in the middle of padding, return the |
---|
| 1070 | + * If the read_pos is in the middle of padding, return the |
---|
1072 | 1071 | * position of the first actually available byte, otherwise |
---|
1073 | 1072 | * return the original value. |
---|
1074 | 1073 | */ |
---|
1075 | | -static size_t relay_file_read_start_pos(size_t read_pos, |
---|
1076 | | - struct rchan_buf *buf) |
---|
| 1074 | +static size_t relay_file_read_start_pos(struct rchan_buf *buf) |
---|
1077 | 1075 | { |
---|
1078 | 1076 | size_t read_subbuf, padding, padding_start, padding_end; |
---|
1079 | 1077 | size_t subbuf_size = buf->chan->subbuf_size; |
---|
1080 | 1078 | size_t n_subbufs = buf->chan->n_subbufs; |
---|
1081 | 1079 | size_t consumed = buf->subbufs_consumed % n_subbufs; |
---|
| 1080 | + size_t read_pos = (consumed * subbuf_size + buf->bytes_consumed) |
---|
| 1081 | + % (n_subbufs * subbuf_size); |
---|
1082 | 1082 | |
---|
1083 | | - if (!read_pos) |
---|
1084 | | - read_pos = consumed * subbuf_size + buf->bytes_consumed; |
---|
1085 | 1083 | read_subbuf = read_pos / subbuf_size; |
---|
1086 | 1084 | padding = buf->padding[read_subbuf]; |
---|
1087 | 1085 | padding_start = (read_subbuf + 1) * subbuf_size - padding; |
---|
.. | .. |
---|
1137 | 1135 | do { |
---|
1138 | 1136 | void *from; |
---|
1139 | 1137 | |
---|
1140 | | - if (!relay_file_read_avail(buf, *ppos)) |
---|
| 1138 | + if (!relay_file_read_avail(buf)) |
---|
1141 | 1139 | break; |
---|
1142 | 1140 | |
---|
1143 | | - read_start = relay_file_read_start_pos(*ppos, buf); |
---|
| 1141 | + read_start = relay_file_read_start_pos(buf); |
---|
1144 | 1142 | avail = relay_file_read_subbuf_avail(read_start, buf); |
---|
1145 | 1143 | if (!avail) |
---|
1146 | 1144 | break; |
---|
.. | .. |
---|
1183 | 1181 | } |
---|
1184 | 1182 | |
---|
1185 | 1183 | static const struct pipe_buf_operations relay_pipe_buf_ops = { |
---|
1186 | | - .can_merge = 0, |
---|
1187 | | - .confirm = generic_pipe_buf_confirm, |
---|
1188 | | - .release = relay_pipe_buf_release, |
---|
1189 | | - .steal = generic_pipe_buf_steal, |
---|
1190 | | - .get = generic_pipe_buf_get, |
---|
| 1184 | + .release = relay_pipe_buf_release, |
---|
| 1185 | + .try_steal = generic_pipe_buf_try_steal, |
---|
| 1186 | + .get = generic_pipe_buf_get, |
---|
1191 | 1187 | }; |
---|
1192 | 1188 | |
---|
1193 | 1189 | static void relay_page_release(struct splice_pipe_desc *spd, unsigned int i) |
---|