From patchwork Sun Dec 2 14:38:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 10707877 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 1F4751057 for ; Sun, 2 Dec 2018 06:39:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 075102B3C3 for ; Sun, 2 Dec 2018 06:39:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECF892B3D6; Sun, 2 Dec 2018 06:39:14 +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=-6.1 required=2.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 794382B3C3 for ; Sun, 2 Dec 2018 06:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725535AbeLBGjO (ORCPT ); Sun, 2 Dec 2018 01:39:14 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44061 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbeLBGjO (ORCPT ); Sun, 2 Dec 2018 01:39:14 -0500 Received: by mail-pf1-f196.google.com with SMTP id u6so4784380pfh.11 for ; Sat, 01 Dec 2018 22:39:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9Ob9CUzmD8sAzSSAwjo4IWvZOovBlakf1kDH8eNSei8=; b=FqZt5kQ4IVN0+yROM5STYs0GDZ6rK4xr5ktSk7JnJGDLuVU6xnA9b2srmdW6F16sJx Q9kTWwYowVSE4PbFxNCIHXzJlQaHA6U/6DY+Od7y+Cde2kLIz16SErvIhg8pBGencaMV WynofQbHlp0tbPT05vInvw7kb+dS035KhfWzrTu5c+ibkdE2x0aQlI5lGT6tEBDJWIkD HAqfdYzfclivIZw/8lXSJ/aBmOBkQvi3zahNbURc+yNg4hk7iTYbO6EO3I1b1O8Vq9Y2 rLDEglPbWkq4lH6kTnV5EBNk59/S4ekByxhfQmKrKLT09c2D3g7zgSPN2kXyIAFNntrj fu/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Ob9CUzmD8sAzSSAwjo4IWvZOovBlakf1kDH8eNSei8=; b=jSd4a26aw4VK/cKE51JWg37xGwOmDjBv8VEejkFB0ij18pvvftPoVogtNJOdyiB/pR TfXP4TjY2reQABYKi+9GtRxIrLSQOaUS9/DzsbEiE7tRat5c/MJ6BtIXJsjIsE7M8Reg dF4thN2WofScefv19pltKIaZ6bIevMxrdg9RJ5owxGmwljKgQp/nm0AEUDuvzV0vVGgR 46EBCF76UwRcrh+OMKBDPf6Lkc7dl1xHZ8FUHa1O5BVFGjDmRcY+Ypd8kr7NTqx91wcY wR2r4b8WPvJrZzCsCxiIk5wWjSnpYo1WEirjDNC5W3c1duEcc+YN/IcvIvc6Yzs8c98g E5yg== X-Gm-Message-State: AA+aEWYAzQmU6+MuOYbdalLrADoSVJ+fezE0de4mCuyzJ8BQ3cGNP4jL 7ubz+CHlFDr3SWsq3DzV/49njWRs X-Google-Smtp-Source: AFSGD/XcGgS5bkQwDGFCVgCmmgz+hWRBhVOpaGhgRfnSn3pqJrBzPjEZV+2/oSNv4y2L3Vb2ea6ilw== X-Received: by 2002:a63:d846:: with SMTP id k6mr8634464pgj.251.1543732752336; Sat, 01 Dec 2018 22:39:12 -0800 (PST) Received: from cat-arch.lan ([173.82.208.113]) by smtp.gmail.com with ESMTPSA id v191sm11584264pgb.77.2018.12.01.22.39.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Dec 2018 22:39:11 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: suy.fnst@cn.fujitsu.com To: linux-btrfs@vger.kernel.org Cc: suy.fnst@cn.fujitsu.com Subject: [PATCH v2 02/13] btrfs-progs: lowmem: move nbytes check before isize check Date: Sun, 2 Dec 2018 14:38:55 +0000 Message-Id: <20181202143855.15533-1-suy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181023094147.7906-3-suy.fnst@cn.fujitsu.com> References: <20181023094147.7906-3-suy.fnst@cn.fujitsu.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 From: Su Yue For files, lowmem repair will try to check nbytes and isize, but isize check depends nbytes. Once bytes has been repaired, then isize should be checked and repaired. So move nbytes check before isize check. Also set nbytes to extent_size once repaired successfully. Signed-off-by: Su Yue --- Changelog: v2 Remove one unrelated change. --- check/mode-lowmem.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 3dce4d3b5fc1..58f8f6fabed7 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -2541,28 +2541,31 @@ out: } } - if (!nbytes && !no_holes && extent_end < isize) { - if (repair) - ret = punch_extent_hole(root, path, inode_id, - extent_end, isize - extent_end); + if (nbytes != extent_size) { + if (repair) { + ret = repair_inode_nbytes_lowmem(root, path, + inode_id, extent_size); + if (!ret) + nbytes = extent_size; + } if (!repair || ret) { err |= NBYTES_ERROR; error( - "root %llu INODE[%llu] size %llu should have a file extent hole", - root->objectid, inode_id, isize); + "root %llu INODE[%llu] nbytes %llu not equal to extent_size %llu", + root->objectid, inode_id, nbytes, + extent_size); } } - if (nbytes != extent_size) { + if (!nbytes && !no_holes && extent_end < isize) { if (repair) - ret = repair_inode_nbytes_lowmem(root, path, - inode_id, extent_size); + ret = punch_extent_hole(root, path, inode_id, + extent_end, isize - extent_end); if (!repair || ret) { err |= NBYTES_ERROR; error( - "root %llu INODE[%llu] nbytes %llu not equal to extent_size %llu", - root->objectid, inode_id, nbytes, - extent_size); + "root %llu INODE[%llu] size %llu should have a file extent hole", + root->objectid, inode_id, isize); } } }