Skip to content

Commit de4eda9

Browse files
author
Al Viro
committed
use less confusing names for iov_iter direction initializers
READ/WRITE proved to be actively confusing - the meanings are "data destination, as used with read(2)" and "data source, as used with write(2)", but people keep interpreting those as "we read data from it" and "we write data to it", i.e. exactly the wrong way. Call them ITER_DEST and ITER_SOURCE - at least that is harder to misinterpret... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent a41dad9 commit de4eda9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+195
-191
lines changed

arch/s390/kernel/crash_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int copy_oldmem_kernel(void *dst, unsigned long src, size_t count)
153153

154154
kvec.iov_base = dst;
155155
kvec.iov_len = count;
156-
iov_iter_kvec(&iter, READ, &kvec, 1, count);
156+
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);
157157
if (copy_oldmem_iter(&iter, src, count) < count)
158158
return -EFAULT;
159159
return 0;

arch/s390/mm/maccess.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int memcpy_real(void *dest, unsigned long src, size_t count)
128128

129129
kvec.iov_base = dest;
130130
kvec.iov_len = count;
131-
iov_iter_kvec(&iter, READ, &kvec, 1, count);
131+
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);
132132
if (memcpy_real_iter(&iter, src, count) < count)
133133
return -EFAULT;
134134
return 0;

arch/x86/kernel/cpu/microcode/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
908908

909909
kvec.iov_base = (void *)firmware->data;
910910
kvec.iov_len = firmware->size;
911-
iov_iter_kvec(&iter, WRITE, &kvec, 1, firmware->size);
911+
iov_iter_kvec(&iter, ITER_SOURCE, &kvec, 1, firmware->size);
912912
ret = generic_load_microcode(cpu, &iter);
913913

914914
release_firmware(firmware);

arch/x86/kernel/crash_dump_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
5757
struct kvec kvec = { .iov_base = buf, .iov_len = count };
5858
struct iov_iter iter;
5959

60-
iov_iter_kvec(&iter, READ, &kvec, 1, count);
60+
iov_iter_kvec(&iter, ITER_DEST, &kvec, 1, count);
6161

6262
return read_from_oldmem(&iter, count, ppos,
6363
cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT));

crypto/testmgr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ static int build_cipher_test_sglists(struct cipher_test_sglists *tsgls,
766766
struct iov_iter input;
767767
int err;
768768

769-
iov_iter_kvec(&input, WRITE, inputs, nr_inputs, src_total_len);
769+
iov_iter_kvec(&input, ITER_SOURCE, inputs, nr_inputs, src_total_len);
770770
err = build_test_sglist(&tsgls->src, cfg->src_divs, alignmask,
771771
cfg->inplace_mode != OUT_OF_PLACE ?
772772
max(dst_total_len, src_total_len) :
@@ -1180,7 +1180,7 @@ static int build_hash_sglist(struct test_sglist *tsgl,
11801180

11811181
kv.iov_base = (void *)vec->plaintext;
11821182
kv.iov_len = vec->psize;
1183-
iov_iter_kvec(&input, WRITE, &kv, 1, vec->psize);
1183+
iov_iter_kvec(&input, ITER_SOURCE, &kv, 1, vec->psize);
11841184
return build_test_sglist(tsgl, cfg->src_divs, alignmask, vec->psize,
11851185
&input, divs);
11861186
}

drivers/acpi/pfr_update.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ static ssize_t pfru_write(struct file *file, const char __user *buf,
455455

456456
iov.iov_base = (void __user *)buf;
457457
iov.iov_len = len;
458-
iov_iter_init(&iter, WRITE, &iov, 1, len);
458+
iov_iter_init(&iter, ITER_SOURCE, &iov, 1, len);
459459

460460
/* map the communication buffer */
461461
phy_addr = (phys_addr_t)((buf_info.addr_hi << 32) | buf_info.addr_lo);

drivers/block/drbd/drbd_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ int drbd_send(struct drbd_connection *connection, struct socket *sock,
18161816

18171817
/* THINK if (signal_pending) return ... ? */
18181818

1819-
iov_iter_kvec(&msg.msg_iter, WRITE, &iov, 1, size);
1819+
iov_iter_kvec(&msg.msg_iter, ITER_SOURCE, &iov, 1, size);
18201820

18211821
if (sock == connection->data.socket) {
18221822
rcu_read_lock();

drivers/block/drbd/drbd_receiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static int drbd_recv_short(struct socket *sock, void *buf, size_t size, int flag
507507
struct msghdr msg = {
508508
.msg_flags = (flags ? flags : MSG_WAITALL | MSG_NOSIGNAL)
509509
};
510-
iov_iter_kvec(&msg.msg_iter, READ, &iov, 1, size);
510+
iov_iter_kvec(&msg.msg_iter, ITER_DEST, &iov, 1, size);
511511
return sock_recvmsg(sock, &msg, msg.msg_flags);
512512
}
513513

drivers/block/loop.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ static int lo_write_bvec(struct file *file, struct bio_vec *bvec, loff_t *ppos)
243243
struct iov_iter i;
244244
ssize_t bw;
245245

246-
iov_iter_bvec(&i, WRITE, bvec, 1, bvec->bv_len);
246+
iov_iter_bvec(&i, ITER_SOURCE, bvec, 1, bvec->bv_len);
247247

248248
file_start_write(file);
249249
bw = vfs_iter_write(file, &i, ppos, 0);
@@ -286,7 +286,7 @@ static int lo_read_simple(struct loop_device *lo, struct request *rq,
286286
ssize_t len;
287287

288288
rq_for_each_segment(bvec, rq, iter) {
289-
iov_iter_bvec(&i, READ, &bvec, 1, bvec.bv_len);
289+
iov_iter_bvec(&i, ITER_DEST, &bvec, 1, bvec.bv_len);
290290
len = vfs_iter_read(lo->lo_backing_file, &i, &pos, 0);
291291
if (len < 0)
292292
return len;
@@ -392,7 +392,7 @@ static void lo_rw_aio_complete(struct kiocb *iocb, long ret)
392392
}
393393

394394
static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
395-
loff_t pos, bool rw)
395+
loff_t pos, int rw)
396396
{
397397
struct iov_iter iter;
398398
struct req_iterator rq_iter;
@@ -448,7 +448,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
448448
cmd->iocb.ki_flags = IOCB_DIRECT;
449449
cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
450450

451-
if (rw == WRITE)
451+
if (rw == ITER_SOURCE)
452452
ret = call_write_iter(file, &cmd->iocb, &iter);
453453
else
454454
ret = call_read_iter(file, &cmd->iocb, &iter);
@@ -490,12 +490,12 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
490490
return lo_fallocate(lo, rq, pos, FALLOC_FL_PUNCH_HOLE);
491491
case REQ_OP_WRITE:
492492
if (cmd->use_aio)
493-
return lo_rw_aio(lo, cmd, pos, WRITE);
493+
return lo_rw_aio(lo, cmd, pos, ITER_SOURCE);
494494
else
495495
return lo_write_simple(lo, rq, pos);
496496
case REQ_OP_READ:
497497
if (cmd->use_aio)
498-
return lo_rw_aio(lo, cmd, pos, READ);
498+
return lo_rw_aio(lo, cmd, pos, ITER_DEST);
499499
else
500500
return lo_read_simple(lo, rq, pos);
501501
default:

drivers/block/nbd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
563563
u32 nbd_cmd_flags = 0;
564564
int sent = nsock->sent, skip = 0;
565565

566-
iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request));
566+
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));
567567

568568
type = req_to_nbd_cmd_type(req);
569569
if (type == U32_MAX)
@@ -649,7 +649,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
649649

650650
dev_dbg(nbd_to_dev(nbd), "request %p: sending %d bytes data\n",
651651
req, bvec.bv_len);
652-
iov_iter_bvec(&from, WRITE, &bvec, 1, bvec.bv_len);
652+
iov_iter_bvec(&from, ITER_SOURCE, &bvec, 1, bvec.bv_len);
653653
if (skip) {
654654
if (skip >= iov_iter_count(&from)) {
655655
skip -= iov_iter_count(&from);
@@ -701,7 +701,7 @@ static int nbd_read_reply(struct nbd_device *nbd, int index,
701701
int result;
702702

703703
reply->magic = 0;
704-
iov_iter_kvec(&to, READ, &iov, 1, sizeof(*reply));
704+
iov_iter_kvec(&to, ITER_DEST, &iov, 1, sizeof(*reply));
705705
result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
706706
if (result < 0) {
707707
if (!nbd_disconnected(nbd->config))
@@ -790,7 +790,7 @@ static struct nbd_cmd *nbd_handle_reply(struct nbd_device *nbd, int index,
790790
struct iov_iter to;
791791

792792
rq_for_each_segment(bvec, req, iter) {
793-
iov_iter_bvec(&to, READ, &bvec, 1, bvec.bv_len);
793+
iov_iter_bvec(&to, ITER_DEST, &bvec, 1, bvec.bv_len);
794794
result = sock_xmit(nbd, index, 0, &to, MSG_WAITALL, NULL);
795795
if (result < 0) {
796796
dev_err(disk_to_dev(nbd->disk), "Receive data failed (result %d)\n",
@@ -1267,7 +1267,7 @@ static void send_disconnects(struct nbd_device *nbd)
12671267
for (i = 0; i < config->num_connections; i++) {
12681268
struct nbd_sock *nsock = config->socks[i];
12691269

1270-
iov_iter_kvec(&from, WRITE, &iov, 1, sizeof(request));
1270+
iov_iter_kvec(&from, ITER_SOURCE, &iov, 1, sizeof(request));
12711271
mutex_lock(&nsock->tx_lock);
12721272
ret = sock_xmit(nbd, i, 1, &from, 0, NULL);
12731273
if (ret < 0)

0 commit comments

Comments
 (0)