aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/quota.c
diff options
context:
space:
mode:
authorGravatar Kent Overstreet <kent.overstreet@gmail.com> 2022-01-03 23:38:50 -0500
committerGravatar Kent Overstreet <kent.overstreet@linux.dev> 2023-10-22 17:09:21 -0400
commitefe68e1d65c008dd1f19517378d0ad0688c6a643 (patch)
tree05163aa98ac4e4ed0d2f057c7f48b3047a012921 /fs/bcachefs/quota.c
parentbcachefs: Use kvmalloc() for array of sorted keys in journal replay (diff)
downloadlinux-efe68e1d65c008dd1f19517378d0ad0688c6a643.tar.gz
linux-efe68e1d65c008dd1f19517378d0ad0688c6a643.tar.bz2
linux-efe68e1d65c008dd1f19517378d0ad0688c6a643.zip
bcachefs: Improved superblock-related error messages
This patch converts bch2_sb_validate() and the .validate methods for the various superblock sections to take printbuf, to which they can print detailed error messages, including printing the entire section that was invalid. This is a great improvement over the previous situation, where we could only return static strings that didn't have precise information about what was wrong. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/quota.c')
-rw-r--r--fs/bcachefs/quota.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/bcachefs/quota.c b/fs/bcachefs/quota.c
index 54bb2a454a5e..6fb8224f565e 100644
--- a/fs/bcachefs/quota.c
+++ b/fs/bcachefs/quota.c
@@ -6,15 +6,17 @@
#include "subvolume.h"
#include "super-io.h"
-static const char *bch2_sb_validate_quota(struct bch_sb *sb,
- struct bch_sb_field *f)
+static int bch2_sb_validate_quota(struct bch_sb *sb, struct bch_sb_field *f,
+ struct printbuf *err)
{
struct bch_sb_field_quota *q = field_to_type(f, quota);
- if (vstruct_bytes(&q->field) != sizeof(*q))
- return "invalid field quota: wrong size";
+ if (vstruct_bytes(&q->field) < sizeof(*q)) {
+ pr_buf(err, "wrong size (got %llu should be %zu)",
+ vstruct_bytes(&q->field), sizeof(*q));
+ }
- return NULL;
+ return 0;
}
const struct bch_sb_field_ops bch_sb_field_ops_quota = {