[BUG] "bio_vec-backed iov_iter" breaks gcc 4.6.4

From: Russell King - ARM Linux
Date: Fri Jun 13 2014 - 13:19:22 EST


Commit 62a8067a7f35dba2de501c9cb00e4cf36da90bc0 has broken the build
with gcc 4.6.4:

diff --git a/include/linux/uio.h b/include/linux/uio.h
struct iov_iter {
...
+ union {
+ const struct iovec *iov;
+ const struct bio_vec *bvec;
+ };
...
diff --git a/mm/page_io.c b/mm/page_io.c
...
+ struct iov_iter from = {
...
+ .bvec = &bv

mm/page_io.c: In function '__swap_writepage':
mm/page_io.c:277:4: error: unknown field 'bvec' specified in initializer
mm/page_io.c:278:3: warning: excess elements in struct initializer
mm/page_io.c:278:3: warning: (near initialization for 'from')
make[2]: *** [mm/page_io.o] Error 1

The problem here is that only relatively recent gcc's are able to deal
with anonymous union/struct initialisers.

Documentation wise, we're telling people that the minimum version of GCC
required to build the kernel is:

o Gnu C 3.2 # gcc --version

The patch below fixes it for me - but it's not ideal because the only
reason it works is that we have the initialisers in the same order as
the structure.

Any suggestions?

mm/page_io.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index 243a9b76e5ce..e9a2a0aca8ea 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -271,10 +271,12 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
};
struct iov_iter from = {
.type = ITER_BVEC | WRITE,
- .count = PAGE_SIZE,
.iov_offset = 0,
+ .count = PAGE_SIZE,
+ {
+ .bvec = &bv
+ },
.nr_segs = 1,
- .bvec = &bv
};

init_sync_kiocb(&kiocb, swap_file);


--
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/