From patchwork Sun Sep 1 15:56:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 2852579 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 0BC87C0AB5 for ; Sun, 1 Sep 2013 15:57:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30C9C202C1 for ; Sun, 1 Sep 2013 15:57:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBE9D20295 for ; Sun, 1 Sep 2013 15:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757644Ab3IAP5I (ORCPT ); Sun, 1 Sep 2013 11:57:08 -0400 Received: from mail-ee0-f43.google.com ([74.125.83.43]:39782 "EHLO mail-ee0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757627Ab3IAP5H (ORCPT ); Sun, 1 Sep 2013 11:57:07 -0400 Received: by mail-ee0-f43.google.com with SMTP id e52so1842822eek.2 for ; Sun, 01 Sep 2013 08:57:05 -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=ii/+xUlRfxR1Shc/ENChtnZyZb8YqvXrgfeH2n27aYA=; b=XLPP/tMrSvYdm+RbvQc/ZeK0R/bQZHuFaStndHGq1FQHY81pF6wbsW/HRrznE/EQgQ kIxhNbwCX2JCvku03pnXu9ASsfEVcnKxlsFGsLQpyxTUTNRqSZ6ONAdsYxUslUoVaucK 0wbx3mE3kA63X6cP2C4fVWofegvC4f4q56h8GF8hAveFNJAOc6ppfE2qvlgAfAutcJ5b 8jhWPHuAnlsUfEcdee6lQh/erLaa9QMWmaSj2B4mcg/ij1zwrfD4PXkOCQ7BzMit2xnr lytT8ibDafwYoO6wNUb1TF5l6c+f9Tis4vAkmf5qUi7kV2VhNIQxLA+hyYWmW4H+QfdU rleg== X-Received: by 10.15.54.72 with SMTP id s48mr767742eew.58.1378051025502; Sun, 01 Sep 2013 08:57:05 -0700 (PDT) Received: from localhost ([109.110.88.55]) by mx.google.com with ESMTPSA id a1sm14360463eem.1.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 01 Sep 2013 08:57:04 -0700 (PDT) From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Stefan Behrens , idryomov@gmail.com Subject: [PATCH] Btrfs: do not add replace target to the alloc_list Date: Sun, 1 Sep 2013 18:56:44 +0300 Message-Id: <1378051004-8369-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.2 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 If replace was suspended by the umount, replace target device is added to the fs_devices->alloc_list during a later mount. This is obviously wrong. ->is_tgtdev_for_dev_replace is supposed to guard against that, but ->is_tgtdev_for_dev_replace is (and can only ever be) initialized *after* everything is opened and fs_devices lists are populated. Fix this by checking the devid instead: for replace targets it's always equal to BTRFS_DEV_REPLACE_DEVID. Cc: Stefan Behrens Signed-off-by: Ilya Dryomov Reviewed-by: Stefan Behrens --- At first I thought this was caused by my btrfs_device rollback patch, but no, it just made it easier to spot -- previously one had to reboot or rmmod/insmod before mounting a suspended replace. fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c9a0977..5b99f19 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -793,7 +793,8 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, fs_devices->rotating = 1; fs_devices->open_devices++; - if (device->writeable && !device->is_tgtdev_for_dev_replace) { + if (device->writeable && + device->devid != BTRFS_DEV_REPLACE_DEVID) { fs_devices->rw_devices++; list_add(&device->dev_alloc_list, &fs_devices->alloc_list);