Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3427923imu; Sun, 11 Nov 2018 14:52:38 -0800 (PST) X-Google-Smtp-Source: AJdET5e5Yaisf+WT/bzZjw0Y+pK4I8DlqHcx7NYTpmPBEEOQifW52BxiSX3Cai3kYV6Qa3mWMORi X-Received: by 2002:a17:902:2:: with SMTP id 2-v6mr18079516pla.178.1541976758273; Sun, 11 Nov 2018 14:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976758; cv=none; d=google.com; s=arc-20160816; b=aKWLuUU+6TWrQPuGevkcBaXkgzZSLrnzQsNvvKcOuvw8Dxn1NbolBZgCPWZrePQ8dj LCPN8TgQnGGmO6U5OdEzft/vRLJsCfz/dQTXwsJeEavoWmwoYs0SV4fuCgWlDFvXZtyK mFOuVuBAs8sD/4KlAehhDz5Eot6OkepWeD/j0oB2b+dnpG7G6S8OJ7hGXuyNloqqzTQY IotWeVUXl3+NgQDn9BOCKp/85RRY9m8F4AERXmN5BNmUvCKBFVHhIpCWlzvco018Wm55 HxcX5ApGijPM/SjdUOe+8AjAawZzmJjyos4diYk+tWqn+X2oBQLwiVrnqyoMGLQSITqE XIrg== 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=WpRqdzBr3COlH8pByl56wpxF+4/QxVWp77Nnm1pYhic=; b=IuhnGcVQfAH3ayImNTnCMUyWcW8ej/fyt2wni5Y3ho6qIPNDNIX6kZVrNvEoCkjf0J 3JN53J6JkA4hhqLlpYIzgrnv93rbPG0iVV5FLD0og/lwracq0yVNM7V7nJ1s7K0qLIHF kJ/JM9Sg0b4o4vW9nMJnb2RZpSY6+10mim/UPHXzvMHCv44uYi9F0ct0ALkiq4ISwJyW f8b0mKEAn/Ihfo5BrulHOsitD9RKIf/+nXiMoyXAvMTh11HEDAkGHSr+RcKtFZ4rag4O ZX3I/5+Tvl+HYxVMyIQDQyeH/Rk7nyjUCt1TMKGPMKxfSABEO8nEoKCFV+/A/0uylPHg hRBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R7oPhkWn; 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 x87-v6si17410070pfk.54.2018.11.11.14.52.23; Sun, 11 Nov 2018 14:52:38 -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=R7oPhkWn; 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 S2404214AbeKLIXJ (ORCPT + 99 others); Mon, 12 Nov 2018 03:23:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:55530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404187AbeKLIXI (ORCPT ); Mon, 12 Nov 2018 03:23:08 -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 EB7C12245E; Sun, 11 Nov 2018 22:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975591; bh=Xu7K2yd4Epr0BeUPgy+u7Nq2bNI2nJVxAWgaAWjzouU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R7oPhkWn/x04RsTfPznfMCFleEjXtdp5YBl5vicl693ch2DCsXaQWZexShHmHJrMn gQ9r76z/+zbhvcQy9SwK1rNqCpcw6xAJ+cM4YPPuab+EMtbrQ6H7idLZqP4V1ywxWO nq8/oSVo/znsoWuC3p7yWMqm+S24AAC72uCeAii4= 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.14 203/222] btrfs: dont attempt to trim devices that dont support it Date: Sun, 11 Nov 2018 14:25:00 -0800 Message-Id: <20181111221704.858304298@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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 @@ -10976,6 +10976,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 (!device->writeable) return 0;