diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-01-12 16:19:36 -0500 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2013-03-06 03:22:36 +0000 |
commit | 99d930c0ffe5396442f93cd3c421a9bd1984b923 (patch) | |
tree | 1766f2e1d4ce0fb4eb92f01845c058e950dc5be9 /fs/ext4/extents.c | |
parent | 066f289835f09a3f744d6bac96f25e25d20b3ded (diff) | |
download | linux-stable-99d930c0ffe5396442f93cd3c421a9bd1984b923.tar.gz linux-stable-99d930c0ffe5396442f93cd3c421a9bd1984b923.tar.bz2 linux-stable-99d930c0ffe5396442f93cd3c421a9bd1984b923.zip |
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/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index fbb92e6434e9..aaa01ccf3e10 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -636,6 +636,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block, struct ext4_extent_header *eh; struct buffer_head *bh; short int depth, i, ppos = 0, alloc = 0; + int ret; eh = ext_inode_hdr(inode); depth = ext_depth(inode); @@ -665,12 +666,15 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block, path[ppos].p_ext = NULL; bh = sb_getblk(inode->i_sb, path[ppos].p_block); - if (unlikely(!bh)) + if (unlikely(!bh)) { + ret = -ENOMEM; goto err; + } if (!bh_uptodate_or_lock(bh)) { trace_ext4_ext_load_extent(inode, block, path[ppos].p_block); - if (bh_submit_read(bh) < 0) { + ret = bh_submit_read(bh); + if (ret < 0) { put_bh(bh); goto err; } @@ -683,13 +687,15 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block, put_bh(bh); EXT4_ERROR_INODE(inode, "ppos %d > depth %d", ppos, depth); + ret = -EIO; goto err; } path[ppos].p_bh = bh; path[ppos].p_hdr = eh; i--; - if (need_to_validate && ext4_ext_check(inode, eh, i)) + ret = need_to_validate ? ext4_ext_check(inode, eh, i) : 0; + if (ret < 0) goto err; } @@ -711,7 +717,7 @@ err: ext4_ext_drop_refs(path); if (alloc) kfree(path); - return ERR_PTR(-EIO); + return ERR_PTR(ret); } /* @@ -866,7 +872,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, } bh = sb_getblk(inode->i_sb, newblock); if (!bh) { - err = -EIO; + err = -ENOMEM; goto cleanup; } lock_buffer(bh); @@ -938,7 +944,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, newblock = ablocks[--a]; bh = sb_getblk(inode->i_sb, newblock); if (!bh) { - err = -EIO; + err = -ENOMEM; goto cleanup; } lock_buffer(bh); @@ -1049,11 +1055,8 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, return err; bh = sb_getblk(inode->i_sb, newblock); - if (!bh) { - err = -EIO; - ext4_std_error(inode->i_sb, err); - return err; - } + if (!bh) + return -ENOMEM; lock_buffer(bh); err = ext4_journal_get_create_access(handle, bh); |