dect
/
linux-2.6
Archived
13
0
Fork 0

staging: zram: fix data corruption issue

In zram_read() and zram_write() we were not incrementing the
index number and thus were reading/writing values from/to
incorrect sectors on zram disk, resulting in data corruption.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Nitin Gupta 2011-02-05 20:34:20 -05:00 committed by Greg Kroah-Hartman
parent 0742cecbd4
commit 5414e557fc
1 changed files with 4 additions and 0 deletions

View File

@ -227,6 +227,7 @@ static int zram_read(struct zram *zram, struct bio *bio)
if (zram_test_flag(zram, index, ZRAM_ZERO)) {
handle_zero_page(page);
index++;
continue;
}
@ -235,12 +236,14 @@ static int zram_read(struct zram *zram, struct bio *bio)
pr_debug("Read before write: sector=%lu, size=%u",
(ulong)(bio->bi_sector), bio->bi_size);
/* Do nothing */
index++;
continue;
}
/* Page is stored uncompressed since it's incompressible */
if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
handle_uncompressed_page(zram, page, index);
index++;
continue;
}
@ -320,6 +323,7 @@ static int zram_write(struct zram *zram, struct bio *bio)
mutex_unlock(&zram->lock);
zram_stat_inc(&zram->stats.pages_zero);
zram_set_flag(zram, index, ZRAM_ZERO);
index++;
continue;
}