From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zqpqh-0001Ei-28 for mharc-grub-devel@gnu.org; Mon, 26 Oct 2015 18:02:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqpqe-0001ES-9o for grub-devel@gnu.org; Mon, 26 Oct 2015 18:02:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zqpqd-00044y-AT for grub-devel@gnu.org; Mon, 26 Oct 2015 18:02:36 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:33330) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zqpqd-00044u-1p for grub-devel@gnu.org; Mon, 26 Oct 2015 18:02:35 -0400 Received: by wijp11 with SMTP id p11so186942603wij.0 for ; Mon, 26 Oct 2015 15:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=4Zl5VeWd/usWPVRmIZ87jSsxbFlZyyEj9krf9ZCwFUE=; b=zra7evZ8KNspgnHIeTv1l2QomHcgWreUhGMDX9PpVdEOMszPHTN/W4pArXKNV9DE9q nG6eEXV7/PGbelpYb6XJ6d4dF0YSc6JK3rv0AzxEavFSlGYVos2jSVRP7kz8OMm1gaXe 7YCEVARqX+VBBEkRhDTdIBMfQxQHzi4yXUEWil2RhntugDkpfmocLgZXgzncOcjmSC+M gjv21rcBVWWbSmxWT5IrleF38kezL33lqodX+u48NMbcdMS72qbIa8EHU9H1kdJ23utk W+tMctrEgU0ijmlgo+Iirphcqv4Pe0VZfh5Bn0bRH8beGCPgQtC+n4An1MXJCo2bhDPw Qh4Q== X-Received: by 10.194.58.142 with SMTP id r14mr27791305wjq.37.1445896954366; Mon, 26 Oct 2015 15:02:34 -0700 (PDT) Received: from ?IPv6:2a02:1205:34c8:dc00:863a:4bff:fe50:abc4? ([2a02:1205:34c8:dc00:863a:4bff:fe50:abc4]) by smtp.gmail.com with ESMTPSA id d10sm8959847wje.14.2015.10.26.15.02.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2015 15:02:33 -0700 (PDT) Subject: Re: [PATCH 3/3] ieee1275: ofdisk - don't continue to query block-size after we have it To: The development of GNU GRUB References: <1671671c705298f7d6e8c7e79805564b3b662548.1445895272.git.eric.snowberg@oracle.com> <0c372888b3d2eff761c27e1d133bd9858d0267f9.1445895272.git.eric.snowberg@oracle.com> From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= Message-ID: <562EA2D8.90401@gmail.com> Date: Mon, 26 Oct 2015 23:02:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.2.0 MIME-Version: 1.0 In-Reply-To: <0c372888b3d2eff761c27e1d133bd9858d0267f9.1445895272.git.eric.snowberg@oracle.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rb8Ra0t7v06PXPMJ5a7dl9eoGTveNxvsV" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22f X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2015 22:02:37 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rb8Ra0t7v06PXPMJ5a7dl9eoGTveNxvsV Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 26.10.2015 22:43, Eric Snowberg wrote: > Within commit: 87ec3b7fa9061f470616ed927fc140e995831c00 - "Don't contin= ue > to query block-size if disk doesn't have it.=E2=80=9D Disks that retur= ned 0 to the > block-size query, still get queried every time. >=20 > Fix logic in grub_ofdisk_get_block_size so the block size is not reques= ted > upon each open since it will not change. >=20 Is it true for removable disks as well? What about someone unplugging USB stick and plugging-in 4K USB HDD? > Signed-off-by: Eric Snowberg > --- > grub-core/disk/ieee1275/ofdisk.c | 30 +++++++++++++++++++++++-------= > 1 files changed, 23 insertions(+), 7 deletions(-) >=20 > diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275= /ofdisk.c > index 297f058..a75ea51 100644 > --- a/grub-core/disk/ieee1275/ofdisk.c > +++ b/grub-core/disk/ieee1275/ofdisk.c > @@ -35,7 +35,8 @@ struct ofdisk_hash_ent > char *grub_devpath; > int is_boot; > int is_removable; > - int block_size_fails; > + int block_size_retries; > + grub_uint32_t block_size; > /* Pointer to shortest available name on nodes representing canonica= l names, > otherwise NULL. */ > const char *shortest; > @@ -446,7 +447,17 @@ grub_ofdisk_open (const char *name, grub_disk_t di= sk) > disk->log_sector_size =3D 9; > } > =20 > + if (last_ihandle) > + grub_ieee1275_close (last_ihandle); > + > + last_ihandle =3D 0; > + last_devpath =3D NULL; > + grub_ieee1275_open (devpath, &last_ihandle); > grub_free (devpath); > + > + if (! last_ihandle) > + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); > + > return 0; > } > =20 > @@ -619,6 +630,12 @@ grub_ofdisk_get_block_size (const char *device, gr= ub_uint32_t *block_size, > grub_ieee1275_cell_t size2; > } args_ieee1275; > =20 > + if ((op->block_size_retries >=3D 2) || (op->block_size > 0)) > + { > + *block_size =3D op->block_size; > + return GRUB_ERR_NONE; > + } > + > if (last_ihandle) > grub_ieee1275_close (last_ihandle); > =20 > @@ -630,9 +647,7 @@ grub_ofdisk_get_block_size (const char *device, gru= b_uint32_t *block_size, > return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); > =20 > *block_size =3D 0; > - > - if (op->block_size_fails >=3D 2) > - return GRUB_ERR_NONE; > + op->block_size_retries++; > =20 > INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2); > args_ieee1275.method =3D (grub_ieee1275_cell_t) "block-size"; > @@ -642,21 +657,22 @@ grub_ofdisk_get_block_size (const char *device, g= rub_uint32_t *block_size, > if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) =3D=3D -1) > { > grub_dprintf ("disk", "can't get block size: failed call-method\= n"); > - op->block_size_fails++; > } > else if (args_ieee1275.result) > { > grub_dprintf ("disk", "can't get block size: %lld\n", > (long long) args_ieee1275.result); > - op->block_size_fails++; > } > else if (args_ieee1275.size1 > && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) > && args_ieee1275.size1 >=3D 512 && args_ieee1275.size1 <=3D 16384)= > { > - op->block_size_fails =3D 0; > + op->block_size =3D args_ieee1275.size1; > *block_size =3D args_ieee1275.size1; > } > =20 > + grub_ieee1275_close (last_ihandle); > + last_ihandle =3D 0; > + > return 0; > } >=20 --rb8Ra0t7v06PXPMJ5a7dl9eoGTveNxvsV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREKAAYFAlYuotgACgkQmBXlbbo5nOt7rQD+ImarH7ch5sdLxDtMQU8woiNp relR/INyjXw6+HuJb6wA/RV5rfeFwd26HJAV9uWcOq4/sPN5PGLuCz83MKrtWulN =q0/D -----END PGP SIGNATURE----- --rb8Ra0t7v06PXPMJ5a7dl9eoGTveNxvsV--