public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] zram: fix data corruption issue
@ 2011-02-06  1:34 Nitin Gupta
  2011-02-06  5:00 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Nitin Gupta @ 2011-02-06  1:34 UTC (permalink / raw)
  To: Greg KH; +Cc: Pekka Enberg, Linux Driver Project, linux-kernel

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>
---
 drivers/staging/zram/zram_drv.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 5415712..4bd8cbd 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -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;
 		}
 
-- 
1.7.3.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram: fix data corruption issue
  2011-02-06  1:34 [PATCH] zram: fix data corruption issue Nitin Gupta
@ 2011-02-06  5:00 ` Greg KH
  2011-02-06  5:03   ` Nitin Gupta
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2011-02-06  5:00 UTC (permalink / raw)
  To: Nitin Gupta; +Cc: Pekka Enberg, Linux Driver Project, linux-kernel

On Sat, Feb 05, 2011 at 08:34:20PM -0500, Nitin Gupta wrote:
> 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.

Is this something that needs to go into .38 or can it wait until .39?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram: fix data corruption issue
  2011-02-06  5:00 ` Greg KH
@ 2011-02-06  5:03   ` Nitin Gupta
  2011-02-06  5:11     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Nitin Gupta @ 2011-02-06  5:03 UTC (permalink / raw)
  To: Greg KH; +Cc: Pekka Enberg, Linux Driver Project, linux-kernel

On 02/06/2011 12:00 AM, Greg KH wrote:
> On Sat, Feb 05, 2011 at 08:34:20PM -0500, Nitin Gupta wrote:
>> 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.
>
> Is this something that needs to go into .38 or can it wait until .39?
>


This really needs to get into .38 or users will see random data 
corruption on zram devices.

Thanks,
Nitin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram: fix data corruption issue
  2011-02-06  5:03   ` Nitin Gupta
@ 2011-02-06  5:11     ` Greg KH
  2011-02-06  5:33       ` Nitin Gupta
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2011-02-06  5:11 UTC (permalink / raw)
  To: Nitin Gupta; +Cc: Pekka Enberg, Linux Driver Project, linux-kernel

On Sun, Feb 06, 2011 at 12:03:12AM -0500, Nitin Gupta wrote:
> On 02/06/2011 12:00 AM, Greg KH wrote:
> >On Sat, Feb 05, 2011 at 08:34:20PM -0500, Nitin Gupta wrote:
> >>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.
> >
> >Is this something that needs to go into .38 or can it wait until .39?
> >
> 
> 
> This really needs to get into .38 or users will see random data
> corruption on zram devices.

Ok, I'll queue it up for there.  What about .37 and/or .36?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] zram: fix data corruption issue
  2011-02-06  5:11     ` Greg KH
@ 2011-02-06  5:33       ` Nitin Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Nitin Gupta @ 2011-02-06  5:33 UTC (permalink / raw)
  To: Greg KH; +Cc: Pekka Enberg, Linux Driver Project, linux-kernel

On 02/06/2011 12:11 AM, Greg KH wrote:
> On Sun, Feb 06, 2011 at 12:03:12AM -0500, Nitin Gupta wrote:
>> On 02/06/2011 12:00 AM, Greg KH wrote:
>>> On Sat, Feb 05, 2011 at 08:34:20PM -0500, Nitin Gupta wrote:
>>>> 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.
>>>
>>> Is this something that needs to go into .38 or can it wait until .39?
>>>
>>
>>
>> This really needs to get into .38 or users will see random data
>> corruption on zram devices.
>
> Ok, I'll queue it up for there.  What about .37 and/or .36?
>


The same problem exists on .37 and .36. I just checked that the same 
patch applies cleanly to both these version so may be included in their 
respective maintenance releases.

Thanks,
Nitin

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-02-06  5:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-06  1:34 [PATCH] zram: fix data corruption issue Nitin Gupta
2011-02-06  5:00 ` Greg KH
2011-02-06  5:03   ` Nitin Gupta
2011-02-06  5:11     ` Greg KH
2011-02-06  5:33       ` Nitin Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox