From: Andre Noll Subject: Re: [PATCH 7/8] md: update_size(): Remove useless variable "fit". Date: Wed, 9 Jul 2008 11:14:27 +0200 Message-ID: <20080709091427.GV23944@skl-net.de> References: <20080708155541.GS23944@skl-net.de> <18547.62297.913913.977355@notabene.brown> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CUrluEZVXmx7ezWQ" Return-path: Content-Disposition: inline In-Reply-To: <18547.62297.913913.977355@notabene.brown> Sender: linux-raid-owner@vger.kernel.org To: Neil Brown Cc: linux-raid@vger.kernel.org List-Id: linux-raid.ids --CUrluEZVXmx7ezWQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 09:08, Neil Brown wrote: > On Saturday April 5, maan@systemlinux.org wrote: > >=20 > > Signed-off-by: Andre Noll > > --- > > drivers/md/md.c | 3 +-- > > 1 files changed, 1 insertions(+), 2 deletions(-) > >=20 > > diff --git a/drivers/md/md.c b/drivers/md/md.c > > index 3f22ec7..98a024c 100644 > > --- a/drivers/md/md.c > > +++ b/drivers/md/md.c > > @@ -4459,7 +4459,6 @@ static int update_size(mddev_t *mddev, unsigned l= ong size) > > mdk_rdev_t * rdev; > > int rv; > > struct list_head *tmp; > > - int fit =3D (size =3D=3D 0); > > =20 > > if (mddev->pers->resize =3D=3D NULL) > > return -EINVAL; > > @@ -4479,7 +4478,7 @@ static int update_size(mddev_t *mddev, unsigned l= ong size) > > sector_t avail; > > avail =3D rdev->size * 2; > > =20 > > - if (fit && (size =3D=3D 0 || size > avail/2)) > > + if (size =3D=3D 0 || size > avail/2) > > size =3D avail/2; > > if (avail < ((sector_t)size << 1)) > > return -ENOSPC; >=20 > This is wrong. > The old code tested for "size =3D=3D 0" once outside a loop. > The new code does the test inside a loop which potentially changes > size. Oops, right you are. Please drop. > If you are keen to do some more tidying up, I would really love it if > all internal values that are currently stored as 'K' would instead be > stored as sectors. > So for example with update_size, we could make the value that is > passed in be a number of sectors, get rid of those divisions. Of course the size unit exported to user space programs via sysfs must not change. So if we change update_size() as you propose, the division has to be done in the size_store() instead, which calls update_size() with a value obtained from sysfs. Therefore I think it's impossible to completely get rid of the divisions/multiplications without breaking user space, but it might still be worth to change the internal representations. I will have a look at it, but I might need some further advice. > BTW your patches arrive without a valid "To" field. The Date is odd > too. They were generated by git-format-patch and then bounced to the list. The date is "correct" in the sense that I checked them in back then. I'll see that subsequent patches have a proper date and a valid "To" field. Thanks Andre --=20 The only person who always got his work done by Friday was Robinson Crusoe --CUrluEZVXmx7ezWQ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFIdIFzWto1QDEAkw8RAngXAKCi4aTIhdHF0Z/0G3nHPlfT4dMgRACeLNdz xCmdTHNRhk6q15jTozb32VU= =ev5+ -----END PGP SIGNATURE----- --CUrluEZVXmx7ezWQ--