Commit d5ac7773 authored by Guo Chao's avatar Guo Chao Committed by Theodore Ts'o
Browse files

ext4: release buffer when checksum failed

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.
Signed-off-by: default avatarGuo Chao <yan@linux.vnet.ibm.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent b06acd38
...@@ -185,6 +185,7 @@ static int ext4_readdir(struct file *filp, ...@@ -185,6 +185,7 @@ static int ext4_readdir(struct file *filp,
"at offset %llu", "at offset %llu",
(unsigned long long)filp->f_pos); (unsigned long long)filp->f_pos);
filp->f_pos += sb->s_blocksize - offset; filp->f_pos += sb->s_blocksize - offset;
brelse(bh);
continue; continue;
} }
set_buffer_verified(bh); set_buffer_verified(bh);
......
...@@ -837,6 +837,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash, ...@@ -837,6 +837,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
!ext4_dx_csum_verify(dir, !ext4_dx_csum_verify(dir,
(struct ext4_dir_entry *)bh->b_data)) { (struct ext4_dir_entry *)bh->b_data)) {
ext4_warning(dir->i_sb, "Node failed checksum"); ext4_warning(dir->i_sb, "Node failed checksum");
brelse(bh);
return -EIO; return -EIO;
} }
set_buffer_verified(bh); set_buffer_verified(bh);
...@@ -877,8 +878,11 @@ static int htree_dirblock_to_tree(struct file *dir_file, ...@@ -877,8 +878,11 @@ static int htree_dirblock_to_tree(struct file *dir_file,
} }
if (!buffer_verified(bh) && 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; return -EIO;
}
set_buffer_verified(bh); set_buffer_verified(bh);
de = (struct ext4_dir_entry_2 *) bh->b_data; de = (struct ext4_dir_entry_2 *) bh->b_data;
...@@ -1929,8 +1933,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, ...@@ -1929,8 +1933,10 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
} }
if (!buffer_verified(bh) && if (!buffer_verified(bh) &&
!ext4_dirent_csum_verify(dir, !ext4_dirent_csum_verify(dir,
(struct ext4_dir_entry *)bh->b_data)) (struct ext4_dir_entry *)bh->b_data)) {
brelse(bh);
return -EIO; return -EIO;
}
set_buffer_verified(bh); set_buffer_verified(bh);
retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
if (retval != -ENOSPC) { if (retval != -ENOSPC) {
...@@ -2492,6 +2498,7 @@ static int empty_dir(struct inode *inode) ...@@ -2492,6 +2498,7 @@ static int empty_dir(struct inode *inode)
(struct ext4_dir_entry *)bh->b_data)) { (struct ext4_dir_entry *)bh->b_data)) {
EXT4_ERROR_INODE(inode, "checksum error reading directory " EXT4_ERROR_INODE(inode, "checksum error reading directory "
"lblock 0"); "lblock 0");
brelse(bh);
return -EIO; return -EIO;
} }
set_buffer_verified(bh); set_buffer_verified(bh);
...@@ -2536,6 +2543,7 @@ static int empty_dir(struct inode *inode) ...@@ -2536,6 +2543,7 @@ static int empty_dir(struct inode *inode)
(struct ext4_dir_entry *)bh->b_data)) { (struct ext4_dir_entry *)bh->b_data)) {
EXT4_ERROR_INODE(inode, "checksum error " EXT4_ERROR_INODE(inode, "checksum error "
"reading directory lblock 0"); "reading directory lblock 0");
brelse(bh);
return -EIO; return -EIO;
} }
set_buffer_verified(bh); set_buffer_verified(bh);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment