Support key extension if the tdb_data_size is an arbitrary integer
multiple of the channel's block size. Before, key extension was only
possible if the tdb_data_size and the channel's block size were
equal.
Note: a key, whose data is the result of a short read, will be
extended if the tdb_data_size and the channel's block size are equal
(that's what the old code did) (if tdb_data_size is an arbitrary
integer multiple (> 1) of the channel's block size, the key might
be extended as well (depending on the keysize)).
Signed-off-by: Marcus Huewe <suse-tux@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
keysz = 0;
}
if (key != NULL &&
- ext2fs_le64_to_cpu(key->fsblk) +
- ((keysz + data->tdb_data_size - 1) /
- data->tdb_data_size) == backing_blk_num &&
+ (ext2fs_le64_to_cpu(key->fsblk) * channel->block_size +
+ channel->block_size - 1 +
+ keysz) / channel->block_size == backing_blk_num &&
E2UNDO_MAX_EXTENT_BLOCKS * data->tdb_data_size >
- keysz + sz) {
+ keysz + data_size) {
blk_crc = ext2fs_le32_to_cpu(key->blk_crc);
blk_crc = ext2fs_crc32c_le(blk_crc, read_ptr, data_size);
key->blk_crc = ext2fs_cpu_to_le32(blk_crc);