NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: misc/54748 (NetBSD 9_RC1 not booting from disklabel partition on RAIDframe on GPT)



The following reply was made to PR misc/54748; it has been noted by GNATS.

From: Emmanuel Dreyfus <manu%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: misc/54748 (NetBSD 9_RC1 not booting from disklabel partition on
 RAIDframe on GPT)
Date: Sun, 8 Dec 2019 08:36:49 +0000

 --ALfTUftag+2gvp1h
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hello
 
 I can reproduce this problem in qemu.
 
 The message "Unexpected raidframe label version" is just there because
 the RAIDframe structure are not fully initialized due to the second
 component being absent. If you configure the RAID with both disks, it
 vanishes. But is is only a warning.
 
 The real problem is here and I will have to investigate:
         NAME=sys0 not found
 
 I have a fix for this, and for another one I encountered while 
 looking at it. Find the patch attached (I can provide you a binary 
 if that helps).
 
 The code to select the inner RAID partition assumed it had a name,
 and hence that there was a GPT inside. I just modified the code
 to let the partition be a candidate for booting if it has no name.
 With it I was able to run this without an error with your setup.
   ls NAME=sys0: 
 
 While there, I noticed that commands like this did not work:
   ls raid0a:
   boot raid0a:/netbsd
 
 This is the second bug. The fix is done in the patch with the
 changes to boot/devopen.c and efiboot/devopen.c
 
 This recalls me some work I did, and I wonder how I could miss it
 in my testings. I suspect I just forgot it when I did my commit.
 On the other hand, it has some breakage potential and should
 be tested a lot. It only impacts operations on devices named
 after NAME=label: or raidNd:
 
 -- 
 Emmanuel Dreyfus
 manu%netbsd.org@localhost
 
 --ALfTUftag+2gvp1h
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="boot2.patch"
 
 Index: boot/devopen.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/boot/devopen.c,v
 retrieving revision 1.9
 diff -U4 -r1.9 devopen.c
 --- boot/devopen.c	18 Aug 2019 02:18:24 -0000	1.9
 +++ boot/devopen.c	8 Dec 2019 03:05:16 -0000
 @@ -155,9 +155,9 @@
  	/* Search by raidframe name */
  	if (strstr(devname, "raid") == devname) {
  		f->f_dev = &devsw[0];		/* must be biosdisk */
  
 -		return biosdisk_open_name(f, devname);
 +		return biosdisk_open_name(f, fname);
  	}
  #endif
  
  	error = dev2bios(devname, unit, &biosdev);
 Index: efiboot/devopen.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/efiboot/devopen.c,v
 retrieving revision 1.8
 diff -U4 -r1.8 devopen.c
 --- efiboot/devopen.c	26 Sep 2019 12:21:03 -0000	1.8
 +++ efiboot/devopen.c	8 Dec 2019 03:05:16 -0000
 @@ -150,8 +150,9 @@
  int
  devopen(struct open_file *f, const char *fname, char **file)
  {
  	char *fsname, *devname;
 +	const char *xname = NULL;
  	int unit, partition;
  	int biosdev;
  	int i, error;
  #if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
 @@ -160,9 +161,8 @@
  	char *filename;
  	size_t fsnamelen;
  	int n;
  #endif
 -
  	error = parsebootfile(fname, &fsname, &devname, &unit, &partition,
  	    (const char **) file);
  	if (error)
  		return error;
 @@ -171,18 +171,22 @@
  	    sizeof(struct fs_ops) * nfsys_disk);
  	nfsys = nfsys_disk;
  
  	/* Search by GPT label or raidframe name */
 -	if ((strstr(devname, "NAME=") == devname) ||
 -	    (strstr(devname, "raid") == devname)) {
 +	if (strstr(devname, "NAME=") == devname)
 +		xname = devname;
 +	if (strstr(devname, "raid") == devname)
 +		xname = fname;
 +
 +	if (xname != NULL) {
  		f->f_dev = &devsw[0];		/* must be biosdisk */
  
  		if (!kernel_loaded) {
  			strncpy(bibp.bootpath, *file, sizeof(bibp.bootpath));
  			BI_ADD(&bibp, BTINFO_BOOTPATH, sizeof(bibp));
  		}
  
 -		error = biosdisk_open_name(f, devname);
 +		error = biosdisk_open_name(f, xname);
  		return error;
  	}
  
  	/*
 Index: lib/biosdisk.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/i386/stand/lib/biosdisk.c,v
 retrieving revision 1.52
 diff -U4 -r1.52 biosdisk.c
 --- lib/biosdisk.c	13 Sep 2019 02:19:46 -0000	1.52
 +++ lib/biosdisk.c	8 Dec 2019 03:05:16 -0000
 @@ -1400,19 +1400,20 @@
  			if (d->part[part].size == 0)
  				continue;
  			if (d->part[part].fstype == FS_UNUSED)
  				continue;
 -			if (d->part[part].part_name == NULL)
 -				continue;
 -			if (strcmp(d->part[part].part_name, name) == 0) {
 +
 +			if (d->part[part].part_name != NULL &&
 +			    strcmp(d->part[part].part_name, name) == 0) {
  				*biosdev = raidframe[i].biosdev;
  				*offset = raidframe[i].offset
  					+ RF_PROTECTED_SECTORS
  					+ d->part[part].offset;
  				*size = d->part[part].size;
  				ret = 0;
  				goto out;
  			}
 +
  			if (strcmp(raidframe[i].parent_name, name) == 0) {
  				if (candidate == -1 || bootme)
  					candidate = part;
  				continue;
 
 --ALfTUftag+2gvp1h--
 


Home | Main Index | Thread Index | Old Index