From patchwork Thu Sep 6 21:18:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 10591109 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 11ED3921 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 F1BB32B2A5 for ; Thu, 6 Sep 2018 21:18:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E606F2B2A1; Thu, 6 Sep 2018 21:18:24 +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 8EAE72B294 for ; Thu, 6 Sep 2018 21:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbeIGBzm (ORCPT ); Thu, 6 Sep 2018 21:55:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:56530 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726031AbeIGBzm (ORCPT ); Thu, 6 Sep 2018 21:55:42 -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 6711BADDD for ; Thu, 6 Sep 2018 21:18:21 +0000 (UTC) Received: from sled4.home.jeffm.io (sled4.home.jeffm.io [IPv6:2001:559:c0d4:6f::8]) by mail.home.jeffm.io (Postfix) with ESMTPS id 0A93181AD3D9; Thu, 6 Sep 2018 17:17:52 -0400 (EDT) Received: by sled4.home.jeffm.io (Postfix, from userid 1000) id 28B7A4CDC; Thu, 6 Sep 2018 17:18:18 -0400 (EDT) From: jeffm@suse.com To: linux-btrfs@vger.kernel.org Cc: Jeff Mahoney Subject: [PATCH 0/3] btrfs: trim latency improvements Date: Thu, 6 Sep 2018 17:18:13 -0400 Message-Id: <20180906211816.12121-1-jeffm@suse.com> X-Mailer: git-send-email 2.12.3 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 This patch set fixes a few issues with trim. 1) Fix device list iteration. We're iterating the ->alloc_list while holding the device_list_mutex. The ->alloc_list is protected by the chunk mutex and we don't want to hold it across the entire trim execution. Instead, use the ->devices list, which is protected by the device_list_mutex. 2) Skip trim on devices that don't support it. Rather than letting the block layer reject it, bounce out early. 3) Don't keep the commit_root_sem locked and the transaction pinned across the block layer component of trim. We only need these to ensure the pending chunks list doesn't go away underneath us, so it's safe to drop across the trim itself. Historically, this caused issues when fstrim and balance would run at the same time since balance would produce lots of transactions and would have to wait constantly, causing problems for everything else that wanted to start a transaction. -Jeff --- Jeff Mahoney (3): btrfs: use ->devices list instead of ->alloc_list in btrfs_trim_fs btrfs: don't attempt to trim devices that don't support it btrfs: keep trim from interfering with transaction commits fs/btrfs/extent-tree.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-)