Skip to contentSkip to conversation

Disable debug messages in reiserfs.mod

PATCH In review Vladimir 'phcoder' Serbinenko 4 participants 5 messages Aug 15, 2009 – Aug 17, 2009 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Disable debug messages in reiserfs.mod

Hello. Recently we had no bug-reports about ReiserFS and debug messages and disabling them saves 533 bytes. I find it important especially because core.img with reiserfs is currently the biggest among filesystems supported in mainstream

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
fs/reiserfs.c +34 -51
index 04d3315..47ba375 100644
@@ -25,11 +25,12 @@
 */
 
 #if 0
-# define GRUB_REISERFS_DEBUG
 # define GRUB_REISERFS_JOURNALING
 # define GRUB_HEXDUMP
 #endif
 
+#define GRUB_REISERFS_DEBUG 0
+
 #include <grub/err.h>
 #include <grub/file.h>
 #include <grub/mm.h>
@@ -514,17 +515,23 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
       if (grub_errno)
         goto fail;
       current_level = grub_le_to_cpu16 (block_header->level);
+#if GRUB_REISERFS_DEBUG >= 1
       grub_dprintf ("reiserfs_tree", " at level %d\n", current_level);
+#endif
       if (current_level >= previous_level)
         {
+#if GRUB_REISERFS_DEBUG >= 1
           grub_dprintf ("reiserfs_tree", "level loop detected, aborting\n");
+#endif
           grub_error (GRUB_ERR_FILE_READ_ERROR, "level loop");
           goto fail;
         }
       previous_level = current_level;
       item_count = grub_le_to_cpu16 (block_header->item_count);
+#if GRUB_REISERFS_DEBUG >= 1
       grub_dprintf ("reiserfs_tree", " number of contained items : %d\n",
                     item_count);
+#endif
       if (current_level > 1)
         {
           /* Internal node. Navigate to the child that should contain
@@ -540,7 +547,7 @@ grub_reiserfs_get_item (struct grub_reiserfs_data *data,
                  && grub_reiserfs_compare_keys (key, &(keys[i])) >= 0;
                i++)
             {
-#ifdef GRUB_REISERFS_DEBUG
+#if GRUB_REISERFS_DEBUG >= 2
               grub_printf("i %03d/%03d ", i + 1, item_count + 1);
               grub_reiserfs_print_key (&(keys[i]));
 #endif
@@ -733,7 +740,9 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
     goto fail;
   block_number = item->block_number;
   block_position = item->block_position;
+#if GRUB_REISERFS_DEBUG >= 1
   grub_dprintf ("reiserfs", "Iterating directory...\n");
+#endif
   do
     {
       struct grub_reiserfs_directory_header *directory_headers;
@@ -749,7 +758,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
       if (grub_errno)
         goto fail;
 
-#if 0
+#if GRUB_REISERFS_DEBUG >= 2
       if (grub_le_to_cpu16 (block_header->level) != 1)
         {
           grub_error (GRUB_ERR_TEST_FAILURE,
@@ -825,7 +834,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
                       entry_version
                         = grub_le_to_cpu16 (entry_item->header.version);
                       entry_block_number = entry_item->block_number;
-#if 0
+#if GRUB_REISERFS_DEBUG >= 2
 		      grub_dprintf ("reiserfs",
                                     "version %04x block %08x (%08x) position %08x\n",
                                     entry_version, entry_block_number,
@@ -842,7 +851,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
                                           (char *) &entry_v1_stat);
                           if (grub_errno)
                             goto fail;
-#if 0
+#if GRUB_REISERFS_DEBUG >= 2
 			  grub_dprintf ("reiserfs",
                                         "%04x %04x %04x %04x %08x %08x | %08x %08x %08x %08x\n",
                                         grub_le_to_cpu16 (entry_v1_stat.mode),
@@ -884,7 +893,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
                                           (char *) &entry_v2_stat);
                           if (grub_errno)
                             goto fail;
-#if 0
+#if GRUB_REISERFS_DEBUG >= 2
 			  grub_dprintf ("reiserfs",
                                         "%04x %04x %08x %08x%08x | %08x %08x %08x %08x | %08x %08x %08x\n",
                                         grub_le_to_cpu16 (entry_v2_stat.mode),
@@ -923,19 +932,23 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
                     }
                   else
                     {
+#if GRUB_REISERFS_DEBUG >= 1
                       /* Pseudo file ".." never has stat block.  */
                       if (grub_strcmp (entry_name, ".."))
                         grub_dprintf ("reiserfs",
                                       "Warning : %s has no stat block !\n",
                                       entry_name);
+#endif
                       grub_free (entry_item);
                       continue;
                     }
                 }
               if (hook (entry_name, entry_type, entry_item))
                 {
+#if GRUB_REISERFS_DEBUG >= 1
                   grub_dprintf ("reiserfs", "Found : %s, type=%d\n",
                                 entry_name, entry_type);
+#endif
                   ret = 1;
                   goto found;
                 }
@@ -1046,9 +1059,11 @@ grub_reiserfs_open (struct grub_file *file, const char *name)
         goto fail;
       file->size = (grub_off_t) grub_le_to_cpu64 (entry_v2_stat.size);
     }
+#if GRUB_REISERFS_DEBUG >= 1
   grub_dprintf ("reiserfs", "file size : %d (%08x%08x)\n",
                 (unsigned int) file->size,
                 (unsigned int) (file->size >> 32), (unsigned int) file->size);
+#endif
   file->offset = 0;
   file->data = found;
   return GRUB_ERR_NONE;
@@ -1087,12 +1102,14 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
   initial_position = file->offset;
   current_position = 0;
   final_position = MIN (len + initial_position, file->size);
+#if GRUB_REISERFS_DEBUG >= 1
   grub_dprintf ("reiserfs",
 		"Reading from %lld to %lld (%lld instead of requested %ld)\n",
 		(unsigned long long) initial_position,
 		(unsigned long long) final_position,
 		(unsigned long long) (final_position - initial_position),
 		(unsigned long) len);
+#endif
   while (current_position < final_position)
     {
       grub_reiserfs_set_key_offset (&key, current_key_offset);
@@ -1106,16 +1123,20 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
         {
         case GRUB_REISERFS_DIRECT:
           block = found.block_number * (block_size  >> GRUB_DISK_SECTOR_BITS);
+#if GRUB_REISERFS_DEBUG >= 1
           grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block);
+#endif
           if (initial_position < current_position + item_size)
             {
               offset = MAX ((signed) (initial_position - current_position), 0);
               length = (MIN (item_size, final_position - current_position)
                         - offset);
+#if GRUB_REISERFS_DEBUG >= 1
               grub_dprintf ("reiserfs",
                             "Reading direct block %u from %u to %u...\n",
                             (unsigned) block, (unsigned) offset,
                             (unsigned) (offset + length));
+#endif
               found.data->disk->read_hook = file->read_hook;
               grub_disk_read (found.data->disk,
                               block,
@@ -1150,18 +1171,22 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
             {
               block = grub_le_to_cpu32 (indirect_block_ptr[indirect_block]) *
                       (block_size >> GRUB_DISK_SECTOR_BITS);
+#if GRUB_REISERFS_DEBUG >= 1
               grub_dprintf ("reiserfs_blocktype", "I: %u\n", (unsigned) block);
+#endif
               if (current_position + block_size >= initial_position)
                 {
                   offset = MAX ((signed) (initial_position - current_position),
                                 0);
                   length = (MIN (block_size, final_position - current_position)
                             - offset);
+#if GRUB_REISERFS_DEBUG >= 1
                   grub_dprintf ("reiserfs",
                                 "Reading indirect block %u from %u to %u...\n",
                                 (unsigned) block, (unsigned) offset,
                                 (unsigned) (offset + length));
-#if 0
+#endif
+#if GRUB_REISERFS_DEBUG >= 2
                   grub_dprintf ("reiserfs",
                                 "\nib=%04d/%04d, ip=%d, cp=%d, fp=%d, off=%d, l=%d, tl=%d\n",
                                 indirect_block + 1, indirect_block_count,
@@ -1187,55 +1212,13 @@ grub_reiserfs_read (grub_file_t file, char *buf, grub_size_t len)
       current_key_offset = current_position + 1;
     }
 
+#if GRUB_REISERFS_DEBUG >= 1
   grub_dprintf ("reiserfs",
 		"Have successfully read %lld bytes (%ld requested)\n",
 		(unsigned long long) (current_position - initial_position),
 		(unsigned long) len);
+#endif
   return current_position - initial_position;
-/*
-  switch (found.type)
-    {
-      case GRUB_REISERFS_DIRECT:
-        read_length = MIN (len, item_size - file->offset);
-        grub_disk_read (found.data->disk,
-                        (found.block_number * block_size) / GRUB_DISK_SECTOR_SIZE,
-                        grub_le_to_cpu16 (found.header.item_location) + file->offset,
-                        read_length, buf);
-        if (grub_errno)
-          goto fail;
-        break;
-      case GRUB_REISERFS_INDIRECT:
-        indirect_block_count = item_size / sizeof (*indirect_block_ptr);
-        indirect_block_ptr = grub_malloc (item_size);
-        if (!indirect_block_ptr)
-          goto fail;
-        grub_disk_read (found.data->disk,
-                        (found.block_number * block_size) / GRUB_DISK_SECTOR_SIZE,
-                        grub_le_to_cpu16 (found.header.item_location),
-                        item_size, (char *) indirect_block_ptr);
-        if (grub_errno)
-          goto fail;
-        len = MIN (len, file->size - file->offset);
-        for (indirect_block = file->offset / block_size;
-             indirect_block < indirect_block_count && read_length < len;
-             indirect_block++)
-          {
-            read = MIN (block_size, len - read_length);
-            grub_disk_read (found.data->disk,
-                            (grub_le_to_cpu32 (indirect_block_ptr[indirect_block]) * block_size) / GRUB_DISK_SECTOR_SIZE,
-                            file->offset % block_size, read,
-                            ((void *) buf) + read_length);
-            if (grub_errno)
-              goto fail;
-            read_length += read;
-          }
-        grub_free (indirect_block_ptr);
-        break;
-      default:
-        goto fail;
-    }
-
-  return read_length;*/
 
  fail:
   grub_free (indirect_block_ptr);
#1 lore raw
Quoted 4 lines · Vladimir 'phcoder' Serbinenko

Hello. Recently we had no bug-reports about ReiserFS and debug messages and disabling them saves 533 bytes. I find it important especially because core.img with reiserfs is currently the biggest among filesystems supported in mainstream

Completely removing debug messages from the compiled binaries should be selectable as a GRUB-wide configure-time switch, defaulting to _include_ such strings. Furthermore, removing the possibility of enabling debug messages at runtime from certain modules (reiserfs) but not others (ext4? vbe? drivemap?) will present the user with an non-uniform interface - confusing and maybe frustrating.

In my opinion, there are better, wiser ways of reducing the size of core.img, such as the new object format proposed by Bean, so unless there is some kind of "emergency" like "some recent patch brought a common pc+biosdisk+reiserfs core.img over the size limit", I don't think this patch would be a good decision.

Signature · 1 line
-- Lazy, Oblivious, Recurrent Disaster -- Habbit
#2 lore raw

2009/8/15 Javier Martín <[email protected]>:

Quoted 6 lines
Quoted 4 lines · Vladimir 'phcoder' Serbinenko

Hello. Recently we had no bug-reports about ReiserFS and debug messages and disabling them saves 533 bytes. I find it important especially because core.img with reiserfs is currently the biggest among filesystems supported in mainstream

Quoted 7 lines

Completely removing debug messages from the compiled binaries should be selectable as a GRUB-wide configure-time switch, defaulting to _include_ such strings. Furthermore, removing the possibility of enabling debug messages at runtime from certain modules (reiserfs) but not others (ext4? vbe? drivemap?) will present the user with an non-uniform interface - confusing and maybe frustrating.

phcoder@phcoder-laptop ~/grub2/gitsvn/fs $ grep -l grub_dprintf * reiserfs.c

As you can see reiserfs.c is the only filesystem module with debugging information. (Now I noticed that affs.c and fat.c have a leftover grub_printf which I'll change to dprintf. In fat.c additionally printf is disabled). So I conclude that the consensus is not to have dprintfs in well-tested filesystem code.
As for vbe and drivemap they don't go to core.img so there is no reason to care too much about their size

Quoted 6 lines

In my opinion, there are better, wiser ways of reducing the size of core.img, such as the new object format proposed by Bean, so unless there is some kind of "emergency" like "some recent patch brought a common pc+biosdisk+reiserfs core.img over the size limit", I don't think this patch would be a good decision.

I have series of patches which will bring pc+ata+<any filesystem except zfs> below 31 KiB margin

Quoted 9 lines

--
-- Lazy, Oblivious, Recurrent Disaster -- Habbit

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
#3 lore raw
Quoted 5 lines · Vladimir 'phcoder' Serbinenko

As you can see reiserfs.c is the only filesystem module with debugging information. (Now I noticed that affs.c and fat.c have a leftover grub_printf which I'll change to dprintf. In fat.c additionally printf is disabled). So I conclude that the consensus is not to have dprintfs in well-tested filesystem code.

I think you have a point, but perhaps it would be better to wait untill GRUB 2 reaches mainstream before removing debug information. The average end user doesn't know how to recompile GRUB, and getting distros to ship a new set of binaries just for debug information isn't going to be possible.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw
In reply to Vladimir 'phcoder' Serbinenko
Quoted 1 line · Vladimir 'phcoder' Serbinenko

Hello. Recently we had no bug-reports about ReiserFS and ...

Maybe it's because people aren't using grub to load things on ReiserFS?
I've stuck with Ext3 everywhere for awhile now and so do a lot of
distros' defaults.

(not arguing against it, just thinking...)

-Isaac