Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 254004
b: refs/heads/master
c: fdd514e
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Jun 9, 2011
1 parent af7ac55 commit e2bb771
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c3af54afbac3675337cedf326b7b127ffa7f7327
refs/heads/master: fdd514e16bb2531c0c61ae8a1f87740ce217f630
10 changes: 10 additions & 0 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ struct disk_events {
struct gendisk *disk; /* the associated disk */
spinlock_t lock;

struct mutex block_mutex; /* protects blocking */
int block; /* event blocking depth */
unsigned int pending; /* events already sent out */
unsigned int clearing; /* events being cleared */
Expand Down Expand Up @@ -1438,12 +1439,20 @@ void disk_block_events(struct gendisk *disk)
if (!ev)
return;

/*
* Outer mutex ensures that the first blocker completes canceling
* the event work before further blockers are allowed to finish.
*/
mutex_lock(&ev->block_mutex);

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

if (cancel)
cancel_delayed_work_sync(&disk->ev->dwork);

mutex_unlock(&ev->block_mutex);
}

static void __disk_unblock_events(struct gendisk *disk, bool check_now)
Expand Down Expand Up @@ -1751,6 +1760,7 @@ static void disk_add_events(struct gendisk *disk)
INIT_LIST_HEAD(&ev->node);
ev->disk = disk;
spin_lock_init(&ev->lock);
mutex_init(&ev->block_mutex);
ev->block = 1;
ev->poll_msecs = -1;
INIT_DELAYED_WORK(&ev->dwork, disk_events_workfn);
Expand Down

0 comments on commit e2bb771

Please sign in to comment.