Add log messages, when kernel doesn't support resize.

This commit is contained in:
daniel.zatovic
2022-03-15 21:05:46 +01:00
parent 4eba55c73e
commit d20d41c7a5
3 changed files with 17 additions and 0 deletions

View File

@@ -2858,6 +2858,8 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
struct crypt_dm_active_device dmdq, dmd = {};
struct dm_target *tgt = &dmdq.segment;
struct crypt_params_integrity params = {};
uint32_t supported_flags = 0;
uint64_t old_size;
int r;
/*
@@ -2921,6 +2923,11 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
* superblock.
*/
if (!new_size && tgt->type == DM_INTEGRITY) {
r = INTEGRITY_data_sectors(cd, crypt_metadata_device(cd),
crypt_get_data_offset(cd) * SECTOR_SIZE, &old_size);
if (r < 0)
return r;
dmd.size = dmdq.size;
dmd.flags = dmdq.flags | CRYPT_ACTIVATE_REFRESH | CRYPT_ACTIVATE_PRIVATE;
@@ -2943,6 +2950,9 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
if (r < 0)
return r;
log_dbg(cd, "Maximum integrity device size from kernel %lu", new_size);
if (old_size == new_size && new_size == dmdq.size && !dm_flags(cd, tgt->type, &supported_flags) && !(supported_flags & DM_INTEGRITY_RESIZE_SUPPORTED))
log_std(cd, _("WARNING: Maximum size already set or kernel doesn't support resize.\n"));
}
r = device_block_adjust(cd, crypt_data_device(cd), DEV_OK,
@@ -2998,6 +3008,9 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size)
r = LUKS2_unmet_requirements(cd, &cd->u.luks2.hdr, 0, 0);
if (!r)
r = _reload_device(cd, name, &dmd);
if (r && tgt->type == DM_INTEGRITY && !dm_flags(cd, tgt->type, &supported_flags) && !(supported_flags & DM_INTEGRITY_RESIZE_SUPPORTED))
log_err(cd, _("Resize failed, the kernel doesn't support it."));
}
out:
dm_targets_free(cd, &dmd);

View File

@@ -70,6 +70,7 @@ static inline uint32_t act2dmflags(uint32_t act_flags)
#define DM_BITLK_ELEPHANT_SUPPORTED (1 << 21) /* Elephant diffuser for BITLK supported */
#define DM_VERITY_SIGNATURE_SUPPORTED (1 << 22) /* Verity option root_hash_sig_key_desc supported */
#define DM_INTEGRITY_DISCARDS_SUPPORTED (1 << 23) /* dm-integrity discards/TRIM option is supported */
#define DM_INTEGRITY_RESIZE_SUPPORTED (1 << 23) /* dm-integrity resize of the integrity device supported (introduced in the same version as discards)*/
#define DM_VERITY_PANIC_CORRUPTION_SUPPORTED (1 << 24) /* dm-verity panic on corruption */
#define DM_CRYPT_NO_WORKQUEUE_SUPPORTED (1 << 25) /* dm-crypt suppot for bypassing workqueues */
#define DM_INTEGRITY_FIX_HMAC_SUPPORTED (1 << 26) /* hmac covers also superblock */

View File

@@ -261,6 +261,9 @@ static int action_resize(void)
} else {
log_dbg("Setting recalculate flag");
r = crypt_activate_by_volume_key(cd, action_argv[0], NULL, 0, CRYPT_ACTIVATE_REFRESH | CRYPT_ACTIVATE_RECALCULATE);
if (r == -ENOTSUP)
log_err(_("Setting recalculate flag is not supported, you may consider using --wipe instead."));
}
}
out: