* [PATCH] zram: correct offset usage in zram_bio_discard @ 2014-04-22 3:14 Weijie Yang 2014-04-22 9:06 ` Sergey Senozhatsky 2014-04-22 19:55 ` Andrew Morton 0 siblings, 2 replies; 7+ messages in thread From: Weijie Yang @ 2014-04-22 3:14 UTC (permalink / raw) To: 'Minchan Kim' Cc: 'Andrew Morton', 'Nitin Gupta', iamjoonsoo.kim, 'Sergey Senozhatsky', 'Bob Liu', 'linux-kernel' we want to skip the logical block which is partially covered by the discard bio, so check the remaining size and subtract it if there is a need to goto the next logical block. This patch corrects the offset usage in zram_bio_discard. Signed-off-by: Weijie Yang <weijie.yang@samsung.com> --- drivers/block/zram/zram_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 9849b52..48eccb3 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -572,10 +572,10 @@ static void zram_bio_discard(struct zram *zram, u32 index, * skipping this logical block is appropriate here. */ if (offset) { - if (n < offset) + if (n <= (PAGE_SIZE - offset)) return; - n -= offset; + n -= (PAGE_SIZE - offset); index++; } -- 1.7.10.4 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zram: correct offset usage in zram_bio_discard 2014-04-22 3:14 [PATCH] zram: correct offset usage in zram_bio_discard Weijie Yang @ 2014-04-22 9:06 ` Sergey Senozhatsky 2014-04-22 19:55 ` Andrew Morton 1 sibling, 0 replies; 7+ messages in thread From: Sergey Senozhatsky @ 2014-04-22 9:06 UTC (permalink / raw) To: Weijie Yang Cc: 'Minchan Kim', 'Andrew Morton', 'Nitin Gupta', iamjoonsoo.kim, 'Sergey Senozhatsky', 'Bob Liu', 'linux-kernel' On (04/22/14 11:14), Weijie Yang wrote: > > we want to skip the logical block which is partially covered by > the discard bio, so check the remaining size and subtract it if > there is a need to goto the next logical block. > looks sane. -ss > This patch corrects the offset usage in zram_bio_discard. > > Signed-off-by: Weijie Yang <weijie.yang@samsung.com> > --- > drivers/block/zram/zram_drv.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c > index 9849b52..48eccb3 100644 > --- a/drivers/block/zram/zram_drv.c > +++ b/drivers/block/zram/zram_drv.c > @@ -572,10 +572,10 @@ static void zram_bio_discard(struct zram *zram, u32 index, > * skipping this logical block is appropriate here. > */ > if (offset) { > - if (n < offset) > + if (n <= (PAGE_SIZE - offset)) > return; > > - n -= offset; > + n -= (PAGE_SIZE - offset); > index++; > } > > -- > 1.7.10.4 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zram: correct offset usage in zram_bio_discard 2014-04-22 3:14 [PATCH] zram: correct offset usage in zram_bio_discard Weijie Yang 2014-04-22 9:06 ` Sergey Senozhatsky @ 2014-04-22 19:55 ` Andrew Morton 2014-04-23 2:32 ` Weijie Yang 1 sibling, 1 reply; 7+ messages in thread From: Andrew Morton @ 2014-04-22 19:55 UTC (permalink / raw) To: Weijie Yang Cc: 'Minchan Kim', 'Nitin Gupta', iamjoonsoo.kim, 'Sergey Senozhatsky', 'Bob Liu', 'linux-kernel' On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote: > we want to skip the logical block which is partially covered by > the discard bio, so check the remaining size and subtract it if > there is a need to goto the next logical block. > > This patch corrects the offset usage in zram_bio_discard. > What were the end-user visible effects of the bug? Please always include this information when fixing something so that others can work out which kernel(s) need patching. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zram: correct offset usage in zram_bio_discard 2014-04-22 19:55 ` Andrew Morton @ 2014-04-23 2:32 ` Weijie Yang 2014-04-23 3:08 ` Joonsoo Kim 0 siblings, 1 reply; 7+ messages in thread From: Weijie Yang @ 2014-04-23 2:32 UTC (permalink / raw) To: Andrew Morton Cc: Weijie Yang, Minchan Kim, Nitin Gupta, iamjoonsoo.kim, Sergey Senozhatsky, Bob Liu, linux-kernel On Wed, Apr 23, 2014 at 3:55 AM, Andrew Morton <akpm@linux-foundation.org> wrote: > On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote: > >> we want to skip the logical block which is partially covered by >> the discard bio, so check the remaining size and subtract it if >> there is a need to goto the next logical block. >> >> This patch corrects the offset usage in zram_bio_discard. >> > > What were the end-user visible effects of the bug? > > Please always include this information when fixing something so that > others can work out which kernel(s) need patching. > Thanks for your advise, I will resend this patch and add the end-user visible effect information. > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zram: correct offset usage in zram_bio_discard 2014-04-23 2:32 ` Weijie Yang @ 2014-04-23 3:08 ` Joonsoo Kim 2014-04-23 3:52 ` Weijie Yang 0 siblings, 1 reply; 7+ messages in thread From: Joonsoo Kim @ 2014-04-23 3:08 UTC (permalink / raw) To: Weijie Yang Cc: Andrew Morton, Weijie Yang, Minchan Kim, Nitin Gupta, Sergey Senozhatsky, Bob Liu, linux-kernel On Wed, Apr 23, 2014 at 10:32:30AM +0800, Weijie Yang wrote: > On Wed, Apr 23, 2014 at 3:55 AM, Andrew Morton > <akpm@linux-foundation.org> wrote: > > On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote: > > > >> we want to skip the logical block which is partially covered by > >> the discard bio, so check the remaining size and subtract it if > >> there is a need to goto the next logical block. > >> > >> This patch corrects the offset usage in zram_bio_discard. > >> > > > > What were the end-user visible effects of the bug? > > > > Please always include this information when fixing something so that > > others can work out which kernel(s) need patching. > > > > Thanks for your advise, I will resend this patch and add the end-user > visible effect information. Thanks for fixing it. As far as I understand, there is no end-user visible effect, because request size is alway PAGE_SIZE aligned and if n < PAGE_SIZE, no real operation happens. Am I missing? Anyway, Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zram: correct offset usage in zram_bio_discard 2014-04-23 3:08 ` Joonsoo Kim @ 2014-04-23 3:52 ` Weijie Yang 2014-04-23 5:00 ` Joonsoo Kim 0 siblings, 1 reply; 7+ messages in thread From: Weijie Yang @ 2014-04-23 3:52 UTC (permalink / raw) To: Joonsoo Kim Cc: Andrew Morton, Weijie Yang, Minchan Kim, Nitin Gupta, Sergey Senozhatsky, Bob Liu, linux-kernel On Wed, Apr 23, 2014 at 11:08 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote: > On Wed, Apr 23, 2014 at 10:32:30AM +0800, Weijie Yang wrote: >> On Wed, Apr 23, 2014 at 3:55 AM, Andrew Morton >> <akpm@linux-foundation.org> wrote: >> > On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote: >> > >> >> we want to skip the logical block which is partially covered by >> >> the discard bio, so check the remaining size and subtract it if >> >> there is a need to goto the next logical block. >> >> >> >> This patch corrects the offset usage in zram_bio_discard. >> >> >> > >> > What were the end-user visible effects of the bug? >> > >> > Please always include this information when fixing something so that >> > others can work out which kernel(s) need patching. >> > >> >> Thanks for your advise, I will resend this patch and add the end-user >> visible effect information. > > Thanks for fixing it. > > As far as I understand, there is no end-user visible effect, because > request size is alway PAGE_SIZE aligned and if n < PAGE_SIZE, > no real operation happens. Am I missing? The zram only limit ZRAM_LOGICAL_BLOCK_SIZE(4K) aligned, not PAGE_SIZE aligned. Consider the following scenario: on some architecture or config, PAGE_SIZE is 64K for example filesystem is set up on zram disk without PAGE_SIZE aligned. a discard bio leads to a offset = 4K, size=72K normally, it should not really discard any physical block as it partially cover two physical blocks. However, with the current offset usage, it will discard the second physical block and free its memory, which will cause filesystem breakdown. regards, > Anyway, > > Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> > > Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] zram: correct offset usage in zram_bio_discard 2014-04-23 3:52 ` Weijie Yang @ 2014-04-23 5:00 ` Joonsoo Kim 0 siblings, 0 replies; 7+ messages in thread From: Joonsoo Kim @ 2014-04-23 5:00 UTC (permalink / raw) To: Weijie Yang Cc: Andrew Morton, Weijie Yang, Minchan Kim, Nitin Gupta, Sergey Senozhatsky, Bob Liu, linux-kernel On Wed, Apr 23, 2014 at 11:52:08AM +0800, Weijie Yang wrote: > On Wed, Apr 23, 2014 at 11:08 AM, Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote: > > On Wed, Apr 23, 2014 at 10:32:30AM +0800, Weijie Yang wrote: > >> On Wed, Apr 23, 2014 at 3:55 AM, Andrew Morton > >> <akpm@linux-foundation.org> wrote: > >> > On Tue, 22 Apr 2014 11:14:02 +0800 Weijie Yang <weijie.yang@samsung.com> wrote: > >> > > >> >> we want to skip the logical block which is partially covered by > >> >> the discard bio, so check the remaining size and subtract it if > >> >> there is a need to goto the next logical block. > >> >> > >> >> This patch corrects the offset usage in zram_bio_discard. > >> >> > >> > > >> > What were the end-user visible effects of the bug? > >> > > >> > Please always include this information when fixing something so that > >> > others can work out which kernel(s) need patching. > >> > > >> > >> Thanks for your advise, I will resend this patch and add the end-user > >> visible effect information. > > > > Thanks for fixing it. > > > > As far as I understand, there is no end-user visible effect, because > > request size is alway PAGE_SIZE aligned and if n < PAGE_SIZE, > > no real operation happens. Am I missing? > > The zram only limit ZRAM_LOGICAL_BLOCK_SIZE(4K) aligned, > not PAGE_SIZE aligned. > > Consider the following scenario: > on some architecture or config, PAGE_SIZE is 64K for example > filesystem is set up on zram disk without PAGE_SIZE aligned. > a discard bio leads to a offset = 4K, size=72K > normally, it should not really discard any physical block as it partially > cover two physical blocks. > However, with the current offset usage, it will discard the second > physical block and free its memory, which will cause filesystem breakdown. > I misunderstood what discard_granularity means. I thought that if I set discard_granularity=PAGE_SIZE, the size of discard request is aligned to PAGE_SIZE. But, by looking at the code, I notice that isn't true. So now, I understand your patch compeletely. Thanks again. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-04-23 4:59 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-04-22 3:14 [PATCH] zram: correct offset usage in zram_bio_discard Weijie Yang 2014-04-22 9:06 ` Sergey Senozhatsky 2014-04-22 19:55 ` Andrew Morton 2014-04-23 2:32 ` Weijie Yang 2014-04-23 3:08 ` Joonsoo Kim 2014-04-23 3:52 ` Weijie Yang 2014-04-23 5:00 ` Joonsoo Kim
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®