Skip to content

Commit f9f8514

Browse files
Christoph Hellwigbrauner
authored andcommitted
fs, iomap: remove IOCB_DIO_CALLER_COMP
This was added by commit 099ada2 ("io_uring/rw: add write support for IOCB_DIO_CALLER_COMP") and disabled a little later by commit 838b35b ("io_uring/rw: disable IOCB_DIO_CALLER_COMP") because it didn't work. Remove all the related code that sat unused for 2 years. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20251113170633.1453259-2-hch@lst.de Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent f53d302 commit f9f8514

5 files changed

Lines changed: 13 additions & 112 deletions

File tree

Documentation/filesystems/iomap/operations.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,6 @@ These ``struct kiocb`` flags are significant for direct I/O with iomap:
490490
Only meaningful for asynchronous I/O, and only if the entire I/O can
491491
be issued as a single ``struct bio``.
492492

493-
* ``IOCB_DIO_CALLER_COMP``: Try to run I/O completion from the caller's
494-
process context.
495-
See ``linux/fs.h`` for more details.
496-
497493
Filesystems should call ``iomap_dio_rw`` from ``->read_iter`` and
498494
``->write_iter``, and set ``FMODE_CAN_ODIRECT`` in the ``->open``
499495
function for the file.

fs/backing-file.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,6 @@ ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter,
227227
!(file->f_mode & FMODE_CAN_ODIRECT))
228228
return -EINVAL;
229229

230-
/*
231-
* Stacked filesystems don't support deferred completions, don't copy
232-
* this property in case it is set by the issuer.
233-
*/
234-
flags &= ~IOCB_DIO_CALLER_COMP;
235-
236230
old_cred = override_creds(ctx->cred);
237231
if (is_sync_kiocb(iocb)) {
238232
rwf_t rwf = iocb_to_rw_flags(flags);

fs/iomap/direct-io.c

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
* Private flags for iomap_dio, must not overlap with the public ones in
1717
* iomap.h:
1818
*/
19-
#define IOMAP_DIO_NO_INVALIDATE (1U << 25)
20-
#define IOMAP_DIO_CALLER_COMP (1U << 26)
19+
#define IOMAP_DIO_NO_INVALIDATE (1U << 26)
2120
#define IOMAP_DIO_INLINE_COMP (1U << 27)
2221
#define IOMAP_DIO_WRITE_THROUGH (1U << 28)
2322
#define IOMAP_DIO_NEED_SYNC (1U << 29)
@@ -140,11 +139,6 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio)
140139
}
141140
EXPORT_SYMBOL_GPL(iomap_dio_complete);
142141

143-
static ssize_t iomap_dio_deferred_complete(void *data)
144-
{
145-
return iomap_dio_complete(data);
146-
}
147-
148142
static void iomap_dio_complete_work(struct work_struct *work)
149143
{
150144
struct iomap_dio *dio = container_of(work, struct iomap_dio, aio.work);
@@ -182,29 +176,6 @@ static void iomap_dio_done(struct iomap_dio *dio)
182176
} else if (dio->flags & IOMAP_DIO_INLINE_COMP) {
183177
WRITE_ONCE(iocb->private, NULL);
184178
iomap_dio_complete_work(&dio->aio.work);
185-
} else if (dio->flags & IOMAP_DIO_CALLER_COMP) {
186-
/*
187-
* If this dio is flagged with IOMAP_DIO_CALLER_COMP, then
188-
* schedule our completion that way to avoid an async punt to a
189-
* workqueue.
190-
*/
191-
/* only polled IO cares about private cleared */
192-
iocb->private = dio;
193-
iocb->dio_complete = iomap_dio_deferred_complete;
194-
195-
/*
196-
* Invoke ->ki_complete() directly. We've assigned our
197-
* dio_complete callback handler, and since the issuer set
198-
* IOCB_DIO_CALLER_COMP, we know their ki_complete handler will
199-
* notice ->dio_complete being set and will defer calling that
200-
* handler until it can be done from a safe task context.
201-
*
202-
* Note that the 'res' being passed in here is not important
203-
* for this case. The actual completion value of the request
204-
* will be gotten from dio_complete when that is run by the
205-
* issuer.
206-
*/
207-
iocb->ki_complete(iocb, 0);
208179
} else {
209180
struct inode *inode = file_inode(iocb->ki_filp);
210181

@@ -261,7 +232,6 @@ u32 iomap_finish_ioend_direct(struct iomap_ioend *ioend)
261232
dio->flags |= IOMAP_DIO_INLINE_COMP;
262233
dio->flags |= IOMAP_DIO_NO_INVALIDATE;
263234
}
264-
dio->flags &= ~IOMAP_DIO_CALLER_COMP;
265235
iomap_dio_done(dio);
266236
}
267237

@@ -380,19 +350,6 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
380350

381351
if (!(bio_opf & REQ_FUA))
382352
dio->flags &= ~IOMAP_DIO_WRITE_THROUGH;
383-
384-
/*
385-
* We can only do deferred completion for pure overwrites that
386-
* don't require additional I/O at completion time.
387-
*
388-
* This rules out writes that need zeroing or extent conversion,
389-
* extend the file size, or issue metadata I/O or cache flushes
390-
* during completion processing.
391-
*/
392-
if (need_zeroout || (pos >= i_size_read(inode)) ||
393-
((dio->flags & IOMAP_DIO_NEED_SYNC) &&
394-
!(bio_opf & REQ_FUA)))
395-
dio->flags &= ~IOMAP_DIO_CALLER_COMP;
396353
} else {
397354
bio_opf |= REQ_OP_READ;
398355
}
@@ -413,7 +370,7 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
413370
* ones we set for inline and deferred completions. If none of those
414371
* are available for this IO, clear the polled flag.
415372
*/
416-
if (!(dio->flags & (IOMAP_DIO_INLINE_COMP|IOMAP_DIO_CALLER_COMP)))
373+
if (!(dio->flags & IOMAP_DIO_INLINE_COMP))
417374
dio->iocb->ki_flags &= ~IOCB_HIPRI;
418375

419376
if (need_zeroout) {
@@ -669,15 +626,6 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
669626
iomi.flags |= IOMAP_WRITE;
670627
dio->flags |= IOMAP_DIO_WRITE;
671628

672-
/*
673-
* Flag as supporting deferred completions, if the issuer
674-
* groks it. This can avoid a workqueue punt for writes.
675-
* We may later clear this flag if we need to do other IO
676-
* as part of this IO completion.
677-
*/
678-
if (iocb->ki_flags & IOCB_DIO_CALLER_COMP)
679-
dio->flags |= IOMAP_DIO_CALLER_COMP;
680-
681629
if (dio_flags & IOMAP_DIO_OVERWRITE_ONLY) {
682630
ret = -EAGAIN;
683631
if (iomi.pos >= dio->i_size ||

include/linux/fs.h

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -367,23 +367,9 @@ struct readahead_control;
367367
#define IOCB_NOIO (1 << 20)
368368
/* can use bio alloc cache */
369369
#define IOCB_ALLOC_CACHE (1 << 21)
370-
/*
371-
* IOCB_DIO_CALLER_COMP can be set by the iocb owner, to indicate that the
372-
* iocb completion can be passed back to the owner for execution from a safe
373-
* context rather than needing to be punted through a workqueue. If this
374-
* flag is set, the bio completion handling may set iocb->dio_complete to a
375-
* handler function and iocb->private to context information for that handler.
376-
* The issuer should call the handler with that context information from task
377-
* context to complete the processing of the iocb. Note that while this
378-
* provides a task context for the dio_complete() callback, it should only be
379-
* used on the completion side for non-IO generating completions. It's fine to
380-
* call blocking functions from this callback, but they should not wait for
381-
* unrelated IO (like cache flushing, new IO generation, etc).
382-
*/
383-
#define IOCB_DIO_CALLER_COMP (1 << 22)
384370
/* kiocb is a read or write operation submitted by fs/aio.c. */
385-
#define IOCB_AIO_RW (1 << 23)
386-
#define IOCB_HAS_METADATA (1 << 24)
371+
#define IOCB_AIO_RW (1 << 22)
372+
#define IOCB_HAS_METADATA (1 << 23)
387373

388374
/* for use in trace events */
389375
#define TRACE_IOCB_STRINGS \
@@ -400,7 +386,6 @@ struct readahead_control;
400386
{ IOCB_WAITQ, "WAITQ" }, \
401387
{ IOCB_NOIO, "NOIO" }, \
402388
{ IOCB_ALLOC_CACHE, "ALLOC_CACHE" }, \
403-
{ IOCB_DIO_CALLER_COMP, "CALLER_COMP" }, \
404389
{ IOCB_AIO_RW, "AIO_RW" }, \
405390
{ IOCB_HAS_METADATA, "AIO_HAS_METADATA" }
406391

@@ -412,23 +397,13 @@ struct kiocb {
412397
int ki_flags;
413398
u16 ki_ioprio; /* See linux/ioprio.h */
414399
u8 ki_write_stream;
415-
union {
416-
/*
417-
* Only used for async buffered reads, where it denotes the
418-
* page waitqueue associated with completing the read. Valid
419-
* IFF IOCB_WAITQ is set.
420-
*/
421-
struct wait_page_queue *ki_waitq;
422-
/*
423-
* Can be used for O_DIRECT IO, where the completion handling
424-
* is punted back to the issuer of the IO. May only be set
425-
* if IOCB_DIO_CALLER_COMP is set by the issuer, and the issuer
426-
* must then check for presence of this handler when ki_complete
427-
* is invoked. The data passed in to this handler must be
428-
* assigned to ->private when dio_complete is assigned.
429-
*/
430-
ssize_t (*dio_complete)(void *data);
431-
};
400+
401+
/*
402+
* Only used for async buffered reads, where it denotes the page
403+
* waitqueue associated with completing the read.
404+
* Valid IFF IOCB_WAITQ is set.
405+
*/
406+
struct wait_page_queue *ki_waitq;
432407
};
433408

434409
static inline bool is_sync_kiocb(struct kiocb *kiocb)

io_uring/rw.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ static int __io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,
277277
} else {
278278
rw->kiocb.ki_ioprio = get_current_ioprio();
279279
}
280-
rw->kiocb.dio_complete = NULL;
281280
rw->kiocb.ki_flags = 0;
282281
rw->kiocb.ki_write_stream = READ_ONCE(sqe->write_stream);
283282

@@ -566,15 +565,6 @@ static inline int io_fixup_rw_res(struct io_kiocb *req, long res)
566565

567566
void io_req_rw_complete(struct io_kiocb *req, io_tw_token_t tw)
568567
{
569-
struct io_rw *rw = io_kiocb_to_cmd(req, struct io_rw);
570-
struct kiocb *kiocb = &rw->kiocb;
571-
572-
if ((kiocb->ki_flags & IOCB_DIO_CALLER_COMP) && kiocb->dio_complete) {
573-
long res = kiocb->dio_complete(rw->kiocb.private);
574-
575-
io_req_set_res(req, io_fixup_rw_res(req, res), 0);
576-
}
577-
578568
io_req_io_end(req);
579569

580570
if (req->flags & (REQ_F_BUFFER_SELECTED|REQ_F_BUFFER_RING))
@@ -589,10 +579,8 @@ static void io_complete_rw(struct kiocb *kiocb, long res)
589579
struct io_rw *rw = container_of(kiocb, struct io_rw, kiocb);
590580
struct io_kiocb *req = cmd_to_io_kiocb(rw);
591581

592-
if (!kiocb->dio_complete || !(kiocb->ki_flags & IOCB_DIO_CALLER_COMP)) {
593-
__io_complete_rw_common(req, res);
594-
io_req_set_res(req, io_fixup_rw_res(req, res), 0);
595-
}
582+
__io_complete_rw_common(req, res);
583+
io_req_set_res(req, io_fixup_rw_res(req, res), 0);
596584
req->io_task_work.func = io_req_rw_complete;
597585
__io_req_task_work_add(req, IOU_F_TWQ_LAZY_WAKE);
598586
}

0 commit comments

Comments
 (0)