I confirm that the patch attached to this message was written by me
without copying/porting/ other code.

A commit message for this single patch could be:

The ZFS code actually present in GRUB2 is able to correctly read from
RAID-Z vdev's, but zfsinfo reports them as unknown vdev's.
This commit fixes zfsinfo to correctly report informations about RAID-Z
vdev's.

Regards,
Massimo Maggi

On 05/05/2013 00:58, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> The patches look ok. The patches it's based on look like original work.
> However your patches are corrupted by your mailer beyond recovery. Can
> you resend them as attachements with changelog mentionning the origin?
> 
> On 04.02.2013 12:08, Massimo Maggi wrote:
> 
>> Author: Massimo Maggi <m...@massimo-maggi.eu>
>> ---
>>  grub-core/fs/zfs/zfsinfo.c | 20 +++++++++++++++-----
>>  1 file changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c
>> index fdb587a..c96bf21 100644
>> --- a/grub-core/fs/zfs/zfsinfo.c
>> +++ b/grub-core/fs/zfs/zfsinfo.c
>> @@ -132,21 +132,31 @@ print_vdev_info (char *nvlist, int tab)
>>        grub_free (path);
>>        return GRUB_ERR_NONE;
>>      }
>> +  char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0);
>> +  char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0);
>>  -  if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0)
>> +  if (is_mirror || is_raidz)
>>      {
>>        int nelm, i;
>>         nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm
>>      (nvlist, ZPOOL_CONFIG_CHILDREN);
>>  +      if(is_mirror){
>> +     grub_puts_ (N_("This VDEV is a mirror"));
>> +      }
>> +      else if(is_raidz){
>> +     grub_uint64_t parity;
>> +     grub_zfs_nvlist_lookup_uint64(nvlist,"nparity",&parity);
>> +     grub_printf_ (N_("This VDEV is a RAIDZ%llu\n"),(unsigned long
>> long)parity);
>> +      }
>>        print_tabs (tab);
>>        if (nelm <= 0)
>>      {
>> -      grub_puts_ (N_("Incorrect mirror"));
>> +      grub_puts_ (N_("Incorrect VDEV"));
>>        return GRUB_ERR_NONE;
>>      }
>> -      grub_printf_ (N_("Mirror with %d children\n"), nelm);
>> +      grub_printf_ (N_("VDEV with %d children\n"), nelm);
>>        print_state (nvlist, tab);
>>        for (i = 0; i < nelm; i++)
>>      {
>> @@ -162,14 +172,14 @@ print_vdev_info (char *nvlist, int tab)
>>               total element number. And the number itself is fine,
>>               only the element isn't.
>>            */
>> -          grub_printf_ (N_("Mirror element number %d isn't correct\n"), i);
>> +          grub_printf_ (N_("VDEV element number %d isn't correct\n"), i);
>>            continue;
>>          }
>>        /* TRANSLATORS: it's the element carying the number %d, not
>>           total element number. This is used in enumeration
>>           "Element number 1", "Element number 2", ... */
>> -      grub_printf_ (N_("Mirror element number %d:\n"), i);
>> +      grub_printf_ (N_("VDEV element number %d:\n"), i);
>>        print_vdev_info (child, tab + 1);
>>        grub_free (child);
>>
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> 
> 

diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c
index fdb587a..c96bf21 100644
--- a/grub-core/fs/zfs/zfsinfo.c
+++ b/grub-core/fs/zfs/zfsinfo.c
@@ -132,21 +132,31 @@ print_vdev_info (char *nvlist, int tab)
       grub_free (path);
       return GRUB_ERR_NONE;
     }
+  char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0);
+  char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0);
 
-  if (grub_strcmp (type, VDEV_TYPE_MIRROR) == 0)
+  if (is_mirror || is_raidz)
     {
       int nelm, i;
 
       nelm = grub_zfs_nvlist_lookup_nvlist_array_get_nelm
 	(nvlist, ZPOOL_CONFIG_CHILDREN);
 
+      if(is_mirror){
+	 grub_puts_ (N_("This VDEV is a mirror"));
+      }
+      else if(is_raidz){
+	 grub_uint64_t parity;
+	 grub_zfs_nvlist_lookup_uint64(nvlist,"nparity",&parity);
+	 grub_printf_ (N_("This VDEV is a RAIDZ%llu\n"),(unsigned long long)parity);
+      }
       print_tabs (tab);
       if (nelm <= 0)
 	{
-	  grub_puts_ (N_("Incorrect mirror"));
+	  grub_puts_ (N_("Incorrect VDEV"));
 	  return GRUB_ERR_NONE;
 	}
-      grub_printf_ (N_("Mirror with %d children\n"), nelm);
+      grub_printf_ (N_("VDEV with %d children\n"), nelm);
       print_state (nvlist, tab);
       for (i = 0; i < nelm; i++)
 	{
@@ -162,14 +172,14 @@ print_vdev_info (char *nvlist, int tab)
 		 total element number. And the number itself is fine,
 		 only the element isn't.
 	      */
-	      grub_printf_ (N_("Mirror element number %d isn't correct\n"), i);
+	      grub_printf_ (N_("VDEV element number %d isn't correct\n"), i);
 	      continue;
 	    }
 
 	  /* TRANSLATORS: it's the element carying the number %d, not
 	     total element number. This is used in enumeration
 	     "Element number 1", "Element number 2", ... */
-	  grub_printf_ (N_("Mirror element number %d:\n"), i);
+	  grub_printf_ (N_("VDEV element number %d:\n"), i);
 	  print_vdev_info (child, tab + 1);
 
 	  grub_free (child);

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to