grub-0.97/btrfs: [PATCH] against fedora 10
Hello everyone.
This is the support for default single-device configuration. Subvolumes are _allowed_. Transparent compression is not allowed. Leafsize != 4K is not allowed. Nodesize != 4K is not allowed. Grub-0.97+btrfs doesn't understand exotic things like preallocated extents (e.g. files composed by fallocate(2), posix_fallocate(3)). Also grub-0.97 doesn't check btrfs checksums. In such configurations btrfs_stage1_5 doesn't exceed 62 sectors in size and can be installed to the boot area.
Technical overview:
Things are complicated because of logical/physical block translations. We can not afford to maintain a long cache, so grub will search like a mad. The main search routine aux_tree_lookup() is recursive with depth 2. On the upper level we traverse the chunk tree and scroll the system array for a translation map. We have 3 different pools for search so that logical threads (e.g. name resolution, updating fs_root, looking for translation map) won't step on each other. Every such pool is represented by structure btrfs_path, which has one "sliding" 4K-buffer.
btrfs_mount() looks through super versions and pick up the most recent one. Then chunk_root and tree_root are installed to the global structure btrfs_fs_info. At the end we pick up and install the latest version of fs_tree.
btrfs_dir() updates the fs_tree during path walk every time when we jump to another subvolume.
This stuff can be easily adjusted for other grub versions.
Attached is the patch against the package grub-0.97-38.fc10.src.rpm that can be found on the fedora mirrors, for example here:
http://ucho.ignum.cz/fedora/linux/releases/10/Fedora/source/SRPMS/grub-0.97-38.fc10.src.rpm
All comments, bugreports, etc. are welcome as usual.
Thanks,
Edward.
--- AUTHORS | 2 INSTALL | 3 configure.in | 7 docs/grub.texi | 3 stage2/Makefile.am | 38 - stage2/btrfs.h | 1413 ++++++++++++++++++++++++++++++++++++++++++++++++++++ stage2/builtins.c | 1 stage2/disk_io.c | 3 stage2/filesys.h | 10 stage2/fsys_btrfs.c | 1402 +++++++++++++++++++++++++++++++++++++++++++++++++++ stage2/shared.h | 13 11 files changed, 2876 insertions(+), 19 deletions(-)
INSTALL +3 -0
@@ -207,6 +207,9 @@ operates. `--disable-reiserfs' Omit the ReiserFS support in Stage 2. +`--disable-btrfs' + Omit the BtrFS support in Stage 2. + `--disable-vstafs' Omit the VSTa filesystem support in Stage 2.
configure.in +7 -0
@@ -337,6 +337,13 @@ if test x"$enable_reiserfs" != xno; then FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_REISERFS=1" fi +AC_ARG_ENABLE(btrfs, + [ --disable-btrfs disable BtrFS support in Stage 2]) + +if test x"$enable_btrfs" != xno; then + FSYS_CFLAGS="$FSYS_CFLAGS -DFSYS_BTRFS=1" +fi + AC_ARG_ENABLE(vstafs, [ --disable-vstafs disable VSTa FS support in Stage 2])
docs/grub.texi +2 -1
@@ -283,7 +283,7 @@ devices, partitions, and files in a dire Support multiple filesystem types transparently, plus a useful explicit blocklist notation. The currently supported filesystem types are @dfn{BSD FFS}, @dfn{DOS FAT16 and FAT32}, @dfn{Minix fs}, @dfn{Linux -ext2fs}, @dfn{ReiserFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa +ext2fs}, @dfn{ReiserFS}, @dfn{BtrFS}, @dfn{JFS}, @dfn{XFS}, and @dfn{VSTa fs}. @xref{Filesystem}, for more information. @item Support automatic decompression
@@ -1776,6 +1776,7 @@ itself. Usually, this is put in a filesy @itemx jfs_stage1_5 @itemx minix_stage1_5 @itemx reiserfs_stage1_5 +@itemx btrfs_stage1_5 @itemx vstafs_stage1_5 @itemx xfs_stage1_5
stage2/Makefile.am +25 -13
@@ -21,13 +21,13 @@ noinst_LIBRARIES = libgrub.a endif libgrub_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \ disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \ - fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ + fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_btrfs.c fsys_ufs2.c \ fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ terminfo.c tparm.c graphics.c libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \ -DGRUB_UTIL=1 -DFSYS_EXT2FS=1 -DFSYS_FAT=1 -DFSYS_FFS=1 \ -DFSYS_ISO9660=1 -DFSYS_JFS=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1 \ - -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \ + -DFSYS_BTRFS=1 -DFSYS_UFS2=1 -DFSYS_VSTAFS=1 -DFSYS_XFS=1 \ -DUSE_MD5_PASSWORDS=1 -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 # Stage 2 and Stage 1.5's.
@@ -40,24 +40,26 @@ EXTRA_PROGRAMS = nbloader.exec pxeloader if DISKLESS_SUPPORT pkgdata_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ - reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \ - nbgrub pxegrub + reiserfs_stage1_5 btrfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 \ + xfs_stage1_5 nbgrub pxegrub noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \ e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \ iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ - reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \ - xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec + reiserfs_stage1_5.exec btrfs_stage1_5.exec ufs2_stage1_5.exec \ + vstafs_stage1_5.exec xfs_stage1_5.exec nbloader.exec \ + pxeloader.exec diskless.exec else pkgdata_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ - reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 + reiserfs_stage1_5 btrfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 \ + xfs_stage1_5 noinst_DATA = pre_stage2 start start_eltorito noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \ e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \ iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ - reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \ - xfs_stage1_5.exec + reiserfs_stage1_5.exec btrfs_stage1_5.exec ufs2_stage1_5.exec \ + vstafs_stage1_5.exec xfs_stage1_5.exec endif MOSTLYCLEANFILES = $(noinst_PROGRAMS)
@@ -98,7 +100,7 @@ STAGE2_COMPILE = $(STAGE2_CFLAGS) -fno-b libstage2_a_SOURCES = boot.c builtins.c char_io.c cmdline.c common.c \ disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \ - fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ + fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_btrfs.c fsys_ufs2.c \ fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ terminfo.c tparm.c libstage2_a_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS)
@@ -112,9 +114,9 @@ STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DN pre_stage2_exec_SOURCES = asm.S bios.c boot.c builtins.c char_io.c \ cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \ fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ - fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \ - hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \ - graphics.c + fsys_reiserfs.c fsys_btrfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c \ + gunzip.c hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c \ + tparm.c graphics.c pre_stage2_exec_CFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) pre_stage2_exec_CCASFLAGS = $(STAGE2_COMPILE) $(FSYS_CFLAGS) pre_stage2_exec_LDFLAGS = $(PRE_STAGE2_LINK)
@@ -223,6 +225,16 @@ reiserfs_stage1_5_exec_CCASFLAGS = $(STA reiserfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) reiserfs_stage1_5_exec_LDADD = @LIBGCC@ +# For btrfs_stage1_5 target. +btrfs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \ + disk_io.c stage1_5.c fsys_btrfs.c bios.c +btrfs_stage1_5_exec_CFLAGS = $(STAGE1_5_COMPILE) -DFSYS_BTRFS=1 \ + -DNO_BLOCK_FILES=1 +btrfs_stage1_5_exec_CCASFLAGS = $(STAGE1_5_COMPILE) -DFSYS_BTRFS=1 \ + -DNO_BLOCK_FILES=1 +btrfs_stage1_5_exec_LDFLAGS = $(STAGE1_5_LINK) +btrfs_stage1_5_exec_LDADD = @LIBGCC@ + # For vstafs_stage1_5 target. vstafs_stage1_5_exec_SOURCES = start.S asm.S common.c char_io.c \ disk_io.c stage1_5.c fsys_vstafs.c bios.c
stage2/btrfs.h new file +1413 -0
1,413 lines not on this page · raw message
stage2/builtins.c +1 -0
@@ -4170,6 +4170,7 @@ setup_func (char *arg, int flags) {"jfs", "/jfs_stage1_5"}, {"minix", "/minix_stage1_5"}, {"reiserfs", "/reiserfs_stage1_5"}, + {"btrfs", "/btrfs_stage1_5"}, {"vstafs", "/vstafs_stage1_5"}, {"xfs", "/xfs_stage1_5"} };
stage2/disk_io.c +3 -0
@@ -64,6 +64,9 @@ struct fsys_entry fsys_table[NUM_FSYS + # ifdef FSYS_REISERFS {"reiserfs", reiserfs_mount, reiserfs_read, reiserfs_dir, 0, reiserfs_embed}, # endif +# ifdef FSYS_BTRFS + {"btrfs", btrfs_mount, btrfs_read, btrfs_dir, 0, 0}, +# endif # ifdef FSYS_VSTAFS {"vstafs", vstafs_mount, vstafs_read, vstafs_dir, 0, 0}, # endif
stage2/filesys.h +10 -0
@@ -77,6 +77,16 @@ int reiserfs_embed (int *start_sector, i#define FSYS_REISERFS_NUM 0#endif +#ifdef FSYS_BTRFS +#define FSYS_BTRFS_NUM 1 +int btrfs_mount (void ); +int btrfs_read (char *buf,int len); +int btrfs_dir (char *dirname); +int btrfs_embed (int *start_sector,int needed_sectors); +#else +#define FSYS_BTRFS_NUM 0 +#endif +#ifdef FSYS_VSTAFS #define FSYS_VSTAFS_NUM 1int vstafs_mount (void );
stage2/fsys_btrfs.c new file +1402 -0
1,402 lines not on this page · raw message
stage2/shared.h +8 -5
@@ -210,11 +210,12 @@ extern void *grub_scratch_mem;#define STAGE2_ID_FAT_STAGE1_5 3#define STAGE2_ID_MINIX_STAGE1_5 4#define STAGE2_ID_REISERFS_STAGE1_5 5 -#define STAGE2_ID_VSTAFS_STAGE1_5 6 -#define STAGE2_ID_JFS_STAGE1_5 7 -#define STAGE2_ID_XFS_STAGE1_5 8 -#define STAGE2_ID_ISO9660_STAGE1_5 9 -#define STAGE2_ID_UFS2_STAGE1_5 10 +#define STAGE2_ID_BTRFS_STAGE1_5 6 +#define STAGE2_ID_VSTAFS_STAGE1_5 7 +#define STAGE2_ID_JFS_STAGE1_5 8 +#define STAGE2_ID_XFS_STAGE1_5 9 +#define STAGE2_ID_ISO9660_STAGE1_5 10 +#define STAGE2_ID_UFS2_STAGE1_5 11#ifndef STAGE1_5 # define STAGE2_ID STAGE2_ID_STAGE2
@@ -229,6 +230,8 @@ extern void *grub_scratch_mem;# define STAGE2_ID STAGE2_ID_MINIX_STAGE1_5# elif defined(FSYS_REISERFS )# define STAGE2_ID STAGE2_ID_REISERFS_STAGE1_5 +# elif defined(FSYS_BTRFS ) +# define STAGE2_ID STAGE2_ID_BTRFS_STAGE1_5# elif defined(FSYS_VSTAFS )# define STAGE2_ID STAGE2_ID_VSTAFS_STAGE1_5# elif defined(FSYS_JFS )
AUTHORS +2 -0
@@ -41,6 +41,8 @@ Kristoffer Branemyr added VSTa filesyste Serguei Tzukanov added JFS and XFS support. +Edward Shishkin added Btrfs support. + Jason Thomas added Linux DAC960 support and support for hiding/unhiding logical partitions, and did a significant bugfix for the terminal stuff.
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.