NetBSD Problem Report #40258

From mhitch@montana.edu  Tue Dec 23 06:47:41 2008
Return-Path: <mhitch@montana.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id 036D963B121
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 23 Dec 2008 06:47:40 +0000 (UTC)
Message-Id: <20081223064732.7C4D221295@net4bb.msu.montana.edu>
Date: Mon, 22 Dec 2008 23:47:32 -0700 (MST)
From: mhitch@lightning.msu.montana.edu
Reply-To: mhitch@lightning.msu.montana.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: sysutils/grub does not work with ffs file systems with blocksize > 8K
X-Send-Pr-Version: 3.95

>Number:         40258
>Category:       pkg
>Synopsis:       sysutils/grub does not work with ffs file systems with blocksize > 8K
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gdt
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 23 06:50:00 +0000 2008
>Closed-Date:    
>Last-Modified:  Sun Dec 19 02:05:01 +0000 2021
>Originator:     Michael L. Hitch
>Release:        NetBSD 5.0_BETA
>Organization:
Montana State University

>Environment:


System: NetBSD Pavilion 5.0_BETA NetBSD 5.0_BETA (GENERIC) #0: Fri Dec 19 23:17:57 MST 2008 mhitch@Pavilion:/home/mhitch/netbsd-5/OBJ/amd64/home/mhitch/netbsd-5/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
Sysutils/grub has a well-known problem of not working with ffs file systems 
with a blocksize > 8K.  Since NetBSD typically defaults to 16K, that results
in a file system that grub fails to work with.  It's sometimes a pain to
rebuild the filesystem, so it would be nice if grub would work with larger
block sizes.
>How-To-Repeat:
Install grub on a file system with 16K blocksize and watch it (usually) fail.
>Fix:
Not wanting to rebuild a root file system I had, I looked at how grub handles
ffs file systems.  After puzzling over it for a while, I finally figured out
there was a rather minor bug in how fsys_ffs.c handles the indirect blocks.
The following patch fixes that bug.  It also changes the layout of the file
system buffer area to put the superblock at the end of that buffer to
reduce the likelyhood of it getting overwritten when the directory is
read into the file system buffer.  Most root directories are likely to be
less than 24K in size and shouldn't cause any problems.  I've been able to
boot from file systems with blocksizes of 64K, as well as with larger partitions
beyond the limit noted in the ffs restrictions I've seen documented.


diff -u work.xxx/grub-0.97/stage2/fsys_ffs.c work/grub-0.97/stage2/fsys_ffs.c
--- work.xxx/grub-0.97/stage2/fsys_ffs.c	2008-07-22 11:06:41.000000000 -0600
+++ work/grub-0.97/stage2/fsys_ffs.c	2008-07-22 11:07:37.000000000 -0600
@@ -71,9 +71,9 @@
 static int mapblock_bsize;

 /* pointer to superblock */
-#define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 8192 ))
+#define SUPERBLOCK ((struct fs *) ( FSYS_BUF + 24576 ))
 #define INODE ((struct icommon *) ( FSYS_BUF + 16384 ))
-#define MAPBUF ( FSYS_BUF + 24576 )
+#define MAPBUF ( FSYS_BUF + 8192 )
 #define MAPBUF_LEN 8192


@@ -106,15 +106,16 @@

   /* If the blockmap loaded does not include FILE_BLOCK,
      load a new blockmap.  */
+  offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK));
   if ((bnum = fsbtodb (SUPERBLOCK, INODE->i_ib[0])) != mapblock
-      || (mapblock_offset <= bnum && bnum <= mapblock_offset + mapblock_bsize))
+      || ( offset < mapblock_offset || offset >= mapblock_offset + (MAPBUF_LEN / sizeof(int))))
     {
       if (MAPBUF_LEN < SUPERBLOCK->fs_bsize)
 	{
 	  offset = ((file_block - NDADDR) % NINDIR (SUPERBLOCK));
 	  bsize = MAPBUF_LEN;

-	  if (offset + MAPBUF_LEN > SUPERBLOCK->fs_bsize)
+	  if (offset * sizeof (int) + MAPBUF_LEN > SUPERBLOCK->fs_bsize)
 	    offset = (SUPERBLOCK->fs_bsize - MAPBUF_LEN) / sizeof (int);
 	}
       else

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->gdt
Responsible-Changed-By: gdt@NetBSD.org
Responsible-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
Responsible-Changed-Why:
I am volunteering to close this if it's appropriate to do so.


State-Changed-From-To: open->feedback
State-Changed-By: gdt@NetBSD.org
State-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
State-Changed-Why:
should be filed upstream, vs pkgsrc.
probably fixed; is 3 years old.
30 day timer to close if not addressed upstream
and confirmed still an issue


From: "Michael L. Hitch" <mhitch@lightning.msu.montana.edu>
To: gnats-bugs@NetBSD.org
Cc: gdt@NetBSD.org, pkg-manager@netbsd.org
Subject: Re: pkg/40258 (sysutils/grub does not work with ffs file systems
 with blocksize > 8K)
Date: Wed, 14 Dec 2011 11:58:46 -0700 (MST)

 On Wed, 14 Dec 2011, gdt@NetBSD.org wrote:

 > Synopsis: sysutils/grub does not work with ffs file systems with blocksize > 8K
 >
 > Responsible-Changed-From-To: pkg-manager->gdt
 > Responsible-Changed-By: gdt@NetBSD.org
 > Responsible-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
 > Responsible-Changed-Why:
 > I am volunteering to close this if it's appropriate to do so.
 >
 >
 > State-Changed-From-To: open->feedback
 > State-Changed-By: gdt@NetBSD.org
 > State-Changed-When: Wed, 14 Dec 2011 17:20:28 +0000
 > State-Changed-Why:
 > should be filed upstream, vs pkgsrc.
 > probably fixed; is 3 years old.
 > 30 day timer to close if not addressed upstream
 > and confirmed still an issue

    As best I can tell, the pkgsrc version will still have the same issue. 
 The pkgsrc version is 0.97, the "Legacy Grub", which is not being 
 developed.  I don't know if Grub2 has addressed this issue.

    This hasn't been an issue for me, since I have local patches if I ever 
 want to use grub again (since NetBSD can now boot xen with the native 
 bootloader, I don't have much use for grub anymore).

 --
 Michael L. Hitch			mhitch@montana.edu
 Computer Consultant
 Information Technology Center
 Montana State University	Bozeman, MT	USA

State-Changed-From-To: feedback->open
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 15 Dec 2011 05:52:34 +0000
State-Changed-Why:
feedback received


From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/40258: sysutils/grub does not work with ffs file systems
 with blocksize > 8K
Date: Sun, 19 Dec 2021 02:00:30 +0000

  > Sysutils/grub has a well-known problem of not working with ffs file systems 
  > with a blocksize > 8K.  Since NetBSD typically defaults to 16K, that results
  > in a file system that grub fails to work with.  It's sometimes a pain to
  > rebuild the filesystem, so it would be nice if grub would work with larger
  > block sizes.

 Since we still have grub 0.97 in pkgsrc and this patch isn't in it, we
 should commit the patch already. It's only been sitting in gnats 13
 years.

 I'd do it but with something like grub the results really ought to be
 tested and I'm not in a position to do that. Can someone who is attend
 to it?

 (Alternatively, can someone point me at something I can use to
 generate a qemu-bootable disk image with a pkgsrc grub in it and
 something to boot from grub where one can tell if it worked?)

 -- 
 David A. Holland
 dholland@netbsd.org

>Unformatted:

 1) This seems like a grub bug, not a pkgsrc bug.  Please address it
 upstream.  After there's a bug open and a patch upstream, it's
 reasonable for pkgsrc to add a patch.

 2) This PR is from 2008.  Is this still an issue?

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.