Skip to contentSkip to conversation

bio: Fix build failure.

PATCH In review Tetsuo Handa 3 participants 6 messages Jun 13, 2014 – Jun 16, 2014

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

PATCH 1/1 bio: Fix build failure.

Quoted 1 line

From 75b9f78ddc8ab30555a520f5a2477a9340341dd1 Mon Sep 17 00:00:00 2001

From: Tetsuo Handa <[email protected]>
Date: Fri, 13 Jun 2014 12:35:35 +0900
Subject: [PATCH pre 3.16-rc1] bio: Fix build failure.

Commit 62a8067a7f "bio_vec-backed iov_iter" introduced an unnamed union inside a struct which gcc-4.4.7 cannot handle. Name the unnamed union as u in order to fix build failure.

---
 fs/fuse/file.c      |    6 ++--
 fs/splice.c         |    2 +-
 include/linux/uio.h |    6 ++--
 mm/iov_iter.c       |   64 +++++++++++++++++++++++++-------------------------
 mm/page_io.c        |    2 +-
 5 files changed, 40 insertions(+), 40 deletions(-)
fs/fuse/file.c +3 -3
index 6e16dad..6ea6124 100644
@@ -1271,7 +1271,7 @@ static inline void fuse_page_descs_length_init(struct fuse_req *req,
 
 static inline unsigned long fuse_get_user_addr(const struct iov_iter *ii)
 {
-	return (unsigned long)ii->iov->iov_base + ii->iov_offset;
+	return (unsigned long)ii->u.iov->iov_base + ii->iov_offset;
 }
 
 static inline size_t fuse_get_frag_size(const struct iov_iter *ii,
@@ -2349,8 +2349,8 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
 		kaddr = kmap(page);
 
 		while (todo) {
-			char __user *uaddr = ii.iov->iov_base + ii.iov_offset;
-			size_t iov_len = ii.iov->iov_len - ii.iov_offset;
+			char __user *uaddr = ii.u.iov->iov_base + ii.iov_offset;
+			size_t iov_len = ii.u.iov->iov_len - ii.iov_offset;
 			size_t copy = min(todo, iov_len);
 			size_t left;
 
fs/splice.c +1 -1
index f5cb9ba..a50a379 100644
@@ -1007,7 +1007,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
 
 		/* ... iov_iter */
 		from.type = ITER_BVEC | WRITE;
-		from.bvec = array;
+		from.u.bvec = array;
 		from.nr_segs = n;
 		from.count = sd.total_len - left;
 		from.iov_offset = 0;
include/linux/uio.h +3 -3
index e2231e4..9fb76ad 100644
@@ -32,7 +32,7 @@ struct iov_iter {
 	union {
 		const struct iovec *iov;
 		const struct bio_vec *bvec;
-	};
+	} u;
 	unsigned long nr_segs;
 };
 
@@ -56,9 +56,9 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
 static inline struct iovec iov_iter_iovec(const struct iov_iter *iter)
 {
 	return (struct iovec) {
-		.iov_base = iter->iov->iov_base + iter->iov_offset,
+		.iov_base = iter->u.iov->iov_base + iter->iov_offset,
 		.iov_len = min(iter->count,
-			       iter->iov->iov_len - iter->iov_offset),
+			       iter->u.iov->iov_len - iter->iov_offset),
 	};
 }
 
mm/iov_iter.c +32 -32

219 lines not on this page · raw message

mm/page_io.c +1 -1
index 243a9b7..875a460 100644
@@ -274,7 +274,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 			.count = PAGE_SIZE,
 			.iov_offset = 0,
 			.nr_segs = 1,
-			.bvec = &bv
+			.u.bvec = &bv
 		};
 
 		init_sync_kiocb(&kiocb, swap_file);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 8 lines · Tetsuo Handa
Quoted 1 line

From 75b9f78ddc8ab30555a520f5a2477a9340341dd1 Mon Sep 17 00:00:00 2001

From: Tetsuo Handa <[email protected]>
Date: Fri, 13 Jun 2014 12:35:35 +0900
Subject: [PATCH pre 3.16-rc1] bio: Fix build failure.

Commit 62a8067a7f "bio_vec-backed iov_iter" introduced an unnamed union inside a struct which gcc-4.4.7 cannot handle. Name the unnamed union as u in order to fix build failure.

Same problem here. Jens tracked it down to the anon union and the named initialization done in page_io.c

Quoted 6 lines
mm/page_io.c +0 -0
index 243a9b7..875a460 100644

mm/page_io.c int __swap_writepage(struct page *page, struct writeback_control *wbc, · line 280

Quoted 8 lines
mm/page_io.c +1 -1
@@ -274,7 +274,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 			.count = PAGE_SIZE,
 			.iov_offset = 0,
 			.nr_segs = 1,
-			.bvec = &bv
+			.u.bvec = &bv
 		};
 
 		init_sync_kiocb(&kiocb, swap_file);

-chris

maintainer
#2 lore raw
In reply to Tetsuo Handa
Quoted 8 lines · Tetsuo Handa
Quoted 1 line

From 75b9f78ddc8ab30555a520f5a2477a9340341dd1 Mon Sep 17 00:00:00 2001

From: Tetsuo Handa <[email protected]>
Date: Fri, 13 Jun 2014 12:35:35 +0900
Subject: [PATCH pre 3.16-rc1] bio: Fix build failure.

Commit 62a8067a7f "bio_vec-backed iov_iter" introduced an unnamed union inside a struct which gcc-4.4.7 cannot handle. Name the unnamed union as u in order to fix build failure.

Sigh... Oh, well - it will be a while until we can use them (anon union and struct members are valid C11; it's not just gccism). Applied, will push to Linus today if he hasn't picked that one up himself.

maintainer
#3 lore raw

PATCH 1/1 fix __swap_writepage() compile failure on old gcc versions

Quoted 6 lines · Al Viro
Quoted 5 lines · Tetsuo Handa
Quoted 1 line

From 75b9f78ddc8ab30555a520f5a2477a9340341dd1 Mon Sep 17 00:00:00 2001

From: Tetsuo Handa <[email protected]>
Date: Fri, 13 Jun 2014 12:35:35 +0900
Subject: [PATCH pre 3.16-rc1] bio: Fix build failure.

Quoted 7 lines
Quoted 3 lines

Commit 62a8067a7f "bio_vec-backed iov_iter" introduced an unnamed union inside a struct which gcc-4.4.7 cannot handle. Name the unnamed union as u in order to fix build failure.

Sigh... Oh, well - it will be a while until we can use them (anon union and struct members are valid C11; it's not just gccism). Applied, will push to Linus today if he hasn't picked that one up himself.

Let's do this instead: there is only one place in the entire tree that steps into this breakage. Anon structs and unions work in older gcc versions; as the matter of fact, we have those in the tree - see e.g. struct ieee80211_tx_info in include/net/mac80211.h

What doesn't work is handling their initializers:

struct {
	int a;
	union {
		int b;
		char c;
	};
} x[2] = {{.a = 1, .c = 'a'}, {.a = 0, .b = 1}};

is the obvious syntax for initializer, perfectly fine for C11 and handled correctly by gcc-4.7 or later. Earlier versions, though, break on it - declaration is fine and so's access to fields (i.e. x[0].c = 'a'; would produce the right code), but members of the anon structs and unions are not inserted into the right namespace. Tellingly, those older versions will not barf on struct {int a; struct {int a;};}; - looks like they just have it hacked up somewhere around the handling of . and -> instead of doing the right thing.

The easiest way to deal with that crap is to turn initialization of those fields (in the only place where we have such initializer of iov_iter) into plain assignment.

---

mm/page_io.c +1 -1
index 33bb38c..fe24f78 100644
@@ -269,8 +269,8 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 			.count = PAGE_SIZE,
 			.iov_offset = 0,
 			.nr_segs = 1,
-			.bvec = &bv
 		};
+		from.bvec = &bv;	/* older gcc versions are broken */
 
 		init_sync_kiocb(&kiocb, swap_file);
 		kiocb.ki_pos = page_file_offset(page);
#4 lore raw

Re: [PATCH] fix __swap_writepage() compile failure on old gcc versions

Quoted 3 lines · Al Viro

The easiest way to deal with that crap is to turn initialization of those fields (in the only place where we have such initializer of iov_iter) into plain assignment.

OK. It passed my tests on gcc 4.4.7. Thank you.

Well, gcc 3.3.5-13 / binutils 2.15-6 can no longer build current kernel.

arch/x86/boot/bioscall.S: Assembler messages:
arch/x86/boot/bioscall.S:68: Error: `68(%esp)' is not a valid 16 bit base/index expression make[3]: *** [arch/x86/realmode/rm/bioscall.o] Error 1

Time to update Current Minimal Requirements in Documentation/Changes ?

  o  Gnu C                  3.2                     # gcc --version
  o  binutils               2.12                    # ld -v
#5 lore raw

Re: [PATCH] fix __swap_writepage() compile failure on old gcc versions

In reply to Al Viro
Quoted 21 lines · Al Viro
Quoted 6 lines · Al Viro
Quoted 5 lines · Tetsuo Handa
Quoted 1 line

From 75b9f78ddc8ab30555a520f5a2477a9340341dd1 Mon Sep 17 00:00:00 2001

From: Tetsuo Handa <[email protected]>
Date: Fri, 13 Jun 2014 12:35:35 +0900
Subject: [PATCH pre 3.16-rc1] bio: Fix build failure.

Quoted 7 lines
Quoted 3 lines

Commit 62a8067a7f "bio_vec-backed iov_iter" introduced an unnamed union inside a struct which gcc-4.4.7 cannot handle. Name the unnamed union as u in order to fix build failure.

Sigh... Oh, well - it will be a while until we can use them (anon union and struct members are valid C11; it's not just gccism). Applied, will push to Linus today if he hasn't picked that one up himself.

Let's do this instead: there is only one place in the entire tree that steps into this breakage. Anon structs and unions work in older gcc versions; as the matter of fact, we have those in the tree - see e.g. struct ieee80211_tx_info in include/net/mac80211.h

What doesn't work is handling their initializers:

[ ... ]

mm/page_io.c int __swap_writepage(struct page *page, struct writeback_control *wbc, · line 273

Quoted 12 lines

---

mm/page_io.c +1 -1
index 33bb38c..fe24f78 100644
@@ -269,8 +269,8 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
 			.count = PAGE_SIZE,
 			.iov_offset = 0,
 			.nr_segs = 1,
-			.bvec = &bv
 		};
+		from.bvec = &bv;	/* older gcc versions are broken */

This was how I tested before my last pull request, it was enough to compile on gcc 4.4.6.

-chris