NetBSD-Bugs archive

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

Re: kern/43344



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

From: Jeff Rizzo <riz%NetBSD.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/43344
Date: Tue, 15 Jun 2010 21:14:37 -0700

 --jI8keyz6grp/JLjh
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Can you try this patch against 5.1_RC3 and let me know if it does
 what you expect?  (this is from the kern/40936 commits)
 
 It's too late for 5.1, but I can get it pulled up for 5.2 if it works
 for you.
 
 --jI8keyz6grp/JLjh
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="ext2.patch"
 
 Index: sys/ufs/ext2fs/ext2fs_dinode.h
 ===================================================================
 RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_dinode.h,v
 retrieving revision 1.16.28.1
 diff -u -r1.16.28.1 ext2fs_dinode.h
 --- sys/ufs/ext2fs/ext2fs_dinode.h     29 Nov 2008 23:10:18 -0000      
1.16.28.1
 +++ sys/ufs/ext2fs/ext2fs_dinode.h     16 Jun 2010 04:10:59 -0000
 @@ -154,7 +154,7 @@
  #define EXT2_NODUMP           0x00000040      /* do not dump file */
  
  /* Size of on-disk inode. */
 -#define       EXT2_DINODE_SIZE        (sizeof(struct ext2fs_dinode))  /* 128 
*/
 +#define EXT2_DINODE_SIZE(s)   (s)->e2fs.e2fs_inode_size
  
  /*
   * The e2di_blocks fields may be overlaid with other information for
 Index: sys/ufs/ext2fs/ext2fs_inode.c
 ===================================================================
 RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_inode.c,v
 retrieving revision 1.66.8.1
 diff -u -r1.66.8.1 ext2fs_inode.c
 --- sys/ufs/ext2fs/ext2fs_inode.c      22 Feb 2010 04:43:46 -0000      1.66.8.1
 +++ sys/ufs/ext2fs/ext2fs_inode.c      16 Jun 2010 04:10:59 -0000
 @@ -221,7 +221,7 @@
        }
        ip->i_flag &= ~(IN_MODIFIED | IN_ACCESSED);
        cp = (char *)bp->b_data +
 -          (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE);
 +          (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
        e2fs_isave(ip->i_din.e2fs_din, (struct ext2fs_dinode *)cp);
        if ((updflags & (UPDATE_WAIT|UPDATE_DIROP)) != 0 &&
            (flags & IN_MODIFIED) != 0 &&
 Index: sys/ufs/ext2fs/ext2fs_vfsops.c
 ===================================================================
 RCS file: /cvsroot/src/sys/ufs/ext2fs/ext2fs_vfsops.c,v
 retrieving revision 1.137.6.5
 diff -u -r1.137.6.5 ext2fs_vfsops.c
 --- sys/ufs/ext2fs/ext2fs_vfsops.c     27 Oct 2009 21:41:07 -0000      
1.137.6.5
 +++ sys/ufs/ext2fs/ext2fs_vfsops.c     16 Jun 2010 04:10:59 -0000
 @@ -577,7 +577,7 @@
        fs->e2fs_bmask = ~fs->e2fs_qbmask;
        fs->e2fs_ngdb =
            howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd));
 -      fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE;
 +      fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE(fs);
        fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb;
        brelse(bp, 0);
  
 @@ -646,7 +646,7 @@
                        break;
                }
                cp = (char *)bp->b_data +
 -                  (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE);
 +                  (ino_to_fsbo(fs, ip->i_number) * EXT2_DINODE_SIZE(fs));
                e2fs_iload((struct ext2fs_dinode *)cp, ip->i_din.e2fs_din);
                ext2fs_set_inode_guid(ip);
                brelse(bp, 0);
 @@ -696,8 +696,7 @@
        ump = NULL;
  
  #ifdef DEBUG_EXT2
 -      printf("sb size: %d ino size %d\n", sizeof(struct ext2fs),
 -          EXT2_DINODE_SIZE);
 +      printf("ext2 sb size: %d\n", sizeof(struct ext2fs));
  #endif
        error = bread(devvp, (SBOFF / size), SBSIZE, cred, 0, &bp);
        if (error)
 @@ -717,6 +716,10 @@
        bp = NULL;
        m_fs = ump->um_e2fs;
        m_fs->e2fs_ronly = ronly;
 +
 +#ifdef DEBUG_EXT2
 +      printf("ext2 ino size %d\n", EXT2_DINODE_SIZE(m_fs));
 +#endif
        if (ronly == 0) {
                if (m_fs->e2fs.e2fs_state == E2FS_ISCLEAN)
                        m_fs->e2fs.e2fs_state = 0;
 @@ -737,7 +740,7 @@
        m_fs->e2fs_bmask = ~m_fs->e2fs_qbmask;
        m_fs->e2fs_ngdb =
            howmany(m_fs->e2fs_ncg, m_fs->e2fs_bsize / sizeof(struct ext2_gd));
 -      m_fs->e2fs_ipb = m_fs->e2fs_bsize / EXT2_DINODE_SIZE;
 +      m_fs->e2fs_ipb = m_fs->e2fs_bsize / EXT2_DINODE_SIZE(m_fs);
        m_fs->e2fs_itpg = m_fs->e2fs.e2fs_ipg / m_fs->e2fs_ipb;
  
        m_fs->e2fs_gd = malloc(m_fs->e2fs_ngdb * m_fs->e2fs_bsize,
 @@ -1078,7 +1081,7 @@
                *vpp = NULL;
                return (error);
        }
 -      cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE);
 +      cp = (char *)bp->b_data + (ino_to_fsbo(fs, ino) * EXT2_DINODE_SIZE(fs));
        ip->i_din.e2fs_din = pool_get(&ext2fs_dinode_pool, PR_WAITOK);
        e2fs_iload((struct ext2fs_dinode *)cp, ip->i_din.e2fs_din);
        ext2fs_set_inode_guid(ip);
 @@ -1260,9 +1263,8 @@
                return (EINVAL);           /* XXX needs translation */
        }
        if (fs2h32(fs->e2fs_rev) > E2FS_REV0) {
 -              if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO ||
 -                  fs2h16(fs->e2fs_inode_size) != EXT2_DINODE_SIZE) {
 -                      printf("Ext2 fs: unsupported inode size\n");
 +              if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) {
 +                      printf("Ext2 fs: unsupported first inode position\n");
                        return (EINVAL);      /* XXX needs translation */
                }
                if (fs2h32(fs->e2fs_features_incompat) &
 Index: sbin/newfs_ext2fs/extern.h
 ===================================================================
 RCS file: /cvsroot/src/sbin/newfs_ext2fs/extern.h,v
 retrieving revision 1.2
 diff -u -r1.2 extern.h
 --- sbin/newfs_ext2fs/extern.h 14 Dec 2007 13:19:35 -0000      1.2
 +++ sbin/newfs_ext2fs/extern.h 16 Jun 2010 04:10:59 -0000
 @@ -41,6 +41,7 @@
  extern int    Oflag;          /* format as an 4.3BSD file system */
  extern int    verbosity;      /* amount of printf() output */
  extern int64_t        fssize;         /* file system size */
 +extern uint16_t       inodesize;      /* bytes per inode */
  extern uint   sectorsize;     /* sector size */
  extern uint   fsize;          /* fragment size */
  extern uint   bsize;          /* block size */
 Index: sbin/newfs_ext2fs/mke2fs.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/newfs_ext2fs/mke2fs.c,v
 retrieving revision 1.9
 diff -u -r1.9 mke2fs.c
 --- sbin/newfs_ext2fs/mke2fs.c 28 Aug 2008 16:29:24 -0000      1.9
 +++ sbin/newfs_ext2fs/mke2fs.c 16 Jun 2010 04:10:59 -0000
 @@ -248,11 +248,12 @@
        sblock.e2fs.e2fs_fsize = ilog2(fsize) - LOG_MINBSIZE;
  
        sblock.e2fs_bsize = bsize;
 +      sblock.e2fs.e2fs_inode_size = inodesize;
        sblock.e2fs_bshift = sblock.e2fs.e2fs_log_bsize + LOG_MINBSIZE;
        sblock.e2fs_qbmask = sblock.e2fs_bsize - 1;
        sblock.e2fs_bmask = ~sblock.e2fs_qbmask;
        sblock.e2fs_fsbtodb = ilog2(sblock.e2fs_bsize) - ilog2(sectorsize);
 -      sblock.e2fs_ipb = sblock.e2fs_bsize / EXT2_DINODE_SIZE;
 +      sblock.e2fs_ipb = sblock.e2fs_bsize / inodesize;
  
        /*
         * Ext2fs preserves BBSIZE (1024 bytes) space at the top for
 @@ -301,7 +302,7 @@
                num_inodes = UINT16_MAX * ncg;  /* ext2bgd_nifree is uint16_t */
  
        inodes_per_cg = num_inodes / ncg;
 -      iblocks_per_cg = howmany(EXT2_DINODE_SIZE * inodes_per_cg, bsize);
 +      iblocks_per_cg = howmany(inodesize * inodes_per_cg, bsize);
  
        /* Check that the last cylinder group has enough space for inodes */
        minblocks_per_cg =
 @@ -404,7 +405,6 @@
        sblock.e2fs.e2fs_rgid = getegid();
  
        sblock.e2fs.e2fs_first_ino = EXT2_FIRSTINO;
 -      sblock.e2fs.e2fs_inode_size = EXT2_DINODE_SIZE;
  
        /* e2fs_block_group_nr is set on writing superblock to each group */
  
 Index: sbin/newfs_ext2fs/newfs_ext2fs.8
 ===================================================================
 RCS file: /cvsroot/src/sbin/newfs_ext2fs/newfs_ext2fs.8,v
 retrieving revision 1.1
 diff -u -r1.1 newfs_ext2fs.8
 --- sbin/newfs_ext2fs/newfs_ext2fs.8   17 Nov 2007 16:50:26 -0000      1.1
 +++ sbin/newfs_ext2fs/newfs_ext2fs.8   16 Jun 2010 04:10:59 -0000
 @@ -29,7 +29,7 @@
  .\"
  .\"     @(#)newfs.8   8.6 (Berkeley) 5/3/95
  .\"
 -.Dd November 17, 2007
 +.Dd March 1, 2009
  .Dt NEWFS_EXT2FS 8
  .Os
  .Sh NAME
 @@ -37,6 +37,7 @@
  .Nd construct a new Ext2 file system
  .Sh SYNOPSIS
  .Nm
 +.Op Fl D Ar inodesize
  .Op Fl FINZ
  .Op Fl b Ar block-size
  .Op Fl f Ar frag-size
 @@ -93,6 +94,9 @@
  .It \*[Gt] 512 MB
  4 KB
  .El
 +.It Fl D
 +Set the inode size. Defaults to 128, and can also be set to 256 for
 +compatibility with ext4.
  .It Fl F
  Create a file system image in
  .Ar special .
 Index: sbin/newfs_ext2fs/newfs_ext2fs.c
 ===================================================================
 RCS file: /cvsroot/src/sbin/newfs_ext2fs/newfs_ext2fs.c,v
 retrieving revision 1.4
 diff -u -r1.4 newfs_ext2fs.c
 --- sbin/newfs_ext2fs/newfs_ext2fs.c   20 Jul 2008 01:20:23 -0000      1.4
 +++ sbin/newfs_ext2fs/newfs_ext2fs.c   16 Jun 2010 04:10:59 -0000
 @@ -104,6 +104,7 @@
  #define DEFAULT_VERBOSITY 3   /* 4 is traditional behavior of newfs(8) */
  int64_t fssize;                       /* file system size */
  uint  sectorsize;             /* bytes/sector */
 +uint16_t inodesize = 128;     /* inode size */
  uint  fsize = 0;              /* fragment size */
  uint  bsize = 0;              /* block size */
  uint  minfree = MINFREE;      /* free space threshold */
 @@ -133,10 +134,16 @@
        fsi = fso = -1;
        Fflag = Iflag = Zflag = 0;
        verbosity = -1;
 -      opstring = "FINO:S:V:Zb:f:i:l:m:n:s:v:";
 +      opstring = "D:FINO:S:V:Zb:f:i:l:m:n:s:v:";
        byte_sized = 0;
        while ((ch = getopt(argc, argv, opstring)) != -1)
                switch (ch) {
 +              case 'D':
 +                      inodesize = (uint16_t)strtol(optarg, &s1, 0);
 +                      if (*s1 || inodesize != 128 || inodesize != 256)
 +                              errx(1, "Bad inode size %d "
 +                                  "(only 128 and 256 supported)", inodesize);
 +                      break;
                case 'F':
                        Fflag = 1;
                        break;
 @@ -449,6 +456,7 @@
  }
  
  static const char help_strings[] =
 +      "\t-D inodesize\tsize of an inode in bytes (128 or 256)\n"
        "\t-F \t\tcreate file system image in regular file\n"
        "\t-I \t\tdo not check that the file system type is `Linux Ext2'\n"
        "\t-N \t\tdo not create file system, just print out parameters\n"
 Index: sys/lib/libsa/ext2fs.c
 ===================================================================
 RCS file: /cvsroot/src/sys/lib/libsa/ext2fs.c,v
 retrieving revision 1.4
 diff -u -r1.4 ext2fs.c
 --- sys/lib/libsa/ext2fs.c     2 Dec 2007 06:47:43 -0000       1.4
 +++ sys/lib/libsa/ext2fs.c     16 Jun 2010 04:10:59 -0000
 @@ -431,7 +431,7 @@
        if (ext2fs.e2fs_rev > E2FS_REV1 ||
            (ext2fs.e2fs_rev == E2FS_REV1 &&
             (ext2fs.e2fs_first_ino != EXT2_FIRSTINO ||
 -            ext2fs.e2fs_inode_size != EXT2_DINODE_SIZE ||
 +           (ext2fs.e2fs_inode_size != 128 && ext2fs.e2fs_inode_size != 256) ||
              ext2fs.e2fs_features_incompat & ~EXT2F_INCOMPAT_SUPP))) {
                return ENODEV;
        }
 @@ -449,7 +449,7 @@
        fs->e2fs_bmask = ~fs->e2fs_qbmask;
        fs->e2fs_ngdb =
            howmany(fs->e2fs_ncg, fs->e2fs_bsize / sizeof(struct ext2_gd));
 -      fs->e2fs_ipb = fs->e2fs_bsize / EXT2_DINODE_SIZE;
 +      fs->e2fs_ipb = fs->e2fs_bsize / ext2fs.e2fs_inode_size;
        fs->e2fs_itpg = fs->e2fs.e2fs_ipg / fs->e2fs_ipb;
  
        return 0;
 
 --jI8keyz6grp/JLjh--
 


Home | Main Index | Thread Index | Old Index