diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-02-26 22:29:52 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:35 -0400 |
commit | 38f0664a5f596faf7d0a247697d6f21a85133cb9 (patch) | |
tree | 171468acc16501fe1213207b79324732e0e6d5df /fs/bcachefs/buckets.c | |
parent | f1f5f114cdd1af3ff68a0da972454d9956c26eb0 (diff) | |
download | lwn-38f0664a5f596faf7d0a247697d6f21a85133cb9.tar.gz lwn-38f0664a5f596faf7d0a247697d6f21a85133cb9.zip |
bcachefs: Fix error message on bucket sector count overflow
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.c')
-rw-r--r-- | fs/bcachefs/buckets.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 9fae7d9fb495..7e0412dac5ff 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -1444,8 +1444,7 @@ static int bch2_trans_mark_pointer(struct btree_trans *trans, struct bkey_s_c k; struct bkey_alloc_unpacked u; struct bkey_i_alloc *a; - u16 *dst_sectors; - bool overflow; + u16 *dst_sectors, orig_sectors; int ret; ret = trans_get_key(trans, BTREE_ID_ALLOC, @@ -1502,13 +1501,12 @@ static int bch2_trans_mark_pointer(struct btree_trans *trans, dst_sectors = !p.ptr.cached ? &u.dirty_sectors : &u.cached_sectors; + orig_sectors = *dst_sectors; - overflow = checked_add(*dst_sectors, sectors); - - if (overflow) { + if (checked_add(*dst_sectors, sectors)) { bch2_fs_inconsistent(c, "bucket sector count overflow: %u + %lli > U16_MAX", - *dst_sectors, sectors); + orig_sectors, sectors); /* return an error indicating that we need full fsck */ ret = -EIO; goto out; |