diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-22 15:59:53 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:45 -0400 |
commit | a10195764901e0a41e64d596de57a957e7f982f0 (patch) | |
tree | fec47a1ad4a508d47299715baabf7a7242ddf90b | |
parent | d4bce63636ab81ca4aed03d6641ad70c8416e921 (diff) |
bcachefs: More style fixes
Fixes for various checkpatch errors.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
30 files changed, 112 insertions, 96 deletions
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 488db3211ce4..318beb588aa9 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -87,34 +87,34 @@ int bch2_alloc_v4_invalid(const struct bch_fs *, struct bkey_s_c, int, struct pr void bch2_alloc_v4_swab(struct bkey_s); void bch2_alloc_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_alloc (struct bkey_ops) { \ +#define bch2_bkey_ops_alloc ((struct bkey_ops) { \ .key_invalid = bch2_alloc_v1_invalid, \ .val_to_text = bch2_alloc_to_text, \ .trans_trigger = bch2_trans_mark_alloc, \ .atomic_trigger = bch2_mark_alloc, \ -} +}) -#define bch2_bkey_ops_alloc_v2 (struct bkey_ops) { \ +#define bch2_bkey_ops_alloc_v2 ((struct bkey_ops) { \ .key_invalid = bch2_alloc_v2_invalid, \ .val_to_text = bch2_alloc_to_text, \ .trans_trigger = bch2_trans_mark_alloc, \ .atomic_trigger = bch2_mark_alloc, \ -} +}) -#define bch2_bkey_ops_alloc_v3 (struct bkey_ops) { \ +#define bch2_bkey_ops_alloc_v3 ((struct bkey_ops) { \ .key_invalid = bch2_alloc_v3_invalid, \ .val_to_text = bch2_alloc_to_text, \ .trans_trigger = bch2_trans_mark_alloc, \ .atomic_trigger = bch2_mark_alloc, \ -} +}) -#define bch2_bkey_ops_alloc_v4 (struct bkey_ops) { \ +#define bch2_bkey_ops_alloc_v4 ((struct bkey_ops) { \ .key_invalid = bch2_alloc_v4_invalid, \ .val_to_text = bch2_alloc_to_text, \ .swab = bch2_alloc_v4_swab, \ .trans_trigger = bch2_trans_mark_alloc, \ .atomic_trigger = bch2_mark_alloc, \ -} +}) static inline bool bkey_is_alloc(const struct bkey *k) { diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 18fe09cdae4d..c0416258985b 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -282,7 +282,7 @@ do { \ "When reading btree nodes, read all replicas and " \ "compare them") -/* Parameters that should only be compiled in in debug mode: */ +/* Parameters that should only be compiled in debug mode: */ #define BCH_DEBUG_PARAMS_DEBUG() \ BCH_DEBUG_PARAM(expensive_debug_checks, \ "Enables various runtime debugging checks that " \ diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index 35fe7002b37d..6e01fd81e3f0 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1840,6 +1840,7 @@ enum bch_compression_opts { static inline __le64 __bch2_sb_magic(struct bch_sb *sb) { __le64 ret; + memcpy(&ret, &sb->uuid, sizeof(ret)); return ret; } diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c index 161b5bd60a63..1c9c02deffbe 100644 --- a/fs/bcachefs/bkey.c +++ b/fs/bcachefs/bkey.c @@ -17,9 +17,6 @@ const struct bkey_format bch2_bkey_format_current = BKEY_FORMAT_CURRENT; -struct bkey __bch2_bkey_unpack_key(const struct bkey_format *, - const struct bkey_packed *); - void bch2_bkey_packed_to_binary_text(struct printbuf *out, const struct bkey_format *f, const struct bkey_packed *k) diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c index f2351e5ee7c1..141754db5fa1 100644 --- a/fs/bcachefs/bkey_methods.c +++ b/fs/bcachefs/bkey_methods.c @@ -28,13 +28,13 @@ static int deleted_key_invalid(const struct bch_fs *c, struct bkey_s_c k, return 0; } -#define bch2_bkey_ops_deleted (struct bkey_ops) { \ +#define bch2_bkey_ops_deleted ((struct bkey_ops) { \ .key_invalid = deleted_key_invalid, \ -} +}) -#define bch2_bkey_ops_whiteout (struct bkey_ops) { \ +#define bch2_bkey_ops_whiteout ((struct bkey_ops) { \ .key_invalid = deleted_key_invalid, \ -} +}) static int empty_val_key_invalid(const struct bch_fs *c, struct bkey_s_c k, int rw, struct printbuf *err) @@ -48,9 +48,9 @@ static int empty_val_key_invalid(const struct bch_fs *c, struct bkey_s_c k, return 0; } -#define bch2_bkey_ops_error (struct bkey_ops) { \ +#define bch2_bkey_ops_error ((struct bkey_ops) { \ .key_invalid = empty_val_key_invalid, \ -} +}) static int key_type_cookie_invalid(const struct bch_fs *c, struct bkey_s_c k, int rw, struct printbuf *err) @@ -64,13 +64,13 @@ static int key_type_cookie_invalid(const struct bch_fs *c, struct bkey_s_c k, return 0; } -#define bch2_bkey_ops_cookie (struct bkey_ops) { \ +#define bch2_bkey_ops_cookie ((struct bkey_ops) { \ .key_invalid = key_type_cookie_invalid, \ -} +}) -#define bch2_bkey_ops_hash_whiteout (struct bkey_ops) { \ +#define bch2_bkey_ops_hash_whiteout ((struct bkey_ops) {\ .key_invalid = empty_val_key_invalid, \ -} +}) static int key_type_inline_data_invalid(const struct bch_fs *c, struct bkey_s_c k, int rw, struct printbuf *err) @@ -88,10 +88,10 @@ static void key_type_inline_data_to_text(struct printbuf *out, struct bch_fs *c, datalen, min(datalen, 32U), d.v->data); } -#define bch2_bkey_ops_inline_data (struct bkey_ops) { \ +#define bch2_bkey_ops_inline_data ((struct bkey_ops) { \ .key_invalid = key_type_inline_data_invalid, \ .val_to_text = key_type_inline_data_to_text, \ -} +}) static int key_type_set_invalid(const struct bch_fs *c, struct bkey_s_c k, int rw, struct printbuf *err) @@ -111,10 +111,10 @@ static bool key_type_set_merge(struct bch_fs *c, struct bkey_s l, struct bkey_s_ return true; } -#define bch2_bkey_ops_set (struct bkey_ops) { \ +#define bch2_bkey_ops_set ((struct bkey_ops) { \ .key_invalid = key_type_set_invalid, \ .key_merge = key_type_set_merge, \ -} +}) const struct bkey_ops bch2_bkey_ops[] = { #define x(name, nr) [KEY_TYPE_##name] = bch2_bkey_ops_##name, @@ -439,6 +439,7 @@ void __bch2_bkey_compat(unsigned level, enum btree_id btree_id, btree_id == BTREE_ID_inodes) { if (!bkey_packed(k)) { struct bkey_i *u = packed_to_bkey(k); + swap(u->k.p.inode, u->k.p.offset); } else if (f->bits_per_field[BKEY_FIELD_INODE] && f->bits_per_field[BKEY_FIELD_OFFSET]) { diff --git a/fs/bcachefs/bkey_methods.h b/fs/bcachefs/bkey_methods.h index cff6f6dc44c4..0c74ba335e64 100644 --- a/fs/bcachefs/bkey_methods.h +++ b/fs/bcachefs/bkey_methods.h @@ -18,7 +18,7 @@ extern const char * const bch2_bkey_types[]; * * When invalid, error string is returned via @err. @rw indicates whether key is * being read or written; more aggressive checks can be enabled when rw == WRITE. -*/ + */ struct bkey_ops { int (*key_invalid)(const struct bch_fs *c, struct bkey_s_c k, int rw, struct printbuf *err); diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 709453a909fc..5adfdc5afbea 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -112,7 +112,9 @@ static int btree_node_data_alloc(struct bch_fs *c, struct btree *b, gfp_t gfp) static struct btree *__btree_node_mem_alloc(struct bch_fs *c, gfp_t gfp) { - struct btree *b = kzalloc(sizeof(struct btree), gfp); + struct btree *b; + + b = kzalloc(sizeof(struct btree), gfp); if (!b) return NULL; @@ -128,7 +130,9 @@ static struct btree *__btree_node_mem_alloc(struct bch_fs *c, gfp_t gfp) struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c) { struct btree_cache *bc = &c->btree_cache; - struct btree *b = __btree_node_mem_alloc(c, GFP_KERNEL); + struct btree *b; + + b = __btree_node_mem_alloc(c, GFP_KERNEL); if (!b) return NULL; @@ -147,6 +151,7 @@ struct btree *__bch2_btree_node_mem_alloc(struct bch_fs *c) void bch2_btree_node_hash_remove(struct btree_cache *bc, struct btree *b) { int ret = rhashtable_remove_fast(&bc->table, &b->hash, bch_btree_cache_params); + BUG_ON(ret); /* Cause future lookups for this node to fail: */ diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 1bc5bded0546..3395fa56c724 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -199,7 +199,7 @@ static int set_node_min(struct bch_fs *c, struct btree *b, struct bpos new_min) struct bkey_i_btree_ptr_v2 *new; int ret; - new = kmalloc(BKEY_BTREE_PTR_U64s_MAX * sizeof(u64), GFP_KERNEL); + new = kmalloc_array(BKEY_BTREE_PTR_U64s_MAX, sizeof(u64), GFP_KERNEL); if (!new) return -ENOMEM; @@ -228,7 +228,7 @@ static int set_node_max(struct bch_fs *c, struct btree *b, struct bpos new_max) if (ret) return ret; - new = kmalloc(BKEY_BTREE_PTR_U64s_MAX * sizeof(u64), GFP_KERNEL); + new = kmalloc_array(BKEY_BTREE_PTR_U64s_MAX, sizeof(u64), GFP_KERNEL); if (!new) return -ENOMEM; diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index dd149de8d31d..5d750f447241 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1224,6 +1224,7 @@ static void btree_node_read_endio(struct bio *bio) if (rb->have_ioref) { struct bch_dev *ca = bch_dev_bkey_exists(c, rb->pick.ptr.dev); + bch2_latency_acct(ca, rb->start_time, READ); } @@ -1411,6 +1412,7 @@ static void btree_node_read_all_replicas_endio(struct bio *bio) if (rb->have_ioref) { struct bch_dev *ca = bch_dev_bkey_exists(c, rb->pick.ptr.dev); + bch2_latency_acct(ca, rb->start_time, READ); } diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 5af295317cee..cbba0b79fdb8 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -200,6 +200,7 @@ err: if (p) { struct bkey uk = bkey_unpack_key(l->b, p); + bch2_bkey_to_text(&buf2, &uk); } else { prt_printf(&buf2, "(none)"); @@ -207,6 +208,7 @@ err: if (k) { struct bkey uk = bkey_unpack_key(l->b, k); + bch2_bkey_to_text(&buf3, &uk); } else { prt_printf(&buf3, "(none)"); diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index 670746e72dab..eccea15fca79 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _BCACHEFS_BTREE_KEY_CACHE_H #define _BCACHEFS_BTREE_KEY_CACHE_H diff --git a/fs/bcachefs/checksum.h b/fs/bcachefs/checksum.h index c86c3c05d620..3d6d13bcfd72 100644 --- a/fs/bcachefs/checksum.h +++ b/fs/bcachefs/checksum.h @@ -78,15 +78,15 @@ static inline enum bch_csum_type bch2_csum_opt_to_type(enum bch_csum_opts type, { switch (type) { case BCH_CSUM_OPT_none: - return BCH_CSUM_none; + return BCH_CSUM_none; case BCH_CSUM_OPT_crc32c: - return data ? BCH_CSUM_crc32c : BCH_CSUM_crc32c_nonzero; + return data ? BCH_CSUM_crc32c : BCH_CSUM_crc32c_nonzero; case BCH_CSUM_OPT_crc64: - return data ? BCH_CSUM_crc64 : BCH_CSUM_crc64_nonzero; + return data ? BCH_CSUM_crc64 : BCH_CSUM_crc64_nonzero; case BCH_CSUM_OPT_xxhash: - return BCH_CSUM_xxhash; + return BCH_CSUM_xxhash; default: - BUG(); + BUG(); } } diff --git a/fs/bcachefs/dirent.h b/fs/bcachefs/dirent.h index b1466932c768..1a2c9108f864 100644 --- a/fs/bcachefs/dirent.h +++ b/fs/bcachefs/dirent.h @@ -9,10 +9,10 @@ extern const struct bch_hash_desc bch2_dirent_hash_desc; int bch2_dirent_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); void bch2_dirent_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_dirent (struct bkey_ops) { \ +#define bch2_bkey_ops_dirent ((struct bkey_ops) { \ .key_invalid = bch2_dirent_invalid, \ .val_to_text = bch2_dirent_to_text, \ -} +}) struct qstr; struct file; diff --git a/fs/bcachefs/ec.h b/fs/bcachefs/ec.h index c53187df4651..8596fa763b4c 100644 --- a/fs/bcachefs/ec.h +++ b/fs/bcachefs/ec.h @@ -12,13 +12,13 @@ int bch2_stripe_invalid(const struct bch_fs *, struct bkey_s_c, void bch2_stripe_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_stripe (struct bkey_ops) { \ +#define bch2_bkey_ops_stripe ((struct bkey_ops) { \ .key_invalid = bch2_stripe_invalid, \ .val_to_text = bch2_stripe_to_text, \ .swab = bch2_ptr_swab, \ .trans_trigger = bch2_trans_mark_stripe, \ .atomic_trigger = bch2_mark_stripe, \ -} +}) static inline unsigned stripe_csums_per_device(const struct bch_stripe *s) { diff --git a/fs/bcachefs/errcode.c b/fs/bcachefs/errcode.c index cc9ce0be356e..dc906fc9176f 100644 --- a/fs/bcachefs/errcode.c +++ b/fs/bcachefs/errcode.c @@ -23,6 +23,7 @@ static unsigned bch2_errcode_parents[] = { const char *bch2_err_str(int err) { const char *errstr; + err = abs(err); BUG_ON(err >= BCH_ERR_MAX); diff --git a/fs/bcachefs/extents.h b/fs/bcachefs/extents.h index 3c17b81130bb..224df17206cb 100644 --- a/fs/bcachefs/extents.h +++ b/fs/bcachefs/extents.h @@ -198,6 +198,7 @@ static inline struct bkey_ptrs_c bch2_bkey_ptrs_c(struct bkey_s_c k) switch (k.k->type) { case KEY_TYPE_btree_ptr: { struct bkey_s_c_btree_ptr e = bkey_s_c_to_btree_ptr(k); + return (struct bkey_ptrs_c) { to_entry(&e.v->start[0]), to_entry(extent_entry_last(e)) @@ -205,6 +206,7 @@ static inline struct bkey_ptrs_c bch2_bkey_ptrs_c(struct bkey_s_c k) } case KEY_TYPE_extent: { struct bkey_s_c_extent e = bkey_s_c_to_extent(k); + return (struct bkey_ptrs_c) { e.v->start, extent_entry_last(e) @@ -212,6 +214,7 @@ static inline struct bkey_ptrs_c bch2_bkey_ptrs_c(struct bkey_s_c k) } case KEY_TYPE_stripe: { struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k); + return (struct bkey_ptrs_c) { to_entry(&s.v->ptrs[0]), to_entry(&s.v->ptrs[s.v->nr_blocks]), @@ -227,6 +230,7 @@ static inline struct bkey_ptrs_c bch2_bkey_ptrs_c(struct bkey_s_c k) } case KEY_TYPE_btree_ptr_v2: { struct bkey_s_c_btree_ptr_v2 e = bkey_s_c_to_btree_ptr_v2(k); + return (struct bkey_ptrs_c) { to_entry(&e.v->start[0]), to_entry(extent_entry_last(e)) @@ -342,7 +346,7 @@ out: \ #define extent_for_each_entry_from(_e, _entry, _start) \ __bkey_extent_entry_for_each_from(_start, \ - extent_entry_last(_e),_entry) + extent_entry_last(_e), _entry) #define extent_for_each_entry(_e, _entry) \ extent_for_each_entry_from(_e, _entry, (_e).v->start) @@ -376,28 +380,28 @@ void bch2_btree_ptr_v2_to_text(struct printbuf *, struct bch_fs *, struct bkey_s void bch2_btree_ptr_v2_compat(enum btree_id, unsigned, unsigned, int, struct bkey_s); -#define bch2_bkey_ops_btree_ptr (struct bkey_ops) { \ +#define bch2_bkey_ops_btree_ptr ((struct bkey_ops) { \ .key_invalid = bch2_btree_ptr_invalid, \ .val_to_text = bch2_btree_ptr_to_text, \ .swab = bch2_ptr_swab, \ .trans_trigger = bch2_trans_mark_extent, \ .atomic_trigger = bch2_mark_extent, \ -} +}) -#define bch2_bkey_ops_btree_ptr_v2 (struct bkey_ops) { \ +#define bch2_bkey_ops_btree_ptr_v2 ((struct bkey_ops) { \ .key_invalid = bch2_btree_ptr_v2_invalid, \ .val_to_text = bch2_btree_ptr_v2_to_text, \ .swab = bch2_ptr_swab, \ .compat = bch2_btree_ptr_v2_compat, \ .trans_trigger = bch2_trans_mark_extent, \ .atomic_trigger = bch2_mark_extent, \ -} +}) /* KEY_TYPE_extent: */ bool bch2_extent_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c); -#define bch2_bkey_ops_extent (struct bkey_ops) { \ +#define bch2_bkey_ops_extent ((struct bkey_ops) { \ .key_invalid = bch2_bkey_ptrs_invalid, \ .val_to_text = bch2_bkey_ptrs_to_text, \ .swab = bch2_ptr_swab, \ @@ -405,7 +409,7 @@ bool bch2_extent_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c); .key_merge = bch2_extent_merge, \ .trans_trigger = bch2_trans_mark_extent, \ .atomic_trigger = bch2_mark_extent, \ -} +}) /* KEY_TYPE_reservation: */ @@ -414,13 +418,13 @@ int bch2_reservation_invalid(const struct bch_fs *, struct bkey_s_c, void bch2_reservation_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); bool bch2_reservation_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c); -#define bch2_bkey_ops_reservation (struct bkey_ops) { \ +#define bch2_bkey_ops_reservation ((struct bkey_ops) { \ .key_invalid = bch2_reservation_invalid, \ .val_to_text = bch2_reservation_to_text, \ .key_merge = bch2_reservation_merge, \ .trans_trigger = bch2_trans_mark_reservation, \ .atomic_trigger = bch2_mark_reservation, \ -} +}) /* Extent checksum entries: */ diff --git a/fs/bcachefs/fifo.h b/fs/bcachefs/fifo.h index cdb272708a4b..66b945be10c2 100644 --- a/fs/bcachefs/fifo.h +++ b/fs/bcachefs/fifo.h @@ -65,7 +65,7 @@ do { \ (((p) - (fifo)->data))) #define fifo_entry_idx(fifo, p) (((p) - &fifo_peek_front(fifo)) & (fifo)->mask) -#define fifo_idx_entry(fifo, i) (fifo)->data[((fifo)->front + (i)) & (fifo)->mask] +#define fifo_idx_entry(fifo, i) ((fifo)->data[((fifo)->front + (i)) & (fifo)->mask]) #define fifo_push_back_ref(f) \ (fifo_full((f)) ? NULL : &(f)->data[(f)->back++ & (f)->mask]) diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 6f7310f010b9..f4f0e0cec85d 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -848,8 +848,7 @@ out: printbuf_exit(&buf); return ret; bad_hash: - if (fsck_err(c, "hash table key at wrong offset: btree %s inode %llu offset %llu, " - "hashed to %llu\n%s", + if (fsck_err(c, "hash table key at wrong offset: btree %s inode %llu offset %llu, hashed to %llu\n%s", bch2_btree_ids[desc.btree_id], hash_k.k->p.inode, hash_k.k->p.offset, hash, (printbuf_reset(&buf), bch2_bkey_val_to_text(&buf, c, hash_k), buf.buf))) { diff --git a/fs/bcachefs/inode.h b/fs/bcachefs/inode.h index 5c80bdf587f9..9ea0d575a183 100644 --- a/fs/bcachefs/inode.h +++ b/fs/bcachefs/inode.h @@ -11,19 +11,19 @@ int bch2_inode_invalid(const struct bch_fs *, struct bkey_s_c, int, struct print int bch2_inode_v2_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); void bch2_inode_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_inode (struct bkey_ops) { \ +#define bch2_bkey_ops_inode ((struct bkey_ops) { \ .key_invalid = bch2_inode_invalid, \ .val_to_text = bch2_inode_to_text, \ .trans_trigger = bch2_trans_mark_inode, \ .atomic_trigger = bch2_mark_inode, \ -} +}) -#define bch2_bkey_ops_inode_v2 (struct bkey_ops) { \ +#define bch2_bkey_ops_inode_v2 ((struct bkey_ops) { \ .key_invalid = bch2_inode_v2_invalid, \ .val_to_text = bch2_inode_to_text, \ .trans_trigger = bch2_trans_mark_inode, \ .atomic_trigger = bch2_mark_inode, \ -} +}) static inline bool bkey_is_inode(const struct bkey *k) { @@ -35,10 +35,10 @@ int bch2_inode_generation_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); void bch2_inode_generation_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_inode_generation (struct bkey_ops) { \ +#define bch2_bkey_ops_inode_generation ((struct bkey_ops) { \ .key_invalid = bch2_inode_generation_invalid, \ .val_to_text = bch2_inode_generation_to_text, \ -} +}) #if 0 typedef struct { diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h index d3caa7ea7ce9..3e93f0d67c09 100644 --- a/fs/bcachefs/journal.h +++ b/fs/bcachefs/journal.h @@ -29,8 +29,8 @@ * * Synchronous updates are specified by passing a closure (@flush_cl) to * bch2_btree_insert() or bch_btree_insert_node(), which then pass that parameter - * down to the journalling code. That closure will will wait on the journal - * write to complete (via closure_wait()). + * down to the journalling code. That closure will wait on the journal write to + * complete (via closure_wait()). * * If the index update wasn't synchronous, the journal entry will be * written out after 10 ms have elapsed, by default (the delay_ms field diff --git a/fs/bcachefs/lru.h b/fs/bcachefs/lru.h index 3decb7b1dde2..925c29b49b86 100644 --- a/fs/bcachefs/lru.h +++ b/fs/bcachefs/lru.h @@ -5,10 +5,10 @@ int bch2_lru_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); void bch2_lru_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_lru (struct bkey_ops) { \ +#define bch2_bkey_ops_lru ((struct bkey_ops) { \ .key_invalid = bch2_lru_invalid, \ .val_to_text = bch2_lru_to_text, \ -} +}) int bch2_lru_delete(struct btree_trans *, u64, u64, u64, struct bkey_s_c); int bch2_lru_set(struct btree_trans *, u64, u64, u64 *); diff --git a/fs/bcachefs/quota.h b/fs/bcachefs/quota.h index 8c67ae1da7c7..59bed1148201 100644 --- a/fs/bcachefs/quota.h +++ b/fs/bcachefs/quota.h @@ -10,10 +10,10 @@ extern const struct bch_sb_field_ops bch_sb_field_ops_quota; int bch2_quota_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); void bch2_quota_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_quota (struct bkey_ops) { \ +#define bch2_bkey_ops_quota ((struct bkey_ops) { \ .key_invalid = bch2_quota_invalid, \ .val_to_text = bch2_quota_to_text, \ -} +}) static inline struct bch_qid bch_qid(struct bch_inode_unpacked *u) { diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index b2379adcf8ae..7eaced534a5b 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -1509,8 +1509,7 @@ int bch2_fs_initialize(struct bch_fs *c) goto err; bch_verbose(c, "reading snapshots done"); - bch2_inode_init(c, &root_inode, 0, 0, - S_IFDIR|S_IRWXU|S_IRUGO|S_IXUGO, 0, NULL); + bch2_inode_init(c, &root_inode, 0, 0, S_IFDIR|0755, 0, NULL); root_inode.bi_inum = BCACHEFS_ROOT_INO; root_inode.bi_subvol = BCACHEFS_ROOT_SUBVOL; bch2_inode_pack(c, &packed_inode, &root_inode); diff --git a/fs/bcachefs/reflink.h b/fs/bcachefs/reflink.h index f9848dc3eebb..ce0012aa99c6 100644 --- a/fs/bcachefs/reflink.h +++ b/fs/bcachefs/reflink.h @@ -8,13 +8,13 @@ void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c); -#define bch2_bkey_ops_reflink_p (struct bkey_ops) { \ +#define bch2_bkey_ops_reflink_p ((struct bkey_ops) { \ .key_invalid = bch2_reflink_p_invalid, \ .val_to_text = bch2_reflink_p_to_text, \ .key_merge = bch2_reflink_p_merge, \ .trans_trigger = bch2_trans_mark_reflink_p, \ .atomic_trigger = bch2_mark_reflink_p, \ -} +}) int bch2_reflink_v_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); @@ -23,13 +23,13 @@ void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *, int bch2_trans_mark_reflink_v(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned); -#define bch2_bkey_ops_reflink_v (struct bkey_ops) { \ +#define bch2_bkey_ops_reflink_v ((struct bkey_ops) { \ .key_invalid = bch2_reflink_v_invalid, \ .val_to_text = bch2_reflink_v_to_text, \ .swab = bch2_ptr_swab, \ .trans_trigger = bch2_trans_mark_reflink_v, \ .atomic_trigger = bch2_mark_extent, \ -} +}) int bch2_indirect_inline_data_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); @@ -40,11 +40,11 @@ int bch2_trans_mark_indirect_inline_data(struct btree_trans *, struct bkey_s_c, struct bkey_i *, unsigned); -#define bch2_bkey_ops_indirect_inline_data (struct bkey_ops) { \ +#define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) { \ .key_invalid = bch2_indirect_inline_data_invalid, \ .val_to_text = bch2_indirect_inline_data_to_text, \ .trans_trigger = bch2_trans_mark_indirect_inline_data, \ -} +}) static inline const __le64 *bkey_refcount_c(struct bkey_s_c k) { diff --git a/fs/bcachefs/replicas_types.h b/fs/bcachefs/replicas_types.h index 0535b1d3760e..f12a35b3dbcf 100644 --- a/fs/bcachefs/replicas_types.h +++ b/fs/bcachefs/replicas_types.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef _BCACHEFS_REPLICAS_TYPES_H #define _BCACHEFS_REPLICAS_TYPES_H diff --git a/fs/bcachefs/subvolume.c b/fs/bcachefs/subvolume.c index 8c98bacca290..1133783477e1 100644 --- a/fs/bcachefs/subvolume.c +++ b/fs/bcachefs/subvolume.c @@ -158,6 +158,7 @@ static int bch2_snapshot_set_equiv(struct btree_trans *trans, struct bkey_s_c k) for (i = 0; i < 2; i++) { int ret = snapshot_live(trans, child[i]); + if (ret < 0) return ret; diff --git a/fs/bcachefs/subvolume.h b/fs/bcachefs/subvolume.h index 02a636644988..c694c1c24483 100644 --- a/fs/bcachefs/subvolume.h +++ b/fs/bcachefs/subvolume.h @@ -9,10 +9,10 @@ void bch2_snapshot_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); int bch2_snapshot_invalid(const struct bch_fs *, struct bkey_s_c, int rw, struct printbuf *); -#define bch2_bkey_ops_snapshot (struct bkey_ops) { \ +#define bch2_bkey_ops_snapshot ((struct bkey_ops) { \ .key_invalid = bch2_snapshot_invalid, \ .val_to_text = bch2_snapshot_to_text, \ -} +}) int bch2_mark_snapshot(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); @@ -109,10 +109,10 @@ int bch2_subvolume_invalid(const struct bch_fs *, struct bkey_s_c, int rw, struct printbuf *); void bch2_subvolume_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_subvolume (struct bkey_ops) { \ +#define bch2_bkey_ops_subvolume ((struct bkey_ops) { \ .key_invalid = bch2_subvolume_invalid, \ .val_to_text = bch2_subvolume_to_text, \ -} +}) int bch2_subvolume_get(struct btree_trans *, unsigned, bool, int, struct bch_subvolume *); diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c index db3d377ba10c..7ccdf3197d51 100644 --- a/fs/bcachefs/sysfs.c +++ b/fs/bcachefs/sysfs.c @@ -89,9 +89,9 @@ static ssize_t fn ## _store_inner(struct kobject *kobj, struct attribute *attr,\ static struct attribute sysfs_##_name = \ { .name = #_name, .mode = _mode } -#define write_attribute(n) __sysfs_attribute(n, S_IWUSR) -#define read_attribute(n) __sysfs_attribute(n, S_IRUGO) -#define rw_attribute(n) __sysfs_attribute(n, S_IRUGO|S_IWUSR) +#define write_attribute(n) __sysfs_attribute(n, 0200) +#define read_attribute(n) __sysfs_attribute(n, 0444) +#define rw_attribute(n) __sysfs_attribute(n, 0644) #define sysfs_printf(file, fmt, ...) \ do { \ @@ -228,13 +228,13 @@ write_attribute(perf_test); #define x(_name) \ static struct attribute sysfs_time_stat_##_name = \ - { .name = #_name, .mode = S_IRUGO }; + { .name = #_name, .mode = 0444 }; BCH_TIME_STATS() #undef x static struct attribute sysfs_state_rw = { .name = "state", - .mode = S_IRUGO + .mode = 0444, }; static size_t bch2_btree_cache_size(struct bch_fs *c) @@ -610,12 +610,14 @@ struct attribute *bch2_fs_counters_files[] = { SHOW(bch2_fs_internal) { struct bch_fs *c = container_of(kobj, struct bch_fs, internal); + return bch2_fs_to_text(out, &c->kobj, attr); } STORE(bch2_fs_internal) { struct bch_fs *c = container_of(kobj, struct bch_fs, internal); + return bch2_fs_store(&c->kobj, attr, buf, size); } SYSFS_OPS(bch2_fs_internal); diff --git a/fs/bcachefs/trace.h b/fs/bcachefs/trace.h index b5f44c4e80d1..7004da8d341f 100644 --- a/fs/bcachefs/trace.h +++ b/fs/bcachefs/trace.h @@ -354,7 +354,7 @@ TRACE_EVENT(btree_reserve_get_fail, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->required = required; ), @@ -411,7 +411,7 @@ TRACE_EVENT(btree_path_relock_fail, TP_fast_assign( struct btree *b = btree_path_node(path, level); - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->btree_id = path->btree_id; __entry->level = path->level; @@ -462,7 +462,7 @@ TRACE_EVENT(btree_path_upgrade_fail, TP_fast_assign( struct six_lock_count c; - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->btree_id = path->btree_id; __entry->level = level; @@ -544,7 +544,7 @@ DECLARE_EVENT_CLASS(bucket_alloc, TP_fast_assign( __entry->dev = ca->dev; - strlcpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); + strscpy(__entry->reserve, alloc_reserve, sizeof(__entry->reserve)); __entry->user = user; __entry->bucket = bucket; __entry->free = free; @@ -556,7 +556,7 @@ DECLARE_EVENT_CLASS(bucket_alloc, __entry->need_journal_commit = s->skipped_need_journal_commit; __entry->nouse = s->skipped_nouse; __entry->nonblocking = nonblocking; - strlcpy(__entry->err, err, sizeof(__entry->err)); + strscpy(__entry->err, err, sizeof(__entry->err)); ), TP_printk("%d,%d reserve %s user %u bucket %llu free %llu avail %llu copygc_wait %llu/%lli seen %llu open %llu need_journal_commit %llu nouse %llu nonblocking %u err %s", @@ -628,7 +628,7 @@ TRACE_EVENT(discard_buckets, __entry->open = open; __entry->need_journal_commit = need_journal_commit; __entry->discarded = discarded; - strlcpy(__entry->err, err, sizeof(__entry->err)); + strscpy(__entry->err, err, sizeof(__entry->err)); ), TP_printk("%d%d seen %llu open %llu need_journal_commit %llu discarded %llu err %s", @@ -778,7 +778,7 @@ DECLARE_EVENT_CLASS(transaction_event, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; ), @@ -823,7 +823,7 @@ TRACE_EVENT(trans_restart_journal_preres_get, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->flags = flags; ), @@ -883,7 +883,7 @@ DECLARE_EVENT_CLASS(transaction_restart_iter, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->btree_id = path->btree_id; TRACE_BPOS_assign(pos, path->pos) @@ -930,7 +930,7 @@ TRACE_EVENT(trans_restart_upgrade, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->btree_id = path->btree_id; __entry->old_locks_want = old_locks_want; @@ -1039,7 +1039,7 @@ TRACE_EVENT(trans_restart_would_deadlock_write, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); ), TP_printk("%s", __entry->trans_fn) @@ -1058,7 +1058,7 @@ TRACE_EVENT(trans_restart_mem_realloced, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->bytes = bytes; ), @@ -1087,7 +1087,7 @@ TRACE_EVENT(trans_restart_key_cache_key_realloced, ), TP_fast_assign( - strlcpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); + strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn)); __entry->caller_ip = caller_ip; __entry->btree_id = path->btree_id; diff --git a/fs/bcachefs/xattr.h b/fs/bcachefs/xattr.h index 66d7a1e30350..03f1b73fc926 100644 --- a/fs/bcachefs/xattr.h +++ b/fs/bcachefs/xattr.h @@ -9,10 +9,10 @@ extern const struct bch_hash_desc bch2_xattr_hash_desc; int bch2_xattr_invalid(const struct bch_fs *, struct bkey_s_c, int, struct printbuf *); void bch2_xattr_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c); -#define bch2_bkey_ops_xattr (struct bkey_ops) { \ +#define bch2_bkey_ops_xattr ((struct bkey_ops) { \ .key_invalid = bch2_xattr_invalid, \ .val_to_text = bch2_xattr_to_text, \ -} +}) static inline unsigned xattr_val_u64s(unsigned name_len, unsigned val_len) { |