From patchwork Thu Sep 6 21:18:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 10591111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41BB0139B for ; Thu, 6 Sep 2018 21:18:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D6112B2A7 for ; Thu, 6 Sep 2018 21:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21C8B2B2AB; Thu, 6 Sep 2018 21:18:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72722B263 for ; Thu, 6 Sep 2018 21:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728386AbeIGBzn (ORCPT ); Thu, 6 Sep 2018 21:55:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:56540 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727126AbeIGBzn (ORCPT ); Thu, 6 Sep 2018 21:55:43 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BF8CBAE23 for ; Thu, 6 Sep 2018 21:18:21 +0000 (UTC) Received: from sled4.home.jeffm.io (sled4.home.jeffm.io [192.168.111.8]) by mail.home.jeffm.io (Postfix) with ESMTPS id 79C3881AD3E6; Thu, 6 Sep 2018 17:17:53 -0400 (EDT) Received: by sled4.home.jeffm.io (Postfix, from userid 1000) id A53F64CE0; Thu, 6 Sep 2018 17:18:19 -0400 (EDT) From: jeffm@suse.com To: linux-btrfs@vger.kernel.org Cc: Jeff Mahoney Subject: [PATCH 2/3] btrfs: don't attempt to trim devices that don't support it Date: Thu, 6 Sep 2018 17:18:15 -0400 Message-Id: <20180906211816.12121-3-jeffm@suse.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180906211816.12121-1-jeffm@suse.com> References: <20180906211816.12121-1-jeffm@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Mahoney 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) Signed-off-by: Jeff Mahoney Reviewed-by: David Sterba --- fs/btrfs/extent-tree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a0e82589c3e8..92e5e9fd9bdd 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10887,6 +10887,10 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, *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;