On Fri, Jun 13, 2008 at 6:01 PM, Bean <[EMAIL PROTECTED]> wrote:
> On Fri, Jun 13, 2008 at 5:05 PM, Bean <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I think we need to disable journal sometimes. Tools like grub-setup
>> and grub-install is run in an active system, that means sectors could
>> easily end up in the journal. However, journal is a temperately
>> buffer, space can be reused after a while. In this case, we should
>> bypass the journal and access the underlying file system directly.
>> Perhaps we can use a variable like no_journal to control the journal
>> support, any suggestions ?
>
> More thoughts about this issue. I think the problem is in the
> read_hook. If we're just reading, it make no difference whether it's
> from journal or real location, however, if the read_hook is not empty,
> we also need to pass the sector location to upper layer. Perhaps we
> can disable journal when the read hook is not null ?

Hi,

This patch should fix the above problem.

-- 
Bean
diff --git a/fs/ext2.c b/fs/ext2.c
index 184b973..0b96909 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -318,7 +318,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 +329,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));
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/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);
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to