bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] ext2fs/pager.c:diskfs_grow: another logic error


From: Marcus Brinkmann
Subject: Re: [patch] ext2fs/pager.c:diskfs_grow: another logic error
Date: Wed, 5 Jun 2002 15:45:03 +0200
User-agent: Mutt/1.3.28i

On Fri, Apr 05, 2002 at 10:41:35PM -0500, Neal H Walfield wrote:
> 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  <neal@cs.uml.edu>
> 
>       * pager.c (diskfs_grow): Correctly recalculate NEW_SIZE.

I applied this patch.  After studying the surrounding code some more, I
believe it is correct (the patch was obviously correct, but I wasn't sure
about the rest of the code).

If someone could do some stress test on filesystems with various block
sizes, that would be nice.  (Like, creating files, appending to them, etc).

> 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
> Bug-hurd@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-hurd
> 

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]