disk: Prioritize OS disk devices over memdisk and procfs
PATCH 1/1 disk: Prioritize OS disk devices over memdisk and procfs
Refine iteration to prioritize returning system disk devices over memdisk and procfs. This adjustment brings about a modest improvement in search efficiency, particularly during file or UUID-based searches for a root file system. Additionally, it helps mitigate potential collisions in file-based searches where memdisk may mistakenly take precedence over system disks.
--- include/grub/disk.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/grub/disk.h +6 -1
@@ -242,7 +242,12 @@ grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data)for (pull =0 ; pull <GRUB_DISK_PULL_MAX ; pull++)for (p = grub_disk_dev_list; p; p = p->next) -if (p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) +if ((p->id !=GRUB_DISK_DEVICE_MEMDISK_ID && p->id !=GRUB_DISK_DEVICE_PROCFS_ID ) && p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) +return 1 ; + +for (pull =0 ; pull <GRUB_DISK_PULL_MAX ; pull++) +for (p = grub_disk_dev_list; p; p = p->next) +if ((p->id ==GRUB_DISK_DEVICE_MEMDISK_ID || p->id ==GRUB_DISK_DEVICE_PROCFS_ID ) && p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull))return 1 ;return 0 ;
Signature · 7 lines
2.44.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 6 lines · Michael Chang via Grub-devel
Refine iteration to prioritize returning system disk devices over memdisk and procfs. This adjustment brings about a modest improvement in search efficiency, particularly during file or UUID-based searches for a root file system. Additionally, it helps mitigate potential collisions in file-based searches where memdisk may mistakenly take precedence over system disks.
It seems to me you could do this without adding additional loops. If it is not possible the change begs for comment.
Daniel
Quoted 13 lines
Signed-off-by Michael Chang <[email protected]>--- include/grub/disk.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)include/grub/disk.h +0
-0@@ -242,7 +242,12 @@ grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data)for (pull =0 ; pull <GRUB_DISK_PULL_MAX ; pull++)for (p = grub_disk_dev_list; p; p = p->next)
include/grub/disk.h grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data) · line 253
Quoted 10 lines
include/grub/disk.h +6
-1-if (p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) +if ((p->id !=GRUB_DISK_DEVICE_MEMDISK_ID && p->id !=GRUB_DISK_DEVICE_PROCFS_ID ) && p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) +return 1 ; + +for (pull =0 ; pull <GRUB_DISK_PULL_MAX ; pull++) +for (p = grub_disk_dev_list; p; p = p->next) +if ((p->id ==GRUB_DISK_DEVICE_MEMDISK_ID || p->id ==GRUB_DISK_DEVICE_PROCFS_ID ) && p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull))return 1 ;return 0 ;
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Daniel Kiper
Quoted 6 lines · Michael Chang via Grub-devel
Refine iteration to prioritize returning system disk devices over memdisk and procfs. This adjustment brings about a modest improvement in search efficiency, particularly during file or UUID-based searches for a root file system. Additionally, it helps mitigate potential collisions in file-based searches where memdisk may mistakenly take precedence over system disks.
It seems to me you could do this without adding additional loops. If it is not possible the change begs for comment.
Thanks for review. The added loop for proc and memdisk in the final output is required for the `ls' to output list of all devices. I'll add this to the comment and send v2 patch.
Thanks,
Michael
Quoted 25 lines
Daniel
Quoted 22 lines
Signed-off-by Michael Chang <[email protected]>--- include/grub/disk.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)include/grub/disk.h +6
-1@@ -242,7 +242,12 @@ grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data)for (pull =0 ; pull <GRUB_DISK_PULL_MAX ; pull++)for (p = grub_disk_dev_list; p; p = p->next) -if (p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) +if ((p->id !=GRUB_DISK_DEVICE_MEMDISK_ID && p->id !=GRUB_DISK_DEVICE_PROCFS_ID ) && p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull)) +return 1 ; + +for (pull =0 ; pull <GRUB_DISK_PULL_MAX ; pull++) +for (p = grub_disk_dev_list; p; p = p->next) +if ((p->id ==GRUB_DISK_DEVICE_MEMDISK_ID || p->id ==GRUB_DISK_DEVICE_PROCFS_ID ) && p->disk_iterate && (p->disk_iterate) (hook, hook_data, pull))return 1 ;
Quoted 1 line
include/grub/disk.h grub_disk_dev_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data) · line 253
Quoted 1 line
include/grub/disk.h +0
-0return 0 ;
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 9 lines · Michael Chang
Quoted 8 lines · Daniel Kiper
Quoted 6 lines · Michael Chang via Grub-devel
Refine iteration to prioritize returning system disk devices over memdisk and procfs. This adjustment brings about a modest improvement in search efficiency, particularly during file or UUID-based searches for a root file system. Additionally, it helps mitigate potential collisions in file-based searches where memdisk may mistakenly take precedence over system disks.
Quoted 6 lines
Quoted 2 lines
It seems to me you could do this without adding additional loops. If it is not possible the change begs for comment.
Thanks for review. The added loop for proc and memdisk in the final output is required for the `ls' to output list of all devices. I'll add this to the comment and send v2 patch.
I understand that. However, by adding two ifs and two variables or so you would be able to avoid two additional loops. And I would really prefer that...
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 13 lines · Daniel Kiper
Quoted 12 lines · Michael Chang
Quoted 10 lines · Daniel Kiper
Quoted 6 lines · Michael Chang via Grub-devel
Refine iteration to prioritize returning system disk devices over memdisk and procfs. This adjustment brings about a modest improvement in search efficiency, particularly during file or UUID-based searches for a root file system. Additionally, it helps mitigate potential collisions in file-based searches where memdisk may mistakenly take precedence over system disks.
It seems to me you could do this without adding additional loops. If it is not possible the change begs for comment.
Quoted 7 lines
Quoted 3 lines
Thanks for review. The added loop for proc and memdisk in the final output is required for the `ls' to output list of all devices. I'll add this to the comment and send v2 patch.
I understand that. However, by adding two ifs and two variables or so you would be able to avoid two additional loops. And I would really prefer that...
The intention behind using two loops is to facilitate two separate rounds of disk pull. The first round specifically targets system disks, helping to exclude undesired factors such as memdisk or procfs in between totally. In my opinion, this sequential approach appears to offer advantages over a single loop where all disk types are mixed together in one type of pull.
Thanks,
Michael
Quoted 2 lines
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel