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:  Thu Dec 15 05:52:34 +0000 2011
>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


>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.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.