Obviously, used bytes can't be larger than total bytes.

Signed-off-by: Qu Wenruo <w...@suse.com>
---
 check/mode-lowmem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index d387423639e6..c50e34236ac8 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -4074,6 +4074,11 @@ static int check_dev_item(struct btrfs_fs_info *fs_info,
        used = btrfs_device_bytes_used(eb, dev_item);
        total_bytes = btrfs_device_total_bytes(eb, dev_item);
 
+       if (used > total_bytes) {
+               error("device %llu has incorrect used bytes %llu > total bytes 
%llu",
+                       dev_id, used, total_bytes);
+               return ACCOUNTING_MISMATCH;
+       }
        key.objectid = dev_id;
        key.type = BTRFS_DEV_EXTENT_KEY;
        key.offset = 0;
-- 
2.19.0

Reply via email to