Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3468783imu; Sun, 11 Nov 2018 15:48:52 -0800 (PST) X-Google-Smtp-Source: AJdET5f+eTvBFsqtqkq4aki73e3/NuLmdQeuiLKpwTALRsT1zXMRalXVrW1bXi0ReQNRnAjxFIhB X-Received: by 2002:a63:dd15:: with SMTP id t21mr1861981pgg.347.1541980132848; Sun, 11 Nov 2018 15:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980132; cv=none; d=google.com; s=arc-20160816; b=IpHZ/vK0TWRrzTm531SGewYN/zkidpW1BrSwYCSsC7bfi43TpiRNDu6g7qdNk9rW84 ND9YZahX7l/eWzEuTS0iwy1bQAnGhyygVG17udvjaDeAp3xJm3LjL+5IVsJYox9VYQ0m gCiLYGx5C3Rtin9ftjPOj2wSRoW8CkPG+ihKxTSaV7v3YDQtTnlFSNjqlxWuqiuJp6Q6 2mgrv1j31sdj78viK2WiSXhLom8ENh3URsu7Cl7dFhaaPgBGo2HZ4YdJ5vkICKaCuMHb TqqlGrWuuVTE/mV/fvLyAfmtk0Gyib9Bcb6psMadRZGBORX1x6TynOR/9wgPCRQM1vgT B2sA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tmbAu9U9CHeE+50xDpcWp1TYc48nIKRqaZ0skclM8PY=; b=E57Atca5vGAc64lzlnE8oM43dJ3Jyr97E21RAQ7i2TOcTzJuSOYq5OLgK9KbCmSqPX AXCZjvVWxn5MoExX+whuW/K8/UicYOHe16qkwy6xBGlVHlTU9Uc5S4MEYHGYlMzAmlMW srmU43jWYDRGLYmF2g3JpY2PcrxtTy1xbAAl5ACEnKU89TuRd67ZXia0emib1Z9aySmH L5mYWFBwW/NNO8eLCzgvN3pr8JmzrS7zKHb+4nxkzBd5w5bCsoRWG7u+XBfMC6l3rs2l bKbee9ffLH8vZPMi09fZXuv21Rb5lih7XRQEeCj7cEEFMXWdHngAm1DTUwt8P2uqAmy9 0tyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="EmH/j839"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13-v6si13552207pgj.229.2018.11.11.15.48.37; Sun, 11 Nov 2018 15:48:52 -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="EmH/j839"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733138AbeKLISo (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:38896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733025AbeKLISm (ORCPT ); Mon, 12 Nov 2018 03:18:42 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0DFC222505; Sun, 11 Nov 2018 22:28:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975326; bh=ZTJsefSQkSI0A0ark5cMGBLUObxsapm0GfCSOnAu0Yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmH/j839VniASY6RyssT15ug8aHcs7uTrK48InIwnTV8fQzBT1UddZ7xu2FtYEQYR lzn6QVqW+2s2LEZNZDlUFAqSiXonC8U1JY5yeJs2KhNji1IrzNfUhfx46TKOOb4ude MO1ne3XrrkS7Meq40oEzk5HfE4lIr07yLl9MX/Jw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Mahoney , David Sterba Subject: [PATCH 4.19 334/361] btrfs: dont attempt to trim devices that dont support it Date: Sun, 11 Nov 2018 14:21:21 -0800 Message-Id: <20181111221700.155040019@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Mahoney commit 0be88e367fd8fbdb45257615d691f4675dda062f upstream. We check whether any device the file system is using supports discard in the ioctl call, but then we attempt to trim free extents on every device regardless of whether discard is supported. Due to the way we mask off EOPNOTSUPP, we can end up issuing the trim operations on each free range on devices that don't support it, just wasting time. Fixes: 499f377f49f08 ("btrfs: iterate over unused chunk space in FITRIM") CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Jeff Mahoney Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10789,6 +10789,10 @@ static int btrfs_trim_free_extents(struc *trimmed = 0; + /* Discard not supported = nothing to do. */ + if (!blk_queue_discard(bdev_get_queue(device->bdev))) + return 0; + /* Not writeable = nothing to do. */ if (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) return 0;