From patchwork Mon Apr 30 15:32:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10372001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5BC5860540 for ; Mon, 30 Apr 2018 15:33:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AB8928113 for ; Mon, 30 Apr 2018 15:33:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F90D283D9; Mon, 30 Apr 2018 15:33:03 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable 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 B925B28113 for ; Mon, 30 Apr 2018 15:33:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754761AbeD3PdB (ORCPT ); Mon, 30 Apr 2018 11:33:01 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:33014 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754645AbeD3Pc7 (ORCPT ); Mon, 30 Apr 2018 11:32:59 -0400 Received: by mail-io0-f195.google.com with SMTP id e78-v6so10639249iod.0 for ; Mon, 30 Apr 2018 08:32:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K96wYQD+NhyuQuG9KAZkgcpDqtvEFRE6+t+8jepgEq4=; b=aE/VOjcNHzmhnDPCjXU6UVCBRgS1FQej5dw6NYTzIkPU/Ht3SHiuAgUO28Nxd+Pf8a oDzdk5051H2FEbkKH8B2cFZMdR97gYp65CEhl8bK5Sx9PFZcn7PdKB9lkvIvOacfHIB5 yQp1rzxBquwa8EawDhncyRMqMi5NY+pOuumakSMzphspIagpTBPuoUvwP4Qw2Br5k6O0 6lYLTOBElUpw+naPC0Ld2SIxZgCpRxAyqL0MNEaU67HK10cNEzP53hTsM1DKycfCRmnl NW2HCkQERZ9lRFVcXxuqW1nBYpXi1h7inRwpcvpg1nLNIzgz1X9ZFVJ3WieGN6BeOdwM qj3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K96wYQD+NhyuQuG9KAZkgcpDqtvEFRE6+t+8jepgEq4=; b=R807PnSUQT/fHz7lCtpB+H476g2H9OgX12GeGDLAqR7D8p6sRJzEl+Ur7W5e7ZImhK 5iVwMQJyyd2CCL97U6ZBmp4G4ddnzgPbt/58pHXx15snsDH7tlx/WqmzZv3YgJ+lRsgr +uai+1upENBxhW7km1udZCKeHQtreK4hI6dvDtGyYt0Qu1OIm52H10nU+9XWZILFBbpW 54UI/OoX8R59EcX7mg7KS56qr3cI1KlwcNaGp9eXPLyIT01kPfvWluI4K3vf0lDbIDRH r6LTRA0miuloQiL+2Vxs+fCkFJXLc4ci6AEsHMTpED06mkF6I6Ry+rUTSRXridqxHYlF pu2g== X-Gm-Message-State: ALQs6tAHQLsDX+hqpSMYYTo+DmNBGWyJsd9EPXykLhP3W1kjdXkow46x d1+i1PfGoc4rzTtCh6RU2PXcB6vQNRY= X-Google-Smtp-Source: AB8JxZo4wFxqNp1jYDxI/VVnY8gF4Uv18TqXcI+vtntcTfztxBMekbxcF7KvzTn0pwVSK4zaTIZxVg== X-Received: by 2002:a6b:b889:: with SMTP id i131-v6mr12969926iof.300.1525102378190; Mon, 30 Apr 2018 08:32:58 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id z88-v6sm3850877ioi.25.2018.04.30.08.32.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Apr 2018 08:32:57 -0700 (PDT) From: Jens Axboe To: linux-xfs@vger.kernel.org, linux-block@vger.kernel.org Cc: hch@lst.de, Jens Axboe Subject: [PATCH 2/2] xfs: add 'discard_sync' mount flag Date: Mon, 30 Apr 2018 09:32:52 -0600 Message-Id: <1525102372-8430-3-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525102372-8430-1-git-send-email-axboe@kernel.dk> References: <1525102372-8430-1-git-send-email-axboe@kernel.dk> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP XFS recently added support for async discards. While this can be a win for some workloads and devices, there are also cases where async bursty discard will severly harm the latencies of reads and writes. Add a 'discard_sync' mount flag to revert to using sync discard, issuing them one at the time and waiting for each one. This fixes a big performance regression we had moving to kernels that include the XFS async discard support. Signed-off-by: Jens Axboe --- fs/xfs/xfs_log_cil.c | 18 ++++++++++++++---- fs/xfs/xfs_mount.h | 1 + fs/xfs/xfs_super.c | 7 ++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index 4668403b1741..4eced3eceea5 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c @@ -552,10 +552,16 @@ xlog_discard_busy_extents( struct bio *bio = NULL; struct blk_plug plug; int error = 0; + int discard_flags = 0; + bool sync_discard = mp->m_flags & XFS_MOUNT_DISCARD_SYNC; ASSERT(mp->m_flags & XFS_MOUNT_DISCARD); - blk_start_plug(&plug); + if (!sync_discard) + blk_start_plug(&plug); + else + discard_flags = BLKDEV_DISCARD_SYNC; + list_for_each_entry(busyp, list, list) { trace_xfs_discard_extent(mp, busyp->agno, busyp->bno, busyp->length); @@ -563,7 +569,7 @@ xlog_discard_busy_extents( error = __blkdev_issue_discard(mp->m_ddev_targp->bt_bdev, XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno), XFS_FSB_TO_BB(mp, busyp->length), - GFP_NOFS, 0, &bio); + GFP_NOFS, discard_flags, &bio); if (error && error != -EOPNOTSUPP) { xfs_info(mp, "discard failed for extent [0x%llx,%u], error %d", @@ -574,14 +580,18 @@ xlog_discard_busy_extents( } } - if (bio) { + if (sync_discard) { + xfs_extent_busy_clear(mp, &ctx->busy_extents, false); + kmem_free(ctx); + } else if (bio) { bio->bi_private = ctx; bio->bi_end_io = xlog_discard_endio; submit_bio(bio); + blk_finish_plug(&plug); } else { xlog_discard_endio_work(&ctx->discard_endio_work); + blk_finish_plug(&plug); } - blk_finish_plug(&plug); } /* diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 10b90bbc5162..3f0b7b9106c7 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -219,6 +219,7 @@ typedef struct xfs_mount { operations, typically for disk errors in metadata */ #define XFS_MOUNT_DISCARD (1ULL << 5) /* discard unused blocks */ +#define XFS_MOUNT_DISCARD_SYNC (1ULL << 6) /* discard unused blocks sync */ #define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment allocations */ #define XFS_MOUNT_ATTR2 (1ULL << 8) /* allow use of attr2 format */ diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index d71424052917..6d960bb4725f 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -83,7 +83,7 @@ enum { Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota, Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce, - Opt_discard, Opt_nodiscard, Opt_dax, Opt_err, + Opt_discard, Opt_nodiscard, Opt_dax, Opt_err, Opt_discard_sync, }; static const match_table_t tokens = { @@ -129,6 +129,7 @@ static const match_table_t tokens = { {Opt_pqnoenforce,"pqnoenforce"},/* project quota limit enforcement */ {Opt_qnoenforce, "qnoenforce"}, /* same as uqnoenforce */ {Opt_discard, "discard"}, /* Discard unused blocks */ + {Opt_discard_sync,"discard_sync"},/* Discard unused blocks sync */ {Opt_nodiscard, "nodiscard"}, /* Do not discard unused blocks */ {Opt_dax, "dax"}, /* Enable direct access to bdev pages */ @@ -363,11 +364,15 @@ xfs_parseargs( mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE); mp->m_qflags &= ~XFS_GQUOTA_ENFD; break; + case Opt_discard_sync: + mp->m_flags |= XFS_MOUNT_DISCARD_SYNC; + /* fall through and set XFS_MOUNT_DISCARD too */ case Opt_discard: mp->m_flags |= XFS_MOUNT_DISCARD; break; case Opt_nodiscard: mp->m_flags &= ~XFS_MOUNT_DISCARD; + mp->m_flags &= ~XFS_MOUNT_DISCARD_SYNC; break; #ifdef CONFIG_FS_DAX case Opt_dax: