Skip to content

Commit

Permalink
aoe: Avoid flush_scheduled_work() usage
Browse files Browse the repository at this point in the history
Flushing system-wide workqueues is dangerous and will be forbidden.
Replace system_wq with local aoe_wq.

Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
  • Loading branch information
Tetsuo Handa authored and intel-lab-lkp committed Apr 18, 2022
1 parent cc521f6 commit b1ae05b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions drivers/block/aoe/aoe.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,5 @@ void aoenet_exit(void);
void aoenet_xmit(struct sk_buff_head *);
int is_aoe_netif(struct net_device *ifp);
int set_aoe_iflist(const char __user *str, size_t size);

extern struct workqueue_struct *aoe_wq;
2 changes: 1 addition & 1 deletion drivers/block/aoe/aoeblk.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ aoeblk_gdalloc(void *vp)
err:
spin_lock_irqsave(&d->lock, flags);
d->flags &= ~DEVFL_GD_NOW;
schedule_work(&d->work);
queue_work(aoe_wq, &d->work);
spin_unlock_irqrestore(&d->lock, flags);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/block/aoe/aoecmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
d->flags |= DEVFL_NEWSIZE;
else
d->flags |= DEVFL_GDALLOC;
schedule_work(&d->work);
queue_work(aoe_wq, &d->work);
}

static void
Expand Down
4 changes: 2 additions & 2 deletions drivers/block/aoe/aoedev.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ flush(const char __user *str, size_t cnt, int exiting)
specified = 1;
}

flush_scheduled_work();
flush_workqueue(aoe_wq);
/* pass one: do aoedev_downdev, which might sleep */
restart1:
spin_lock_irqsave(&devlist_lock, flags);
Expand Down Expand Up @@ -520,7 +520,7 @@ freetgt(struct aoedev *d, struct aoetgt *t)
void
aoedev_exit(void)
{
flush_scheduled_work();
flush_workqueue(aoe_wq);
flush(NULL, 0, EXITING);
}

Expand Down
9 changes: 8 additions & 1 deletion drivers/block/aoe/aoemain.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,21 @@ aoe_exit(void)
aoechr_exit();
aoedev_exit();
aoeblk_exit(); /* free cache after de-allocating bufs */
destroy_workqueue(aoe_wq);
}

static int __init
aoe_init(void)
{
int ret;

aoe_wq = alloc_workqueue("aoe_wq", 0, 0);
if (!aoe_wq)
return -ENOMEM;

ret = aoedev_init();
if (ret)
return ret;
goto dev_fail;
ret = aoechr_init();
if (ret)
goto chr_fail;
Expand Down Expand Up @@ -77,6 +82,8 @@ aoe_init(void)
aoechr_exit();
chr_fail:
aoedev_exit();
dev_fail:
destroy_workqueue(aoe_wq);

printk(KERN_INFO "aoe: initialisation failure.\n");
return ret;
Expand Down

0 comments on commit b1ae05b

Please sign in to comment.