Skip to contentSkip to conversation

ext4: fix usless declarations

PATCH Applied Dmitry Monakhov 3 participants 16 messages Apr 3, 2013 – Apr 10, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ext4: fix usless declarations

This patch should fix sparse complains about shadow declatations.

---
 fs/ext4/ialloc.c      |    1 -
 fs/ext4/ioctl.c       |    1 -
 fs/ext4/mballoc.c     |    1 -
 fs/ext4/move_extent.c |    1 -
 4 files changed, 0 insertions(+), 4 deletions(-)
fs/ext4/ialloc.c +0 -1
index 6c5bb8d..4c358f7 100644
@@ -899,7 +899,6 @@ got:
 	if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
 			EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) {
 		__u32 csum;
-		struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 		__le32 inum = cpu_to_le32(inode->i_ino);
 		__le32 gen = cpu_to_le32(inode->i_generation);
 		csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&inum,
fs/ext4/ioctl.c +0 -1
index a07b7bc..fb4e77f 100644
@@ -355,7 +355,6 @@ group_add_out:
 
 	case EXT4_IOC_RESIZE_FS: {
 		ext4_fsblk_t n_blocks_count;
-		struct super_block *sb = inode->i_sb;
 		int err = 0, err2 = 0;
 		ext4_group_t o_group = EXT4_SB(sb)->s_groups_count;
 
fs/ext4/mballoc.c +0 -1
index 580aada..5bf8056 100644
@@ -860,7 +860,6 @@ static int ext4_mb_init_cache(struct page *page, char *incore)
 
 	first_block = page->index * blocks_per_page;
 	for (i = 0; i < blocks_per_page; i++) {
-		int group;
 
 		group = (first_block + i) >> 1;
 		if (group >= ngroups)
fs/ext4/move_extent.c +0 -1
index 33e1c08..7f3ed63 100644
@@ -856,7 +856,6 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
 		if (buffer_uptodate(bh))
 			continue;
 		if (!buffer_mapped(bh)) {
-			int err = 0;
 			err = ext4_get_block(inode, block, bh, 0);
 			if (err) {
 				SetPageError(page);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/2 ext4: fix cpu_vs_disk conversions

All new features are broken on bigendian hosts due to lack of conversion:
es_cache: https://lkml.org/lkml/2013/3/28/64
inode's csum and ext_to_ind_migrate are also broken.

Testcase: make C=2 CF="-D__CHECK_ENDIAN__

---
 fs/ext4/extents.c           |   12 ++++++------
 fs/ext4/indirect.c          |    4 ++--
 fs/ext4/inode.c             |    8 ++++----
 fs/ext4/mmp.c               |    2 +-
 fs/ext4/namei.c             |    4 ++--
 fs/ext4/super.c             |    4 ++--
 fs/ext4/xattr.c             |   11 +++++------
 include/trace/events/ext4.h |    6 +++---
 8 files changed, 25 insertions(+), 26 deletions(-)
fs/ext4/extents.c +6 -6
index 1530cf4..3c3410e 100644
@@ -2784,7 +2784,7 @@ again:
 	}
 
 	trace_ext4_ext_remove_space_done(inode, start, depth, partial_cluster,
-			path->p_hdr->eh_entries);
+					 path->p_hdr->eh_entries);
 
 	/* If we still have something in the partial cluster and we have removed
 	 * even the first extent, then we should free the blocks in the partial
@@ -2999,20 +2999,20 @@ static int ext4_split_extent_at(handle_t *handle,
 			if (split_flag & EXT4_EXT_DATA_VALID1) {
 				err = ext4_ext_zeroout(inode, ex2);
 				zero_ex.ee_block = ex2->ee_block;
-				zero_ex.ee_len = ext4_ext_get_actual_len(ex2);
+				zero_ex.ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex2));
 				ext4_ext_store_pblock(&zero_ex,
 						      ext4_ext_pblock(ex2));
 			} else {
 				err = ext4_ext_zeroout(inode, ex);
 				zero_ex.ee_block = ex->ee_block;
-				zero_ex.ee_len = ext4_ext_get_actual_len(ex);
+				zero_ex.ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex));
 				ext4_ext_store_pblock(&zero_ex,
 						      ext4_ext_pblock(ex));
 			}
 		} else {
 			err = ext4_ext_zeroout(inode, &orig_ex);
 			zero_ex.ee_block = orig_ex.ee_block;
-			zero_ex.ee_len = ext4_ext_get_actual_len(&orig_ex);
+			zero_ex.ee_len = cpu_to_le16(ext4_ext_get_actual_len(&orig_ex));
 			ext4_ext_store_pblock(&zero_ex,
 					      ext4_ext_pblock(&orig_ex));
 		}
@@ -3272,7 +3272,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
 		if (err)
 			goto out;
 		zero_ex.ee_block = ex->ee_block;
-		zero_ex.ee_len = ext4_ext_get_actual_len(ex);
+		zero_ex.ee_len = cpu_to_le16(ext4_ext_get_actual_len(ex));
 		ext4_ext_store_pblock(&zero_ex, ext4_ext_pblock(ex));
 
 		err = ext4_ext_get_access(handle, inode, path + depth);
@@ -4639,7 +4639,7 @@ int ext4_ind_migrate(struct inode *inode)
 	eh = ext_inode_hdr(inode);
 	ex  = EXT_FIRST_EXTENT(eh);
 	if (ext4_blocks_count(es) > EXT4_MAX_BLOCK_FILE_PHYS ||
-	    eh->eh_depth != 0 || eh->eh_entries > 1) {
+	    eh->eh_depth != 0 || le16_to_cpu(eh->eh_entries) > 1) {
 		ret = -EOPNOTSUPP;
 		goto errout;
 	}
fs/ext4/indirect.c +2 -2
index 80a798b..98be6f6 100644
@@ -1324,9 +1324,9 @@ static int free_hole_blocks(handle_t *handle, struct inode *inode,
 		blk = *i_data;
 		if (level > 0) {
 			ext4_lblk_t first2;
-			bh = sb_bread(inode->i_sb, blk);
+			bh = sb_bread(inode->i_sb, le32_to_cpu(blk));
 			if (!bh) {
-				EXT4_ERROR_INODE_BLOCK(inode, blk,
+				EXT4_ERROR_INODE_BLOCK(inode, le32_to_cpu(blk),
 						       "Read failure");
 				return -EIO;
 			}
fs/ext4/inode.c +4 -4
index 7712aff..a2c4f14 100644
@@ -55,21 +55,21 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
 	__u16 csum_hi = 0;
 	__u32 csum;
 
-	csum_lo = raw->i_checksum_lo;
+	csum_lo = le16_to_cpu(raw->i_checksum_lo);
 	raw->i_checksum_lo = 0;
 	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
-		csum_hi = raw->i_checksum_hi;
+		csum_hi = le16_to_cpu(raw->i_checksum_hi);
 		raw->i_checksum_hi = 0;
 	}
 
 	csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw,
 			   EXT4_INODE_SIZE(inode->i_sb));
 
-	raw->i_checksum_lo = csum_lo;
+	raw->i_checksum_lo = cpu_to_le16(csum_lo);
 	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
-		raw->i_checksum_hi = csum_hi;
+		raw->i_checksum_hi = cpu_to_le16(csum_hi);
 
 	return csum;
 }
fs/ext4/mmp.c +1 -1
index f9b5515..b3b1f7d 100644
@@ -7,7 +7,7 @@
 #include "ext4.h"
 
 /* Checksumming functions */
-static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
+static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	int offset = offsetof(struct mmp_struct, mmp_checksum);
fs/ext4/namei.c +2 -2
index 3825d6a..5a29ea6 100644
@@ -420,11 +420,11 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
 	int size;
 
 	size = count_offset + (count * sizeof(struct dx_entry));
-	old_csum = t->dt_checksum;
+	old_csum = le32_to_cpu(t->dt_checksum);
 	t->dt_checksum = 0;
 	csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
 	csum = ext4_chksum(sbi, csum, (__u8 *)t, sizeof(struct dx_tail));
-	t->dt_checksum = old_csum;
+	t->dt_checksum = cpu_to_le32(old_csum);
 
 	return cpu_to_le32(csum);
 }
fs/ext4/super.c +2 -2
index 280a918..c712c8f 100644
@@ -1954,13 +1954,13 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
 		__u16 old_csum;
 		__u32 csum32;
 
-		old_csum = gdp->bg_checksum;
+		old_csum = le16_to_cpu(gdp->bg_checksum);
 		gdp->bg_checksum = 0;
 		csum32 = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&le_group,
 				     sizeof(le_group));
 		csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp,
 				     sbi->s_desc_size);
-		gdp->bg_checksum = old_csum;
+		gdp->bg_checksum = cpu_to_le16(old_csum);
 
 		crc = csum32 & 0xFFFF;
 		goto out;
fs/ext4/xattr.c +5 -6
index 3a120b2..34da740 100644
@@ -123,16 +123,15 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	__u32 csum, old;
-
-	old = hdr->h_checksum;
+	__le64 dsk_block_nr = cpu_to_le64(block_nr);
+	old = le32_to_cpu(hdr->h_checksum);
 	hdr->h_checksum = 0;
-	block_nr = cpu_to_le64(block_nr);
-	csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&block_nr,
-			   sizeof(block_nr));
+	csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&dsk_block_nr,
+			   sizeof(dsk_block_nr));
 	csum = ext4_chksum(sbi, csum, (__u8 *)hdr,
 			   EXT4_BLOCK_SIZE(inode->i_sb));
 
-	hdr->h_checksum = old;
+	hdr->h_checksum = cpu_to_le32(old);
 	return cpu_to_le32(csum);
 }
 
include/trace/events/ext4.h +3 -3
index 58459b7..d0e6864 100644
@@ -1948,7 +1948,7 @@ TRACE_EVENT(ext4_remove_blocks,
 		__entry->to		= to;
 		__entry->partial	= partial_cluster;
 		__entry->ee_pblk	= ext4_ext_pblock(ex);
-		__entry->ee_lblk	= cpu_to_le32(ex->ee_block);
+		__entry->ee_lblk	= le32_to_cpu(ex->ee_block);
 		__entry->ee_len		= ext4_ext_get_actual_len(ex);
 	),
 
@@ -2052,7 +2052,7 @@ TRACE_EVENT(ext4_ext_remove_space,
 
 TRACE_EVENT(ext4_ext_remove_space_done,
 	TP_PROTO(struct inode *inode, ext4_lblk_t start, int depth,
-		ext4_lblk_t partial, unsigned short eh_entries),
+		ext4_lblk_t partial, __le16 eh_entries),
 
 	TP_ARGS(inode, start, depth, partial, eh_entries),
 
@@ -2071,7 +2071,7 @@ TRACE_EVENT(ext4_ext_remove_space_done,
 		__entry->start		= start;
 		__entry->depth		= depth;
 		__entry->partial	= partial;
-		__entry->eh_entries	= eh_entries;
+		__entry->eh_entries	= le16_to_cpu(eh_entries);
 	),
 
 	TP_printk("dev %d,%d ino %lu since %u depth %d partial %u "
Signature · 1 line
1.7.1
maintainer
#2 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

Quoted 7 lines · Dmitry Monakhov

All new features are broken on bigendian hosts due to lack of conversion:
es_cache: https://lkml.org/lkml/2013/3/28/64
inode's csum and ext_to_ind_migrate are also broken.

Testcase: make C=2 CF="-D__CHECK_ENDIAN__

Thanks for this comprehensive patch. I'm currently trying to decide how much of this I should try to push in before the next 3.9-rcX window, and how much can wait until the next merge window.

We definitely want to fix the fs corruption bug for big-endian systems. For the rest, I'm on the fence, since they are less likely to bite people hard --- metadata checksum is still pretty new and not fully supported, and the punch hole bug is again also pretty new functionality.

Also, pushing something to Linus now could potentially disrupt the patches in the ext4 dev tree for the next merge window. For the zero extents problem, there's no question what are priorities should be; user dataloss trumps developer convenience any day. For the rest, what do you all think? Are they likely to hit people hard enough that it's worth trying to get this to Linus sooner, as opposed to having the fixes for the rest of the big endian issues land in 3.10 and 3.9.1?

- Ted

#3 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

Quoted 19 lines · Theodore Ts'o
Quoted 7 lines · Dmitry Monakhov

All new features are broken on bigendian hosts due to lack of conversion:
es_cache: https://lkml.org/lkml/2013/3/28/64
inode's csum and ext_to_ind_migrate are also broken.

Testcase: make C=2 CF="-D__CHECK_ENDIAN__

Thanks for this comprehensive patch. I'm currently trying to decide how much of this I should try to push in before the next 3.9-rcX window, and how much can wait until the next merge window.

We definitely want to fix the fs corruption bug for big-endian systems. For the rest, I'm on the fence, since they are less likely to bite people hard --- metadata checksum is still pretty new and not fully supported, and the punch hole bug is again also pretty new functionality.

Quoted 8 lines

Also, pushing something to Linus now could potentially disrupt the patches in the ext4 dev tree for the next merge window. For the zero extents problem, there's no question what are priorities should be; user dataloss trumps developer convenience any day. For the rest, what do you all think? Are they likely to hit people hard enough that it's worth trying to get this to Linus sooner, as opposed to having the fixes for the rest of the big endian issues land in 3.10 and 3.9.1?

Hi Ted,

I agree with you that we need to fix the big-endian bug in extent tree because it affects all people who use ext4 file system. Meanwhile I think we need to fix the problem in punching hole and xattr because that has been there. I have looked at Dmitry's patch, and it fixes some problems that is only in dev branch (e.g. migration). I think this problem can be fixed in 3.10 later. Meanwhile metadata_csum is still under ext4dev. So I think it also can be fixed in next merge window.

Thanks,
- Zheng

maintainer
#4 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

Quoted 7 lines · Zheng Liu

I agree with you that we need to fix the big-endian bug in extent tree because it affects all people who use ext4 file system. Meanwhile I think we need to fix the problem in punching hole and xattr because that has been there. I have looked at Dmitry's patch, and it fixes some problems that is only in dev branch (e.g. migration). I think this problem can be fixed in 3.10 later. Meanwhile metadata_csum is still under ext4dev. So I think it also can be fixed in next merge window.

I took a closer look at the issues that Dmitry found in the checksum code (including in xattr.c), and it doesn't actually fix any runtime bugs. It's mainly issues picked up by static code analyzers, but it's not anything which is high priority to backport to stable kernels.

It's also the case that the zero_ex code was fine in 3.8; the bug where we failed to introduce byte swapping was introduced in 3.9-rc1.

So the good news is that from what I can tell, there is no actual bug leading to fs/data corruption relating to big endian systems in the 3.8.x kernels, and hence, the fixup patch will not need a cc:[email protected] tag.

So what I am currently thinking about doing is fixing the actual bugs (zero_ex and indirect punch hole) for 3.9-rc6. The cleanup changes is important so we can more easily find bugs using static code analyzers, but that can be saved for the next merge window. Sounds like a plan?

- Ted

#5 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

In reply to Theodore Ts'o
Quoted 13 lines · Theodore Ts'o
Quoted 7 lines · Dmitry Monakhov

All new features are broken on bigendian hosts due to lack of conversion:
es_cache: https://lkml.org/lkml/2013/3/28/64
inode's csum and ext_to_ind_migrate are also broken.

Testcase: make C=2 CF="-D__CHECK_ENDIAN__

Thanks for this comprehensive patch. I'm currently trying to decide how much of this I should try to push in before the next 3.9-rcX window, and how much can wait until the next merge window.

Quoted 8 lines

We definitely want to fix the fs corruption bug for big-endian systems. For the rest, I'm on the fence, since they are less likely to bite people hard --- metadata checksum is still pretty new and not fully supported, and the punch hole bug is again also pretty new functionality.

Also, pushing something to Linus now could potentially disrupt the patches in the ext4 dev tree for the next merge window. For the zero

But how? the patch is simple as potato.
It does not conflict with any other patches in dev branch (actually i've prepared it against ext4/dev branch)
Personally I'll vote for rebase ext4/dev to 3.9-rc5 (or rc6) because rc4 has a bug which prevent two of my boxes from boot.
So I can't see any difficulties with it.
But off course if we think in terms of ultra-conservative terms it is reasonable to just push es_cache fixes to linus and leave others for devel branch. IMHO we already have done too many mistakes during that release so it is too late to pretend to being too cautious.

Quoted 12 lines

extents problem, there's no question what are priorities should be; user dataloss trumps developer convenience any day. For the rest, what do you all think? Are they likely to hit people hard enough that it's worth trying to get this to Linus sooner, as opposed to having the fixes for the rest of the big endian issues land in 3.10 and 3.9.1?

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#6 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

In reply to Dmitry Monakhov

fs/ext4/xattr.c static __le32 ext4_xattr_block_csum(struct inode *inode, · line 127

Quoted 12 lines · Dmitry Monakhov
fs/ext4/xattr.c +2 -2
index 3a120b2..34da740 100644
@@ -123,16 +123,15 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	__u32 csum, old;
-
-	old = hdr->h_checksum;
+	__le64 dsk_block_nr = cpu_to_le64(block_nr);
+	old = le32_to_cpu(hdr->h_checksum);

We're just saving and restoring hdr->h_checksum. So instead of byte-swapping the checksum in old, and then swapping it back, why not just do this instead:

     __le32 old;

     old = hdr->h_checksum;
     ...
     hdr->h_checksum = old;

					- Ted
#7 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

Quoted 18 lines · Theodore Ts'o

fs/ext4/xattr.c static __le32 ext4_xattr_block_csum(struct inode *inode, · line 127

Quoted 12 lines · Dmitry Monakhov
fs/ext4/xattr.c +2 -2
index 3a120b2..34da740 100644
@@ -123,16 +123,15 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	__u32 csum, old;
-
-	old = hdr->h_checksum;
+	__le64 dsk_block_nr = cpu_to_le64(block_nr);
+	old = le32_to_cpu(hdr->h_checksum);

We're just saving and restoring hdr->h_checksum. So instead of byte-swapping the checksum in old, and then swapping it back, why not just do this instead:

Quoted 5 lines
     __le32 old;

     old = hdr->h_checksum;
     ...
     hdr->h_checksum = old;

yes. obviously that is correct.

Quoted 6 lines

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw

Re: [PATCH 2/2] ext4: fix cpu_vs_disk conversions

In reply to Dmitry Monakhov

Today I've asked our admins about antiquarian hardware
Now I'm happy owner of:
1) Itanium2 : DualCore Processor 9020 x2 sockets, 12Gb Ram This one is not big-endian(at least linux does not support that) but it has 64k pages which allow hard core testing for 1kb fs block size :)
2) PowerMac: G5 powerpc x2 sockets, 2Gb (big endian arch)

I'll install debian on this irons this weekend. So let's hope we next time will find issues earlier.

maintainer
#10 lore raw

PATCH 1/3 ext4: fix big-endian bug in extent migration code

From: Dmitry Monakhov <[email protected]>

---
 fs/ext4/extents.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/extents.c +1 -1
index c1c0094..fa85ce8 100644
@@ -4760,7 +4760,7 @@ int ext4_ind_migrate(struct inode *inode)
 	eh = ext_inode_hdr(inode);
 	ex  = EXT_FIRST_EXTENT(eh);
 	if (ext4_blocks_count(es) > EXT4_MAX_BLOCK_FILE_PHYS ||
-	    eh->eh_depth != 0 || eh->eh_entries > 1) {
+	    eh->eh_depth != 0 || le16_to_cpu(eh->eh_entries) > 1) {
 		ret = -EOPNOTSUPP;
 		goto errout;
 	}
Signature · 1 line
1.7.12.rc0.22.gcdd159b
maintainer
#11 lore raw

PATCH 2/3 ext4: fix big-endian bug in metadata checksum calculations

From: Dmitry Monakhov <[email protected]>

---
 fs/ext4/inode.c | 8 ++++----
 fs/ext4/mmp.c   | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
fs/ext4/inode.c +4 -4
index 629d67b..62189c8 100644
@@ -55,21 +55,21 @@ static __u32 ext4_inode_csum(struct inode *inode, struct ext4_inode *raw,
 	__u16 csum_hi = 0;
 	__u32 csum;
 
-	csum_lo = raw->i_checksum_lo;
+	csum_lo = le16_to_cpu(raw->i_checksum_lo);
 	raw->i_checksum_lo = 0;
 	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi)) {
-		csum_hi = raw->i_checksum_hi;
+		csum_hi = le16_to_cpu(raw->i_checksum_hi);
 		raw->i_checksum_hi = 0;
 	}
 
 	csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)raw,
 			   EXT4_INODE_SIZE(inode->i_sb));
 
-	raw->i_checksum_lo = csum_lo;
+	raw->i_checksum_lo = cpu_to_le16(csum_lo);
 	if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
 	    EXT4_FITS_IN_INODE(raw, ei, i_checksum_hi))
-		raw->i_checksum_hi = csum_hi;
+		raw->i_checksum_hi = cpu_to_le16(csum_hi);
 
 	return csum;
 }
fs/ext4/mmp.c +1 -1
index f9b5515..b3b1f7d 100644
@@ -7,7 +7,7 @@
 #include "ext4.h"
 
 /* Checksumming functions */
-static __u32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
+static __le32 ext4_mmp_csum(struct super_block *sb, struct mmp_struct *mmp)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	int offset = offsetof(struct mmp_struct, mmp_checksum);
Signature · 1 line
1.7.12.rc0.22.gcdd159b
maintainer
#12 lore raw

PATCH 3/3 ext4: fix miscellaneous big endian warnings

In reply to Theodore Ts'o

None of these result in any bug, but they makes sparse complain.

---
 fs/ext4/namei.c             |  7 ++++---
 fs/ext4/super.c             |  6 +++---
 fs/ext4/xattr.c             | 13 +++++++------
 include/trace/events/ext4.h |  6 +++---
 4 files changed, 17 insertions(+), 15 deletions(-)
fs/ext4/namei.c +4 -3
index ede1337..955c907 100644
@@ -416,15 +416,16 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
 	struct ext4_inode_info *ei = EXT4_I(inode);
-	__u32 csum, old_csum;
+	__u32 csum;
+	__le32 save_csum;
 	int size;
 
 	size = count_offset + (count * sizeof(struct dx_entry));
-	old_csum = t->dt_checksum;
+	save_csum = t->dt_checksum;
 	t->dt_checksum = 0;
 	csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
 	csum = ext4_chksum(sbi, csum, (__u8 *)t, sizeof(struct dx_tail));
-	t->dt_checksum = old_csum;
+	t->dt_checksum = save_csum;
 
 	return cpu_to_le32(csum);
 }
fs/ext4/super.c +3 -3
index 6fea87d..f355c28 100644
@@ -1952,16 +1952,16 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group,
 	if ((sbi->s_es->s_feature_ro_compat &
 	     cpu_to_le32(EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))) {
 		/* Use new metadata_csum algorithm */
-		__u16 old_csum;
+		__le16 save_csum;
 		__u32 csum32;
 
-		old_csum = gdp->bg_checksum;
+		save_csum = gdp->bg_checksum;
 		gdp->bg_checksum = 0;
 		csum32 = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&le_group,
 				     sizeof(le_group));
 		csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp,
 				     sbi->s_desc_size);
-		gdp->bg_checksum = old_csum;
+		gdp->bg_checksum = save_csum;
 
 		crc = csum32 & 0xFFFF;
 		goto out;
fs/ext4/xattr.c +7 -6
index 3a120b2..c081e34 100644
@@ -122,17 +122,18 @@ static __le32 ext4_xattr_block_csum(struct inode *inode,
 				    struct ext4_xattr_header *hdr)
 {
 	struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
-	__u32 csum, old;
+	__u32 csum;
+	__le32 save_csum;
+	__le64 dsk_block_nr = cpu_to_le64(block_nr);
 
-	old = hdr->h_checksum;
+	save_csum = hdr->h_checksum;
 	hdr->h_checksum = 0;
-	block_nr = cpu_to_le64(block_nr);
-	csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&block_nr,
-			   sizeof(block_nr));
+	csum = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&dsk_block_nr,
+			   sizeof(dsk_block_nr));
 	csum = ext4_chksum(sbi, csum, (__u8 *)hdr,
 			   EXT4_BLOCK_SIZE(inode->i_sb));
 
-	hdr->h_checksum = old;
+	hdr->h_checksum = save_csum;
 	return cpu_to_le32(csum);
 }
 
include/trace/events/ext4.h +3 -3
index 58459b7..d0e6864 100644
@@ -1948,7 +1948,7 @@ TRACE_EVENT(ext4_remove_blocks,
 		__entry->to		= to;
 		__entry->partial	= partial_cluster;
 		__entry->ee_pblk	= ext4_ext_pblock(ex);
-		__entry->ee_lblk	= cpu_to_le32(ex->ee_block);
+		__entry->ee_lblk	= le32_to_cpu(ex->ee_block);
 		__entry->ee_len		= ext4_ext_get_actual_len(ex);
 	),
 
@@ -2052,7 +2052,7 @@ TRACE_EVENT(ext4_ext_remove_space,
 
 TRACE_EVENT(ext4_ext_remove_space_done,
 	TP_PROTO(struct inode *inode, ext4_lblk_t start, int depth,
-		ext4_lblk_t partial, unsigned short eh_entries),
+		ext4_lblk_t partial, __le16 eh_entries),
 
 	TP_ARGS(inode, start, depth, partial, eh_entries),
 
@@ -2071,7 +2071,7 @@ TRACE_EVENT(ext4_ext_remove_space_done,
 		__entry->start		= start;
 		__entry->depth		= depth;
 		__entry->partial	= partial;
-		__entry->eh_entries	= eh_entries;
+		__entry->eh_entries	= le16_to_cpu(eh_entries);
 	),
 
 	TP_printk("dev %d,%d ino %lu since %u depth %d partial %u "
Signature · 1 line
1.7.12.rc0.22.gcdd159b
maintainer
#13 lore raw
In reply to Dmitry Monakhov
Quoted 1 line · Dmitry Monakhov

This patch should fix sparse complains about shadow declatations.

Nothing here is fixing serious regressions, right? This is just to make static code checkers happy?

- Ted

#14 lore raw
Quoted 5 lines · Theodore Ts'o
Quoted 1 line · Dmitry Monakhov

This patch should fix sparse complains about shadow declatations.

Nothing here is fixing serious regressions, right? This is just to make static code checkers happy?

Yep... but fixes are also quite simple.

Quoted 6 lines

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html