* [PATCH] md: remove redudent code
@ 2012-05-15 8:00 Yuanhan Liu
2012-05-15 8:03 ` NeilBrown
0 siblings, 1 reply; 3+ messages in thread
From: Yuanhan Liu @ 2012-05-15 8:00 UTC (permalink / raw)
To: neilb, linux-raid; +Cc: linux-kernel, Yuanhan Liu
The code does nothing but repating assigning sb->sb_csum with original
value.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
drivers/md/md.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0bd44e3..f2d799a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1439,15 +1439,12 @@ super_90_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
{
- __le32 disk_csum;
u32 csum;
unsigned long long newcsum;
int size = 256 + le32_to_cpu(sb->max_dev)*2;
__le32 *isuper = (__le32*)sb;
int i;
- disk_csum = sb->sb_csum;
- sb->sb_csum = 0;
newcsum = 0;
for (i=0; size>=4; size -= 4 )
newcsum += le32_to_cpu(*isuper++);
@@ -1456,7 +1453,6 @@ static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
newcsum += le16_to_cpu(*(__le16*) isuper);
csum = (newcsum & 0xffffffff) + (newcsum >> 32);
- sb->sb_csum = disk_csum;
return cpu_to_le32(csum);
}
--
1.7.7.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] md: remove redudent code
2012-05-15 8:00 [PATCH] md: remove redudent code Yuanhan Liu
@ 2012-05-15 8:03 ` NeilBrown
2012-05-15 8:12 ` Yuanhan Liu
0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2012-05-15 8:03 UTC (permalink / raw)
To: Yuanhan Liu; +Cc: linux-raid, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]
On Tue, 15 May 2012 16:00:25 +0800 Yuanhan Liu <yuanhan.liu@linux.intel.com>
wrote:
> The code does nothing but repating assigning sb->sb_csum with original
> value.
This code sets the sb_csum to 0 while the csum is calculated.
Without this, calculating the csum, setting it, then calculating again would
produce a different result.
So the code is correct as is.
Thanks,
NeilBrown
>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> ---
> drivers/md/md.c | 4 ----
> 1 files changed, 0 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 0bd44e3..f2d799a 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1439,15 +1439,12 @@ super_90_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
>
> static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
> {
> - __le32 disk_csum;
> u32 csum;
> unsigned long long newcsum;
> int size = 256 + le32_to_cpu(sb->max_dev)*2;
> __le32 *isuper = (__le32*)sb;
> int i;
>
> - disk_csum = sb->sb_csum;
> - sb->sb_csum = 0;
> newcsum = 0;
> for (i=0; size>=4; size -= 4 )
> newcsum += le32_to_cpu(*isuper++);
> @@ -1456,7 +1453,6 @@ static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
> newcsum += le16_to_cpu(*(__le16*) isuper);
>
> csum = (newcsum & 0xffffffff) + (newcsum >> 32);
> - sb->sb_csum = disk_csum;
> return cpu_to_le32(csum);
> }
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] md: remove redudent code
2012-05-15 8:03 ` NeilBrown
@ 2012-05-15 8:12 ` Yuanhan Liu
0 siblings, 0 replies; 3+ messages in thread
From: Yuanhan Liu @ 2012-05-15 8:12 UTC (permalink / raw)
To: NeilBrown; +Cc: linux-raid, linux-kernel
On Tue, May 15, 2012 at 06:03:49PM +1000, NeilBrown wrote:
> On Tue, 15 May 2012 16:00:25 +0800 Yuanhan Liu <yuanhan.liu@linux.intel.com>
> wrote:
>
> > The code does nothing but repating assigning sb->sb_csum with original
> > value.
>
> This code sets the sb_csum to 0 while the csum is calculated.
>
> Without this, calculating the csum, setting it, then calculating again would
> produce a different result.
>
> So the code is correct as is.
Aha, got it. And sorry for the wrong patch.
Thanks,
Yuanhan Liu
>
> Thanks,
> NeilBrown
>
>
> >
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > ---
> > drivers/md/md.c | 4 ----
> > 1 files changed, 0 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/md/md.c b/drivers/md/md.c
> > index 0bd44e3..f2d799a 100644
> > --- a/drivers/md/md.c
> > +++ b/drivers/md/md.c
> > @@ -1439,15 +1439,12 @@ super_90_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
> >
> > static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
> > {
> > - __le32 disk_csum;
> > u32 csum;
> > unsigned long long newcsum;
> > int size = 256 + le32_to_cpu(sb->max_dev)*2;
> > __le32 *isuper = (__le32*)sb;
> > int i;
> >
> > - disk_csum = sb->sb_csum;
> > - sb->sb_csum = 0;
> > newcsum = 0;
> > for (i=0; size>=4; size -= 4 )
> > newcsum += le32_to_cpu(*isuper++);
> > @@ -1456,7 +1453,6 @@ static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
> > newcsum += le16_to_cpu(*(__le16*) isuper);
> >
> > csum = (newcsum & 0xffffffff) + (newcsum >> 32);
> > - sb->sb_csum = disk_csum;
> > return cpu_to_le32(csum);
> > }
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-15 8:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-15 8:00 [PATCH] md: remove redudent code Yuanhan Liu
2012-05-15 8:03 ` NeilBrown
2012-05-15 8:12 ` Yuanhan Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).