Re: [PATCH v1 1/2] Ext2: free memory allocated and forget buffer head when io error happens

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

 



On Sat 12-01-13 01:19:32, shilong wang wrote:
> From: Wang Shilong <wangsl-fnst@xxxxxxxxxxxxxx>
> 
> Add a necessary check when an io error happens.
> If io error happens,free the memory allocated and forget
> buffer head.
  Thanks. I've added the patch to my tree.

								Honza
> 
> Signed-off-by: Wang Shilong <wangsl-fnst@xxxxxxxxxxxxxx>
> ---
>  fs/ext2/inode.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index 6363ac6..c3881e5 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -495,6 +495,10 @@ static int ext2_alloc_branch(struct inode *inode,
>  		 * parent to disk.
>  		 */
>  		bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
> +		if (unlikely(!bh)) {
> +			err = -ENOMEM;
> +			goto failed;
> +		}
>  		branch[n].bh = bh;
>  		lock_buffer(bh);
>  		memset(bh->b_data, 0, blocksize);
> @@ -523,6 +527,14 @@ static int ext2_alloc_branch(struct inode *inode,
>  	}
>  	*blks = num;
>  	return err;
> +
> +failed:
> +	for (i = 1; i < n; i++)
> +		bforget(branch[i].bh);
> +	for (i = 0; i < indirect_blks; i++)
> +		ext2_free_blocks(inode, new_blocks[i], 1);
> +	ext2_free_blocks(inode, new_blocks[i], num);
> +	return err;
>  }
> 
>  /**
> -- 
> 1.7.7.6
-- 
Jan Kara <jack@xxxxxxx>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux