1 ext4: simplify some code in read_mmp_block()
3 From: Dan Carpenter <dan.carpenter@oracle.com>
5 My static check complains because we have:
11 The second check is unnecessary.
13 I've simplified this code by moving the "if (!*bh)" checks around. Also
14 Andreas Dilger says we should probably print a warning if sb_getblk()
17 [ Restructured the code so that we print a warning message as well if
18 the mmp block doesn't check out, and to print the error code to
19 disambiguate between the error cases. - TYT ]
21 Reviewed-by: Andreas Dilger <adilger@dilger.ca>
22 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
23 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
25 fs/ext4/mmp.c | 46 +++++++++++++++++++++++++---------------------
26 1 file changed, 25 insertions(+), 21 deletions(-)
28 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
29 index 8313ca3..048c52a 100644
32 @@ -69,6 +69,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
33 ext4_fsblk_t mmp_block)
35 struct mmp_struct *mmp;
39 clear_buffer_uptodate(*bh);
40 @@ -76,33 +77,36 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
41 /* This would be sb_bread(sb, mmp_block), except we need to be sure
42 * that the MD RAID device cache has been bypassed, and that the read
43 * is not blocked in the elevator. */
46 *bh = sb_getblk(sb, mmp_block);
52 - (*bh)->b_end_io = end_buffer_read_sync;
53 - submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh);
54 - wait_on_buffer(*bh);
55 - if (!buffer_uptodate(*bh)) {
63 - if (unlikely(!*bh)) {
64 - ext4_warning(sb, "Error while reading MMP block %llu",
70 + (*bh)->b_end_io = end_buffer_read_sync;
71 + submit_bh(READ_SYNC | REQ_META | REQ_PRIO, *bh);
72 + wait_on_buffer(*bh);
73 + if (!buffer_uptodate(*bh)) {
80 mmp = (struct mmp_struct *)((*bh)->b_data);
81 - if (le32_to_cpu(mmp->mmp_magic) != EXT4_MMP_MAGIC ||
82 - !ext4_mmp_csum_verify(sb, mmp))
86 + if (le32_to_cpu(mmp->mmp_magic) == EXT4_MMP_MAGIC &&
87 + ext4_mmp_csum_verify(sb, mmp))
92 + ext4_warning(sb, "Error %d while reading MMP block %llu",