From patchwork Fri Oct 26 00:38:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10656835 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 05CD813A9 for ; Fri, 26 Oct 2018 00:38:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECCBC2C4B8 for ; Fri, 26 Oct 2018 00:38:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF9922C7D4; Fri, 26 Oct 2018 00:38:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 7D66D2C4B8 for ; Fri, 26 Oct 2018 00:38:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725842AbeJZJNF (ORCPT ); Fri, 26 Oct 2018 05:13:05 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42760 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbeJZJNF (ORCPT ); Fri, 26 Oct 2018 05:13:05 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9Q0YBAH075316; Fri, 26 Oct 2018 00:38:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=3BiI91kZ3/f/KMaCoJuRw7FMCsiAGCZX8YmTlzjDezE=; b=HlHA2aTX8uPgqlphoh3dubu+FrX+bi4SPjvhVZ4OQXqsEAj2IKWYXpxzoxXCGdGA4lzF C18QJmK4+dP92oy8UuZDD2NqHTo2gfZk8GLlFda4EVysDITC/7WPkV3lRi43X+5i43Kr RgwqE1P4v497iACtp9ZkOxVgw6YBf/Z6YgSnYlVSMfMqbl1GPH6QU/9iujEKtBmDDonG jsI7aUs+h2LYXwVfO6eKW3L+Ze/ki1FlsLlWwy4Y13F4CrLi4qBVK+02vYvbIPgsbIBw Tmqx/ZEPGEKAh2Ui1sE6WbpX8a0A9cGINbJG3wNJf5uKRAhQAbKmQRk8J+YYw7a0RKHC jg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n7usumkpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Oct 2018 00:38:12 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9Q0cCgF005564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Oct 2018 00:38:12 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9Q0cB84007934; Fri, 26 Oct 2018 00:38:11 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Oct 2018 17:38:11 -0700 Date: Thu, 25 Oct 2018 17:38:10 -0700 From: "Darrick J. Wong" To: Eric Sandeen Cc: xfs , Dave Chinner Subject: [RFC PATCH] libxfs: add missing agfl free deferred op type Message-ID: <20181026003810.GE28243@magnolia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9057 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810260003 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 Soo... I tried to run xfs_repair in gdb on arekm's big filesystem, but we forgot to port deferred agfl free defer ops type to xfsprogs so it blew up earlier this afternoon. This is a patch to add it in, but since it takes a while to get far enough to start rebuilding directories, this is basically an untested patch. Which I'm sending out in case sandeen/dchinner are doing the same thing I am. :P --D Reviewed-by: Eric Sandeen --- From: Darrick J. Wong When we added a new defer op type for agfl block freeing to the kernel, we forgot to add that type to the userspace side of things. This will cause spontaneous combustion in xfs_repair if we try to rebuild directories. Fixes: d5c1b462232 ("xfs: defer agfl block frees when dfops is available") Signed-off-by: Darrick J. Wong --- libxfs/defer_item.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/libxfs/defer_item.c b/libxfs/defer_item.c index b7185c1a..82aa32a8 100644 --- a/libxfs/defer_item.c +++ b/libxfs/defer_item.c @@ -118,11 +118,55 @@ static const struct xfs_defer_op_type xfs_extent_free_defer_type = { .cancel_item = xfs_extent_free_cancel_item, }; +/* + * AGFL blocks are accounted differently in the reserve pools and are not + * inserted into the busy extent list. + */ +STATIC int +xfs_agfl_free_finish_item( + struct xfs_trans *tp, + struct list_head *item, + void *done_item, + void **state) +{ + struct xfs_mount *mp = tp->t_mountp; + struct xfs_extent_free_item *free; + struct xfs_buf *agbp; + int error; + xfs_agnumber_t agno; + xfs_agblock_t agbno; + + free = container_of(item, struct xfs_extent_free_item, xefi_list); + ASSERT(free->xefi_blockcount == 1); + agno = XFS_FSB_TO_AGNO(mp, free->xefi_startblock); + agbno = XFS_FSB_TO_AGBNO(mp, free->xefi_startblock); + + error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp); + if (!error) + error = xfs_free_agfl_block(tp, agno, agbno, agbp, + &free->xefi_oinfo); + kmem_free(free); + return error; +} + +/* sub-type with special handling for AGFL deferred frees */ +static const struct xfs_defer_op_type xfs_agfl_free_defer_type = { + .type = XFS_DEFER_OPS_TYPE_AGFL_FREE, + .diff_items = xfs_extent_free_diff_items, + .create_intent = xfs_extent_free_create_intent, + .abort_intent = xfs_extent_free_abort_intent, + .log_item = xfs_extent_free_log_item, + .create_done = xfs_extent_free_create_done, + .finish_item = xfs_agfl_free_finish_item, + .cancel_item = xfs_extent_free_cancel_item, +}; + /* Register the deferred op type. */ void xfs_extent_free_init_defer_op(void) { xfs_defer_init_op_type(&xfs_extent_free_defer_type); + xfs_defer_init_op_type(&xfs_agfl_free_defer_type); } /* Reverse Mapping */