ieee1275/powerpc: enables device mapper discovery
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Vladimir,
We have implemented this code to enable the ieee1275 hint for grub. We had scenarios (in SLES) like the disk had PReP partition followed by an LVM and, inside this LVM , the boot partition. So, we implemented this code to make grub able to generate the hint. Without this code, we were unable to find the hint for the boot process. And, in some scenarios, due the amount of disks in the machine, the process could take a lot to finish. Shall we limit this function call specific to PowerPC? Something like this below:
#ifdef __powerpc__
realname = get_slave_from_dm (name_buf);
if (realname)
{
free (name_buf);
name_buf = realname;
}#endif
Please suggest us.
Thank you so much!
Regards,
Avnish Chouhan
Quoted 200 lines · On 2024-06-07 15:05, [email protected] wrote:
Send Grub-devel mailing list submissions to
[email protected]
------------------------------Message: 4
Date: Fri, 7 Jun 2024 11:34:45 +0200
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: avnish <[email protected]>
Cc: The development of GNU GRUB <[email protected]>, Daniel Kiper
<[email protected]>, [email protected], [email protected], Diego Domingos <[email protected]>
Subject: Re: [PATCH v3 2/6] ieee1275/powerpc: enables device mapper
discovery
Message-ID:
<CAEaD8JN1BuOYCxSEP0dQTv7VML6vyCNFg3tSUrLigbrN9uY7AQ@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"Quoted 13 lines · avnish
Quoted 11 lines · Vladimir 'phcoder' Serbinenko
2 problems: * How does dm device ends up on ofpathname? It should be handled by grub internal logic in most cases and not end up in of-specific paths * Why not use existing devmapper functions already present in codebase? Le jeu. 6 juin 2024,
2 problems:
* How does dm device ends up on ofpathname? It should be handled by grub internal logic in most cases and not end up in of-specific paths
* Why not use existing devmapper functions already present in codebase?Quoted 6 lines
Hi Vladimir,
Thank you so much for your response!We have observed that whenever we are dealing with the devices like "
/dev/dm-*", the ofpath returns null.It's expected behavior
Quoted 4 lines
To resolve this, as no such required functions has been implemented to handle this kind of case. We have done changes based on the requirement that will look into
/sys/block/dm-*devices and search slave devices recursively inside slaves directory to find the root disk.Installing on e.g. LVM is invalid. Only 3 cases can your approach work:
1) multipath
2) maybe RAID1 as well in some cases
3) if ofw assembles raid somehow
Which one do you have? We need more details.
This patch enables invalid configs like installing on LVMQuoted 131 lines
Regards,
Avnish ChouhanQuoted 117 lines
Le jeu. 6 juin 2024, 14:40, Avnish Chouhan <[email protected]> a écrit :
Quoted 114 lines
This patch enables the device mapper discovery on
ofpath.c. Currently,
when we are dealing with a device like/dev/dm-*the ofpath returns null
since there is no function implemented to handle this case.This patch implements a function that will look into
/sys/block/dm-*devices and search recursively inside slaves directory to find the root
disk.Signed-off-by Diego Domingos <[email protected]>Signed-off-by Avnish Chouhan <[email protected]>---
grub-core/osdep/linux/ofpath.c| 64
+++++++++++++++++++++++++++++++++++++++++-1 file changed, 63 insertions(+), 1 deletion(-)grub-core/osdep/linux/ofpath.c +1
-0@@ -37,6 +37,7 @@#include <fcntl.h> #include <errno.h> #include <ctype.h> +#include <dirent.h> #ifdef __sparc__typedef enum
grub-core/osdep/linux/ofpath.c +12
-0@@ -755,13 +756,74 @@ strip_trailing_digits (const char *p)return new; } +static char * +get_slave_from_dm (const char * device) +{ +char *curr_device, *tmp; +char *directory; +char *ret =NULL ; + directory =grub_strdup (device); + tmp =get_basename (directory); + curr_device =grub_strdup (tmp); + *tmp ='\0' ; + +/* Recursively check for slaves devices so we can find the root device */
+ while ((curr_device[0] == 'd') && (curr_device[1] == 'm') && (curr_device[2] == '-'))grub-core/osdep/linux/ofpath.c +5
-0+ { +DIR *dp; +struct dirent *ep; +char * device_path; + device_path = grub_xasprintf ("/sys/block/%s/slaves",
curr_device);grub-core/osdep/linux/ofpath.c +18
-0+ dp =opendir (device_path); + +if (dp !=NULL ) + { + ep =readdir (dp); + +while (ep !=NULL ) + { +/* avoid some system directories */ +if (!strcmp (ep->d_name,"." )) + goto next_dir; +if (!strcmp (ep->d_name,".." )) + goto next_dir; + +free (curr_device); +free (ret); + curr_device =grub_strdup (ep->d_name); + ret = grub_xasprintf ("%s%s", directory,
curr_device);grub-core/osdep/linux/ofpath.c +10
-0+break ; + + next_dir: + ep =readdir (dp); +continue ; + } +closedir (dp); + } +else + grub_util_warn (_("cannot open directory `%s'"),
device_path);grub-core/osdep/linux/ofpath.c +8
-0+free (device_path); + } +free (directory); +free (curr_device); + +return ret; +} +char *
grub_util_devname_to_ofpath(const char*sys_devname) {grub-core/osdep/linux/ofpath.c +1
-1-char *name_buf, *device, *devnode, *devicenode, *ofpath; + char *name_buf, *device, *devnode, *devicenode, *ofpath,*realname;
name_buf= xrealpath (sys_devname);grub-core/osdep/linux/ofpath.c +7
-0+ realname =get_slave_from_dm (name_buf); +if (realname) + { +free (name_buf); + name_buf = realname; + } +device =
get_basename(name_buf);
devnode =strip_trailing_digits(name_buf);
devicenode =strip_trailing_digits(device);Quoted 10 lines
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-develLinks:
------
[1]-------------- next part -------------- An HTML attachment was scrubbed... URL:
<https://lists.gnu.org/archive/html/grub-devel/attachments/20240607/d6db1c71/attachment.htm>------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 4 lines
------------------------------
End of Grub-devel Digest, Vol 244, Issue 12
*******************************************
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Concept of ofpathname is clear: return OF path to a given device or NULL if none. Returning anything else is a bug even if it ends up helping you somewhere.
Quoted 6 lines · avnish
Hi Vladimir,
We have implemented this code to enable the ieee1275 hint for grub. We had scenarios (in SLES) like the disk had PReP partition followed by an LVM and, inside this LVM , the boot partition. So, we implemented this code to make grub able to generate the hint.
Do you mean search hint? Correct hint for lvm is lvmid/... .
As for restricting to PPC: it solves exactly nothing of concerns.
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 8 lines · avnish
Hi Vladimir,
We have implemented this code to enable the ieee1275 hint for grub. We had scenarios (in SLES) like the disk had PReP partition followed by an LVM and, inside this LVM , the boot partition. So, we implemented this code to make grub able to generate the hint. Without this code, we were unable to find the hint for the boot process. And, in some scenarios, due the amount of disks in the machine, the process could take a lot to finish.
As Vladimir pointed out, the correct search hint should be lvmid/<UUID>, so grub will try to assemble the root logical volume first in the process of looking up the root file system. This way, time won't be wasted on trying those OpenFirmware raw disks, as they are not the target.
The problem here is that bringing up the logical volume itself can be very slow, and grub lacks measures like an LVM filter, which would help to restrict which devices are scanned and improve performance. In the end, the patch doesn't help either way.
In my opinion, this patch is more about updating the system bootlist than achieving the proclaimed boot time enhancement.
Thanks,
Michael
Quoted 222 lines
Shall we limit this function call specific to PowerPC? Something like this below:
#ifdef
__powerpc__
realname =get_slave_from_dm(name_buf);
if (realname){ free (name_buf); name_buf = realname; }#endif
Please suggest us.
Thank you so much!Regards,
Avnish ChouhanQuoted 202 lines · On 2024-06-07 15:05, [email protected] wrote:
Send Grub-devel mailing list submissions to
[email protected]
------------------------------Message: 4
Date: Fri, 7 Jun 2024 11:34:45 +0200
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: avnish <[email protected]>
Cc: The development of GNU GRUB <[email protected]>, Daniel Kiper
<[email protected]>, [email protected], [email protected], Diego Domingos <[email protected]>
Subject: Re: [PATCH v3 2/6] ieee1275/powerpc: enables device mapper
discovery
Message-ID:
<CAEaD8JN1BuOYCxSEP0dQTv7VML6vyCNFg3tSUrLigbrN9uY7AQ@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"Quoted 12 lines · avnish
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
2 problems: * How does dm device ends up on ofpathname? It should be handled by grub internal logic in most cases and not end up in of-specific paths * Why not use existing devmapper functions already present in codebase? Le jeu. 6 juin 2024,
Quoted 1 line
2 problems:
* How does dm device ends up on ofpathname? It should be handled by grub internal logic in most cases and not end up in of-specific paths
* Why not use existing devmapper functions already present in codebase?Quoted 6 lines
Hi Vladimir,
Thank you so much for your response!We have observed that whenever we are dealing with the devices like "
/dev/dm-*", the ofpath returns null.It's expected behavior
Quoted 5 lines
To resolve this, as no such required functions has been implemented to handle this kind of case. We have done changes based on the requirement
that will look into/sys/block/dm-*devices and search slave devices recursively inside slaves directory to find the root disk.Installing on e.g. LVM is invalid. Only 3 cases can your approach work:
1) multipath
2) maybe RAID1 as well in some cases
3) if ofw assembles raid somehow
Which one do you have? We need more details.
This patch enables invalid configs like installing on LVMQuoted 131 lines
Regards,
Avnish ChouhanQuoted 117 lines
Le jeu. 6 juin 2024, 14:40, Avnish Chouhan <[email protected]> a écrit :
Quoted 114 lines
This patch enables the device mapper discovery on
ofpath.c. Currently,
when we are dealing with a device like/dev/dm-*the ofpath returns null
since there is no function implemented to handle this case.This patch implements a function that will look into
/sys/block/dm-*devices and search recursively inside slaves directory to find the root
disk.Signed-off-by Diego Domingos <[email protected]>Signed-off-by Avnish Chouhan <[email protected]>---
grub-core/osdep/linux/ofpath.c| 64
+++++++++++++++++++++++++++++++++++++++++-1 file changed, 63 insertions(+), 1 deletion(-)grub-core/osdep/linux/ofpath.c +1
-0@@ -37,6 +37,7 @@#include <fcntl.h> #include <errno.h> #include <ctype.h> +#include <dirent.h> #ifdef __sparc__typedef enum
grub-core/osdep/linux/ofpath.c +12
-0@@ -755,13 +756,74 @@ strip_trailing_digits (const char *p)return new; } +static char * +get_slave_from_dm (const char * device) +{ +char *curr_device, *tmp; +char *directory; +char *ret =NULL ; + directory =grub_strdup (device); + tmp =get_basename (directory); + curr_device =grub_strdup (tmp); + *tmp ='\0' ; + +/* Recursively check for slaves devices so we can find the root device */
+ while ((curr_device[0] == 'd') && (curr_device[1] == 'm') && (curr_device[2] == '-'))grub-core/osdep/linux/ofpath.c +5
-0+ { +DIR *dp; +struct dirent *ep; +char * device_path; + device_path = grub_xasprintf ("/sys/block/%s/slaves",
curr_device);grub-core/osdep/linux/ofpath.c +18
-0+ dp =opendir (device_path); + +if (dp !=NULL ) + { + ep =readdir (dp); + +while (ep !=NULL ) + { +/* avoid some system directories */ +if (!strcmp (ep->d_name,"." )) + goto next_dir; +if (!strcmp (ep->d_name,".." )) + goto next_dir; + +free (curr_device); +free (ret); + curr_device =grub_strdup (ep->d_name); + ret = grub_xasprintf ("%s%s", directory,
curr_device);grub-core/osdep/linux/ofpath.c +10
-0+break ; + + next_dir: + ep =readdir (dp); +continue ; + } +closedir (dp); + } +else + grub_util_warn (_("cannot open directory `%s'"),
device_path);grub-core/osdep/linux/ofpath.c +8
-0+free (device_path); + } +free (directory); +free (curr_device); + +return ret; +} +char *
grub_util_devname_to_ofpath(const char*sys_devname) {grub-core/osdep/linux/ofpath.c +1
-1-char *name_buf, *device, *devnode, *devicenode, *ofpath; + char *name_buf, *device, *devnode, *devicenode, *ofpath,*realname;
name_buf= xrealpath (sys_devname);grub-core/osdep/linux/ofpath.c +7
-0+ realname =get_slave_from_dm (name_buf); +if (realname) + { +free (name_buf); + name_buf = realname; + } +device =
get_basename(name_buf);
devnode =strip_trailing_digits(name_buf);
devicenode =strip_trailing_digits(device);Quoted 10 lines
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-develLinks:
------
[1]-------------- next part -------------- An HTML attachment was scrubbed... URL:
<https://lists.gnu.org/archive/html/grub-devel/attachments/20240607/d6db1c71/attachment.htm>------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel------------------------------
Quoted 7 lines
Quoted 2 lines
End of Grub-devel Digest, Vol 244, Issue 12
*******************************************_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 21 lines · Michael Chang
Quoted 8 lines · avnish
Hi Vladimir,
We have implemented this code to enable the ieee1275 hint for grub. We had scenarios (in SLES) like the disk had PReP partition followed by an LVM and, inside this LVM , the boot partition. So, we implemented this code to make grub able to generate the hint. Without this code, we were unable to find the hint for the boot process. And, in some scenarios, due the amount of disks in the machine, the process could take a lot to finish.
As Vladimir pointed out, the correct search hint should be lvmid/<UUID>, so grub will try to assemble the root logical volume first in the process of looking up the root file system. This way, time won't be wasted on trying those OpenFirmware raw disks, as they are not the target.
The problem here is that bringing up the logical volume itself can be very slow, and grub lacks measures like an LVM filter, which would help to restrict which devices are scanned and improve performance. In the end, the patch doesn't help either way.
Quoted 6 lines
In my opinion, this patch is more about updating the system bootlist than achieving the proclaimed boot time enhancement.
Thanks,
Michael
Hi Vladimir and Michael,
Thank you so much for helping us on this patch!
Based on the inputs received. We would like to re analyze the fix done by us. We'll check the fix whether this is really required for the problem we have observed earlier. And based on our analysis, we'll update on it.
For NVMeOF patch series, we would like to drop off this patch from patch series (We'll remove this patch in next version).
Vladimir and Michael, please share your reviews on the other patches in the NVMeOf series. We'll do the required changes as per suggestions on the other patches. Thank you!
Regards,
Avnish Chouhan
Quoted 222 lines
Quoted 222 lines
Shall we limit this function call specific to PowerPC? Something like this below:
#ifdef
__powerpc__
realname =get_slave_from_dm(name_buf);
if (realname){ free (name_buf); name_buf = realname; }#endif
Please suggest us.
Thank you so much!Regards,
Avnish ChouhanQuoted 202 lines · On 2024-06-07 15:05, [email protected] wrote:
Send Grub-devel mailing list submissions to
[email protected]
------------------------------Message: 4
Date: Fri, 7 Jun 2024 11:34:45 +0200
From: "Vladimir 'phcoder' Serbinenko" <[email protected]>
To: avnish <[email protected]>
Cc: The development of GNU GRUB <[email protected]>, Daniel Kiper
<[email protected]>, [email protected], [email protected], Diego Domingos <[email protected]>
Subject: Re: [PATCH v3 2/6] ieee1275/powerpc: enables device mapper
discovery
Message-ID:
<CAEaD8JN1BuOYCxSEP0dQTv7VML6vyCNFg3tSUrLigbrN9uY7AQ@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"Quoted 12 lines · avnish
Quoted 10 lines · Vladimir 'phcoder' Serbinenko
2 problems: * How does dm device ends up on ofpathname? It should be handled by grub internal logic in most cases and not end up in of-specific paths * Why not use existing devmapper functions already present in codebase? Le jeu. 6 juin 2024,
Quoted 1 line
2 problems:
* How does dm device ends up on ofpathname? It should be handled by grub internal logic in most cases and not end up in of-specific paths
* Why not use existing devmapper functions already present in codebase?Quoted 6 lines
Hi Vladimir,
Thank you so much for your response!We have observed that whenever we are dealing with the devices like "
/dev/dm-*", the ofpath returns null.It's expected behavior
Quoted 5 lines
To resolve this, as no such required functions has been implemented to handle this kind of case. We have done changes based on the requirement
that will look into/sys/block/dm-*devices and search slave devices recursively inside slaves directory to find the root disk.Installing on e.g. LVM is invalid. Only 3 cases can your approach work:
1) multipath
2) maybe RAID1 as well in some cases
3) if ofw assembles raid somehow
Which one do you have? We need more details.
This patch enables invalid configs like installing on LVMQuoted 131 lines
Regards,
Avnish ChouhanQuoted 117 lines
Le jeu. 6 juin 2024, 14:40, Avnish Chouhan <[email protected]> a écrit :
Quoted 114 lines
This patch enables the device mapper discovery on
ofpath.c. Currently,
when we are dealing with a device like/dev/dm-*the ofpath returns null
since there is no function implemented to handle this case.This patch implements a function that will look into
/sys/block/dm-*devices and search recursively inside slaves directory to find the root
disk.Signed-off-by Diego Domingos <[email protected]>Signed-off-by Avnish Chouhan <[email protected]>---
grub-core/osdep/linux/ofpath.c| 64
+++++++++++++++++++++++++++++++++++++++++-1 file changed, 63 insertions(+), 1 deletion(-)grub-core/osdep/linux/ofpath.c +1
-0@@ -37,6 +37,7 @@#include <fcntl.h> #include <errno.h> #include <ctype.h> +#include <dirent.h> #ifdef __sparc__typedef enum
grub-core/osdep/linux/ofpath.c +12
-0@@ -755,13 +756,74 @@ strip_trailing_digits (const char *p)return new; } +static char * +get_slave_from_dm (const char * device) +{ +char *curr_device, *tmp; +char *directory; +char *ret =NULL ; + directory =grub_strdup (device); + tmp =get_basename (directory); + curr_device =grub_strdup (tmp); + *tmp ='\0' ; + +/* Recursively check for slaves devices so we can find the root device */
+ while ((curr_device[0] == 'd') && (curr_device[1] == 'm') && (curr_device[2] == '-'))grub-core/osdep/linux/ofpath.c +5
-0+ { +DIR *dp; +struct dirent *ep; +char * device_path; + device_path = grub_xasprintf ("/sys/block/%s/slaves",
curr_device);grub-core/osdep/linux/ofpath.c +18
-0+ dp =opendir (device_path); + +if (dp !=NULL ) + { + ep =readdir (dp); + +while (ep !=NULL ) + { +/* avoid some system directories */ +if (!strcmp (ep->d_name,"." )) + goto next_dir; +if (!strcmp (ep->d_name,".." )) + goto next_dir; + +free (curr_device); +free (ret); + curr_device =grub_strdup (ep->d_name); + ret = grub_xasprintf ("%s%s", directory,
curr_device);grub-core/osdep/linux/ofpath.c +10
-0+break ; + + next_dir: + ep =readdir (dp); +continue ; + } +closedir (dp); + } +else + grub_util_warn (_("cannot open directory `%s'"),
device_path);grub-core/osdep/linux/ofpath.c +8
-0+free (device_path); + } +free (directory); +free (curr_device); + +return ret; +} +char *
grub_util_devname_to_ofpath(const char*sys_devname) {grub-core/osdep/linux/ofpath.c +1
-1-char *name_buf, *device, *devnode, *devicenode, *ofpath; + char *name_buf, *device, *devnode, *devicenode, *ofpath,*realname;
name_buf= xrealpath (sys_devname);grub-core/osdep/linux/ofpath.c +7
-0+ realname =get_slave_from_dm (name_buf); +if (realname) + { +free (name_buf); + name_buf = realname; + } +device =
get_basename(name_buf);
devnode =strip_trailing_digits(name_buf);
devicenode =strip_trailing_digits(device);Quoted 10 lines
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-develLinks:
------
[1]-------------- next part -------------- An HTML attachment was scrubbed... URL:
<https://lists.gnu.org/archive/html/grub-devel/attachments/20240607/d6db1c71/attachment.htm>------------------------------
Subject: Digest Footer
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel------------------------------
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
End of Grub-devel Digest, Vol 244, Issue 12
*******************************************_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel