efidisk: prevent errors from diskfilter scan of removable drives
PATCH 1/1 efidisk: prevent errors from diskfilter scan of removable drives
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 <[email protected]>
--- grub-core/disk/efi/efidisk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
grub-core/disk/efi/efidisk.c +6 -2
@@ -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);
Signature · 1 line
tg: (67dba97..) u/efi-no-media (depends on: master)
Quoted 10 lines · Andrei Borzenkov
Map
EFI_NO_MEDIAtoGRUB_ERR_OUT_OF_RANGEthat 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 <[email protected]>
I feel like we should be fixing diskfilter. Consider another case: dead disk dangling on cable and returning mostly I/O errors
Quoted 31 lines
--- grub-core/disk/efi/efidisk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)grub-core/disk/efi/efidisk.c +6
-2@@ -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);
Quoted 5 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 4 lines · Andrei Borzenkov
Map
EFI_NO_MEDIAtoGRUB_ERR_OUT_OF_RANGEthat is ignored by diskfilter. This actually matches pretty close (we obviously attempt to read outside of media) and avoids adding more error codes.
Quoted 8 lines
Quoted 6 lines
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 <[email protected]>
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.
Quoted 13 lines · Andrei Borzenkov
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 10 lines · Andrei Borzenkov
Map
EFI_NO_MEDIAtoGRUB_ERR_OUT_OF_RANGEthat 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 <[email protected]>
Quoted 8 lines
Quoted 2 lines
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
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
12.02.2016 17:49, Vladimir 'φ-coder/phcoder' Serbinenko пишет:
Quoted 17 lines · Andrei Borzenkov
Quoted 16 lines
Quoted 13 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 10 lines · Andrei Borzenkov
Map
EFI_NO_MEDIAtoGRUB_ERR_OUT_OF_RANGEthat 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 <[email protected]>
I feel like we should be fixing diskfilter. Consider another case: dead disk dangling on cable and returning mostly I/O errors
Quoted 8 lines
Quoted 5 lines
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.
Go ahead
Le sam. 13 févr. 2016 06:41, Andrei Borzenkov <[email protected]> a écrit :
Quoted 45 lines
12.02.2016 17:49, Vladimir 'φ-coder/phcoder' Serbinenko пишет:
Quoted 5 lines · Andrei Borzenkov
Quoted 4 lines
Quoted 2 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 1 line · Andrei Borzenkov
Map
EFI_NO_MEDIAtoGRUB_ERR_OUT_OF_RANGEthat is ignored bydiskfilter. This
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
actually matches pretty close (we obviously attempt to read outside
of media)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
and avoids adding more error codes.
This affects only internally initiated scans. If read/write from
removable is
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
explicitly requested, we still return an error and text explanation
is more
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
clear for user than generic error.
Reported and tested by Andreas Loew <[email protected]>
I feel like we should be fixing diskfilter. Consider another case: dead disk dangling on cable and returning mostly I/O errors
Quoted 8 lines
Quoted 5 lines
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
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel