From patchwork Wed Dec 10 20:51:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mwilck@arcor.de X-Patchwork-Id: 5472491 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 12BD2BEEA8 for ; Wed, 10 Dec 2014 21:06:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 378A1201B4 for ; Wed, 10 Dec 2014 21:06:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E4E32018E for ; Wed, 10 Dec 2014 21:06:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933357AbaLJVGF (ORCPT ); Wed, 10 Dec 2014 16:06:05 -0500 Received: from mail-in-03.arcor-online.net ([151.189.21.43]:41849 "EHLO mail-in-03.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933320AbaLJVFn (ORCPT ); Wed, 10 Dec 2014 16:05:43 -0500 Received: from mail-in-15-z2.arcor-online.net (mail-in-15-z2.arcor-online.net [151.189.8.32]) by mx.arcor.de (Postfix) with ESMTP id 8C4DCD8511 for ; Wed, 10 Dec 2014 22:05:42 +0100 (CET) Received: from mail-in-10.arcor-online.net (mail-in-10.arcor-online.net [151.189.21.50]) by mail-in-15-z2.arcor-online.net (Postfix) with ESMTP id 8B712112047; Wed, 10 Dec 2014 22:05:42 +0100 (CET) X-Greylist: Passed host: 188.96.131.100 X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-10.arcor-online.net 5ED492D6670 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1418245542; bh=/L0Rs1gsBRikBvD0WYURWnTZqTei3ii/jiiQ3OjCQUQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=iYPvwvpZLFG7a7uBQ5fV5fFdVbmFIk2g9ZNb50lO+qkJhUVLyWbhzGYL/UPcdHo7k fX3Z2ZFEHyuCZlWLoFb5cOInkLPsEMRdQQ6GK7Dm1F3sPkMn11MrVxXerA6Vf2EM0J jcTpamNPJzM9wh4IQwNogkbX3TbWGR+NTakLg9gA= X-Greylist: Passed host: 188.96.131.100 Received: from localhost.localdomain (dslb-188-096-131-100.188.096.pools.vodafone-ip.de [188.96.131.100]) (Authenticated sender: mwilck@arcor.de) by mail-in-10.arcor-online.net (Postfix) with ESMTPSA id 5ED492D6670; Wed, 10 Dec 2014 22:05:42 +0100 (CET) From: mwilck@arcor.de To: linux-btrfs@vger.kernel.org Cc: mwilck@arcor.de Subject: [PATCH 13/18] btrfs restore: improve user-asking logic for files with many extents Date: Wed, 10 Dec 2014 21:51:43 +0100 Message-Id: <1418244708-7087-14-git-send-email-mwilck@arcor.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1418244708-7087-1-git-send-email-mwilck@arcor.de> References: <1418244708-7087-1-git-send-email-mwilck@arcor.de> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Wilck The logic to ask after 1024 extents is broken. It unnecessarily confuses users if big files are being restored, making them think somthing is going wrong. Change it to two cases: 1) no or little progress restoring, 2) writing beyond the file size. Signed-off-by: Martin Wilck --- cmds-restore.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cmds-restore.c b/cmds-restore.c index 80081b8..8ae3337 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -661,7 +661,7 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, #define MAYBE_NL (verbose && (next_pos >> display_shift) ? "\n" : "") const u64 display_shift = 16; struct stat st; - + int dont_ask = 0; path = btrfs_alloc_path(); if (!path) { fprintf(stderr, "Ran out of memory\n"); @@ -697,9 +697,21 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, } while (1) { - if (loops >= 0 && loops++ >= 1024) { + int problem = 0; + if (st.st_size == _INVALID_SIZE && next_pos > st.st_size) { + fprintf(stderr, "%swriting at offset %llu beyond size " + "of file (%llu)\n", + MAYBE_NL, next_pos, st.st_size); + problem = 1; + } + if ((++loops % 1024) == 0 && (next_pos / loops < 4096)) { + fprintf(stderr, "%smany loops (%d) and little progress " + "(%llu bytes)\n", + MAYBE_NL, loops, next_pos); + problem = 1; + } + if (problem && !dont_ask && loops++) { enum loop_response resp; - resp = ask_to_continue(file); if (resp == LOOP_STOP) break;