[PATCH v2 1/1] io_uring: cleanup files_update looping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace a while with a simple for loop, that looks way more natural, and
enables us to use "contiune" as indexes are no more updated by hand in
the end of the loop.

Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
---

v2: rebased onto for-5.12/io_uring

 fs/io_uring.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7a17c947e64b..783b3b7406ef 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8011,9 +8011,8 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
 		return -ENOMEM;
 	init_fixed_file_ref_node(ctx, ref_node);
 
-	done = 0;
 	fds = u64_to_user_ptr(up->data);
-	while (nr_args) {
+	for (done = 0; done < nr_args; done++) {
 		struct fixed_rsrc_table *table;
 		unsigned index;
 
@@ -8022,7 +8021,7 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
 			err = -EFAULT;
 			break;
 		}
-		i = array_index_nospec(up->offset, ctx->nr_user_files);
+		i = array_index_nospec(up->offset + done, ctx->nr_user_files);
 		table = &ctx->file_data->table[i >> IORING_FILE_TABLE_SHIFT];
 		index = i & IORING_FILE_TABLE_MASK;
 		if (table->files[index]) {
@@ -8060,9 +8059,6 @@ static int __io_sqe_files_update(struct io_ring_ctx *ctx,
 				break;
 			}
 		}
-		nr_args--;
-		done++;
-		up->offset++;
 	}
 
 	if (needs_switch) {
-- 
2.24.0




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux