aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/indirect.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-01-12 16:19:36 -0500
committerBen Hutchings <ben@decadent.org.uk>2013-03-06 03:22:36 +0000
commit99d930c0ffe5396442f93cd3c421a9bd1984b923 (patch)
tree1766f2e1d4ce0fb4eb92f01845c058e950dc5be9 /fs/ext4/indirect.c
parent066f289835f09a3f744d6bac96f25e25d20b3ded (diff)
downloadkernel_samsung_smdk4412-99d930c0ffe5396442f93cd3c421a9bd1984b923.zip
kernel_samsung_smdk4412-99d930c0ffe5396442f93cd3c421a9bd1984b923.tar.gz
kernel_samsung_smdk4412-99d930c0ffe5396442f93cd3c421a9bd1984b923.tar.bz2
ext4: return ENOMEM if sb_getblk() fails
commit 860d21e2c585f7ee8a4ecc06f474fdc33c9474f4 upstream. The only reason for sb_getblk() failing is if it can't allocate the buffer_head. So ENOMEM is more appropriate than EIO. In addition, make sure that the file system is marked as being inconsistent if sb_getblk() fails. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> [bwh: Backported to 3.2: - Adjust context - Drop change to inline.c - Call to ext4_ext_check() from ext4_ext_find_extent() is conditional] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs/ext4/indirect.c')
-rw-r--r--fs/ext4/indirect.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 3cfc73f..26d6dbf 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -146,6 +146,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
struct super_block *sb = inode->i_sb;
Indirect *p = chain;
struct buffer_head *bh;
+ int ret = -EIO;
*err = 0;
/* i_data is not going away, no lock needed */
@@ -154,8 +155,10 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
goto no_block;
while (--depth) {
bh = sb_getblk(sb, le32_to_cpu(p->key));
- if (unlikely(!bh))
+ if (unlikely(!bh)) {
+ ret = -ENOMEM;
goto failure;
+ }
if (!bh_uptodate_or_lock(bh)) {
if (bh_submit_read(bh) < 0) {
@@ -177,7 +180,7 @@ static Indirect *ext4_get_branch(struct inode *inode, int depth,
return NULL;
failure:
- *err = -EIO;
+ *err = ret;
no_block:
return p;
}
@@ -471,7 +474,7 @@ static int ext4_alloc_branch(handle_t *handle, struct inode *inode,
*/
bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
if (unlikely(!bh)) {
- err = -EIO;
+ err = -ENOMEM;
goto failed;
}