On Sat, Jun 14, 2008 at 11:32 AM, Bean <[EMAIL PROTECTED]> wrote:
> On Sat, Jun 14, 2008 at 4:40 AM, Pavel Roskin <[EMAIL PROTECTED]> wrote:
>> On Fri, 2008-06-13 at 15:45 -0400, Isaac Dupree wrote:
>>> can you send a message when GRUB2 CVS is considered no longer broken for
>>> use with ext3? (so I'll know when is a good time for me to install a
>>> newer version -- since I'm not in a hurry -- or is it a better bet
>>> stability-wise within the next month, to go with a revision from May
>>> instead?)
>>
>> I'm afraid it's not going to work this way.  I can imagine that some
>> fixes will be applied, but it's also possible that they will be
>> incomplete.  That would require further fixes.  I don't think anybody
>> would want to be in the position to announce that ext3 is fixed and then
>> announce the opposite, possibly within hours.
>>
>> The true stability is proven by testing and time.
>
> Hi,
>
> You're right, the journal code is not quite stable right now. Perhaps
> we can use variable journal to control it. By default, it's not set so
> that journal is disabled. After all, even if the fs is uncleaned, it
> can still be bootable. If automatic booting fails, users can set
> journal=1 and retry, if they're lucky, it could work without using fs
> recover tools.

Hi,

This is the patch.

-- 
Bean
diff --git a/fs/ext2.c b/fs/ext2.c
index 184b973..e2b1a6f 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -50,6 +50,7 @@
 #include <grub/dl.h>
 #include <grub/types.h>
 #include <grub/fshelp.h>
+#include <grub/env.h>
 
 /* Log2 size of ext2 block in 512 blocks.  */
 #define LOG2_EXT2_BLOCK_SIZE(data)			\
@@ -318,7 +319,7 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
       blknr = -1;
     }
 
-  return grub_fshelp_map_block (data->journal, blknr);
+  return blknr;
 }
 
 /* Read LEN bytes from the file described by DATA starting with byte
@@ -329,7 +330,8 @@ grub_ext2_read_file (grub_fshelp_node_t node,
 					unsigned offset, unsigned length),
 		     int pos, grub_size_t len, char *buf)
 {
-  return grub_fshelp_read_file (node->data->disk, node, read_hook,
+  return grub_fshelp_read_jour (node->data->journal,
+				node->data->disk, node, read_hook,
 				pos, len, buf, grub_ext2_read_block,
 				node->inode.size,
 				LOG2_EXT2_BLOCK_SIZE (node->data));
@@ -385,8 +387,6 @@ grub_ext3_get_journal (struct grub_ext2_data *data)
         block = log->first_block;
     }
 
-  data->journal = 0;
-
   if (! (data->sblock.feature_compatibility & EXT3_FEATURE_COMPAT_HAS_JOURNAL))
     return;
 
@@ -553,7 +553,10 @@ grub_ext2_mount (grub_disk_t disk)
     goto fail;
   
   data->disk = disk;
-  grub_ext3_get_journal (data);
+  data->journal = 0;
+
+  if (grub_env_get ("journal"))
+    grub_ext3_get_journal (data);
 
   data->diropen.data = data;
   data->diropen.ino = 2;
diff --git a/fs/fshelp.c b/fs/fshelp.c
index 2fae065..23a019e 100644
--- a/fs/fshelp.c
+++ b/fs/fshelp.c
@@ -269,6 +269,21 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
                                                       grub_disk_addr_t block),
 		       grub_off_t filesize, int log2blocksize)
 {
+  return grub_fshelp_read_jour (0, disk, node, read_hook, pos, len, buf, get_block,
+                                filesize, log2blocksize);
+}
+
+grub_ssize_t
+grub_fshelp_read_jour (grub_fshelp_journal_t log,
+		       grub_disk_t disk, grub_fshelp_node_t node,
+		       void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
+                                                           unsigned offset,
+                                                           unsigned length),
+		       grub_off_t pos, grub_size_t len, char *buf,
+		       grub_disk_addr_t (*get_block) (grub_fshelp_node_t node,
+                                                      grub_disk_addr_t block),
+		       grub_off_t filesize, int log2blocksize)
+{
   grub_disk_addr_t i, blockcnt;
   int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
 
@@ -314,6 +329,8 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
       if (blknr)
 	{
 	  disk->read_hook = read_hook;	  
+	  if (! read_hook)
+	    blknr = grub_fshelp_map_block (log, blknr);
 
 	  grub_disk_read (disk, blknr, skipfirst,
 			  blockend, buf);
diff --git a/fs/reiserfs.c b/fs/reiserfs.c
index 9a059e3..94754aa 100644
--- a/fs/reiserfs.c
+++ b/fs/reiserfs.c
@@ -39,6 +39,7 @@
 #include <grub/dl.h>
 #include <grub/types.h>
 #include <grub/fshelp.h>
+#include <grub/env.h>
 
 #define MIN(a, b) \
   ({ typeof (a) _a = (a); \
@@ -694,8 +695,6 @@ grub_reiserfs_get_journal (struct grub_reiserfs_data *data)
   int base_block = grub_le_to_cpu32 (data->superblock.journal_block);
   int last_num, num, block;
 
-  data->journal = 0;
-
   if (! data->superblock.journal_block)
     return;
 
@@ -819,7 +818,11 @@ grub_reiserfs_mount (grub_disk_t disk)
       goto fail;
     }
   data->disk = disk;
-  grub_reiserfs_get_journal (data);
+  data->journal = 0;
+
+  if (grub_env_get ("journal"))
+    grub_reiserfs_get_journal (data);
+
   return data;
 
  fail:
diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h
index 847f78e..da70e4e 100644
--- a/include/grub/fshelp.h
+++ b/include/grub/fshelp.h
@@ -108,6 +108,17 @@ EXPORT_FUNC(grub_fshelp_read_file) (grub_disk_t disk, grub_fshelp_node_t node,
                                                                    grub_disk_addr_t block),
 				    grub_off_t filesize, int log2blocksize);
 
+grub_ssize_t
+EXPORT_FUNC(grub_fshelp_read_jour) (grub_fshelp_journal_t log,
+				    grub_disk_t disk, grub_fshelp_node_t node,
+				    void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
+                                                                        unsigned offset,
+                                                                        unsigned length),
+				    grub_off_t pos, grub_size_t len, char *buf,
+				    grub_disk_addr_t (*get_block) (grub_fshelp_node_t node,
+                                                                   grub_disk_addr_t block),
+				    grub_off_t filesize, int log2blocksize);
+
 unsigned int
 EXPORT_FUNC(grub_fshelp_log2blksize) (unsigned int blksize,
 				      unsigned int *pow);
diff --git a/util/grub-fstest.c b/util/grub-fstest.c
index 3872ff1..e21fbdb 100644
--- a/util/grub-fstest.c
+++ b/util/grub-fstest.c
@@ -331,6 +331,7 @@ static struct option options[] = {
   {"length", required_argument, 0, 'n'},
   {"debug", required_argument, 0, 'd'},
   {"raw", no_argument, 0, 'r'},
+  {"journal", no_argument, 0, 'j'},
   {"long", no_argument, 0, 'l'},
   {"help", no_argument, 0, 'h'},
   {"version", no_argument, 0, 'V'},
@@ -361,6 +362,7 @@ Debug tool for filesystem driver.\n\
   -n, --length=N            handle N bytes in output file\n\
   -d, --debug=S             Set debug environment variable\n\
   -r, --raw                 disable auto decompression\n\
+  -j, --journal             enable journal support\n\
   -l, --long                show long directory list\n\
   -h, --help                display this message and exit\n\
   -V, --version             print version information and exit\n\
@@ -375,7 +377,7 @@ int
 main (int argc, char *argv[])
 {
   char *image_path, *debug_str = 0;
-  int cmd, is_raw = 0, is_long = 0;
+  int cmd, is_raw = 0, use_journal = 0, is_long = 0;
 
   progname = "grub-fstest";
 
@@ -409,6 +411,10 @@ main (int argc, char *argv[])
 	    is_raw = 1;
 	    break;
 
+	  case 'j':
+	    use_journal = 1;
+	    break;
+
 	  case 'l':
 	    is_long = 1;
 	    break;
@@ -506,6 +512,9 @@ main (int argc, char *argv[])
   if (is_raw)
     grub_env_set ("filehook", "0");
 
+  if (use_journal)
+    grub_env_set ("journal", "1");
+
   if (debug_str)
     grub_env_set ("debug", debug_str);
 
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to