From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B437AC54E4A for ; Thu, 7 Mar 2024 15:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=E17RS1gXdmfEVxJtjtbtf9HhycP12pKLgfmDFXFlsBQ=; b=jeq/z61sseaYOPJBRRwaFj/gGW tVYe2qZMDiKCDcFcTQ074q8aux8wRP9NVGJOH3NBRWFQoSCm/zIpjocO6LYKH84WuFErUk5sUF8kQ nBjnxKA5PdiULD0OtvYCbw+qdlej2fFm/+qPCzyOqRbKbpOa0wWI0UyrEgqsRqETrYg13EWvdrMcU gkxoiUngW7FK+eMTNofvNSvrZmT1yoGZNiYrhTnvpEkP+nSICUFfeXmrVbTOXFoyDJmgM1s3yCngx W2j19YMlZyVLUrk8ZB4GF5TbZJOxe+b42B5Ec7TEGPnMwyw6ZV7BVq0lArt4v0C6h8ztsG3lT6lkh Wu6A82BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riFPm-00000005DCp-0oJh; Thu, 07 Mar 2024 15:12:10 +0000 Received: from [66.60.99.14] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1riFPf-00000005D8W-46ov; Thu, 07 Mar 2024 15:12:04 +0000 From: Christoph Hellwig To: Jens Axboe , Chandan Babu R , Keith Busch Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-xfs@vger.kernel.org Subject: [PATCH 04/10] xfs: switch to using blk_next_discard_bio directly Date: Thu, 7 Mar 2024 08:11:51 -0700 Message-Id: <20240307151157.466013-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240307151157.466013-1-hch@lst.de> References: <20240307151157.466013-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org This fixes fatal signals getting into the way and corrupting the bio chain and removes the need to handle synchronous errors. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_discard.c | 47 ++++++++++++++------------------------------ fs/xfs/xfs_discard.h | 2 +- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index d5787991bb5b46..6396a4e14809a2 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c @@ -102,33 +102,26 @@ xfs_discard_endio( * list. We plug and chain the bios so that we only need a single completion * call to clear all the busy extents once the discards are complete. */ -int +void xfs_discard_extents( struct xfs_mount *mp, struct xfs_busy_extents *extents) { + struct block_device *bdev = mp->m_ddev_targp->bt_bdev; struct xfs_extent_busy *busyp; struct bio *bio = NULL; struct blk_plug plug; - int error = 0; blk_start_plug(&plug); list_for_each_entry(busyp, &extents->extent_list, list) { + sector_t sector = XFS_AGB_TO_DADDR(mp, busyp->agno, busyp->bno); + sector_t nr_sects = XFS_FSB_TO_BB(mp, busyp->length); + trace_xfs_discard_extent(mp, busyp->agno, busyp->bno, busyp->length); - - 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, &bio); - if (error && error != -EOPNOTSUPP) { - xfs_info(mp, - "discard failed for extent [0x%llx,%u], error %d", - (unsigned long long)busyp->bno, - busyp->length, - error); - break; - } + while (blk_next_discard_bio(bdev, &bio, §or, &nr_sects, + GFP_NOFS)) + ; } if (bio) { @@ -139,11 +132,8 @@ xfs_discard_extents( xfs_discard_endio_work(&extents->endio_work); } blk_finish_plug(&plug); - - return error; } - static int xfs_trim_gather_extents( struct xfs_perag *pag, @@ -306,16 +296,14 @@ xfs_trim_extents( .ar_blockcount = pag->pagf_longest, .ar_startblock = NULLAGBLOCK, }; - int error = 0; do { struct xfs_busy_extents *extents; + int error; extents = kzalloc(sizeof(*extents), GFP_KERNEL); - if (!extents) { - error = -ENOMEM; - break; - } + if (!extents) + return -ENOMEM; extents->mount = pag->pag_mount; extents->owner = extents; @@ -325,7 +313,7 @@ xfs_trim_extents( &tcur, extents, blocks_trimmed); if (error) { kfree(extents); - break; + return error; } /* @@ -338,17 +326,12 @@ xfs_trim_extents( * list after this function call, as it may have been freed by * the time control returns to us. */ - error = xfs_discard_extents(pag->pag_mount, extents); - if (error) - break; - + xfs_discard_extents(pag->pag_mount, extents); if (xfs_trim_should_stop()) - break; - + return 0; } while (tcur.ar_blockcount != 0); - return error; - + return 0; } /* diff --git a/fs/xfs/xfs_discard.h b/fs/xfs/xfs_discard.h index 2b1a85223a56c6..8c5cc4af6a0787 100644 --- a/fs/xfs/xfs_discard.h +++ b/fs/xfs/xfs_discard.h @@ -6,7 +6,7 @@ struct fstrim_range; struct xfs_mount; struct xfs_busy_extents; -int xfs_discard_extents(struct xfs_mount *mp, struct xfs_busy_extents *busy); +void xfs_discard_extents(struct xfs_mount *mp, struct xfs_busy_extents *busy); int xfs_ioc_trim(struct xfs_mount *mp, struct fstrim_range __user *fstrim); #endif /* XFS_DISCARD_H */ -- 2.39.2