From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, "Theodore Tso" <tytso@mit.edu>
Subject: [ 48/77] ext4: return ENOMEM if sb_getblk() fails
Date: Fri, 1 Mar 2013 11:44:33 -0800 [thread overview]
Message-ID: <20130301194357.044995353@linuxfoundation.org> (raw)
In-Reply-To: <20130301194351.913471337@linuxfoundation.org>
3.8-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <tytso@mit.edu>
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/ext4/extents.c | 25 ++++++++++++++-----------
fs/ext4/indirect.c | 9 ++++++---
fs/ext4/inline.c | 2 +-
fs/ext4/inode.c | 9 +++------
fs/ext4/mmp.c | 2 ++
fs/ext4/resize.c | 8 ++++----
fs/ext4/xattr.c | 3 ++-
7 files changed, 32 insertions(+), 26 deletions(-)
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -725,6 +725,7 @@ ext4_ext_find_extent(struct inode *inode
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);
@@ -752,12 +753,15 @@ ext4_ext_find_extent(struct inode *inode
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;
}
@@ -768,13 +772,15 @@ ext4_ext_find_extent(struct inode *inode
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 (ext4_ext_check_block(inode, eh, i, bh))
+ ret = ext4_ext_check_block(inode, eh, i, bh);
+ if (ret < 0)
goto err;
}
@@ -796,7 +802,7 @@ err:
ext4_ext_drop_refs(path);
if (alloc)
kfree(path);
- return ERR_PTR(-EIO);
+ return ERR_PTR(ret);
}
/*
@@ -951,7 +957,7 @@ static int ext4_ext_split(handle_t *hand
}
bh = sb_getblk(inode->i_sb, newblock);
if (!bh) {
- err = -EIO;
+ err = -ENOMEM;
goto cleanup;
}
lock_buffer(bh);
@@ -1024,7 +1030,7 @@ static int ext4_ext_split(handle_t *hand
newblock = ablocks[--a];
bh = sb_getblk(inode->i_sb, newblock);
if (!bh) {
- err = -EIO;
+ err = -ENOMEM;
goto cleanup;
}
lock_buffer(bh);
@@ -1136,11 +1142,8 @@ static int ext4_ext_grow_indepth(handle_
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);
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -146,6 +146,7 @@ static Indirect *ext4_get_branch(struct
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
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
return NULL;
failure:
- *err = -EIO;
+ *err = ret;
no_block:
return p;
}
@@ -471,7 +474,7 @@ static int ext4_alloc_branch(handle_t *h
*/
bh = sb_getblk(inode->i_sb, new_blocks[n-1]);
if (unlikely(!bh)) {
- err = -EIO;
+ err = -ENOMEM;
goto failed;
}
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1188,7 +1188,7 @@ static int ext4_convert_inline_data_nolo
data_bh = sb_getblk(inode->i_sb, map.m_pblk);
if (!data_bh) {
- error = -EIO;
+ error = -ENOMEM;
goto out_restore;
}
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -714,7 +714,7 @@ struct buffer_head *ext4_getblk(handle_t
bh = sb_getblk(inode->i_sb, map.m_pblk);
if (!bh) {
- *errp = -EIO;
+ *errp = -ENOMEM;
return NULL;
}
if (map.m_flags & EXT4_MAP_NEW) {
@@ -3660,11 +3660,8 @@ static int __ext4_get_inode_loc(struct i
iloc->offset = (inode_offset % inodes_per_block) * EXT4_INODE_SIZE(sb);
bh = sb_getblk(sb, block);
- if (!bh) {
- EXT4_ERROR_INODE_BLOCK(inode, block,
- "unable to read itable block");
- return -EIO;
- }
+ if (!bh)
+ return -ENOMEM;
if (!buffer_uptodate(bh)) {
lock_buffer(bh);
--- a/fs/ext4/mmp.c
+++ b/fs/ext4/mmp.c
@@ -80,6 +80,8 @@ static int read_mmp_block(struct super_b
* is not blocked in the elevator. */
if (!*bh)
*bh = sb_getblk(sb, mmp_block);
+ if (!*bh)
+ return -ENOMEM;
if (*bh) {
get_bh(*bh);
lock_buffer(*bh);
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -334,7 +334,7 @@ static struct buffer_head *bclean(handle
bh = sb_getblk(sb, blk);
if (!bh)
- return ERR_PTR(-EIO);
+ return ERR_PTR(-ENOMEM);
if ((err = ext4_journal_get_write_access(handle, bh))) {
brelse(bh);
bh = ERR_PTR(err);
@@ -411,7 +411,7 @@ static int set_flexbg_block_bitmap(struc
bh = sb_getblk(sb, flex_gd->groups[group].block_bitmap);
if (!bh)
- return -EIO;
+ return -ENOMEM;
err = ext4_journal_get_write_access(handle, bh);
if (err)
@@ -501,7 +501,7 @@ static int setup_new_flex_group_blocks(s
gdb = sb_getblk(sb, block);
if (!gdb) {
- err = -EIO;
+ err = -ENOMEM;
goto out;
}
@@ -1065,7 +1065,7 @@ static void update_backups(struct super_
bh = sb_getblk(sb, backup_block);
if (!bh) {
- err = -EIO;
+ err = -ENOMEM;
break;
}
ext4_debug("update metadata backup %llu(+%llu)\n",
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -887,16 +887,17 @@ inserted:
new_bh = sb_getblk(sb, block);
if (!new_bh) {
+ error = -ENOMEM;
getblk_failed:
ext4_free_blocks(handle, inode, NULL, block, 1,
EXT4_FREE_BLOCKS_METADATA);
- error = -EIO;
goto cleanup;
}
lock_buffer(new_bh);
error = ext4_journal_get_create_access(handle, new_bh);
if (error) {
unlock_buffer(new_bh);
+ error = -EIO;
goto getblk_failed;
}
memcpy(new_bh->b_data, s->base, new_bh->b_size);
next prev parent reply other threads:[~2013-03-01 19:44 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-01 19:43 [ 00/77] 3.8.2-stable review Greg Kroah-Hartman
2013-03-01 19:43 ` [ 01/77] mm: do not grow the stack vma just because of an overrun on preceding vma Greg Kroah-Hartman
2013-03-01 19:43 ` [ 02/77] ALSA: bt87x: Make load_all parameter working again Greg Kroah-Hartman
2013-03-01 19:43 ` [ 03/77] ALSA: hda - hdmi: Make jacks phantom, if theyre not detectable Greg Kroah-Hartman
2013-03-01 19:43 ` [ 04/77] ALSA: emu10k1: Fix regression in emu1010 firmware loading Greg Kroah-Hartman
2013-03-01 19:43 ` [ 05/77] ALSA: emu10k1: Load firmware when it was already cached Greg Kroah-Hartman
2013-03-01 19:43 ` [ 06/77] IB/srp: Track connection state properly Greg Kroah-Hartman
2013-03-01 19:43 ` [ 07/77] IB/srp: Avoid sending a task management function needlessly Greg Kroah-Hartman
2013-03-01 19:43 ` [ 08/77] IB/srp: Avoid endless SCSI error handling loop Greg Kroah-Hartman
2013-03-01 19:43 ` [ 09/77] IB/srp: Fail I/O requests if the transport is offline Greg Kroah-Hartman
2013-03-01 19:43 ` [ 10/77] quota: autoload the quota_v2 module for QFMT_VFS_V1 quota format Greg Kroah-Hartman
2013-03-01 19:43 ` [ 11/77] usb: dwc3: Enable usb2 LPM only when connected as usb2.0 Greg Kroah-Hartman
2013-03-01 19:43 ` [ 12/77] usb: dwc3: gadget: fix missed isoc Greg Kroah-Hartman
2013-03-01 19:43 ` [ 13/77] usb: dwc3: gadget: fix isoc END TRANSFER Condition Greg Kroah-Hartman
2013-03-01 19:43 ` [ 14/77] usb: dwc3: gadget: fix skip LINK_TRB on ISOC Greg Kroah-Hartman
2013-03-01 19:44 ` [ 15/77] usb: dwc3: gadget: change HIRD threshold to 12 Greg Kroah-Hartman
2013-03-01 19:44 ` [ 16/77] b43: Fix lockdep splat on module unload Greg Kroah-Hartman
2013-03-01 19:44 ` [ 17/77] UBIFS: fix use of freed ubifs_orphan objects Greg Kroah-Hartman
2013-03-01 19:44 ` [ 18/77] UBIFS: fix double free of " Greg Kroah-Hartman
2013-03-01 19:44 ` [ 19/77] iommu/amd: Initialize device table after dma_ops Greg Kroah-Hartman
2013-03-01 19:44 ` [ 20/77] posix-timer: Dont call idr_find() with out-of-range ID Greg Kroah-Hartman
2013-03-01 19:44 ` [ 21/77] ftrace: Call ftrace cleanup module notifier after all other notifiers Greg Kroah-Hartman
2013-03-01 19:44 ` [ 22/77] x86/apic: Fix parsing of the lapic cmdline option Greg Kroah-Hartman
2013-03-01 19:44 ` [ 23/77] x86, efi: Make "noefi" really disable EFI runtime serivces Greg Kroah-Hartman
2013-03-01 19:44 ` [ 24/77] doc, xen: Mention earlyprintk=xen in the documentation Greg Kroah-Hartman
2013-03-01 19:44 ` [ 25/77] doc, kernel-parameters: Document console=hvc<n> Greg Kroah-Hartman
2013-03-01 19:44 ` [ 26/77] x86: Make sure we can boot in the case the BDA contains pure garbage Greg Kroah-Hartman
2013-03-01 19:44 ` [ 27/77] target: Fix lookup of dynamic NodeACLs during cached demo-mode operation Greg Kroah-Hartman
2013-03-01 19:44 ` [ 28/77] target: Add missing mapped_lun bounds checking during make_mappedlun setup Greg Kroah-Hartman
2013-03-01 19:44 ` [ 29/77] ocfs2: fix possible use-after-free with AIO Greg Kroah-Hartman
2013-03-01 19:44 ` [ 30/77] ocfs2: fix ocfs2_init_security_and_acl() to initialize acl correctly Greg Kroah-Hartman
2013-03-01 19:44 ` [ 31/77] ocfs2: ac->ac_allow_chain_relink=0 wont disable group relink Greg Kroah-Hartman
2013-03-01 19:44 ` [ 32/77] block: fix ext_devt_idr handling Greg Kroah-Hartman
2013-03-01 19:44 ` [ 33/77] xen-blkback: do not leak mode property Greg Kroah-Hartman
2013-03-01 19:44 ` [ 34/77] xen/blkback: Dont trust the handle from the frontend Greg Kroah-Hartman
2013-03-01 21:12 ` Paul Bolle
2013-03-02 19:48 ` Ben Hutchings
2013-03-02 22:35 ` Paul Bolle
2013-03-02 23:10 ` Ben Hutchings
2013-03-03 10:20 ` Paul Bolle
2013-03-04 2:45 ` Greg Kroah-Hartman
2013-03-04 7:55 ` Jan Beulich
2013-03-04 9:11 ` Paul Bolle
2013-03-04 9:14 ` Jan Beulich
2013-03-04 15:02 ` Konrad Rzeszutek Wilk
2013-03-12 22:10 ` Greg Kroah-Hartman
2013-04-03 14:01 ` William Dauchy
2013-04-03 16:01 ` Greg Kroah-Hartman
2013-04-03 16:38 ` Konrad Rzeszutek Wilk
2013-04-03 17:08 ` Greg Kroah-Hartman
2013-03-01 19:44 ` [ 35/77] xen-blkfront: drop the use of llist_for_each_entry_safe Greg Kroah-Hartman
2013-03-01 19:44 ` [ 36/77] xen-blkback: use balloon pages for persistent grants Greg Kroah-Hartman
2013-03-01 19:44 ` [ 37/77] idr: fix a subtle bug in idr_get_next() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 38/77] block: fix synchronization and limit check in blk_alloc_devt() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 39/77] firewire: add minor number range check to fw_device_init() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 40/77] sysctl: fix null checking in bin_dn_node_address() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 41/77] nbd: fsync and kill block device on shutdown Greg Kroah-Hartman
2013-03-01 19:44 ` [ 42/77] fs: Fix possible use-after-free with AIO Greg Kroah-Hartman
2013-03-01 19:44 ` [ 43/77] ext4: fix " Greg Kroah-Hartman
2013-03-01 19:44 ` [ 44/77] media: cx18/ivtv: fix regression: remove __init from a non-init function Greg Kroah-Hartman
2013-03-01 19:44 ` [ 45/77] media: v4l: Reset subdev v4l2_dev field to NULL if registration fails Greg Kroah-Hartman
2013-03-01 19:44 ` [ 46/77] media: omap_vout: find_vma() needs ->mmap_sem held Greg Kroah-Hartman
2013-03-01 19:44 ` [ 47/77] media: rc: unlock on error in show_protocols() Greg Kroah-Hartman
2013-03-01 19:44 ` Greg Kroah-Hartman [this message]
2013-03-01 19:44 ` [ 49/77] ext4: check bh in ext4_read_block_bitmap() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 50/77] ext4: release sysfs kobject when failing to enable quotas on mount Greg Kroah-Hartman
2013-03-01 19:44 ` [ 51/77] ext4: fix race in ext4_mb_add_n_trim() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 52/77] ext4: fix xattr block allocation/release with bigalloc Greg Kroah-Hartman
2013-03-01 19:44 ` [ 53/77] ext4: fix free clusters calculation in bigalloc filesystem Greg Kroah-Hartman
2013-03-01 19:44 ` [ 54/77] nfsd: Fix memleak Greg Kroah-Hartman
2013-03-01 19:44 ` [ 55/77] svcrpc: make svc_age_temp_xprts enqueue under sv_lock Greg Kroah-Hartman
2013-03-01 19:44 ` [ 56/77] svcrpc: fix rpc server shutdown races Greg Kroah-Hartman
2013-03-01 19:44 ` [ 57/77] HID: add support for Sony RF receiver with USB product id 0x0374 Greg Kroah-Hartman
2013-03-01 19:44 ` [ 58/77] HID: clean up quirk for Sony RF receivers Greg Kroah-Hartman
2013-03-01 19:44 ` [ 59/77] fuse: dont WARN when nlink is zero Greg Kroah-Hartman
2013-03-01 19:44 ` [ 60/77] workqueue: consider work function when searching for busy work items Greg Kroah-Hartman
2013-03-01 19:44 ` [ 61/77] pstore: Avoid deadlock in panic and emergency-restart path Greg Kroah-Hartman
2013-03-01 19:44 ` [ 62/77] cpuset: fix cpuset_print_task_mems_allowed() vs rename() race Greg Kroah-Hartman
2013-03-01 19:44 ` [ 63/77] cgroup: fix exit() vs rmdir() race Greg Kroah-Hartman
2013-03-01 19:44 ` [ 64/77] bq27x00_battery: Fix bugs introduced with BQ27425 support Greg Kroah-Hartman
2013-03-01 19:44 ` [ 65/77] ab8500-chargalg: Only root should have write permission on sysfs file Greg Kroah-Hartman
2013-03-01 19:44 ` [ 66/77] ab8500_btemp: Demote initcall sequence Greg Kroah-Hartman
2013-03-01 19:44 ` [ 67/77] ACPI: Add DMI entry for Sony VGN-FW41E_H Greg Kroah-Hartman
2013-03-01 19:44 ` [ 68/77] staging: comedi: check s->async for poll(), read() and write() Greg Kroah-Hartman
2013-03-01 19:44 ` [ 69/77] ata_piix: IDE-mode SATA patch for Intel Avoton DeviceIDs Greg Kroah-Hartman
2013-03-01 19:44 ` [ 70/77] ata_piix: Add Device IDs for Intel Wellsburg PCH Greg Kroah-Hartman
2013-03-01 19:44 ` [ 71/77] ahci: AHCI-mode SATA patch for Intel Avoton DeviceIDs Greg Kroah-Hartman
2013-03-01 19:44 ` [ 72/77] ahci: Add Device IDs for Intel Wellsburg PCH Greg Kroah-Hartman
2013-03-01 19:44 ` [ 73/77] [hid] usb hid quirks for Masterkit MA901 usb radio Greg Kroah-Hartman
2013-03-04 11:05 ` Alexey Klimov
2013-03-04 14:25 ` Ben Hutchings
2013-03-01 19:44 ` [ 74/77] x86, efi: Allow slash in file path of initrd Greg Kroah-Hartman
2013-03-01 19:45 ` [ 75/77] ACPI: Overriding ACPI tables via initrd only works with an initrd and on X86 Greg Kroah-Hartman
2013-03-01 19:45 ` [ 76/77] efivarfs: Validate filenames much more aggressively Greg Kroah-Hartman
2013-03-01 19:45 ` [ 77/77] efivarfs: guid part of filenames are case-insensitive Greg Kroah-Hartman
2013-03-02 3:59 ` [ 00/77] 3.8.2-stable review Shuah Khan
2013-03-02 5:21 ` Greg Kroah-Hartman
2013-03-03 11:49 ` Satoru Takeuchi
2013-03-03 15:26 ` Greg Kroah-Hartman
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=20130301194357.044995353@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
/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).