Message ID | 20250221081109.734170-2-zhengqixing@huaweicloud.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | badblocks: bugfix and cleanup for badblocks | expand |
在 2025/02/21 16:10, Zheng Qixing 写道: > From: Li Nan <linan122@huawei.com> > > 'bb->shift' is used directly in badblocks. It is wrong, fix it. > > Fixes: 3ea3354cb9f0 ("badblocks: improve badblocks_check() for multiple ranges handling") > Signed-off-by: Li Nan <linan122@huawei.com> > --- > block/badblocks.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > LGTM Reviewed-by: Yu Kuai <yukuai3@huawei.com> > diff --git a/block/badblocks.c b/block/badblocks.c > index db4ec8b9b2a8..bcee057efc47 100644 > --- a/block/badblocks.c > +++ b/block/badblocks.c > @@ -880,8 +880,8 @@ static int _badblocks_set(struct badblocks *bb, sector_t s, int sectors, > /* round the start down, and the end up */ > sector_t next = s + sectors; > > - rounddown(s, bb->shift); > - roundup(next, bb->shift); > + rounddown(s, 1 << bb->shift); > + roundup(next, 1 << bb->shift); > sectors = next - s; > } > > @@ -1157,8 +1157,8 @@ static int _badblocks_clear(struct badblocks *bb, sector_t s, int sectors) > * isn't than to think a block is not bad when it is. > */ > target = s + sectors; > - roundup(s, bb->shift); > - rounddown(target, bb->shift); > + roundup(s, 1 << bb->shift); > + rounddown(target, 1 << bb->shift); > sectors = target - s; > } > > @@ -1288,8 +1288,8 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors, > > /* round the start down, and the end up */ > target = s + sectors; > - rounddown(s, bb->shift); > - roundup(target, bb->shift); > + rounddown(s, 1 << bb->shift); > + roundup(target, 1 << bb->shift); > sectors = target - s; > } > >
On Fri, Feb 21, 2025 at 04:10:58PM +0800, Zheng Qixing wrote: > From: Li Nan <linan122@huawei.com> > Looks good to me. Acked-by: Coly Li <colyli@kernel.org> Thanks. > 'bb->shift' is used directly in badblocks. It is wrong, fix it. > > Fixes: 3ea3354cb9f0 ("badblocks: improve badblocks_check() for multiple ranges handling") > Signed-off-by: Li Nan <linan122@huawei.com> > --- > block/badblocks.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/block/badblocks.c b/block/badblocks.c > index db4ec8b9b2a8..bcee057efc47 100644 > --- a/block/badblocks.c > +++ b/block/badblocks.c > @@ -880,8 +880,8 @@ static int _badblocks_set(struct badblocks *bb, sector_t s, int sectors, > /* round the start down, and the end up */ > sector_t next = s + sectors; > > - rounddown(s, bb->shift); > - roundup(next, bb->shift); > + rounddown(s, 1 << bb->shift); > + roundup(next, 1 << bb->shift); > sectors = next - s; > } > > @@ -1157,8 +1157,8 @@ static int _badblocks_clear(struct badblocks *bb, sector_t s, int sectors) > * isn't than to think a block is not bad when it is. > */ > target = s + sectors; > - roundup(s, bb->shift); > - rounddown(target, bb->shift); > + roundup(s, 1 << bb->shift); > + rounddown(target, 1 << bb->shift); > sectors = target - s; > } > > @@ -1288,8 +1288,8 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors, > > /* round the start down, and the end up */ > target = s + sectors; > - rounddown(s, bb->shift); > - roundup(target, bb->shift); > + rounddown(s, 1 << bb->shift); > + roundup(target, 1 << bb->shift); > sectors = target - s; > } > > -- > 2.39.2 >
diff --git a/block/badblocks.c b/block/badblocks.c index db4ec8b9b2a8..bcee057efc47 100644 --- a/block/badblocks.c +++ b/block/badblocks.c @@ -880,8 +880,8 @@ static int _badblocks_set(struct badblocks *bb, sector_t s, int sectors, /* round the start down, and the end up */ sector_t next = s + sectors; - rounddown(s, bb->shift); - roundup(next, bb->shift); + rounddown(s, 1 << bb->shift); + roundup(next, 1 << bb->shift); sectors = next - s; } @@ -1157,8 +1157,8 @@ static int _badblocks_clear(struct badblocks *bb, sector_t s, int sectors) * isn't than to think a block is not bad when it is. */ target = s + sectors; - roundup(s, bb->shift); - rounddown(target, bb->shift); + roundup(s, 1 << bb->shift); + rounddown(target, 1 << bb->shift); sectors = target - s; } @@ -1288,8 +1288,8 @@ static int _badblocks_check(struct badblocks *bb, sector_t s, int sectors, /* round the start down, and the end up */ target = s + sectors; - rounddown(s, bb->shift); - roundup(target, bb->shift); + rounddown(s, 1 << bb->shift); + roundup(target, 1 << bb->shift); sectors = target - s; }