Handle closing an unopened ZVOL

Thank to commit a4430fce69 we're
now correctly returning EROFS when opening a zvol on a read-only
pool.  Unfortunately, it looks like this causes us to trigger
some unexpected behavior by __blkdev_get().

In the failure case it's possible __blkdev_get() will call
__blkdev_put() for a bdev which was never successfully opened.
This results in us trying to close the device again and hitting
the NULL dereference.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1343
This commit is contained in:
Brian Behlendorf 2013-03-08 10:48:18 -08:00
parent a127e841de
commit 0365064a97
1 changed files with 5 additions and 5 deletions

View File

@ -1055,11 +1055,11 @@ zvol_release(struct gendisk *disk, fmode_t mode)
drop_mutex = 1;
}
ASSERT3P(zv, !=, NULL);
ASSERT3U(zv->zv_open_count, >, 0);
zv->zv_open_count--;
if (zv->zv_open_count == 0)
zvol_last_close(zv);
if (zv->zv_open_count > 0) {
zv->zv_open_count--;
if (zv->zv_open_count == 0)
zvol_last_close(zv);
}
if (drop_mutex)
mutex_exit(&zvol_state_lock);