Commit 82697a10 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix 32 bit build

vstruct_bytes() was returning a u64 - it should be a size_t, the corect
type for the size of anything that fits in memory.

Also replace a 64 bit divide with div_u64().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 78a8f362
...@@ -1105,7 +1105,7 @@ int bch2_journal_read(struct bch_fs *c, struct list_head *list, ...@@ -1105,7 +1105,7 @@ int bch2_journal_read(struct bch_fs *c, struct list_head *list,
struct journal_replay *p = list_prev_entry(i, list); struct journal_replay *p = list_prev_entry(i, list);
bch2_journal_ptrs_to_text(&out, c, p); bch2_journal_ptrs_to_text(&out, c, p);
pr_buf(&out, " size %llu", vstruct_sectors(&p->j, c->block_bits)); pr_buf(&out, " size %zu", vstruct_sectors(&p->j, c->block_bits));
} else } else
sprintf(buf1, "(none)"); sprintf(buf1, "(none)");
bch2_journal_ptrs_to_text(&PBUF(buf2), c, i); bch2_journal_ptrs_to_text(&PBUF(buf2), c, i);
......
...@@ -23,7 +23,7 @@ static int bch2_sb_quota_validate(struct bch_sb *sb, struct bch_sb_field *f, ...@@ -23,7 +23,7 @@ static int bch2_sb_quota_validate(struct bch_sb *sb, struct bch_sb_field *f,
struct bch_sb_field_quota *q = field_to_type(f, quota); struct bch_sb_field_quota *q = field_to_type(f, quota);
if (vstruct_bytes(&q->field) < sizeof(*q)) { if (vstruct_bytes(&q->field) < sizeof(*q)) {
pr_buf(err, "wrong size (got %llu should be %zu)", pr_buf(err, "wrong size (got %zu should be %zu)",
vstruct_bytes(&q->field), sizeof(*q)); vstruct_bytes(&q->field), sizeof(*q));
return -EINVAL; return -EINVAL;
} }
......
...@@ -1147,7 +1147,7 @@ static int bch2_sb_crypt_validate(struct bch_sb *sb, ...@@ -1147,7 +1147,7 @@ static int bch2_sb_crypt_validate(struct bch_sb *sb,
struct bch_sb_field_crypt *crypt = field_to_type(f, crypt); struct bch_sb_field_crypt *crypt = field_to_type(f, crypt);
if (vstruct_bytes(&crypt->field) < sizeof(*crypt)) { if (vstruct_bytes(&crypt->field) < sizeof(*crypt)) {
pr_buf(err, "wrong size (got %llu should be %zu)", pr_buf(err, "wrong size (got %zu should be %zu)",
vstruct_bytes(&crypt->field), sizeof(*crypt)); vstruct_bytes(&crypt->field), sizeof(*crypt));
return -EINVAL; return -EINVAL;
} }
...@@ -1390,7 +1390,7 @@ static int bch2_sb_clean_validate(struct bch_sb *sb, ...@@ -1390,7 +1390,7 @@ static int bch2_sb_clean_validate(struct bch_sb *sb,
struct bch_sb_field_clean *clean = field_to_type(f, clean); struct bch_sb_field_clean *clean = field_to_type(f, clean);
if (vstruct_bytes(&clean->field) < sizeof(*clean)) { if (vstruct_bytes(&clean->field) < sizeof(*clean)) {
pr_buf(err, "wrong size (got %llu should be %zu)", pr_buf(err, "wrong size (got %zu should be %zu)",
vstruct_bytes(&clean->field), sizeof(*clean)); vstruct_bytes(&clean->field), sizeof(*clean));
return -EINVAL; return -EINVAL;
} }
...@@ -1467,7 +1467,7 @@ void bch2_sb_field_to_text(struct printbuf *out, struct bch_sb *sb, ...@@ -1467,7 +1467,7 @@ void bch2_sb_field_to_text(struct printbuf *out, struct bch_sb *sb,
else else
pr_buf(out, "(unknown field %u)", type); pr_buf(out, "(unknown field %u)", type);
pr_buf(out, " (size %llu):", vstruct_bytes(f)); pr_buf(out, " (size %zu):", vstruct_bytes(f));
pr_newline(out); pr_newline(out);
if (ops && ops->to_text) { if (ops && ops->to_text) {
...@@ -1543,7 +1543,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb, ...@@ -1543,7 +1543,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
pr_buf(out, "Created: "); pr_buf(out, "Created: ");
if (sb->time_base_lo) if (sb->time_base_lo)
pr_time(out, le64_to_cpu(sb->time_base_lo) / NSEC_PER_SEC); pr_time(out, div_u64(le64_to_cpu(sb->time_base_lo), NSEC_PER_SEC));
else else
pr_buf(out, "(not set)"); pr_buf(out, "(not set)");
pr_newline(out); pr_newline(out);
...@@ -1649,7 +1649,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb, ...@@ -1649,7 +1649,7 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
bch2_flags_to_text(out, bch2_sb_fields, fields_have); bch2_flags_to_text(out, bch2_sb_fields, fields_have);
pr_newline(out); pr_newline(out);
pr_buf(out, "Superblock size: %llu", vstruct_bytes(sb)); pr_buf(out, "Superblock size: %zu", vstruct_bytes(sb));
pr_newline(out); pr_newline(out);
if (print_layout) { if (print_layout) {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
({ \ ({ \
BUILD_BUG_ON(offsetof(_type, _data) % sizeof(u64)); \ BUILD_BUG_ON(offsetof(_type, _data) % sizeof(u64)); \
\ \
(offsetof(_type, _data) + (_u64s) * sizeof(u64)); \ (size_t) (offsetof(_type, _data) + (_u64s) * sizeof(u64)); \
}) })
#define vstruct_bytes(_s) \ #define vstruct_bytes(_s) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment