Fixing the last logic error exposed another error in diskfs_grow: when
we take the correct branch, we miscalculate the value of NEW_SIZE.

Consider the case where the file system block size is 1024 and
diskfs_grow is called with a node that has the allocsize field set to
1024 and with the size argument set to 1025.  After the ext2_getblk
loop, END_BLOCK will be 2 (correctly indicating that block 0 and block
1 are allocated for NODE yielding a total allocation of 2048 bytes).
When we recalculate NEW_SIZE (which is eventually assigned to
NODE->allocsize), we set it to (END_BLOCK - 1) * 1024 or, 1024!  This
should really just be END_BLOCK * 1024.

Here is a patch.  Okay to apply?

2002-04-05  Neal H Walfield  <[EMAIL PROTECTED]>

        * pager.c (diskfs_grow): Correctly recalculate NEW_SIZE.

Index: pager.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/pager.c,v
retrieving revision 1.70
diff -u -p -r1.70 pager.c
--- pager.c     1 Apr 2002 20:12:03 -0000       1.70
+++ pager.c     6 Apr 2002 03:24:25 -0000
@@ -646,7 +646,7 @@ diskfs_grow (struct node *node, off_t si
 
              if (! err)
                /* Reflect how much we allocated successfully.  */
-               new_size = (end_block - 1) << log2_block_size;
+               new_size = end_block << log2_block_size;
              else
                /* See if it's still valid to say this.  */
                dn->last_page_partially_writable =

_______________________________________________
Bug-hurd mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-hurd

Reply via email to