Skip to content

Commit 43c67b9

Browse files
committed
Re-introduce RWF_DONTCACHE
This used to be called RWF_UNCACHED, and it never made it upstream. But as of the 6.14 kernel, RWF_DONTCACHE exists, and provides the same guarantees that the older RWF_UNCACHED did - it's applied to buffered IO, and any page cache instantiated for this read or write will be dropped on IO completion. Any data already in cache will remain in cache and will not cause IO to be issued. This adds support for the io_uring and sync IO engines. Signed-off-by: Jens Axboe <[email protected]>
1 parent eaa9e88 commit 43c67b9

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

engines/io_uring.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct ioring_options {
114114
unsigned int sqpoll_set;
115115
unsigned int sqpoll_cpu;
116116
unsigned int nonvectored;
117+
unsigned int uncached;
117118
unsigned int nowait;
118119
unsigned int force_async;
119120
unsigned int md_per_io_size;
@@ -271,7 +272,11 @@ static struct fio_option options[] = {
271272
{
272273
.name = "uncached",
273274
.lname = "Uncached",
274-
.type = FIO_OPT_SOFT_DEPRECATED,
275+
.type = FIO_OPT_INT,
276+
.off1 = offsetof(struct ioring_options, uncached),
277+
.help = "Use RWF_DONTCACHE for buffered read/writes",
278+
.category = FIO_OPT_C_ENGINE,
279+
.group = FIO_OPT_G_IOURING,
275280
},
276281
{
277282
.name = "nowait",
@@ -432,6 +437,8 @@ static int fio_ioring_prep(struct thread_data *td, struct io_u *io_u)
432437
}
433438
}
434439
sqe->rw_flags = 0;
440+
if (!td->o.odirect && o->uncached)
441+
sqe->rw_flags |= RWF_DONTCACHE;
435442
if (o->nowait)
436443
sqe->rw_flags |= RWF_NOWAIT;
437444
if (td->o.oatomic && io_u->ddir == DDIR_WRITE)
@@ -513,6 +520,8 @@ static int fio_ioring_cmd_prep(struct thread_data *td, struct io_u *io_u)
513520
sqe->fd = f->fd;
514521
}
515522
sqe->rw_flags = 0;
523+
if (!td->o.odirect && o->uncached)
524+
sqe->rw_flags |= RWF_DONTCACHE;
516525
if (o->nowait)
517526
sqe->rw_flags |= RWF_NOWAIT;
518527

engines/sync.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct psyncv2_options {
3939
void *pad;
4040
unsigned int hipri;
4141
unsigned int hipri_percentage;
42+
unsigned int uncached;
4243
unsigned int nowait;
4344
};
4445

@@ -67,7 +68,11 @@ static struct fio_option options[] = {
6768
{
6869
.name = "uncached",
6970
.lname = "Uncached",
70-
.type = FIO_OPT_SOFT_DEPRECATED,
71+
.type = FIO_OPT_INT,
72+
.off1 = offsetof(struct psyncv2_options, uncached),
73+
.help = "Use RWF_DONTCACHE for buffered read/writes",
74+
.category = FIO_OPT_C_ENGINE,
75+
.group = FIO_OPT_G_INVALID,
7176
},
7277
{
7378
.name = "nowait",
@@ -167,6 +172,8 @@ static enum fio_q_status fio_pvsyncio2_queue(struct thread_data *td,
167172
if (o->hipri &&
168173
(rand_between(&sd->rand_state, 1, 100) <= o->hipri_percentage))
169174
flags |= RWF_HIPRI;
175+
if (!td->o.odirect && o->uncached)
176+
flags |= RWF_DONTCACHE;
170177
if (o->nowait)
171178
flags |= RWF_NOWAIT;
172179

os/os-linux.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ static inline int fio_set_sched_idle(void)
333333
#define RWF_ATOMIC 0x00000040
334334
#endif
335335

336+
#ifndef RWF_DONTCACHE
337+
#define RWF_DONTCACHE 0x00000080
338+
#endif
339+
336340
#ifndef RWF_WRITE_LIFE_SHIFT
337341
#define RWF_WRITE_LIFE_SHIFT 4
338342
#define RWF_WRITE_LIFE_SHORT (1 << RWF_WRITE_LIFE_SHIFT)

tools/fiograph/fiograph.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ specific_options=https http_host http_user http_pass http_s3_key http_s3_ke
5151
specific_options=ime_psync ime_psyncv
5252

5353
[ioengine_io_uring]
54-
specific_options=hipri cmdprio_percentage cmdprio_class cmdprio cmdprio_bssplit fixedbufs registerfiles sqthread_poll sqthread_poll_cpu nonvectored nowait force_async atomic
54+
specific_options=hipri cmdprio_percentage cmdprio_class cmdprio cmdprio_bssplit fixedbufs registerfiles sqthread_poll sqthread_poll_cpu nonvectored nowait force_async atomic uncached
5555

5656
[ioengine_io_uring_cmd]
5757
specific_options=hipri cmdprio_percentage cmdprio_class cmdprio cmdprio_bssplit fixedbufs registerfiles sqthread_poll sqthread_poll_cpu nonvectored nowait force_async cmd_type md_per_io_size pi_act pi_chk apptag apptag_mask
@@ -99,7 +99,7 @@ specific_options=hostname bindname port verb
9999
specific_options=hipri readfua writefua sg_write_mode stream_id
100100

101101
[ioengine_pvsync2]
102-
specific_options=hipri hipri_percentage nowait sync psync vsync pvsync atomic
102+
specific_options=hipri hipri_percentage nowait sync psync vsync pvsync atomic uncached
103103

104104
[ioengine_xnvme]
105105
specific_options=hipri sqthread_poll xnvme_be xnvme_async xnvme_sync xnvme_admin xnvme_dev_nsid xnvme_iovec

0 commit comments

Comments
 (0)