mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 11:47:43 +03:00
ZIL claiming should not start user accounting
Currently, ZIL claiming dirties objsets which causes dsl_pool_sync() to attempt to perform user accounting on them. This causes problems for encrypted datasets that were raw received before the system went offline since they cannot perform user accounting until they have their keys loaded. This triggers an ASSERT in zio_encrypt(). Since encryption was added, the code now depends on the fact that data should only be written when objsets are owned. This patch adds a check in dmu_objset_do_userquota_updates() to ensure that useraccounting is only done when the objsets are actually owned for write. As part of this work, the zfsvfs and zvol code was updated so that it no longer lies about owning objsets readonly. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes #6916 Closes #7163
This commit is contained in:
committed by
Brian Behlendorf
parent
cbce581353
commit
163a8c28dd
+6
-10
@@ -1289,10 +1289,11 @@ zvol_resume(zvol_state_t *zv)
|
||||
}
|
||||
|
||||
static int
|
||||
zvol_first_open(zvol_state_t *zv)
|
||||
zvol_first_open(zvol_state_t *zv, boolean_t readonly)
|
||||
{
|
||||
objset_t *os;
|
||||
int error, locked = 0;
|
||||
boolean_t ro;
|
||||
|
||||
ASSERT(RW_READ_HELD(&zv->zv_suspend_lock));
|
||||
ASSERT(MUTEX_HELD(&zv->zv_state_lock));
|
||||
@@ -1321,8 +1322,8 @@ zvol_first_open(zvol_state_t *zv)
|
||||
return (-SET_ERROR(ERESTARTSYS));
|
||||
}
|
||||
|
||||
/* lie and say we're read-only */
|
||||
error = dmu_objset_own(zv->zv_name, DMU_OST_ZVOL, 1, 1, zv, &os);
|
||||
ro = (readonly || (strchr(zv->zv_name, '@') != NULL));
|
||||
error = dmu_objset_own(zv->zv_name, DMU_OST_ZVOL, ro, B_TRUE, zv, &os);
|
||||
if (error)
|
||||
goto out_mutex;
|
||||
|
||||
@@ -1401,17 +1402,12 @@ zvol_open(struct block_device *bdev, fmode_t flag)
|
||||
ASSERT(zv->zv_open_count != 0 || RW_READ_HELD(&zv->zv_suspend_lock));
|
||||
|
||||
if (zv->zv_open_count == 0) {
|
||||
error = zvol_first_open(zv);
|
||||
error = zvol_first_open(zv, !(flag & FMODE_WRITE));
|
||||
if (error)
|
||||
goto out_mutex;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for a bad on-disk format version now since we
|
||||
* lied about owning the dataset readonly before.
|
||||
*/
|
||||
if ((flag & FMODE_WRITE) && ((zv->zv_flags & ZVOL_RDONLY) ||
|
||||
dmu_objset_incompatible_encryption_version(zv->zv_objset))) {
|
||||
if ((flag & FMODE_WRITE) && (zv->zv_flags & ZVOL_RDONLY)) {
|
||||
error = -EROFS;
|
||||
goto out_open_count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user