From patchwork Mon Oct 8 10:44:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10630385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38EF715E2 for ; Mon, 8 Oct 2018 10:44:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2876B26E98 for ; Mon, 8 Oct 2018 10:44:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B04628A34; Mon, 8 Oct 2018 10:44:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C527826E98 for ; Mon, 8 Oct 2018 10:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727278AbeJHRz4 (ORCPT ); Mon, 8 Oct 2018 13:55:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:40930 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726330AbeJHRz4 (ORCPT ); Mon, 8 Oct 2018 13:55:56 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 377C7AEEF for ; Mon, 8 Oct 2018 10:44:50 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 4/5] btrfs-progs: original check: Add dev_item check for used bytes and total bytes Date: Mon, 8 Oct 2018 18:44:35 +0800 Message-Id: <20181008104436.19267-5-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181008104436.19267-1-wqu@suse.com> References: <20181008104436.19267-1-wqu@suse.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Qu Wenruo --- check/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/check/main.c b/check/main.c index ff9a785ce555..12f12e18a83f 100644 --- a/check/main.c +++ b/check/main.c @@ -7938,6 +7938,12 @@ static int check_device_used(struct device_record *dev_rec, struct device_extent_record *dev_extent_rec; u64 total_byte = 0; + if (dev_rec->byte_used > dev_rec->total_byte) { + error("device %llu has incorrect used bytes %llu > total bytes %llu", + dev_rec->devid, dev_rec->byte_used, dev_rec->total_byte); + return -EUCLEAN; + } + cache = search_cache_extent2(&dext_cache->tree, dev_rec->devid, 0); while (cache) { dev_extent_rec = container_of(cache,