* [patch 03/11] libata-core: convert to use cancel_rearming_delayed_work()
@ 2007-07-09 18:46 akpm
2007-07-09 18:59 ` Tejun Heo
2007-07-11 0:55 ` Jeff Garzik
0 siblings, 2 replies; 3+ messages in thread
From: akpm @ 2007-07-09 18:46 UTC (permalink / raw)
To: jeff; +Cc: linux-ide, akpm, oleg
From: Oleg Nesterov <oleg@tv-sign.ru>
We should not use cancel_work_sync(delayed_work->work). This works, but not
good. We can use cancel_rearming_delayed_work(), this also simplifies the
code.
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
drivers/ata/libata-core.c | 44 +++---------------------------------
include/linux/libata.h | 1
2 files changed, 4 insertions(+), 41 deletions(-)
diff -puN drivers/ata/libata-core.c~libata-core-convert-to-use-cancel_rearming_delayed_work drivers/ata/libata-core.c
--- a/drivers/ata/libata-core.c~libata-core-convert-to-use-cancel_rearming_delayed_work
+++ a/drivers/ata/libata-core.c
@@ -1283,18 +1283,11 @@ static unsigned int ata_id_xfermask(cons
void ata_port_queue_task(struct ata_port *ap, work_func_t fn, void *data,
unsigned long delay)
{
- int rc;
-
- if (ap->pflags & ATA_PFLAG_FLUSH_PORT_TASK)
- return;
-
PREPARE_DELAYED_WORK(&ap->port_task, fn);
ap->port_task_data = data;
- rc = queue_delayed_work(ata_wq, &ap->port_task, delay);
-
- /* rc == 0 means that another user is using port task */
- WARN_ON(rc == 0);
+ /* may fail if ata_port_flush_task() in progress */
+ queue_delayed_work(ata_wq, &ap->port_task, delay);
}
/**
@@ -1309,32 +1302,9 @@ void ata_port_queue_task(struct ata_port
*/
void ata_port_flush_task(struct ata_port *ap)
{
- unsigned long flags;
-
DPRINTK("ENTER\n");
- spin_lock_irqsave(ap->lock, flags);
- ap->pflags |= ATA_PFLAG_FLUSH_PORT_TASK;
- spin_unlock_irqrestore(ap->lock, flags);
-
- DPRINTK("flush #1\n");
- cancel_work_sync(&ap->port_task.work); /* akpm: seems unneeded */
-
- /*
- * At this point, if a task is running, it's guaranteed to see
- * the FLUSH flag; thus, it will never queue pio tasks again.
- * Cancel and flush.
- */
- if (!cancel_delayed_work(&ap->port_task)) {
- if (ata_msg_ctl(ap))
- ata_port_printk(ap, KERN_DEBUG, "%s: flush #2\n",
- __FUNCTION__);
- cancel_work_sync(&ap->port_task.work);
- }
-
- spin_lock_irqsave(ap->lock, flags);
- ap->pflags &= ~ATA_PFLAG_FLUSH_PORT_TASK;
- spin_unlock_irqrestore(ap->lock, flags);
+ cancel_rearming_delayed_work(&ap->port_task);
if (ata_msg_ctl(ap))
ata_port_printk(ap, KERN_DEBUG, "%s: EXIT\n", __FUNCTION__);
@@ -6557,13 +6527,7 @@ void ata_port_detach(struct ata_port *ap
spin_unlock_irqrestore(ap->lock, flags);
ata_port_wait_eh(ap);
-
- /* Flush hotplug task. The sequence is similar to
- * ata_port_flush_task().
- */
- cancel_work_sync(&ap->hotplug_task.work); /* akpm: why? */
- cancel_delayed_work(&ap->hotplug_task);
- cancel_work_sync(&ap->hotplug_task.work);
+ cancel_rearming_delayed_work(&ap->hotplug_task);
skip_eh:
/* remove the associated SCSI host */
diff -puN include/linux/libata.h~libata-core-convert-to-use-cancel_rearming_delayed_work include/linux/libata.h
--- a/include/linux/libata.h~libata-core-convert-to-use-cancel_rearming_delayed_work
+++ a/include/linux/libata.h
@@ -196,7 +196,6 @@ enum {
ATA_PFLAG_SCSI_HOTPLUG = (1 << 6), /* SCSI hotplug scheduled */
ATA_PFLAG_INITIALIZING = (1 << 7), /* being initialized, don't touch */
- ATA_PFLAG_FLUSH_PORT_TASK = (1 << 16), /* flush port task */
ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */
ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */
ATA_PFLAG_GTM_VALID = (1 << 19), /* acpi_gtm data valid */
_
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch 03/11] libata-core: convert to use cancel_rearming_delayed_work()
2007-07-09 18:46 [patch 03/11] libata-core: convert to use cancel_rearming_delayed_work() akpm
@ 2007-07-09 18:59 ` Tejun Heo
2007-07-11 0:55 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2007-07-09 18:59 UTC (permalink / raw)
To: akpm; +Cc: jeff, linux-ide, oleg
akpm@linux-foundation.org wrote:
> From: Oleg Nesterov <oleg@tv-sign.ru>
>
> We should not use cancel_work_sync(delayed_work->work). This works, but not
> good. We can use cancel_rearming_delayed_work(), this also simplifies the
> code.
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Tejun Heo <htejun@gmail.com>
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 03/11] libata-core: convert to use cancel_rearming_delayed_work()
2007-07-09 18:46 [patch 03/11] libata-core: convert to use cancel_rearming_delayed_work() akpm
2007-07-09 18:59 ` Tejun Heo
@ 2007-07-11 0:55 ` Jeff Garzik
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2007-07-11 0:55 UTC (permalink / raw)
To: akpm; +Cc: linux-ide, oleg
akpm@linux-foundation.org wrote:
> From: Oleg Nesterov <oleg@tv-sign.ru>
>
> We should not use cancel_work_sync(delayed_work->work). This works, but not
> good. We can use cancel_rearming_delayed_work(), this also simplifies the
> code.
>
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>
> drivers/ata/libata-core.c | 44 +++---------------------------------
> include/linux/libata.h | 1
> 2 files changed, 4 insertions(+), 41 deletions(-)
applied
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-11 0:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-09 18:46 [patch 03/11] libata-core: convert to use cancel_rearming_delayed_work() akpm
2007-07-09 18:59 ` Tejun Heo
2007-07-11 0:55 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).