Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 254003
b: refs/heads/master
c: c3af54a
h: refs/heads/master
i:
  254001: 5cef8bd
  253999: ef0dac7
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Jun 9, 2011
1 parent 5b308ec commit af7ac55
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a9dce2a3b4f0686dd66cb44d4826a59508bce969
refs/heads/master: c3af54afbac3675337cedf326b7b127ffa7f7327
55 changes: 24 additions & 31 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,22 +1414,36 @@ static unsigned long disk_events_poll_jiffies(struct gendisk *disk)
return msecs_to_jiffies(intv_msecs);
}

static void __disk_block_events(struct gendisk *disk, bool sync)
/**
* disk_block_events - block and flush disk event checking
* @disk: disk to block events for
*
* On return from this function, it is guaranteed that event checking
* isn't in progress and won't happen until unblocked by
* disk_unblock_events(). Events blocking is counted and the actual
* unblocking happens after the matching number of unblocks are done.
*
* Note that this intentionally does not block event checking from
* disk_clear_events().
*
* CONTEXT:
* Might sleep.
*/
void disk_block_events(struct gendisk *disk)
{
struct disk_events *ev = disk->ev;
unsigned long flags;
bool cancel;

if (!ev)
return;

spin_lock_irqsave(&ev->lock, flags);
cancel = !ev->block++;
spin_unlock_irqrestore(&ev->lock, flags);

if (cancel) {
if (sync)
cancel_delayed_work_sync(&disk->ev->dwork);
else
cancel_delayed_work(&disk->ev->dwork);
}
if (cancel)
cancel_delayed_work_sync(&disk->ev->dwork);
}

static void __disk_unblock_events(struct gendisk *disk, bool check_now)
Expand Down Expand Up @@ -1460,27 +1474,6 @@ static void __disk_unblock_events(struct gendisk *disk, bool check_now)
spin_unlock_irqrestore(&ev->lock, flags);
}

/**
* disk_block_events - block and flush disk event checking
* @disk: disk to block events for
*
* On return from this function, it is guaranteed that event checking
* isn't in progress and won't happen until unblocked by
* disk_unblock_events(). Events blocking is counted and the actual
* unblocking happens after the matching number of unblocks are done.
*
* Note that this intentionally does not block event checking from
* disk_clear_events().
*
* CONTEXT:
* Might sleep.
*/
void disk_block_events(struct gendisk *disk)
{
if (disk->ev)
__disk_block_events(disk, true);
}

/**
* disk_unblock_events - unblock disk event checking
* @disk: disk to unblock events for
Expand Down Expand Up @@ -1554,7 +1547,7 @@ unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask)
spin_unlock_irq(&ev->lock);

/* uncondtionally schedule event check and wait for it to finish */
__disk_block_events(disk, true);
disk_block_events(disk);
queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
flush_delayed_work(&ev->dwork);
__disk_unblock_events(disk, false);
Expand Down Expand Up @@ -1672,7 +1665,7 @@ static ssize_t disk_events_poll_msecs_store(struct device *dev,
if (intv < 0 && intv != -1)
return -EINVAL;

__disk_block_events(disk, true);
disk_block_events(disk);
disk->ev->poll_msecs = intv;
__disk_unblock_events(disk, true);

Expand Down Expand Up @@ -1778,7 +1771,7 @@ static void disk_del_events(struct gendisk *disk)
if (!disk->ev)
return;

__disk_block_events(disk, true);
disk_block_events(disk);

mutex_lock(&disk_events_mutex);
list_del_init(&disk->ev->node);
Expand Down

0 comments on commit af7ac55

Please sign in to comment.