From patchwork Thu Sep 25 10:28:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 4974081 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5873D9F1D4 for ; Thu, 25 Sep 2014 10:29:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21E2120274 for ; Thu, 25 Sep 2014 10:29:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD25D201CD for ; Thu, 25 Sep 2014 10:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751746AbaIYK3U (ORCPT ); Thu, 25 Sep 2014 06:29:20 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:49792 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751237AbaIYK3T (ORCPT ); Thu, 25 Sep 2014 06:29:19 -0400 Received: by mail-pa0-f53.google.com with SMTP id hz1so10482493pad.26 for ; Thu, 25 Sep 2014 03:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=UZ6xOBDRW8H3CBQRy9mktXHpo2ylDaQlQc6PKOMB/gQ=; b=JAMsd1kEK75KXn5flRUJGgxVdxPM7KFabCtsNNtS9dfHPu4X1IIw50UOq4E70J/0JH Uw5963lljoT69d7aOH0emUmERd4Yhb9RjPAHWyRvbCCgYxqYK5qClwscbzP0aH9WOdLK 4O39tEfgrrhsnroDfz0t8HH4j95F5wRQushI+GCIiaZzv4bgUdp3LjyPONmPrHEcHV+7 Eo7Dqy2WNg2PIVZnZzTkI3NuOy4X8eAOqfhx1IIv7B/p7yqNKJcSIDzyqcsXNzzPuOBg 43RS847bZE1va7u+AeVGWJDxh0LZzWgZPkofkfhGM/3/k2vtPQekBol6hWUXFYM7dq3Q 0VyQ== X-Received: by 10.66.146.35 with SMTP id sz3mr17413111pab.148.1411640959311; Thu, 25 Sep 2014 03:29:19 -0700 (PDT) Received: from localhost ([203.114.244.88]) by mx.google.com with ESMTPSA id nk11sm1784783pdb.40.2014.09.25.03.29.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Sep 2014 03:29:18 -0700 (PDT) From: Eryu Guan To: linux-btrfs@vger.kernel.org Cc: Eryu Guan Subject: [PATCH] Btrfs: return failure if btrfs_dev_replace_finishing() failed Date: Thu, 25 Sep 2014 18:28:14 +0800 Message-Id: <1411640894-5160-1-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 1.9.3 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.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 device replace could fail due to another running scrub process, but this failure doesn't get returned to userspace. The following steps could reproduce this issue mkfs -t btrfs -f /dev/sdb1 /dev/sdb2 mount /dev/sdb1 /mnt/btrfs while true; do btrfs scrub start -B /mnt/btrfs >/dev/null 2>&1 done & btrfs replace start -Bf /dev/sdb2 /dev/sdb3 /mnt/btrfs # if this replace succeeded, do the following and repeat until # you see this log in dmesg # BTRFS: btrfs_scrub_dev(/dev/sdb2, 2, /dev/sdb3) failed -115 #btrfs replace start -Bf /dev/sdb3 /dev/sdb2 /mnt/btrfs # once you see the error log in dmesg, check return value of # replace echo $? Also only WARN_ON if the return code is not -EINPROGRESS. Signed-off-by: Eryu Guan --- fs/btrfs/dev-replace.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index eea26e1..44d32ab 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -418,9 +418,11 @@ int btrfs_dev_replace_start(struct btrfs_root *root, &dev_replace->scrub_progress, 0, 1); ret = btrfs_dev_replace_finishing(root->fs_info, ret); - WARN_ON(ret); + /* don't warn if EINPROGRESS, someone else might be running scrub */ + if (ret != -EINPROGRESS) + WARN_ON(ret); - return 0; + return ret; leave: dev_replace->srcdev = NULL; @@ -538,7 +540,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); - return 0; + return scrub_ret; } printk_in_rcu(KERN_INFO