linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Guo Chao <yan@linux.vnet.ibm.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 1/4] ext4: release buffer when checksum failed
Date: Fri, 18 Jan 2013 13:28:38 -0800	[thread overview]
Message-ID: <20130118212838.GO6426@blackbox.djwong.org> (raw)
In-Reply-To: <1358496074-6228-1-git-send-email-yan@linux.vnet.ibm.com>

On Fri, Jan 18, 2013 at 04:01:11PM +0800, Guo Chao wrote:
> Commit b0336e8d (ext4: calculate and verify checksums of directory leaf
> blocks) and commit dbe89444 (ext4: Calculate and verify checksums for
> htree nodes) forget to release buffer when checksum failed, at some places.
> 
> Cc: D. J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Guo Chao <yan@linux.vnet.ibm.com>

I think this looks ok...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/ext4/dir.c   |    1 +
>  fs/ext4/namei.c |   12 ++++++++++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
> index 80a28b2..3882fbc 100644
> --- a/fs/ext4/dir.c
> +++ b/fs/ext4/dir.c
> @@ -185,6 +185,7 @@ static int ext4_readdir(struct file *filp,
>  					"at offset %llu",
>  					(unsigned long long)filp->f_pos);
>  			filp->f_pos += sb->s_blocksize - offset;
> +			brelse(bh);
>  			continue;
>  		}
>  		set_buffer_verified(bh);
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 8990165..a445247 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -837,6 +837,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
>  		    !ext4_dx_csum_verify(dir,
>  					 (struct ext4_dir_entry *)bh->b_data)) {
>  			ext4_warning(dir->i_sb, "Node failed checksum");
> +			brelse(bh);
>  			return -EIO;
>  		}
>  		set_buffer_verified(bh);
> @@ -877,8 +878,11 @@ static int htree_dirblock_to_tree(struct file *dir_file,
>  	}
>  
>  	if (!buffer_verified(bh) &&
> -	    !ext4_dirent_csum_verify(dir, (struct ext4_dir_entry *)bh->b_data))
> +			!ext4_dirent_csum_verify(dir,
> +				(struct ext4_dir_entry *)bh->b_data)) {
> +		brelse(bh);
>  		return -EIO;
> +	}
>  	set_buffer_verified(bh);
>  
>  	de = (struct ext4_dir_entry_2 *) bh->b_data;
> @@ -1929,8 +1933,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
>  		}
>  		if (!buffer_verified(bh) &&
>  		    !ext4_dirent_csum_verify(dir,
> -				(struct ext4_dir_entry *)bh->b_data))
> +				(struct ext4_dir_entry *)bh->b_data)) {
> +			brelse(bh);
>  			return -EIO;
> +		}
>  		set_buffer_verified(bh);
>  		retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
>  		if (retval != -ENOSPC) {
> @@ -2493,6 +2499,7 @@ static int empty_dir(struct inode *inode)
>  			(struct ext4_dir_entry *)bh->b_data)) {
>  		EXT4_ERROR_INODE(inode, "checksum error reading directory "
>  				 "lblock 0");
> +		brelse(bh);
>  		return -EIO;
>  	}
>  	set_buffer_verified(bh);
> @@ -2537,6 +2544,7 @@ static int empty_dir(struct inode *inode)
>  					(struct ext4_dir_entry *)bh->b_data)) {
>  				EXT4_ERROR_INODE(inode, "checksum error "
>  						 "reading directory lblock 0");
> +				brelse(bh);
>  				return -EIO;
>  			}
>  			set_buffer_verified(bh);
> -- 
> 1.7.9.5
> 

  parent reply	other threads:[~2013-01-18 21:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-18  8:01 [PATCH 1/4] ext4: release buffer when checksum failed Guo Chao
2013-01-18  8:01 ` [PATCH 2/4] ext4: remove unused variable in add_dirent_to_buf() Guo Chao
2013-01-29  1:12   ` Darrick J. Wong
2013-01-29  2:28     ` Theodore Ts'o
2013-01-18  8:01 ` [PATCH 3/4] ext4: remove useless assignment in dx_probe() Guo Chao
2013-01-29  1:21   ` Darrick J. Wong
2013-01-29  2:37     ` Theodore Ts'o
2013-01-29  2:35   ` Theodore Ts'o
2013-01-18  8:01 ` [PATCH 4/4] ext4: remove unnecessary NULL pointer check Guo Chao
2013-01-29  1:24   ` Darrick J. Wong
2013-01-29  2:40     ` Guo Chao
2013-01-29  2:42     ` Theodore Ts'o
2013-01-18 21:28 ` Darrick J. Wong [this message]
2013-01-29  2:25   ` [PATCH 1/4] ext4: release buffer when checksum failed Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130118212838.GO6426@blackbox.djwong.org \
    --to=darrick.wong@oracle.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yan@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).