Skip to content

Commit 008f75a

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: cleanup the flush plug helpers
Consolidate the various helpers into a single blk_flush_plug helper that takes a plk_plug and the from_scheduler bool and switch all callsites to call it directly. Checks that the plug is non-NULL must be performed by the caller, something that most already do anyway. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent b600455 commit 008f75a

File tree

4 files changed

+16
-36
lines changed

4 files changed

+16
-36
lines changed

block/blk-core.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
10891089
return 0;
10901090

10911091
if (current->plug)
1092-
blk_flush_plug_list(current->plug, false);
1092+
blk_flush_plug(current->plug, false);
10931093

10941094
if (blk_queue_enter(q, BLK_MQ_REQ_NOWAIT))
10951095
return 0;
@@ -1637,7 +1637,7 @@ struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug, void *data,
16371637
}
16381638
EXPORT_SYMBOL(blk_check_plugged);
16391639

1640-
void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
1640+
void blk_flush_plug(struct blk_plug *plug, bool from_schedule)
16411641
{
16421642
if (!list_empty(&plug->cb_list))
16431643
flush_plug_callbacks(plug, from_schedule);
@@ -1659,11 +1659,10 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
16591659
*/
16601660
void blk_finish_plug(struct blk_plug *plug)
16611661
{
1662-
if (plug != current->plug)
1663-
return;
1664-
blk_flush_plug_list(plug, false);
1665-
1666-
current->plug = NULL;
1662+
if (plug == current->plug) {
1663+
blk_flush_plug(plug, false);
1664+
current->plug = NULL;
1665+
}
16671666
}
16681667
EXPORT_SYMBOL(blk_finish_plug);
16691668

fs/fs-writeback.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,8 @@ static long writeback_sb_inodes(struct super_block *sb,
18931893
* unplug, so get our IOs out the door before we
18941894
* give up the CPU.
18951895
*/
1896-
blk_flush_plug(current);
1896+
if (current->plug)
1897+
blk_flush_plug(current->plug, false);
18971898
cond_resched();
18981899
}
18991900

@@ -2291,7 +2292,7 @@ void wakeup_flusher_threads(enum wb_reason reason)
22912292
* If we are expecting writeback progress we must submit plugged IO.
22922293
*/
22932294
if (blk_needs_flush_plug(current))
2294-
blk_schedule_flush_plug(current);
2295+
blk_flush_plug(current->plug, true);
22952296

22962297
rcu_read_lock();
22972298
list_for_each_entry_rcu(bdi, &bdi_list, bdi_list)

include/linux/blkdev.h

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,8 @@ extern void blk_set_queue_dying(struct request_queue *);
725725
* as the lock contention for request_queue lock is reduced.
726726
*
727727
* It is ok not to disable preemption when adding the request to the plug list
728-
* or when attempting a merge, because blk_schedule_flush_list() will only flush
729-
* the plug list when the task sleeps by itself. For details, please see
730-
* schedule() where blk_schedule_flush_plug() is called.
728+
* or when attempting a merge. For details, please see schedule() where
729+
* blk_flush_plug() is called.
731730
*/
732731
struct blk_plug {
733732
struct request *mq_list; /* blk-mq requests */
@@ -757,23 +756,8 @@ extern struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug,
757756
extern void blk_start_plug(struct blk_plug *);
758757
extern void blk_start_plug_nr_ios(struct blk_plug *, unsigned short);
759758
extern void blk_finish_plug(struct blk_plug *);
760-
extern void blk_flush_plug_list(struct blk_plug *, bool);
761759

762-
static inline void blk_flush_plug(struct task_struct *tsk)
763-
{
764-
struct blk_plug *plug = tsk->plug;
765-
766-
if (plug)
767-
blk_flush_plug_list(plug, false);
768-
}
769-
770-
static inline void blk_schedule_flush_plug(struct task_struct *tsk)
771-
{
772-
struct blk_plug *plug = tsk->plug;
773-
774-
if (plug)
775-
blk_flush_plug_list(plug, true);
776-
}
760+
void blk_flush_plug(struct blk_plug *plug, bool from_schedule);
777761

778762
static inline bool blk_needs_flush_plug(struct task_struct *tsk)
779763
{
@@ -802,15 +786,10 @@ static inline void blk_finish_plug(struct blk_plug *plug)
802786
{
803787
}
804788

805-
static inline void blk_flush_plug(struct task_struct *task)
806-
{
807-
}
808-
809-
static inline void blk_schedule_flush_plug(struct task_struct *task)
789+
static inline void blk_flush_plug(struct blk_plug *plug, bool async)
810790
{
811791
}
812792

813-
814793
static inline bool blk_needs_flush_plug(struct task_struct *tsk)
815794
{
816795
return false;

kernel/sched/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6343,7 +6343,7 @@ static inline void sched_submit_work(struct task_struct *tsk)
63436343
* make sure to submit it to avoid deadlocks.
63446344
*/
63456345
if (blk_needs_flush_plug(tsk))
6346-
blk_schedule_flush_plug(tsk);
6346+
blk_flush_plug(tsk->plug, true);
63476347
}
63486348

63496349
static void sched_update_worker(struct task_struct *tsk)
@@ -8354,7 +8354,8 @@ int io_schedule_prepare(void)
83548354
int old_iowait = current->in_iowait;
83558355

83568356
current->in_iowait = 1;
8357-
blk_schedule_flush_plug(current);
8357+
if (current->plug)
8358+
blk_flush_plug(current->plug, true);
83588359

83598360
return old_iowait;
83608361
}

0 commit comments

Comments
 (0)