Skip to contentSkip to conversation

bcachefs for v6.7

GIT PULL John Stoffel 2 participants 3 messages Oct 31, 2023 VFS

lore
Share & tools
lore
#0 lore raw

Using latest HEAD from linux git (commit 5a6a09e97199d6600d31383055f9d43fbbcbe86f (HEAD -> master, origin/master, origin/HEAD), and the following config, I get this failure when compiling on x86_64 Debian Bullseye (11):

CC fs/bcachefs/btree_io.o
In file included from fs/bcachefs/btree_io.c:11:
fs/bcachefs/btree_io.c: In function ‘bch2_btree_post_write_cleanup’:
fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds]

     274 |   __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
	 |                                    ^~~~~~~~~~~~~~~~~~~
   In file included from fs/bcachefs/bcachefs.h:206,
		    from fs/bcachefs/btree_io.c:3:
   fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’
    2344 |  struct bkey_packed start[0];
	 |                     ^~~~~
   In file included from fs/bcachefs/btree_io.c:11:
   fs/bcachefs/btree_io.c: In function ‘bch2_btree_init_next’:
   fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds]
     274 |   __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
	 |                                    ^~~~~~~~~~~~~~~~~~~
   In file included from fs/bcachefs/bcachefs.h:206,
		    from fs/bcachefs/btree_io.c:3:
   fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’
    2344 |  struct bkey_packed start[0];
	 |                     ^~~~~

cc1: all warnings being treated as errors
make[4]: *** [scripts/Makefile.build:243: fs/bcachefs/btree_io.o] Error 1 make[3]: *** [scripts/Makefile.build:480: fs/bcachefs] Error 2 make[2]: *** [scripts/Makefile.build:480: fs] Error 2 make[1]: *** [/local/src/kernel/git/linux/Makefile:1913: .] Error 2
make: *** [Makefile:234: __sub-make] Error 2

My .config looks like this for BCACHEFS:

   $ grep BCACHEFS .config
   CONFIG_BCACHEFS_FS=y
   CONFIG_BCACHEFS_QUOTA=y
   CONFIG_BCACHEFS_POSIX_ACL=y
   CONFIG_BCACHEFS_DEBUG_TRANSACTIONS=y
   CONFIG_BCACHEFS_DEBUG=y
   CONFIG_BCACHEFS_TESTS=y
   # CONFIG_BCACHEFS_LOCK_TIME_STATS is not set
   # CONFIG_BCACHEFS_NO_LATENCY_ACCT is not set
#1 lore raw
Quoted 26 lines · John Stoffel

Using latest HEAD from linux git (commit 5a6a09e97199d6600d31383055f9d43fbbcbe86f (HEAD -> master, origin/master, origin/HEAD), and the following config, I get this failure when compiling on x86_64 Debian Bullseye (11):

CC fs/bcachefs/btree_io.o
In file included from fs/bcachefs/btree_io.c:11:

   fs/bcachefs/btree_io.c: In function ‘bch2_btree_post_write_cleanup’:
   fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds]
     274 |   __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
	 |                                    ^~~~~~~~~~~~~~~~~~~
   In file included from fs/bcachefs/bcachefs.h:206,
		    from fs/bcachefs/btree_io.c:3:
   fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’
    2344 |  struct bkey_packed start[0];
	 |                     ^~~~~
   In file included from fs/bcachefs/btree_io.c:11:
   fs/bcachefs/btree_io.c: In function ‘bch2_btree_init_next’:
   fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds]
     274 |   __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
	 |                                    ^~~~~~~~~~~~~~~~~~~
   In file included from fs/bcachefs/bcachefs.h:206,
		    from fs/bcachefs/btree_io.c:3:
   fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’
Quoted 8 lines
    2344 |  struct bkey_packed start[0];
	 |                     ^~~~~
   cc1: all warnings being treated as errors
   make[4]: *** [scripts/Makefile.build:243: fs/bcachefs/btree_io.o] Error 1
   make[3]: *** [scripts/Makefile.build:480: fs/bcachefs] Error 2
   make[2]: *** [scripts/Makefile.build:480: fs] Error 2
   make[1]: *** [/local/src/kernel/git/linux/Makefile:1913: .] Error 2
   make: *** [Makefile:234: __sub-make] Error 2

It seems gcc 10 complains in situations gcc 11 does not.

I've got the following patch running through my testing automation now:

-- >8 --
From: Kent Overstreet <[email protected]>
Date: Tue, 31 Oct 2023 18:05:22 -0400
Subject: [PATCH] bcachefs: Fix build errors with gcc 10

gcc 10 seems to complain about array bounds in situations where gcc 11 does not - curious.

This unfortunately requires adding some casts for now; we may investigate getting rid of our __u64 _data[] VLA in a future patch so that our start[0] members can be VLAs.

fs/bcachefs/bcachefs_format.h +1 -3
index 29b000c6b7e1..5b44598b9df9 100644
@@ -1617,9 +1617,7 @@ struct journal_seq_blacklist_entry {
 
 struct bch_sb_field_journal_seq_blacklist {
 	struct bch_sb_field	field;
-
-	struct journal_seq_blacklist_entry start[0];
-	__u64			_data[];
+	struct journal_seq_blacklist_entry start[];
 };
 
 struct bch_sb_field_errors {
fs/bcachefs/btree_trans_commit.c +3 -3
index 8140b6e6e9a6..32693f7c6221 100644
@@ -681,7 +681,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
 						       BCH_JSET_ENTRY_overwrite,
 						       i->btree_id, i->level,
 						       i->old_k.u64s);
-				bkey_reassemble(&entry->start[0],
+				bkey_reassemble((struct bkey_i *) entry->start,
 						(struct bkey_s_c) { &i->old_k, i->old_v });
 			}
 
@@ -689,7 +689,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
 					       BCH_JSET_ENTRY_btree_keys,
 					       i->btree_id, i->level,
 					       i->k->k.u64s);
-			bkey_copy(&entry->start[0], i->k);
+			bkey_copy((struct bkey_i *) entry->start, i->k);
 		}
 
 		trans_for_each_wb_update(trans, wb) {
@@ -697,7 +697,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
 					       BCH_JSET_ENTRY_btree_keys,
 					       wb->btree, 0,
 					       wb->k.k.u64s);
-			bkey_copy(&entry->start[0], &wb->k);
+			bkey_copy((struct bkey_i *) entry->start, &wb->k);
 		}
 
 		if (trans->journal_seq)
fs/bcachefs/btree_update_interior.c +1 -1
index d029e0348c91..89ada89eafe7 100644
@@ -2411,7 +2411,7 @@ void bch2_journal_entry_to_btree_root(struct bch_fs *c, struct jset_entry *entry
 
 	r->level = entry->level;
 	r->alive = true;
-	bkey_copy(&r->key, &entry->start[0]);
+	bkey_copy(&r->key, (struct bkey_i *) entry->start);
 
 	mutex_unlock(&c->btree_root_lock);
 }
fs/bcachefs/btree_update_interior.h +1 -1
index 5e0a467fe905..d92b3cf5f5e0 100644
@@ -271,7 +271,7 @@ static inline struct btree_node_entry *want_new_bset(struct bch_fs *c,
 	struct btree_node_entry *bne = max(write_block(b),
 			(void *) btree_bkey_last(b, bset_tree_last(b)));
 	ssize_t remaining_space =
-		__bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
+		__bch_btree_u64s_remaining(c, b, bne->keys.start);
 
 	if (unlikely(bset_written(b, bset(b, t)))) {
 		if (remaining_space > (ssize_t) (block_bytes(c) >> 3))
fs/bcachefs/recovery.c +1 -1
index f73338f37bf1..9600b8083175 100644
@@ -226,7 +226,7 @@ static int journal_replay_entry_early(struct bch_fs *c,
 
 		if (entry->u64s) {
 			r->level = entry->level;
-			bkey_copy(&r->key, &entry->start[0]);
+			bkey_copy(&r->key, (struct bkey_i *) entry->start);
 			r->error = 0;
 		} else {
 			r->error = -EIO;
#2 lore raw
Quoted 77 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Kent" == Kent Overstreet <[email protected]> writes:

Quoted 26 lines · John Stoffel

Using latest HEAD from linux git (commit 5a6a09e97199d6600d31383055f9d43fbbcbe86f (HEAD -> master, origin/master, origin/HEAD), and the following config, I get this failure when compiling on x86_64 Debian Bullseye (11):

CC fs/bcachefs/btree_io.o
In file included from fs/bcachefs/btree_io.c:11:
fs/bcachefs/btree_io.c: In function ‘bch2_btree_post_write_cleanup’:
fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds]
274 | __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
| ^~~~~~~~~~~~~~~~~~~
In file included from fs/bcachefs/bcachefs.h:206,
from fs/bcachefs/btree_io.c:3:
fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’
2344 | struct bkey_packed start[0];
| ^~~~~
In file included from fs/bcachefs/btree_io.c:11:
fs/bcachefs/btree_io.c: In function ‘bch2_btree_init_next’:
fs/bcachefs/btree_update_interior.h:274:36: error: array subscript 0 is outside the bounds of an interior zero-length array ‘struct bkey_packed[0]’ [-Werror=zero-length-bounds]
274 | __bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
| ^~~~~~~~~~~~~~~~~~~
In file included from fs/bcachefs/bcachefs.h:206,
from fs/bcachefs/btree_io.c:3:
fs/bcachefs/bcachefs_format.h:2344:21: note: while referencing ‘start’

Quoted 8 lines

2344 | struct bkey_packed start[0];
| ^~~~~
cc1: all warnings being treated as errors
make[4]: *** [scripts/Makefile.build:243: fs/bcachefs/btree_io.o] Error 1 make[3]: *** [scripts/Makefile.build:480: fs/bcachefs] Error 2 make[2]: *** [scripts/Makefile.build:480: fs] Error 2 make[1]: *** [/local/src/kernel/git/linux/Makefile:1913: .] Error 2
make: *** [Makefile:234: __sub-make] Error 2

It seems gcc 10 complains in situations gcc 11 does not.

I've got the following patch running through my testing automation now:

-- >8 --
From: Kent Overstreet <[email protected]>
Date: Tue, 31 Oct 2023 18:05:22 -0400
Subject: [PATCH] bcachefs: Fix build errors with gcc 10

gcc 10 seems to complain about array bounds in situations where gcc 11 does not - curious.

This unfortunately requires adding some casts for now; we may investigate getting rid of our __u64 _data[] VLA in a future patch so that our start[0] members can be VLAs.

fs/bcachefs/bcachefs_format.h +1 -3
index 29b000c6b7e1..5b44598b9df9 100644
@@ -1617,9 +1617,7 @@ struct journal_seq_blacklist_entry {
 
 struct bch_sb_field_journal_seq_blacklist {
 	struct bch_sb_field	field;
-
-	struct journal_seq_blacklist_entry start[0];
-	__u64			_data[];
+	struct journal_seq_blacklist_entry start[];
 };
 
 struct bch_sb_field_errors {
fs/bcachefs/btree_trans_commit.c +0 -0
index 8140b6e6e9a6..32693f7c6221 100644

fs/bcachefs/btree_trans_commit.c bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, · line 681

Quoted 1 line
fs/bcachefs/btree_trans_commit.c +0 -0
@@ -681,7 +681,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
 						       BCH_JSET_ENTRY_overwrite,

i-> btree_id, i->level,
i-> old_k.u64s);

fs/bcachefs/btree_trans_commit.c bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, · line 689

Quoted 7 lines
fs/bcachefs/btree_trans_commit.c +1 -1
-				bkey_reassemble(&entry->start[0],
+				bkey_reassemble((struct bkey_i *) entry->start,
 						(struct bkey_s_c) { &i->old_k, i->old_v });
 			}
 
@@ -689,7 +689,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
 					       BCH_JSET_ENTRY_btree_keys,

i-> btree_id, i->level,
i-> k->k.u64s);

fs/bcachefs/btree_trans_commit.c bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, · line 697

Quoted 7 lines
fs/bcachefs/btree_trans_commit.c +1 -1
-			bkey_copy(&entry->start[0], i->k);
+			bkey_copy((struct bkey_i *) entry->start, i->k);
 		}
 
 		trans_for_each_wb_update(trans, wb) {
@@ -697,7 +697,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
 					       BCH_JSET_ENTRY_btree_keys,

wb-> btree, 0,
wb-> k.k.u64s);

fs/bcachefs/btree_update_interior.c void bch2_journal_entry_to_btree_root(struct bch_fs *c, struct jset_entry *entry

Quoted 10 lines
fs/bcachefs/btree_trans_commit.c +1 -1
-			bkey_copy(&entry->start[0], &wb->k);
+			bkey_copy((struct bkey_i *) entry->start, &wb->k);
 		}
 
 		if (trans->journal_seq)
fs/bcachefs/btree_update_interior.c +0 -0
index d029e0348c91..89ada89eafe7 100644
@@ -2411,7 +2411,7 @@ void bch2_journal_entry_to_btree_root(struct bch_fs *c, struct jset_entry *entry

r-> level = entry->level;
r-> alive = true;

Quoted 23 lines
fs/bcachefs/btree_update_interior.c +1 -1
-	bkey_copy(&r->key, &entry->start[0]);
+	bkey_copy(&r->key, (struct bkey_i *) entry->start);
 
 	mutex_unlock(&c->btree_root_lock);
 }
fs/bcachefs/btree_update_interior.h +1 -1
index 5e0a467fe905..d92b3cf5f5e0 100644
@@ -271,7 +271,7 @@ static inline struct btree_node_entry *want_new_bset(struct bch_fs *c,
 	struct btree_node_entry *bne = max(write_block(b),
 			(void *) btree_bkey_last(b, bset_tree_last(b)));
 	ssize_t remaining_space =
-		__bch_btree_u64s_remaining(c, b, &bne->keys.start[0]);
+		__bch_btree_u64s_remaining(c, b, bne->keys.start);
 
 	if (unlikely(bset_written(b, bset(b, t)))) {
 		if (remaining_space > (ssize_t) (block_bytes(c) >> 3))
fs/bcachefs/recovery.c +0 -0
index f73338f37bf1..9600b8083175 100644

fs/bcachefs/recovery.c static int journal_replay_entry_early(struct bch_fs *c, · line 227

Quoted 2 lines
fs/bcachefs/recovery.c +0 -0
@@ -226,7 +226,7 @@ static int journal_replay_entry_early(struct bch_fs *c,
 
 		if (entry->u64s) {

r-> level = entry->level;

fs/bcachefs/recovery.c static int journal_replay_entry_early(struct bch_fs *c, · line 228

Quoted 2 lines
fs/bcachefs/recovery.c +1 -1
-			bkey_copy(&r->key, &entry->start[0]);
+			bkey_copy(&r->key, (struct bkey_i *) entry->start);

r-> error = 0;

fs/bcachefs/recovery.c static int journal_replay_entry_early(struct bch_fs *c, · line 231

Quoted 1 line
fs/bcachefs/recovery.c +0 -0
 		} else {

r-> error = -EIO;

So this fixes the compile error, thanks! Sorry for not reporting the gcc version better. And it also compiles nicely when I remove all the BACHEFS .config entries, accept all the defaults from 'make oldconfig' and re-compile.

Cheers,
John