[PATCH 4/5] Fix reading of 32-bit tag descriptors

Stephen Tweedie <[email protected]>
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
We must never attempt to read the high 32-bits of a descriptor tag on
a 32-bit journal, even when CONFIG_LBD is set, as we'll end up reading
garbage from the subsequent tag.

Signed-off-by: Stephen Tweedie <[email protected]>
---
 fs/jbd/recovery.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c
index ec8a206..a5fb515 100644
--- a/fs/jbd/recovery.c
+++ b/fs/jbd/recovery.c
@@ -308,11 +308,12 @@ #endif
 	return err;
 }
 
-static inline u64 read_split_be64(__be32 *high, __be32 *low)
+static inline sector_t read_tag_block(int tag_bytes, journal_block_tag_t *tag)
 {
-	u64 ret = be32_to_cpu(*low);
-	ret |= (u64)be32_to_cpu(*high) << 32;
-	return ret;
+	sector_t block = be32_to_cpu(tag->t_blocknr);
+	if (tag_bytes > JBD_TAG_SIZE32)
+		block |= (u64)be32_to_cpu(tag->t_blocknr_high) << 32;
+	return block;
 }
 
 static int do_one_pass(journal_t *journal,
@@ -454,8 +455,8 @@ static int do_one_pass(journal_t *journa
 					sector_t blocknr;
 
 					J_ASSERT(obh != NULL);
-					blocknr = read_split_be64(&tag->t_blocknr_high,
-							&tag->t_blocknr);
+					blocknr = read_tag_block(tag_bytes,
+								 tag);
 
 					/* If the block has been
 					 * revoked, then we're all done
-- 
1.4.0


Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.