hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/kernel/relay.c
....@@ -1,7 +1,7 @@
11 /*
22 * Public API and common code for kernel->userspace relay file support.
33 *
4
- * See Documentation/filesystems/relay.txt for an overview.
4
+ * See Documentation/filesystems/relay.rst for an overview.
55 *
66 * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
77 * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
....@@ -91,7 +91,7 @@
9191 *
9292 * Returns 0 if ok, negative on error
9393 *
94
- * Caller should already have grabbed mmap_sem.
94
+ * Caller should already have grabbed mmap_lock.
9595 */
9696 static int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
9797 {
....@@ -997,14 +997,14 @@
997997 /*
998998 * relay_file_read_avail - boolean, are there unconsumed bytes available?
999999 */
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)
10011001 {
10021002 size_t subbuf_size = buf->chan->subbuf_size;
10031003 size_t n_subbufs = buf->chan->n_subbufs;
10041004 size_t produced = buf->subbufs_produced;
1005
- size_t consumed = buf->subbufs_consumed;
1005
+ size_t consumed;
10061006
1007
- relay_file_read_consume(buf, read_pos, 0);
1007
+ relay_file_read_consume(buf, 0, 0);
10081008
10091009 consumed = buf->subbufs_consumed;
10101010
....@@ -1065,23 +1065,20 @@
10651065
10661066 /**
10671067 * relay_file_read_start_pos - find the first available byte to read
1068
- * @read_pos: file read position
10691068 * @buf: relay channel buffer
10701069 *
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
10721071 * position of the first actually available byte, otherwise
10731072 * return the original value.
10741073 */
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)
10771075 {
10781076 size_t read_subbuf, padding, padding_start, padding_end;
10791077 size_t subbuf_size = buf->chan->subbuf_size;
10801078 size_t n_subbufs = buf->chan->n_subbufs;
10811079 size_t consumed = buf->subbufs_consumed % n_subbufs;
1080
+ size_t read_pos = consumed * subbuf_size + buf->bytes_consumed;
10821081
1083
- if (!read_pos)
1084
- read_pos = consumed * subbuf_size + buf->bytes_consumed;
10851082 read_subbuf = read_pos / subbuf_size;
10861083 padding = buf->padding[read_subbuf];
10871084 padding_start = (read_subbuf + 1) * subbuf_size - padding;
....@@ -1137,10 +1134,10 @@
11371134 do {
11381135 void *from;
11391136
1140
- if (!relay_file_read_avail(buf, *ppos))
1137
+ if (!relay_file_read_avail(buf))
11411138 break;
11421139
1143
- read_start = relay_file_read_start_pos(*ppos, buf);
1140
+ read_start = relay_file_read_start_pos(buf);
11441141 avail = relay_file_read_subbuf_avail(read_start, buf);
11451142 if (!avail)
11461143 break;
....@@ -1183,11 +1180,9 @@
11831180 }
11841181
11851182 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,
1183
+ .release = relay_pipe_buf_release,
1184
+ .try_steal = generic_pipe_buf_try_steal,
1185
+ .get = generic_pipe_buf_get,
11911186 };
11921187
11931188 static void relay_page_release(struct splice_pipe_desc *spd, unsigned int i)