Additional ZVOL cleanup in zvol_set_volsize()

The following cleanup was missed in the first pass when the ZVOL
implementation was updated.  An extra instance of a zvol_state_t
was removed from the stack and the error handling was simplified.
This commit is contained in:
Brian Behlendorf 2010-06-25 23:04:21 -07:00
parent 4aba89bb16
commit d6ea5e8cef
1 changed files with 10 additions and 12 deletions

View File

@ -275,8 +275,6 @@ zvol_set_volsize(const char *name, uint64_t volsize)
zvol_state_t *zv; zvol_state_t *zv;
dmu_object_info_t doi; dmu_object_info_t doi;
objset_t *os = NULL; objset_t *os = NULL;
zvol_state_t state = { 0 };
uint64_t old_volsize = 0ULL;
uint64_t readonly; uint64_t readonly;
int error; int error;
@ -284,24 +282,24 @@ zvol_set_volsize(const char *name, uint64_t volsize)
zv = zvol_find_by_name(name); zv = zvol_find_by_name(name);
if (zv == NULL) { if (zv == NULL) {
error = dmu_objset_hold(name, FTAG, &os); error = ENXIO;
if (error) goto out;
goto out;
zv = &state;
} }
error = dmu_objset_hold(name, FTAG, &os);
if (error)
goto out;
if ((error = dmu_object_info(os, ZVOL_OBJ, &doi)) != 0 ||
(error = zvol_check_volsize(volsize,doi.doi_data_block_size)) != 0)
goto out;
VERIFY(dsl_prop_get_integer(name, "readonly", &readonly, NULL) == 0); VERIFY(dsl_prop_get_integer(name, "readonly", &readonly, NULL) == 0);
if (readonly) { if (readonly) {
error = EROFS; error = EROFS;
goto out; goto out;
} }
old_volsize = zv->zv_volsize;
if ((error = dmu_object_info(os, ZVOL_OBJ, &doi)) != 0 ||
(error = zvol_check_volsize(volsize,doi.doi_data_block_size)) != 0)
goto out;
if (get_disk_ro(zv->zv_disk) || (zv->zv_flags & ZVOL_RDONLY)) { if (get_disk_ro(zv->zv_disk) || (zv->zv_flags & ZVOL_RDONLY)) {
error = EROFS; error = EROFS;
goto out; goto out;