Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f0abb74 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "dm verity: skip verity work on I/O errors when system is shutting down"

parents 7c3f466a 6ecdc849
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -62,6 +62,14 @@ struct dm_verity_prefetch_work {
struct buffer_aux {
	int hash_verified;
};
/*
 * While system shutdown, skip verity work for I/O error.
 */
static inline bool verity_is_system_shutting_down(void)
{
	return system_state == SYSTEM_HALT || system_state == SYSTEM_POWER_OFF
		|| system_state == SYSTEM_RESTART;
}

/*
 * Initialize struct buffer_aux for a freshly created buffer.
@@ -220,10 +228,8 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,
	/* Corruption should be visible in device status in all modes */
	v->hash_failed = 1;

	if (v->corrupted_errs >= DM_VERITY_MAX_CORRUPTED_ERRS) {
		DMERR("%s: reached maximum errors", v->data_dev->name);
	if (v->corrupted_errs >= DM_VERITY_MAX_CORRUPTED_ERRS)
		goto out;
	}

	v->corrupted_errs++;

@@ -241,16 +247,14 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,
	DMERR_LIMIT("%s: %s block %llu is corrupted", v->data_dev->name,
		    type_str, block);

	if (v->corrupted_errs == DM_VERITY_MAX_CORRUPTED_ERRS)
		DMERR("%s: reached maximum errors", v->data_dev->name);

	snprintf(verity_env, DM_VERITY_ENV_LENGTH, "%s=%d,%llu",
		DM_VERITY_ENV_VAR_NAME, type, block);

	kobject_uevent_env(&disk_to_dev(dm_disk(md))->kobj, KOBJ_CHANGE, envp);

	/* corrupted_errs count had not reached limits */
	return 0;


out:
	if (v->mode == DM_VERITY_MODE_LOGGING)
		return 0;
@@ -568,7 +572,8 @@ static void verity_end_io(struct bio *bio)
{
	struct dm_verity_io *io = bio->bi_private;

	if (bio->bi_status && !verity_fec_is_enabled(io->v)) {
	if (bio->bi_status &&
		(!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) {
		verity_finish_io(io, bio->bi_status);
		return;
	}