Re: [PATCH 1/2] reiser4: sanitize deallocations throughout the code.

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

 



On Sunday 31 August 2014 at 13:24:35, Edward Shishkin wrote:	
> 
> On 08/18/2014 01:31 PM, Ivan Shapovalov wrote:
> > - Deferred (BA_DEFER) deallocations do not make use of target stage and
> >    other flags, so remove them to avoid confusion.
> > - mark final deallocations in wandering log code as deferred.
> >
> > With the last point, there is a clear semantic distinction between
> > deferred and immediate deallocations.
> > Deferred mode is used to deallocate blocks that were previously written,
> > immediate mode is used to deallocate "just allocated" blocks in error
> > paths or if some previously allocated blocks turn out to be unneeded.
> >
> > This way, we may get rid of discard-related hack in the deallocation routine,
> > i. e. treating immediate deallocations as deferred (which messes up
> > block accounting). This is done in the next commit.
> >
> > Signed-off-by: Ivan Shapovalov <intelfx100@xxxxxxxxx>
> > ---
> >   fs/reiser4/plugin/txmod.c | 18 ++++++------------
> >   fs/reiser4/tree.c         |  3 +--
> >   fs/reiser4/wander.c       |  5 ++---
> >   3 files changed, 9 insertions(+), 17 deletions(-)
> >
> > diff --git a/fs/reiser4/plugin/txmod.c b/fs/reiser4/plugin/txmod.c
> > index 63d461f..d8a99b7 100644
> > --- a/fs/reiser4/plugin/txmod.c
> > +++ b/fs/reiser4/plugin/txmod.c
> > @@ -287,8 +287,7 @@ static int forward_relocate_unformatted(flush_pos_t *flush_pos,
> >   		 * on relocating - free nodes which are going to be
> >   		 * relocated
> >   		 */
> > -		reiser4_dealloc_blocks(&start, &allocated,
> > -				       BLOCK_ALLOCATED, BA_DEFER);
> > +		reiser4_dealloc_blocks(&start, &allocated, 0, BA_DEFER);
> >   
> >   	/* assign new block numbers to protected nodes */
> >   	assign_real_blocknrs(flush_pos, oid, index, allocated, first_allocated);
> > @@ -386,16 +385,13 @@ static squeeze_result squeeze_relocate_unformatted(znode *left,
> >   	result = put_unit_to_end(left, key, &copy_extent);
> >   
> >   	if (result == -E_NODE_FULL) {
> > -		int target_block_stage;
> >   		/*
> >   		 * free blocks which were just allocated
> >   		 */
> > -		target_block_stage =
> > -			(state ==
> > -			 ALLOCATED_EXTENT) ? BLOCK_FLUSH_RESERVED :
> > -			BLOCK_UNALLOCATED;
> >   		reiser4_dealloc_blocks(&first_allocated, &allocated,
> > -				       target_block_stage,
> > +				       (state == ALLOCATED_EXTENT)
> > +				       ? BLOCK_FLUSH_RESERVED
> > +				       : BLOCK_UNALLOCATED,
> >   				       BA_PERMANENT);
> >   		/*
> >   		 * rewind the preceder
> > @@ -408,8 +404,7 @@ static squeeze_result squeeze_relocate_unformatted(znode *left,
> >   		/*
> >   		 * free nodes which were relocated
> >   		 */
> > -		reiser4_dealloc_blocks(&start, &allocated,
> > -				       BLOCK_ALLOCATED, BA_DEFER);
> > +		reiser4_dealloc_blocks(&start, &allocated, 0, BA_DEFER);
> >   	}
> >   	/*
> >   	 * assign new block numbers to protected nodes
> > @@ -689,8 +684,7 @@ static int forward_try_defragment_locality(znode * node,
> >   		goto exit;
> >   
> >   	if (!ZF_ISSET(node, JNODE_CREATED) &&
> > -	    (ret = reiser4_dealloc_block(znode_get_block(node), 0,
> > -					 BA_DEFER | BA_FORMATTED)))
> > +	    (ret = reiser4_dealloc_block(znode_get_block(node), 0, BA_DEFER)))
> 
> 
> Here you drop BA_FORMATTED flag for the node, which is really formatted.
> It makes a mess. Do you have more neat solution?

I've dropped BA_FORMATTED flag for one reason: if BA_DEFER is specified,
other flags are not taken into account. So it is redundant to specify those.
By the same reason 0 is already passed instead of target block stage.

Actually, only two pieces of this patch are not no-op: I've added BA_DEFER
in dealloc_tx_list() and in dealloc_wmap_actor().

If you think that BA_FORMATTED must remain despite it is unused --
then ok, so it shall be.

Thanks,
-- 
Ivan Shapovalov / intelfx /

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux File System Development]     [Linux BTRFS]     [Linux NFS]     [Linux Filesystems]     [Ext4 Filesystem]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Resources]

  Powered by Linux