From patchwork Tue Mar 29 21:17:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yauhen Kharuzhy X-Patchwork-Id: 8691251 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 261CE9F36E for ; Tue, 29 Mar 2016 21:17:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 110F320279 for ; Tue, 29 Mar 2016 21:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8863201B9 for ; Tue, 29 Mar 2016 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754466AbcC2VRx (ORCPT ); Tue, 29 Mar 2016 17:17:53 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33424 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753971AbcC2VRw (ORCPT ); Tue, 29 Mar 2016 17:17:52 -0400 Received: by mail-pa0-f68.google.com with SMTP id q6so3775547pav.0 for ; Tue, 29 Mar 2016 14:17:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3wkNsZTcmuX8iEDdST00WifxULvenLwh3MTUcTmNsqg=; b=W1jqglQ1sJlNgulsGNcB83aHHp5zyMMocmMq/s3rFCEJQeeznalhU8e6fa/EY91F5H 7Z8Zj4uywnhLVFrU5XiwYQ3vfax8ZF3f/zn5pi8HB/llTXvoT5q222wk7RdI00vphe8i NAgBEtcNRct8Hzt5y2hVuAVr6O2ztIOtDc9hmnNzKeujJfFm87MsEaS+yK4ZSohJxDPo FROyUWuxny04ZajX/2+14RlajhcrDnXInsgIvWQPKbMQV5CyEXlBZNhSNd0Y8G9fVSHi ptydn9Emdhzgb09H9EVulOQp6La6dtmfF4X69x6my6axq5aXN/b6TJTl/7RsLk58ufqK 1ggg== X-Gm-Message-State: AD7BkJI0+stafOQJOa2oKn9yH712q2aKvMvFotNMx5dcjeDxEc6nl2tqufNLxiyE/cSXBw== X-Received: by 10.66.146.196 with SMTP id te4mr6870757pab.125.1459286271959; Tue, 29 Mar 2016 14:17:51 -0700 (PDT) Received: from jek-Latitude-E7440 (sjc00ib2.hgst.com. [199.255.44.5]) by smtp.gmail.com with ESMTPSA id 9sm493401pft.44.2016.03.29.14.17.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Mar 2016 14:17:51 -0700 (PDT) Received: from jek by jek-Latitude-E7440 with local (Exim 4.86) (envelope-from ) id 1al11K-0004Kh-Fn; Tue, 29 Mar 2016 14:17:50 -0700 From: Yauhen Kharuzhy To: linux-btrfs@vger.kernel.org Cc: Yauhen Kharuzhy Subject: [PATCH] btrfs: Reset IO error counters before start of device replacing Date: Tue, 29 Mar 2016 14:17:48 -0700 Message-Id: <1459286268-16461-1-git-send-email-yauhen.kharuzhy@zavadatar.com> X-Mailer: git-send-email 2.5.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 If device replace entry was found on disk at mounting and its num_write_errors stats counter has non-NULL value, then replace operation will never be finished and -EIO error will be reported by btrfs_scrub_dev() because this counter is never reset. # mount -o degraded /media/a4fb5c0a-21c5-4fe7-8d0e-fdd87d5f71ee/ # btrfs replace status /media/a4fb5c0a-21c5-4fe7-8d0e-fdd87d5f71ee/ Started on 25.Mar 07:28:00, canceled on 25.Mar 07:28:01 at 0.0%, 40 write errs, 0 uncorr. read errs # btrfs replace start -B 4 /dev/sdg /media/a4fb5c0a-21c5-4fe7-8d0e-fdd87d5f71ee/ ERROR: ioctl(DEV_REPLACE_START) failed on "/media/a4fb5c0a-21c5-4fe7-8d0e-fdd87d5f71ee/": Input/output error, no error Reset num_write_errors and num_uncorrectable_read_errors counters in the dev_replace structure before start of replacing. Signed-off-by: Yauhen Kharuzhy Reviewed-by: David Sterba --- fs/btrfs/dev-replace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 08d629d..94b12d1 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -394,6 +394,8 @@ int btrfs_dev_replace_start(struct btrfs_root *root, dev_replace->cursor_right = 0; dev_replace->is_valid = 1; dev_replace->item_needs_writeback = 1; + atomic64_set(&dev_replace->num_write_errors, 0); + atomic64_set(&dev_replace->num_uncorrectable_read_errors, 0); args->result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; btrfs_dev_replace_unlock(dev_replace, 1);