From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
alan@lxorguk.ukuu.org.uk, Tao Ma <boyu.mt@taobao.com>,
"Theodore Tso" <tytso@mit.edu>,
Lukas Czerner <lczerner@redhat.com>
Subject: [ 02/85] ext4: Checksum the block bitmap properly with bigalloc enabled
Date: Thu, 25 Oct 2012 17:05:20 -0700 [thread overview]
Message-ID: <20121026000031.372997632@linuxfoundation.org> (raw)
In-Reply-To: <20121026000031.107227138@linuxfoundation.org>
3.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tao Ma <boyu.mt@taobao.com>
commit 79f1ba49569e5aec919b653c55b03274c2331701 upstream.
In mke2fs, we only checksum the whole bitmap block and it is right.
While in the kernel, we use EXT4_BLOCKS_PER_GROUP to indicate the
size of the checksumed bitmap which is wrong when we enable bigalloc.
The right size should be EXT4_CLUSTERS_PER_GROUP and this patch fixes
it.
Also as every caller of ext4_block_bitmap_csum_set and
ext4_block_bitmap_csum_verify pass in EXT4_BLOCKS_PER_GROUP(sb)/8,
we'd better removes this parameter and sets it in the function itself.
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/ext4/balloc.c | 8 +++-----
fs/ext4/bitmap.c | 6 ++++--
fs/ext4/ext4.h | 4 ++--
fs/ext4/ialloc.c | 4 +---
fs/ext4/mballoc.c | 9 +++------
fs/ext4/resize.c | 3 +--
6 files changed, 14 insertions(+), 20 deletions(-)
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -174,8 +174,7 @@ void ext4_init_block_bitmap(struct super
ext4_free_inodes_set(sb, gdp, 0);
ext4_itable_unused_set(sb, gdp, 0);
memset(bh->b_data, 0xff, sb->s_blocksize);
- ext4_block_bitmap_csum_set(sb, block_group, gdp, bh,
- EXT4_BLOCKS_PER_GROUP(sb) / 8);
+ ext4_block_bitmap_csum_set(sb, block_group, gdp, bh);
return;
}
memset(bh->b_data, 0, sb->s_blocksize);
@@ -212,8 +211,7 @@ void ext4_init_block_bitmap(struct super
*/
ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group),
sb->s_blocksize * 8, bh->b_data);
- ext4_block_bitmap_csum_set(sb, block_group, gdp, bh,
- EXT4_BLOCKS_PER_GROUP(sb) / 8);
+ ext4_block_bitmap_csum_set(sb, block_group, gdp, bh);
ext4_group_desc_csum_set(sb, block_group, gdp);
}
@@ -350,7 +348,7 @@ void ext4_validate_block_bitmap(struct s
return;
}
if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
- desc, bh, EXT4_BLOCKS_PER_GROUP(sb) / 8))) {
+ desc, bh))) {
ext4_unlock_group(sb, block_group);
ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
return;
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -58,11 +58,12 @@ void ext4_inode_bitmap_csum_set(struct s
int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
- struct buffer_head *bh, int sz)
+ struct buffer_head *bh)
{
__u32 hi;
__u32 provided, calculated;
struct ext4_sb_info *sbi = EXT4_SB(sb);
+ int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
@@ -84,8 +85,9 @@ int ext4_block_bitmap_csum_verify(struct
void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
- struct buffer_head *bh, int sz)
+ struct buffer_head *bh)
{
+ int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
__u32 csum;
struct ext4_sb_info *sbi = EXT4_SB(sb);
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1867,10 +1867,10 @@ int ext4_inode_bitmap_csum_verify(struct
struct buffer_head *bh, int sz);
void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
- struct buffer_head *bh, int sz);
+ struct buffer_head *bh);
int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
struct ext4_group_desc *gdp,
- struct buffer_head *bh, int sz);
+ struct buffer_head *bh);
/* balloc.c */
extern void ext4_validate_block_bitmap(struct super_block *sb,
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -753,9 +753,7 @@ got:
ext4_free_group_clusters_set(sb, gdp,
ext4_free_clusters_after_init(sb, group, gdp));
ext4_block_bitmap_csum_set(sb, group, gdp,
- block_bitmap_bh,
- EXT4_BLOCKS_PER_GROUP(sb) /
- 8);
+ block_bitmap_bh);
ext4_group_desc_csum_set(sb, group, gdp);
}
ext4_unlock_group(sb, group);
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2804,8 +2804,7 @@ ext4_mb_mark_diskspace_used(struct ext4_
}
len = ext4_free_group_clusters(sb, gdp) - ac->ac_b_ex.fe_len;
ext4_free_group_clusters_set(sb, gdp, len);
- ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh,
- EXT4_BLOCKS_PER_GROUP(sb) / 8);
+ ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh);
ext4_group_desc_csum_set(sb, ac->ac_b_ex.fe_group, gdp);
ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
@@ -4664,8 +4663,7 @@ do_more:
ret = ext4_free_group_clusters(sb, gdp) + count_clusters;
ext4_free_group_clusters_set(sb, gdp, ret);
- ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh,
- EXT4_BLOCKS_PER_GROUP(sb) / 8);
+ ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh);
ext4_group_desc_csum_set(sb, block_group, gdp);
ext4_unlock_group(sb, block_group);
percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters);
@@ -4809,8 +4807,7 @@ int ext4_group_add_blocks(handle_t *hand
mb_free_blocks(NULL, &e4b, bit, count);
blk_free_count = blocks_freed + ext4_free_group_clusters(sb, desc);
ext4_free_group_clusters_set(sb, desc, blk_free_count);
- ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh,
- EXT4_BLOCKS_PER_GROUP(sb) / 8);
+ ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh);
ext4_group_desc_csum_set(sb, block_group, desc);
ext4_unlock_group(sb, block_group);
percpu_counter_add(&sbi->s_freeclusters_counter,
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1121,8 +1121,7 @@ static int ext4_set_bitmap_checksums(str
bh = ext4_get_bitmap(sb, group_data->block_bitmap);
if (!bh)
return -EIO;
- ext4_block_bitmap_csum_set(sb, group, gdp, bh,
- EXT4_BLOCKS_PER_GROUP(sb) / 8);
+ ext4_block_bitmap_csum_set(sb, group, gdp, bh);
brelse(bh);
return 0;
next prev parent reply other threads:[~2012-10-26 0:05 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-26 0:05 [ 00/85] 3.6.4-stable review Greg Kroah-Hartman
2012-10-26 0:05 ` [ 01/85] ext4: race-condition protection for ext4_convert_unwritten_extents_endio Greg Kroah-Hartman
2012-10-26 0:05 ` Greg Kroah-Hartman [this message]
2012-10-26 0:05 ` [ 03/85] ext4: Avoid underflow in ext4_trim_fs() Greg Kroah-Hartman
2012-10-26 0:05 ` [ 04/85] usbdevfs: Fix broken scatter-gather transfer Greg Kroah-Hartman
2012-10-26 0:05 ` [ 05/85] hwmon: (coretemp) Add support for Atom CE4110/4150/4170 Greg Kroah-Hartman
2012-10-26 0:05 ` [ 06/85] nohz: Fix idle ticks in cpu summary line of /proc/stat Greg Kroah-Hartman
2012-10-26 0:05 ` [ 07/85] arch/tile: avoid generating .eh_frame information in modules Greg Kroah-Hartman
2012-10-26 0:05 ` [ 08/85] NLM: nlm_lookup_file() may return NLMv4-specific error codes Greg Kroah-Hartman
2012-10-26 0:05 ` [ 09/85] oprofile, x86: Fix wrapping bug in op_x86_get_ctrl() Greg Kroah-Hartman
2012-10-26 0:05 ` [ 10/85] s390: fix linker script for 31 bit builds Greg Kroah-Hartman
2012-10-26 0:05 ` [ 11/85] SUNRPC: Prevent kernel stack corruption on long values of flush Greg Kroah-Hartman
2012-10-26 0:05 ` [ 12/85] SUNRPC: Set alloc_slot for backchannel tcp ops Greg Kroah-Hartman
2012-10-26 0:05 ` [ 13/85] ring-buffer: Check for uninitialized cpu buffer before resizing Greg Kroah-Hartman
2012-10-26 0:05 ` [ 14/85] pcmcia: sharpsl: dont discard sharpsl_pcmcia_ops Greg Kroah-Hartman
2012-10-26 0:05 ` [ 15/85] kernel/sys.c: fix stack memory content leak via UNAME26 Greg Kroah-Hartman
2012-10-26 0:05 ` [ 17/85] x86, amd, mce: Avoid NULL pointer reference on CPU northbridge lookup Greg Kroah-Hartman
2012-10-26 0:05 ` [ 18/85] x86: Exclude E820_RESERVED regions and memory holes above 4 GB from direct mapping Greg Kroah-Hartman
2012-10-27 16:27 ` Ben Hutchings
2012-10-26 0:05 ` [ 19/85] xen/x86: dont corrupt %eip when returning from a signal handler Greg Kroah-Hartman
2012-10-26 0:05 ` [ 20/85] USB: cdc-acm: fix pipe type of write endpoint Greg Kroah-Hartman
2012-10-26 0:05 ` [ 21/85] usb: acm: fix the computation of the number of data bits Greg Kroah-Hartman
2012-10-26 0:05 ` [ 22/85] USB: io_ti: fix port-data memory leak Greg Kroah-Hartman
2012-10-26 0:05 ` [ 23/85] USB: io_ti: fix sysfs-attribute creation Greg Kroah-Hartman
2012-10-26 0:05 ` [ 24/85] USB: cyberjack: fix port-data memory leak Greg Kroah-Hartman
2012-10-26 0:05 ` [ 25/85] usb: musb: am35xx: drop spurious unplugging a device Greg Kroah-Hartman
2012-10-26 0:05 ` [ 26/85] usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP Greg Kroah-Hartman
2012-10-27 17:18 ` Ben Hutchings
2012-11-01 19:25 ` Sarah Sharp
2012-10-26 0:05 ` [ 27/85] USB: iuu_phoenix: fix port-data memory leak Greg Kroah-Hartman
2012-10-26 0:05 ` [ 28/85] USB: iuu_phoenix: fix sysfs-attribute creation Greg Kroah-Hartman
2012-10-26 0:05 ` [ 29/85] USB: ark3116: fix NULL-pointer dereference Greg Kroah-Hartman
2012-10-26 0:05 ` [ 30/85] USB: f81232: fix port-data memory leak Greg Kroah-Hartman
2012-10-26 0:05 ` [ 31/85] USB: oti6858: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 32/85] USB: belkin_sa: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 33/85] USB: pl2303: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 34/85] USB: ssu100: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 35/85] USB: kobil_sct: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 36/85] USB: cypress_m8: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 37/85] USB: cp210x: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 38/85] USB: spcp8x5: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 39/85] USB: ti_usb_3410_5052: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 40/85] USB: kl5kusb105: " Greg Kroah-Hartman
2012-10-26 0:05 ` [ 41/85] USB: io_edgeport: " Greg Kroah-Hartman
2012-10-26 0:06 ` [ 42/85] USB: keyspan_pda: " Greg Kroah-Hartman
2012-10-26 0:06 ` [ 43/85] USB: option: blacklist net interface on ZTE devices Greg Kroah-Hartman
2012-10-26 0:06 ` [ 44/85] USB: option: add more " Greg Kroah-Hartman
2012-10-26 0:06 ` [ 45/85] usb: dwc3: gadget: fix endpoint always busy bug Greg Kroah-Hartman
2012-10-26 0:06 ` [ 46/85] usb: Dont enable LPM if the exit latency is zero Greg Kroah-Hartman
2012-10-26 0:06 ` [ 47/85] USB: Enable LPM after a failed probe Greg Kroah-Hartman
2012-10-26 0:06 ` [ 48/85] usb: Send Set SEL before enabling parent U1/U2 timeout Greg Kroah-Hartman
2012-10-26 0:06 ` [ 49/85] USB: fix port probing and removal in garmin_gps Greg Kroah-Hartman
2012-10-26 0:06 ` [ 50/85] cgroup: notify_on_release may not be triggered in some cases Greg Kroah-Hartman
2012-10-26 0:06 ` [ 51/85] Revert "cgroup: Remove task_lock() from cgroup_post_fork()" Greg Kroah-Hartman
2012-10-26 0:06 ` [ 52/85] Revert "cgroup: Drop task_lock(parent) on cgroup_fork()" Greg Kroah-Hartman
2012-10-26 0:06 ` [ 53/85] pinctrl: tegra: correct bank for pingroup and drv pingroup Greg Kroah-Hartman
2012-10-26 0:06 ` [ 54/85] dt: Document: correct tegra20/30 pinctrl slew-rate name Greg Kroah-Hartman
2012-10-26 0:06 ` [ 55/85] pinctrl: tegra: set low power mode bank width to 2 Greg Kroah-Hartman
2012-10-26 0:06 ` [ 56/85] pinctrl: remove mutex lock in groups show Greg Kroah-Hartman
2012-10-26 0:06 ` [ 57/85] pinctrl: fix missing unlock on error in pinctrl_groups_show() Greg Kroah-Hartman
2012-10-26 0:06 ` [ 58/85] iommu/tegra: smmu: Fix deadly typo Greg Kroah-Hartman
2012-10-26 0:06 ` [ 59/85] amd64_edac:__amd64_set_scrub_rate(): avoid overindexing scrubrates[] Greg Kroah-Hartman
2012-10-26 0:06 ` [ 60/85] xtensa: add missing system calls to the syscall table Greg Kroah-Hartman
2012-10-27 18:26 ` Ben Hutchings
2012-10-27 21:08 ` Chris Zankel
2012-10-26 0:06 ` [ 61/85] media: au0828: fix case where STREAMOFF being called on stopped stream causes BUG() Greg Kroah-Hartman
2012-10-26 0:06 ` [ 62/85] drm/i915: Use cpu relocations if the object is in the GTT but not mappable Greg Kroah-Hartman
2012-10-26 0:06 ` [ 63/85] netlink: add reference of module in netlink_dump_start Greg Kroah-Hartman
2012-10-26 0:06 ` [ 64/85] infiniband: pass rdma_cm module to netlink_dump_start Greg Kroah-Hartman
2012-10-26 0:06 ` [ 65/85] net: remove skb recycling Greg Kroah-Hartman
2012-10-26 0:06 ` [ 66/85] net: Fix skb_under_panic oops in neigh_resolve_output Greg Kroah-Hartman
2012-10-26 0:06 ` [ 67/85] ipv6: GRO should be ECN friendly Greg Kroah-Hartman
2012-10-26 0:06 ` [ 68/85] ipv4: Always invalidate or update the route on pmtu events Greg Kroah-Hartman
2012-10-26 0:06 ` [ 69/85] ipv4: Dont create nh exeption when the device mtu is smaller than the reported pmtu Greg Kroah-Hartman
2012-10-26 0:06 ` [ 70/85] ipv4: Dont report stale pmtu values to userspace Greg Kroah-Hartman
2012-10-26 0:06 ` [ 71/85] skge: Add DMA mask quirk for Marvell 88E8001 on ASUS P5NSLI motherboard Greg Kroah-Hartman
2012-10-26 0:06 ` [ 72/85] vlan: dont deliver frames for unknown vlans to protocols Greg Kroah-Hartman
2012-10-26 0:06 ` [ 73/85] ipv4: fix sending of redirects Greg Kroah-Hartman
2012-10-26 0:06 ` [ 74/85] ipv4: fix forwarding for strict source routes Greg Kroah-Hartman
2012-10-26 0:06 ` [ 75/85] ipv4: make sure nh_pcpu_rth_output is always allocated Greg Kroah-Hartman
2012-10-26 0:06 ` [ 76/85] ipv4: introduce rt_uses_gateway Greg Kroah-Hartman
2012-10-26 0:06 ` [ 77/85] ipv4: Add FLOWI_FLAG_KNOWN_NH Greg Kroah-Hartman
2012-10-26 0:06 ` [ 78/85] ipvs: fix ARP resolving for direct routing mode Greg Kroah-Hartman
2012-10-26 0:06 ` [ 79/85] RDS: fix rds-ping spinlock recursion Greg Kroah-Hartman
2012-10-26 0:06 ` [ 80/85] tcp: resets are misrouted Greg Kroah-Hartman
2012-10-26 0:06 ` [ 81/85] ipv6: addrconf: fix /proc/net/if_inet6 Greg Kroah-Hartman
2012-10-26 0:06 ` [ 82/85] sparc64: fix ptrace interaction with force_successful_syscall_return() Greg Kroah-Hartman
2012-10-26 0:06 ` [ 83/85] sparc64: Like x86 we should check current->mm during perf backtrace generation Greg Kroah-Hartman
2012-10-26 0:06 ` [ 84/85] sparc64: Fix bit twiddling in sparc_pmu_enable_event() Greg Kroah-Hartman
2012-10-26 0:06 ` [ 85/85] mac80211: call drv_get_tsf() in sleepable context 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=20121026000031.372997632@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=boyu.mt@taobao.com \
--cc=lczerner@redhat.com \
--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).