Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 258603
b: refs/heads/master
c: 85ef06d
h: refs/heads/master
i:
  258601: b96afef
  258599: 3534dd6
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Jul 1, 2011
1 parent d0a3447 commit d0f36e6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 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: 04bf7869ca0fd12009aee301cac2264a36df4d98
refs/heads/master: 85ef06d1d252f6a2e73b678591ab71caad4667bb
22 changes: 12 additions & 10 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,30 +1500,32 @@ void disk_unblock_events(struct gendisk *disk)
}

/**
* disk_check_events - schedule immediate event checking
* @disk: disk to check events for
* disk_flush_events - schedule immediate event checking and flushing
* @disk: disk to check and flush events for
* @mask: events to flush
*
* Schedule immediate event checking on @disk if not blocked.
* Schedule immediate event checking on @disk if not blocked. Events in
* @mask are scheduled to be cleared from the driver. Note that this
* doesn't clear the events from @disk->ev.
*
* CONTEXT:
* Don't care. Safe to call from irq context.
* If @mask is non-zero must be called with bdev->bd_mutex held.
*/
void disk_check_events(struct gendisk *disk)
void disk_flush_events(struct gendisk *disk, unsigned int mask)
{
struct disk_events *ev = disk->ev;
unsigned long flags;

if (!ev)
return;

spin_lock_irqsave(&ev->lock, flags);
spin_lock_irq(&ev->lock);
ev->clearing |= mask;
if (!ev->block) {
cancel_delayed_work(&ev->dwork);
queue_delayed_work(system_nrt_wq, &ev->dwork, 0);
}
spin_unlock_irqrestore(&ev->lock, flags);
spin_unlock_irq(&ev->lock);
}
EXPORT_SYMBOL_GPL(disk_check_events);

/**
* disk_clear_events - synchronously check, clear and return pending events
Expand Down Expand Up @@ -1713,7 +1715,7 @@ static int disk_events_set_dfl_poll_msecs(const char *val,
mutex_lock(&disk_events_mutex);

list_for_each_entry(ev, &disk_events, node)
disk_check_events(ev->disk);
disk_flush_events(ev->disk, 0);

mutex_unlock(&disk_events_mutex);

Expand Down
23 changes: 14 additions & 9 deletions trunk/fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,8 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)

int blkdev_put(struct block_device *bdev, fmode_t mode)
{
mutex_lock(&bdev->bd_mutex);

if (mode & FMODE_EXCL) {
bool bdev_free;

Expand All @@ -1455,7 +1457,6 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
* are protected with bdev_lock. bd_mutex is to
* synchronize disk_holder unlinking.
*/
mutex_lock(&bdev->bd_mutex);
spin_lock(&bdev_lock);

WARN_ON_ONCE(--bdev->bd_holders < 0);
Expand All @@ -1473,17 +1474,21 @@ int blkdev_put(struct block_device *bdev, fmode_t mode)
* If this was the last claim, remove holder link and
* unblock evpoll if it was a write holder.
*/
if (bdev_free) {
if (bdev->bd_write_holder) {
disk_unblock_events(bdev->bd_disk);
disk_check_events(bdev->bd_disk);
bdev->bd_write_holder = false;
}
if (bdev_free && bdev->bd_write_holder) {
disk_unblock_events(bdev->bd_disk);
bdev->bd_write_holder = false;
}

mutex_unlock(&bdev->bd_mutex);
}

/*
* Trigger event checking and tell drivers to flush MEDIA_CHANGE
* event. This is to ensure detection of media removal commanded
* from userland - e.g. eject(1).
*/
disk_flush_events(bdev->bd_disk, DISK_EVENT_MEDIA_CHANGE);

mutex_unlock(&bdev->bd_mutex);

return __blkdev_put(bdev, mode, 0);
}
EXPORT_SYMBOL(blkdev_put);
Expand Down
2 changes: 1 addition & 1 deletion trunk/include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static inline int get_disk_ro(struct gendisk *disk)

extern void disk_block_events(struct gendisk *disk);
extern void disk_unblock_events(struct gendisk *disk);
extern void disk_check_events(struct gendisk *disk);
extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);

/* drivers/char/random.c */
Expand Down

0 comments on commit d0f36e6

Please sign in to comment.