Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4614641pja; Thu, 21 Nov 2019 22:53:11 -0800 (PST) X-Google-Smtp-Source: APXvYqyoUo2jfTjIzgdiuL8FoO+/aemUWap2h314IoZENvuIUAq4yBqpbQHaM3n6SdVUCedBT7Q1 X-Received: by 2002:a17:907:2070:: with SMTP id qp16mr20303938ejb.115.1574405591315; Thu, 21 Nov 2019 22:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574405591; cv=none; d=google.com; s=arc-20160816; b=Wz5qgkcb1OOu2qfy9ku0ZUM+GWjcyw+pglHCil0iAwY3+XzdHqf+7534SUBFxHqeVE wRQMAMUpSBCWpBKA1WZtnZXMbvmiOdUt/lH5wZNcPPSKhEv3p1kGrYEH9kumtW2+wH/n oaYGLKRO+Vxr0LcHhNj+GZItJ7hL2ihRLO0q0D0tVyr0yMQi9fAwaolYGWVrEDVGSwvP Xf9jYh5cG/fSP3SGuv6ghVsQL3NwbK1dPLZYFFsdxqqJ2EujtBXoEZDPbrNtikY9aGLY 3pKl4/NFY6KImdUjksxGzIYYBFMKHwiHGJkBgA5gRTT62uuQCRuQeuA4xwijxTeSicit 4nTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zh738Ac+2prjpg2F1gDLk7Cypwxvn+zpds2WgFccErI=; b=AHVGweUCX9XhReTV2AMtb+5GymCFoFe23XilzyUyfiuQPyJP7TKlBrLxgv0hy3QHyu Adqo/HlZL6SNfkO86dfE2QXyhGo4qjOkXkCAr2nSyzuIWj2E3jkM14jtlvHaEOVKS17E 91mJehAtCiQLY3mX3+UnUNkXO0E0XllfakaP5nvmDb+lWiNJbpWbIf/m99cWENyGq5nD 1mUe8N3gwyUSA8A01FZybHHOWl1HUdcC/hngY2N9oFGk0VOeSsI+wFuwxkv9VXHdQF5d psVVbYsfI8GuH/XVUdaWYiLw1DL0N5xoola17qxF5g0mkn1Am/d7Fy+PalQEMb94xR7F sSag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SL6V17rw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si3822980edq.176.2019.11.21.22.52.48; Thu, 21 Nov 2019 22:53:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SL6V17rw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728229AbfKVG1O (ORCPT + 99 others); Fri, 22 Nov 2019 01:27:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:55092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727754AbfKVFuc (ORCPT ); Fri, 22 Nov 2019 00:50:32 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3AF2520717; Fri, 22 Nov 2019 05:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401831; bh=ixzM77mmAEzKa7tBc5NRii33XANhKZZ0LS4L+LzBBAE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SL6V17rwLHmPR2f1WhIsWGInhUj1ukWuEfQ3pVFEX5j8u4YgsX5PJ+7J0eaWsfmcP u20EKvGtl8PdeX/xH1K7nxPYk0yv5w6Kbejc5I5bty5Iet6LalReFqqAqonEax3kOt AYRKgdNLXKp2YiNcDr/Ot06QeuvQ6Nl5uR5zzlhE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anand Jain , David Sterba , Sasha Levin , linux-btrfs@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 073/219] btrfs: dev-replace: set result code of cancel by status of scrub Date: Fri, 22 Nov 2019 00:46:45 -0500 Message-Id: <20191122054911.1750-66-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anand Jain [ Upstream commit b47dda2ef6d793b67fd5979032dcd106e3f0a5c9 ] The device-replace needs to check the result code of the scrub workers in btrfs_dev_replace_cancel and distinguish if successful cancel operation and when the there was no operation running. If btrfs_scrub_cancel() fails, return BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED so that user can try to cancel the replace again. Signed-off-by: Anand Jain Reviewed-by: David Sterba [ update changelog ] Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/dev-replace.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 23b13fbecdc22..96763805787ed 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -810,16 +810,23 @@ int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) btrfs_dev_replace_write_unlock(dev_replace); break; case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED: - result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; tgt_device = dev_replace->tgtdev; src_device = dev_replace->srcdev; btrfs_dev_replace_write_unlock(dev_replace); - btrfs_scrub_cancel(fs_info); - /* btrfs_dev_replace_finishing() will handle the cleanup part */ - btrfs_info_in_rcu(fs_info, - "dev_replace from %s (devid %llu) to %s canceled", - btrfs_dev_name(src_device), src_device->devid, - btrfs_dev_name(tgt_device)); + ret = btrfs_scrub_cancel(fs_info); + if (ret < 0) { + result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED; + } else { + result = BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR; + /* + * btrfs_dev_replace_finishing() will handle the + * cleanup part + */ + btrfs_info_in_rcu(fs_info, + "dev_replace from %s (devid %llu) to %s canceled", + btrfs_dev_name(src_device), src_device->devid, + btrfs_dev_name(tgt_device)); + } break; case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED: /* -- 2.20.1