All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efidisk: prevent errors from diskfilter scan of removable drives
@ 2016-02-05 16:56 Andrei Borzenkov
  2016-02-12 14:29 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Andrei Borzenkov @ 2016-02-05 16:56 UTC (permalink / raw)
  To: grub-devel

Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
actually matches pretty close (we obviously attempt to read outside of media)
and avoids adding more error codes.

This affects only internally initiated scans. If read/write from removable is
explicitly requested, we still return an error and text explanation is more
clear for user than generic error.

Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>

---
 grub-core/disk/efi/efidisk.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
index 1c00e3e..ea75344 100644
--- a/grub-core/disk/efi/efidisk.c
+++ b/grub-core/disk/efi/efidisk.c
@@ -547,7 +547,9 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
 
   status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
 
-  if (status != GRUB_EFI_SUCCESS)
+  if (status == GRUB_EFI_NO_MEDIA)
+    return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name));
+  else if (status != GRUB_EFI_SUCCESS)
     return grub_error (GRUB_ERR_READ_ERROR,
 		       N_("failure reading sector 0x%llx from `%s'"),
 		       (unsigned long long) sector,
@@ -568,7 +570,9 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
 
   status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
 
-  if (status != GRUB_EFI_SUCCESS)
+  if (status == GRUB_EFI_NO_MEDIA)
+    return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name));
+  else if (status != GRUB_EFI_SUCCESS)
     return grub_error (GRUB_ERR_WRITE_ERROR,
 		       N_("failure writing sector 0x%llx to `%s'"),
 		       (unsigned long long) sector, disk->name);
-- 
tg: (67dba97..) u/efi-no-media (depends on: master)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] efidisk: prevent errors from diskfilter scan of removable drives
  2016-02-05 16:56 [PATCH] efidisk: prevent errors from diskfilter scan of removable drives Andrei Borzenkov
@ 2016-02-12 14:29 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2016-02-12 14:38   ` Andrei Borzenkov
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2016-02-12 14:29 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2024 bytes --]

On 05.02.2016 17:56, Andrei Borzenkov wrote:
> Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
> actually matches pretty close (we obviously attempt to read outside of media)
> and avoids adding more error codes.
> 
> This affects only internally initiated scans. If read/write from removable is
> explicitly requested, we still return an error and text explanation is more
> clear for user than generic error.
> 
> Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
> 
I feel like we should be fixing diskfilter. Consider another case: dead
disk dangling on cable and returning mostly I/O errors
> ---
>  grub-core/disk/efi/efidisk.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
> index 1c00e3e..ea75344 100644
> --- a/grub-core/disk/efi/efidisk.c
> +++ b/grub-core/disk/efi/efidisk.c
> @@ -547,7 +547,9 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
>  
>    status = grub_efidisk_readwrite (disk, sector, size, buf, 0);
>  
> -  if (status != GRUB_EFI_SUCCESS)
> +  if (status == GRUB_EFI_NO_MEDIA)
> +    return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name));
> +  else if (status != GRUB_EFI_SUCCESS)
>      return grub_error (GRUB_ERR_READ_ERROR,
>  		       N_("failure reading sector 0x%llx from `%s'"),
>  		       (unsigned long long) sector,
> @@ -568,7 +570,9 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
>  
>    status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1);
>  
> -  if (status != GRUB_EFI_SUCCESS)
> +  if (status == GRUB_EFI_NO_MEDIA)
> +    return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name));
> +  else if (status != GRUB_EFI_SUCCESS)
>      return grub_error (GRUB_ERR_WRITE_ERROR,
>  		       N_("failure writing sector 0x%llx to `%s'"),
>  		       (unsigned long long) sector, disk->name);
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efidisk: prevent errors from diskfilter scan of removable drives
  2016-02-12 14:29 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2016-02-12 14:38   ` Andrei Borzenkov
  2016-02-12 14:49     ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Andrei Borzenkov @ 2016-02-12 14:38 UTC (permalink / raw)
  To: The development of GNU GRUB

On Fri, Feb 12, 2016 at 5:29 PM, Vladimir 'φ-coder/phcoder' Serbinenko
<phcoder@gmail.com> wrote:
> On 05.02.2016 17:56, Andrei Borzenkov wrote:
>> Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
>> actually matches pretty close (we obviously attempt to read outside of media)
>> and avoids adding more error codes.
>>
>> This affects only internally initiated scans. If read/write from removable is
>> explicitly requested, we still return an error and text explanation is more
>> clear for user than generic error.
>>
>> Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
>>
> I feel like we should be fixing diskfilter. Consider another case: dead
> disk dangling on cable and returning mostly I/O errors

Could you explain what do you mean? Removable media detection remains
valid case and cannot be solved without low level driver cooperation
anyway. If you mean some ratelimiting, this probably has to go into
core, not in diskfilter, but it looks orthogonal to this patch.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efidisk: prevent errors from diskfilter scan of removable drives
  2016-02-12 14:38   ` Andrei Borzenkov
@ 2016-02-12 14:49     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2016-02-13  5:41       ` Andrei Borzenkov
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2016-02-12 14:49 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]

On 12.02.2016 15:38, Andrei Borzenkov wrote:
> On Fri, Feb 12, 2016 at 5:29 PM, Vladimir 'φ-coder/phcoder' Serbinenko
> <phcoder@gmail.com> wrote:
>> On 05.02.2016 17:56, Andrei Borzenkov wrote:
>>> Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
>>> actually matches pretty close (we obviously attempt to read outside of media)
>>> and avoids adding more error codes.
>>>
>>> This affects only internally initiated scans. If read/write from removable is
>>> explicitly requested, we still return an error and text explanation is more
>>> clear for user than generic error.
>>>
>>> Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
>>>
>> I feel like we should be fixing diskfilter. Consider another case: dead
>> disk dangling on cable and returning mostly I/O errors
> 
> Could you explain what do you mean? Removable media detection remains
> valid case and cannot be solved without low level driver cooperation
> anyway. If you mean some ratelimiting, this probably has to go into
> core, not in diskfilter, but it looks orthogonal to this patch.
> 
I mean what if we have a legitimately bad disk unrelated to any
diskfilter VGs. If diskfilter is unable to read from it, it should still
be able to assemble VGs and skip failed disk
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efidisk: prevent errors from diskfilter scan of removable drives
  2016-02-12 14:49     ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2016-02-13  5:41       ` Andrei Borzenkov
  2016-02-26 13:41         ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Andrei Borzenkov @ 2016-02-13  5:41 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]

12.02.2016 17:49, Vladimir 'φ-coder/phcoder' Serbinenko пишет:
> On 12.02.2016 15:38, Andrei Borzenkov wrote:
>> On Fri, Feb 12, 2016 at 5:29 PM, Vladimir 'φ-coder/phcoder' Serbinenko
>> <phcoder@gmail.com> wrote:
>>> On 05.02.2016 17:56, Andrei Borzenkov wrote:
>>>> Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This
>>>> actually matches pretty close (we obviously attempt to read outside of media)
>>>> and avoids adding more error codes.
>>>>
>>>> This affects only internally initiated scans. If read/write from removable is
>>>> explicitly requested, we still return an error and text explanation is more
>>>> clear for user than generic error.
>>>>
>>>> Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
>>>>
>>> I feel like we should be fixing diskfilter. Consider another case: dead
>>> disk dangling on cable and returning mostly I/O errors
>>
>> Could you explain what do you mean? Removable media detection remains
>> valid case and cannot be solved without low level driver cooperation
>> anyway. If you mean some ratelimiting, this probably has to go into
>> core, not in diskfilter, but it looks orthogonal to this patch.
>>
> I mean what if we have a legitimately bad disk unrelated to any
> diskfilter VGs. If diskfilter is unable to read from it, it should still
> be able to assemble VGs and skip failed disk


There is probably misunderstanding. There is no problem assembling VGs;
diskfilter prints error and continues. The purpose of this patch is to
suppress error print when there is no error (media not present is not an
error when we scan for diskfilter devices).

This was not as cosmetic because on boot from within menu it would stop
telling user to press any key if there are removable devices.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] efidisk: prevent errors from diskfilter scan of removable drives
  2016-02-13  5:41       ` Andrei Borzenkov
@ 2016-02-26 13:41         ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 6+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2016-02-26 13:41 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2138 bytes --]

Go ahead

Le sam. 13 févr. 2016 06:41, Andrei Borzenkov <arvidjaar@gmail.com> a
écrit :

> 12.02.2016 17:49, Vladimir 'φ-coder/phcoder' Serbinenko пишет:
> > On 12.02.2016 15:38, Andrei Borzenkov wrote:
> >> On Fri, Feb 12, 2016 at 5:29 PM, Vladimir 'φ-coder/phcoder' Serbinenko
> >> <phcoder@gmail.com> wrote:
> >>> On 05.02.2016 17:56, Andrei Borzenkov wrote:
> >>>> Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by
> diskfilter. This
> >>>> actually matches pretty close (we obviously attempt to read outside
> of media)
> >>>> and avoids adding more error codes.
> >>>>
> >>>> This affects only internally initiated scans. If read/write from
> removable is
> >>>> explicitly requested, we still return an error and text explanation
> is more
> >>>> clear for user than generic error.
> >>>>
> >>>> Reported and tested by Andreas Loew <Andreas.Loew@gmx.net>
> >>>>
> >>> I feel like we should be fixing diskfilter. Consider another case: dead
> >>> disk dangling on cable and returning mostly I/O errors
> >>
> >> Could you explain what do you mean? Removable media detection remains
> >> valid case and cannot be solved without low level driver cooperation
> >> anyway. If you mean some ratelimiting, this probably has to go into
> >> core, not in diskfilter, but it looks orthogonal to this patch.
> >>
> > I mean what if we have a legitimately bad disk unrelated to any
> > diskfilter VGs. If diskfilter is unable to read from it, it should still
> > be able to assemble VGs and skip failed disk
>
>
> There is probably misunderstanding. There is no problem assembling VGs;
> diskfilter prints error and continues. The purpose of this patch is to
> suppress error print when there is no error (media not present is not an
> error when we scan for diskfilter devices).
>
> This was not as cosmetic because on boot from within menu it would stop
> telling user to press any key if there are removable devices.
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 2928 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-26 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-05 16:56 [PATCH] efidisk: prevent errors from diskfilter scan of removable drives Andrei Borzenkov
2016-02-12 14:29 ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-12 14:38   ` Andrei Borzenkov
2016-02-12 14:49     ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-13  5:41       ` Andrei Borzenkov
2016-02-26 13:41         ` Vladimir 'phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.