dm integrity: use discard support when recalculating
If we have discard support we don't have to recalculate hash - we can just fill the metadata with the discard pattern. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
This commit is contained in:
parent
b1a2b93320
commit
7a5b96b478
1 changed files with 33 additions and 24 deletions
|
@ -2689,6 +2689,7 @@ next_chunk:
|
||||||
if (unlikely(dm_integrity_failed(ic)))
|
if (unlikely(dm_integrity_failed(ic)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
if (!ic->discard) {
|
||||||
io_req.bi_op = REQ_OP_READ;
|
io_req.bi_op = REQ_OP_READ;
|
||||||
io_req.bi_op_flags = 0;
|
io_req.bi_op_flags = 0;
|
||||||
io_req.mem.type = DM_IO_VMA;
|
io_req.mem.type = DM_IO_VMA;
|
||||||
|
@ -2710,6 +2711,9 @@ next_chunk:
|
||||||
integrity_sector_checksum(ic, logical_sector + i, ic->recalc_buffer + (i << SECTOR_SHIFT), t);
|
integrity_sector_checksum(ic, logical_sector + i, ic->recalc_buffer + (i << SECTOR_SHIFT), t);
|
||||||
t += ic->tag_size;
|
t += ic->tag_size;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
t = ic->recalc_tags + (n_sectors >> ic->sb->log2_sectors_per_block) * ic->tag_size;
|
||||||
|
}
|
||||||
|
|
||||||
metadata_block = get_metadata_sector_and_offset(ic, area, offset, &metadata_offset);
|
metadata_block = get_metadata_sector_and_offset(ic, area, offset, &metadata_offset);
|
||||||
|
|
||||||
|
@ -4364,12 +4368,14 @@ try_smaller_buffer:
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
INIT_WORK(&ic->recalc_work, integrity_recalc);
|
INIT_WORK(&ic->recalc_work, integrity_recalc);
|
||||||
|
if (!ic->discard) {
|
||||||
ic->recalc_buffer = vmalloc(RECALC_SECTORS << SECTOR_SHIFT);
|
ic->recalc_buffer = vmalloc(RECALC_SECTORS << SECTOR_SHIFT);
|
||||||
if (!ic->recalc_buffer) {
|
if (!ic->recalc_buffer) {
|
||||||
ti->error = "Cannot allocate buffer for recalculating";
|
ti->error = "Cannot allocate buffer for recalculating";
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ic->recalc_tags = kvmalloc_array(RECALC_SECTORS >> ic->sb->log2_sectors_per_block,
|
ic->recalc_tags = kvmalloc_array(RECALC_SECTORS >> ic->sb->log2_sectors_per_block,
|
||||||
ic->tag_size, GFP_KERNEL);
|
ic->tag_size, GFP_KERNEL);
|
||||||
if (!ic->recalc_tags) {
|
if (!ic->recalc_tags) {
|
||||||
|
@ -4377,6 +4383,9 @@ try_smaller_buffer:
|
||||||
r = -ENOMEM;
|
r = -ENOMEM;
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
if (ic->discard)
|
||||||
|
memset(ic->recalc_tags, DISCARD_FILLER,
|
||||||
|
(RECALC_SECTORS >> ic->sb->log2_sectors_per_block) * ic->tag_size);
|
||||||
} else {
|
} else {
|
||||||
if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) {
|
if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) {
|
||||||
ti->error = "Recalculate can only be specified with internal_hash";
|
ti->error = "Recalculate can only be specified with internal_hash";
|
||||||
|
@ -4570,7 +4579,7 @@ static void dm_integrity_dtr(struct dm_target *ti)
|
||||||
|
|
||||||
static struct target_type integrity_target = {
|
static struct target_type integrity_target = {
|
||||||
.name = "integrity",
|
.name = "integrity",
|
||||||
.version = {1, 8, 0},
|
.version = {1, 9, 0},
|
||||||
.module = THIS_MODULE,
|
.module = THIS_MODULE,
|
||||||
.features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY,
|
.features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY,
|
||||||
.ctr = dm_integrity_ctr,
|
.ctr = dm_integrity_ctr,
|
||||||
|
|
Loading…
Add table
Reference in a new issue