Re: block allocation in ext2fs

From: animesh_singh@bbv.satyam.com
Date: Wed May 03 2000 - 13:16:41 EST


On Wed, 3 May 2000 animesh_singh@bbv.satyam.com wrote:

> Hi
> you can simply mark the buffer head
> uptodate
> to do all that and call
> brelse
> in order to indicate the buffer is no longer used by you(b_count
> is decreased by one if it reduces to zero then buffer head is
> automatically added to the free list)
> Animesh
> On Wed, 3 May 2000, Benhanokh Gabriel wrote:
>
> > hi
> >
> > i'm trying to write a "pure" block allocator i.e. it only allocates
> > blocks, not writing to them( imagine a file which i know that will grow
> > to same limit, like this i can pre-allocate all its block to sit as
> > close as possible)
> >
> > as far as i understood the way block allocating is done in ext2fs is
> > like this:
> > user writes to file -> ext2fs try to find the block -> if block doesn't
> > exists -> block is allocated -> buffer head is filled with zeros ->
> > buffer head is returned to caller -> later to be written to disk.
> >
> > since i'm gonna do only the allocation and write nothing to the disk,
> > and since files are gonna be very big( GBs ), it is a big slow down if
> > those buffer caches ever be written to disk with all those boring zeros,
> > it is also gonna slow down other processes since their buffer cache will
> > be trashed.
> >
> > so i'm thinking of adding a little HACK as follows:
> > let ext2fs allocate the block, and relay on the fact that all writes are
> > performs only to buffer cache, and simply discard the cache after each
> > allocation so those buffers never get written to the disk, and other
> > processes won't suffer since the same buffer_head will be reused again
> > and again.
> > allocating the block will be done with ext2_getblk()
> >
> > but then i need some way to mark the buffer_head as if it was written to
> > disk already AND put back the buffer_head in the end of the free list so
> > it will be reused again in the next call and we won't be trashing the
> > buffer cache
> >
> > it looks like that put_last_free(bh) will do the last part, but how do
> > i mark the buffer_head as if it was written to the disk ?
> > will mark_buffer_clean() do the work
> >
> > the following code suppose to allocate block_num_to_allocate to the
> > given indoe
> >
> > buffer_head * bh;
> > for( block =0; block < block_num_to_alloacte; block++){
> > bh= ext2_getblk( &inode, block, 1, &err); //allocate the
> > block
> > mark_buffer_clean( bh ); // ???
> > put_last_free( bh ); // reuse buffer head
> > }
> >
> > does it looks like this hack work or that i'm gonna create
> > inconsistency in the file system ?
> >
> > THX
> > /gabriel
> >
> > please CC me for any answer
> > 10x again
> >
> >
> > -
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.rutgers.edu
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun May 07 2000 - 21:00:12 EST