Skip to content

Commit ca50496

Browse files
committed
Merge branch 'for-3.7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq
Pull workqueue fixes from Tejun Heo: "So, safe fixes my ass. Commit 8852aac ("workqueue: mod_delayed_work_on() shouldn't queue timer on 0 delay") had the side-effect of performing delayed_work sanity checks even when @delay is 0, which should be fine for any sane use cases. Unfortunately, megaraid was being overly ingenious. It seemingly wanted to use cancel_delayed_work_sync() before cancel_work_sync() was introduced, but didn't want to waste the space for full delayed_work as it was only going to use 0 @delay. So, it only allocated space for struct work_struct and then cast it to struct delayed_work and passed it into delayed_work functions - truly awesome engineering tradeoff to save some bytes. Xiaotian fixed it by making megraid allocate full delayed_work for now. It should be converted to use work_struct and cancel_work_sync() but I think we better do that after 3.7. I added another commit to change BUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s so that the kernel doesn't crash even if there are more such abuses." * 'for-3.7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: convert BUG_ON()s in __queue_delayed_work() to WARN_ON_ONCE()s megaraid: fix BUG_ON() from incorrect use of delayed work
2 parents 609e3ff + fc4b514 commit ca50496

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

drivers/scsi/megaraid/megaraid_sas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ struct megasas_evt_detail {
12761276
} __attribute__ ((packed));
12771277

12781278
struct megasas_aen_event {
1279-
struct work_struct hotplug_work;
1279+
struct delayed_work hotplug_work;
12801280
struct megasas_instance *instance;
12811281
};
12821282

drivers/scsi/megaraid/megaraid_sas_base.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,9 +2060,9 @@ megasas_service_aen(struct megasas_instance *instance, struct megasas_cmd *cmd)
20602060
} else {
20612061
ev->instance = instance;
20622062
instance->ev = ev;
2063-
INIT_WORK(&ev->hotplug_work, megasas_aen_polling);
2064-
schedule_delayed_work(
2065-
(struct delayed_work *)&ev->hotplug_work, 0);
2063+
INIT_DELAYED_WORK(&ev->hotplug_work,
2064+
megasas_aen_polling);
2065+
schedule_delayed_work(&ev->hotplug_work, 0);
20662066
}
20672067
}
20682068
}
@@ -4352,8 +4352,7 @@ megasas_suspend(struct pci_dev *pdev, pm_message_t state)
43524352
/* cancel the delayed work if this work still in queue */
43534353
if (instance->ev != NULL) {
43544354
struct megasas_aen_event *ev = instance->ev;
4355-
cancel_delayed_work_sync(
4356-
(struct delayed_work *)&ev->hotplug_work);
4355+
cancel_delayed_work_sync(&ev->hotplug_work);
43574356
instance->ev = NULL;
43584357
}
43594358

@@ -4545,8 +4544,7 @@ static void __devexit megasas_detach_one(struct pci_dev *pdev)
45454544
/* cancel the delayed work if this work still in queue*/
45464545
if (instance->ev != NULL) {
45474546
struct megasas_aen_event *ev = instance->ev;
4548-
cancel_delayed_work_sync(
4549-
(struct delayed_work *)&ev->hotplug_work);
4547+
cancel_delayed_work_sync(&ev->hotplug_work);
45504548
instance->ev = NULL;
45514549
}
45524550

@@ -5190,7 +5188,7 @@ static void
51905188
megasas_aen_polling(struct work_struct *work)
51915189
{
51925190
struct megasas_aen_event *ev =
5193-
container_of(work, struct megasas_aen_event, hotplug_work);
5191+
container_of(work, struct megasas_aen_event, hotplug_work.work);
51945192
struct megasas_instance *instance = ev->instance;
51955193
union megasas_evt_class_locale class_locale;
51965194
struct Scsi_Host *host;

kernel/workqueue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,8 +1361,8 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
13611361

13621362
WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
13631363
timer->data != (unsigned long)dwork);
1364-
BUG_ON(timer_pending(timer));
1365-
BUG_ON(!list_empty(&work->entry));
1364+
WARN_ON_ONCE(timer_pending(timer));
1365+
WARN_ON_ONCE(!list_empty(&work->entry));
13661366

13671367
/*
13681368
* If @delay is 0, queue @dwork->work immediately. This is for

0 commit comments

Comments
 (0)