Skip to content

Commit 6922833

Browse files
committed
io_uring: unify fsize with def->work_flags
This one was missed in the earlier conversion, should be included like any of the other IO identity flags. Make sure we restore to RLIM_INIFITY when dropping the personality again. Fixes: 98447d6 ("io_uring: move io identity items into separate struct") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 900fad4 commit 6922833

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

fs/io-wq.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ static bool __io_worker_unuse(struct io_wqe *wqe, struct io_worker *worker)
187187
worker->blkcg_css = NULL;
188188
}
189189
#endif
190-
190+
if (current->signal->rlim[RLIMIT_FSIZE].rlim_cur != RLIM_INFINITY)
191+
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
191192
return dropped_lock;
192193
}
193194

@@ -483,7 +484,10 @@ static void io_impersonate_work(struct io_worker *worker,
483484
if ((work->flags & IO_WQ_WORK_CREDS) &&
484485
worker->cur_creds != work->identity->creds)
485486
io_wq_switch_creds(worker, work);
486-
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = work->identity->fsize;
487+
if (work->flags & IO_WQ_WORK_FSIZE)
488+
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = work->identity->fsize;
489+
else if (current->signal->rlim[RLIMIT_FSIZE].rlim_cur != RLIM_INFINITY)
490+
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
487491
io_wq_switch_blkcg(worker, work);
488492
#ifdef CONFIG_AUDIT
489493
current->loginuid = work->identity->loginuid;

fs/io-wq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ enum {
1717
IO_WQ_WORK_MM = 128,
1818
IO_WQ_WORK_CREDS = 256,
1919
IO_WQ_WORK_BLKCG = 512,
20+
IO_WQ_WORK_FSIZE = 1024,
2021

2122
IO_WQ_HASH_SHIFT = 24, /* upper 8 bits are used for hash key */
2223
};

fs/io_uring.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,6 @@ struct io_op_def {
753753
unsigned pollout : 1;
754754
/* op supports buffer selection */
755755
unsigned buffer_select : 1;
756-
/* needs rlimit(RLIMIT_FSIZE) assigned */
757-
unsigned needs_fsize : 1;
758756
/* must always have async data allocated */
759757
unsigned needs_async_data : 1;
760758
/* size of async data needed, if any */
@@ -778,10 +776,10 @@ static const struct io_op_def io_op_defs[] = {
778776
.hash_reg_file = 1,
779777
.unbound_nonreg_file = 1,
780778
.pollout = 1,
781-
.needs_fsize = 1,
782779
.needs_async_data = 1,
783780
.async_size = sizeof(struct io_async_rw),
784-
.work_flags = IO_WQ_WORK_MM | IO_WQ_WORK_BLKCG,
781+
.work_flags = IO_WQ_WORK_MM | IO_WQ_WORK_BLKCG |
782+
IO_WQ_WORK_FSIZE,
785783
},
786784
[IORING_OP_FSYNC] = {
787785
.needs_file = 1,
@@ -799,9 +797,8 @@ static const struct io_op_def io_op_defs[] = {
799797
.hash_reg_file = 1,
800798
.unbound_nonreg_file = 1,
801799
.pollout = 1,
802-
.needs_fsize = 1,
803800
.async_size = sizeof(struct io_async_rw),
804-
.work_flags = IO_WQ_WORK_BLKCG,
801+
.work_flags = IO_WQ_WORK_BLKCG | IO_WQ_WORK_FSIZE,
805802
},
806803
[IORING_OP_POLL_ADD] = {
807804
.needs_file = 1,
@@ -859,8 +856,7 @@ static const struct io_op_def io_op_defs[] = {
859856
},
860857
[IORING_OP_FALLOCATE] = {
861858
.needs_file = 1,
862-
.needs_fsize = 1,
863-
.work_flags = IO_WQ_WORK_BLKCG,
859+
.work_flags = IO_WQ_WORK_BLKCG | IO_WQ_WORK_FSIZE,
864860
},
865861
[IORING_OP_OPENAT] = {
866862
.work_flags = IO_WQ_WORK_FILES | IO_WQ_WORK_BLKCG |
@@ -890,9 +886,9 @@ static const struct io_op_def io_op_defs[] = {
890886
.needs_file = 1,
891887
.unbound_nonreg_file = 1,
892888
.pollout = 1,
893-
.needs_fsize = 1,
894889
.async_size = sizeof(struct io_async_rw),
895-
.work_flags = IO_WQ_WORK_MM | IO_WQ_WORK_BLKCG,
890+
.work_flags = IO_WQ_WORK_MM | IO_WQ_WORK_BLKCG |
891+
IO_WQ_WORK_FSIZE,
896892
},
897893
[IORING_OP_FADVISE] = {
898894
.needs_file = 1,
@@ -1293,8 +1289,11 @@ static bool io_grab_identity(struct io_kiocb *req)
12931289
struct io_identity *id = req->work.identity;
12941290
struct io_ring_ctx *ctx = req->ctx;
12951291

1296-
if (def->needs_fsize && id->fsize != rlimit(RLIMIT_FSIZE))
1297-
return false;
1292+
if (def->work_flags & IO_WQ_WORK_FSIZE) {
1293+
if (id->fsize != rlimit(RLIMIT_FSIZE))
1294+
return false;
1295+
req->work.flags |= IO_WQ_WORK_FSIZE;
1296+
}
12981297

12991298
if (!(req->work.flags & IO_WQ_WORK_FILES) &&
13001299
(def->work_flags & IO_WQ_WORK_FILES) &&

0 commit comments

Comments
 (0)