From patchwork Fri Jun 21 19:57:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11010697 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 D68F61398 for ; Fri, 21 Jun 2019 19:57:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8723289C2 for ; Fri, 21 Jun 2019 19:57:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCC8628BA1; Fri, 21 Jun 2019 19:57:06 +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 68214289C2 for ; Fri, 21 Jun 2019 19:57:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726118AbfFUT5F (ORCPT ); Fri, 21 Jun 2019 15:57:05 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:40088 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbfFUT5F (ORCPT ); Fri, 21 Jun 2019 15:57:05 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJs6Ov001887; Fri, 21 Jun 2019 19:57:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=MRIygYJvFZ/uvy31cmr69RJhJSBOLlFcyTlp0eDk6dQ=; b=QT2fV6xEg/Xa5L8odN0tDe8kPEd/GXTQExg6EJaWWQ3FGDEucjku4C/50jrNj3hMusIB uF9/m7gRPm1rr0lZXSV/Y0OjuIjiHRwfaeEJOF5hIonDd2kaird9d+NztIMXWrs4/nFC uqSsuyN4/MOx8/R/klH+8sRBFDTXtY2iwf33nZAeGs9hq7qIawIm38CL8+aimfj3WoGC zCCEmfdfdJQcJQM9koFwEpgYsdrMVK+cCYHssBPVU8af6QSLZydm4D9tauv02vb7g57L 2IqnQkjHmbgq4kocR9uTMyYdpRW8HqYNwg86wuI5vIagU8PbZ86msmn53RylEDf512Y7 rw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2t7809r5sx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:03 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJtpXF178565; Fri, 21 Jun 2019 19:57:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2t77ypcdye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:02 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5LJv1wL007100; Fri, 21 Jun 2019 19:57:01 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2019 12:57:01 -0700 Subject: [PATCH 1/6] xfs: refactor free space btree record initialization From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Allison Collins Date: Fri, 21 Jun 2019 12:57:00 -0700 Message-ID: <156114702011.1643538.11896501170862991755.stgit@magnolia> In-Reply-To: <156114701371.1643538.316410894576032261.stgit@magnolia> References: <156114701371.1643538.316410894576032261.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 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-1810050000 definitions=main-1906210149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210149 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 From: Darrick J. Wong Refactor the code that populates the free space btrees of a new AG so that we can avoid code duplication once things start getting complicated. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libxfs/xfs_ag.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index 8ee45699..fe79693e 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -57,37 +57,42 @@ xfs_btroot_init( xfs_btree_init_block(mp, bp, id->type, 0, 0, id->agno); } -/* - * Alloc btree root block init functions - */ +/* Finish initializing a free space btree. */ static void -xfs_bnoroot_init( +xfs_freesp_init_recs( struct xfs_mount *mp, struct xfs_buf *bp, struct aghdr_init_data *id) { struct xfs_alloc_rec *arec; - xfs_btree_init_block(mp, bp, XFS_BTNUM_BNO, 0, 1, id->agno); arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1); arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks); arec->ar_blockcount = cpu_to_be32(id->agsize - be32_to_cpu(arec->ar_startblock)); } +/* + * Alloc btree root block init functions + */ static void -xfs_cntroot_init( +xfs_bnoroot_init( struct xfs_mount *mp, struct xfs_buf *bp, struct aghdr_init_data *id) { - struct xfs_alloc_rec *arec; + xfs_btree_init_block(mp, bp, XFS_BTNUM_BNO, 0, 1, id->agno); + xfs_freesp_init_recs(mp, bp, id); +} +static void +xfs_cntroot_init( + struct xfs_mount *mp, + struct xfs_buf *bp, + struct aghdr_init_data *id) +{ xfs_btree_init_block(mp, bp, XFS_BTNUM_CNT, 0, 1, id->agno); - arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1); - arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks); - arec->ar_blockcount = cpu_to_be32(id->agsize - - be32_to_cpu(arec->ar_startblock)); + xfs_freesp_init_recs(mp, bp, id); } /* From patchwork Fri Jun 21 19:57:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11010699 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 B278A1395 for ; Fri, 21 Jun 2019 19:57:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A454B289C2 for ; Fri, 21 Jun 2019 19:57:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 954A228BA1; Fri, 21 Jun 2019 19:57:13 +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 82668289C2 for ; Fri, 21 Jun 2019 19:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfFUT5M (ORCPT ); Fri, 21 Jun 2019 15:57:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57492 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbfFUT5M (ORCPT ); Fri, 21 Jun 2019 15:57:12 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJs3vJ100439; Fri, 21 Jun 2019 19:57:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=O2cqZr73xXERGaHZcosQsp2ip7rKILFMmCFLVIVzkk0=; b=AQPhVXhlF/WXuLxs2w8w8AtWLrO+HO6mf+IT2ywz54d8KKeadPJiqQf+snpSf9o4M/Z5 w44xhcQZvmcsVkAtFDxcEB5/HwUhG9s7JPy6/woWtaSIPUjsLMyk2hGTtElS0jo3gzci U1Yymnf5c0ztaqVmDbs1OxWm3aJH2iZmIdkK3vcaIUr5wls6v9KCkXhYUBiwfMWgtMJj /2YY33cvCXNRHhK5jD8kfmpOLeF3XSlqhBxHUIRzLFiM5+EE44MkutfZ0c/3bmXfSPYZ X66FzwJDUzWhEvmHTAUfRf7lJgGMuTsiX0gNrf9GHEdtgO4WnlFDskU6IVymAIUYRPol 6A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2t7809r6k5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:09 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJthKI178257; Fri, 21 Jun 2019 19:57:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2t77ypce12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:09 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5LJv7sk015749; Fri, 21 Jun 2019 19:57:08 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2019 12:57:07 -0700 Subject: [PATCH 2/6] xfs: account for log space when formatting new AGs From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, Allison Collins Date: Fri, 21 Jun 2019 12:57:06 -0700 Message-ID: <156114702648.1643538.14530619220062934565.stgit@magnolia> In-Reply-To: <156114701371.1643538.316410894576032261.stgit@magnolia> References: <156114701371.1643538.316410894576032261.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 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-1810050000 definitions=main-1906210149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210149 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 From: Darrick J. Wong When we're writing out a fresh new AG, make sure that we don't list an internal log as free and that we create the rmap for the region. growfs never does this, but we will need it when we hook up mkfs. Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Christoph Hellwig --- libxfs/xfs_ag.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libxfs/xfs_ag.c b/libxfs/xfs_ag.c index fe79693e..237d6c53 100644 --- a/libxfs/xfs_ag.c +++ b/libxfs/xfs_ag.c @@ -11,6 +11,7 @@ #include "xfs_shared.h" #include "xfs_format.h" #include "xfs_trans_resv.h" +#include "xfs_bit.h" #include "xfs_sb.h" #include "xfs_mount.h" #include "xfs_btree.h" @@ -45,6 +46,12 @@ xfs_get_aghdr_buf( return bp; } +static inline bool is_log_ag(struct xfs_mount *mp, struct aghdr_init_data *id) +{ + return mp->m_sb.sb_logstart > 0 && + id->agno == XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart); +} + /* * Generic btree root block init function */ @@ -65,11 +72,50 @@ xfs_freesp_init_recs( struct aghdr_init_data *id) { struct xfs_alloc_rec *arec; + struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); arec = XFS_ALLOC_REC_ADDR(mp, XFS_BUF_TO_BLOCK(bp), 1); arec->ar_startblock = cpu_to_be32(mp->m_ag_prealloc_blocks); + + if (is_log_ag(mp, id)) { + struct xfs_alloc_rec *nrec; + xfs_agblock_t start = XFS_FSB_TO_AGBNO(mp, + mp->m_sb.sb_logstart); + + ASSERT(start >= mp->m_ag_prealloc_blocks); + if (start != mp->m_ag_prealloc_blocks) { + /* + * Modify first record to pad stripe align of log + */ + arec->ar_blockcount = cpu_to_be32(start - + mp->m_ag_prealloc_blocks); + nrec = arec + 1; + /* + * Insert second record at start of internal log + * which then gets trimmed. + */ + nrec->ar_startblock = cpu_to_be32( + be32_to_cpu(arec->ar_startblock) + + be32_to_cpu(arec->ar_blockcount)); + arec = nrec; + be16_add_cpu(&block->bb_numrecs, 1); + } + /* + * Change record start to after the internal log + */ + be32_add_cpu(&arec->ar_startblock, mp->m_sb.sb_logblocks); + } + + /* + * Calculate the record block count and check for the case where + * the log might have consumed all available space in the AG. If + * so, reset the record count to 0 to avoid exposure of an invalid + * record start block. + */ arec->ar_blockcount = cpu_to_be32(id->agsize - be32_to_cpu(arec->ar_startblock)); + if (!arec->ar_blockcount) + block->bb_numrecs = 0; } /* @@ -155,6 +201,18 @@ xfs_rmaproot_init( rrec->rm_offset = 0; be16_add_cpu(&block->bb_numrecs, 1); } + + /* account for the log space */ + if (is_log_ag(mp, id)) { + rrec = XFS_RMAP_REC_ADDR(block, + be16_to_cpu(block->bb_numrecs) + 1); + rrec->rm_startblock = cpu_to_be32( + XFS_FSB_TO_AGBNO(mp, mp->m_sb.sb_logstart)); + rrec->rm_blockcount = cpu_to_be32(mp->m_sb.sb_logblocks); + rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_LOG); + rrec->rm_offset = 0; + be16_add_cpu(&block->bb_numrecs, 1); + } } /* @@ -215,6 +273,14 @@ xfs_agfblock_init( agf->agf_refcount_level = cpu_to_be32(1); agf->agf_refcount_blocks = cpu_to_be32(1); } + + if (is_log_ag(mp, id)) { + int64_t logblocks = mp->m_sb.sb_logblocks; + + be32_add_cpu(&agf->agf_freeblks, -logblocks); + agf->agf_longest = cpu_to_be32(id->agsize - + XFS_FSB_TO_AGBNO(mp, mp->m_sb.sb_logstart) - logblocks); + } } static void From patchwork Fri Jun 21 19:57:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11010701 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 D278A1395 for ; Fri, 21 Jun 2019 19:57:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35FE289C2 for ; Fri, 21 Jun 2019 19:57:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B782828BA1; Fri, 21 Jun 2019 19:57: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=-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 5E05C289C2 for ; Fri, 21 Jun 2019 19:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbfFUT5X (ORCPT ); Fri, 21 Jun 2019 15:57:23 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:57654 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbfFUT5X (ORCPT ); Fri, 21 Jun 2019 15:57:23 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJsHRv100765; Fri, 21 Jun 2019 19:57:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=S/9Q7wfk82K25ujRHsHpIwm0KOmA1T8WDm1O2QVuMlA=; b=CcgqtI9dAoAJ6Pr0D0L9sER835L9SXT8dO99zTEvydMh6oQM3HGcpt8RX0ULEq4s/phO 8Imq1VT/vQ4XLpwsSqWwnP2BYXX7+KCBD/7tJ1IamweVWPeAms042OfCLm89V+WoFYLq T+Mc8oBvSnCu2Rjt6rs946tz+yMx/iGx/ycQs6Hmu8oozJl4/qT1VfmhQsSiENgWa0Z4 lSpe8FCsx3bIaQVoXs78MQJMpCK7zpz5bBBhSorUTF/TfKLzhX8sboN3iSIAJccBvzBK i2zPZTs17y+RVui/fFc4Weqi3pjcKeP2vwxMbx/m7sncIOMvSR0GOG0J02leoFBkda3c JQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2t7809r6kp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:21 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJvFcc049513; Fri, 21 Jun 2019 19:57:20 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2t77ypcesn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:20 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5LJvJmI013653; Fri, 21 Jun 2019 19:57:19 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2019 12:57:19 -0700 Subject: [PATCH 3/6] libxfs: fix uncached buffer refcounting From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 21 Jun 2019 12:57:12 -0700 Message-ID: <156114703289.1643538.16263048212251920271.stgit@magnolia> In-Reply-To: <156114701371.1643538.316410894576032261.stgit@magnolia> References: <156114701371.1643538.316410894576032261.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1906210149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210149 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 From: Darrick J. Wong Currently, uncached buffers in userspace are created with zero refcount and are fed to cache_node_put when they're released. This is totally broken -- the refcount should be 1 (because the caller now holds a reference) and we should never be dumping uncached buffers into the cache. Fix both of these problems. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_io.h | 18 ++++++++++++++++++ libxfs/libxfs_priv.h | 2 -- libxfs/rdwr.c | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index 94261270..b6f8756a 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -225,4 +225,22 @@ xfs_buf_associate_memory(struct xfs_buf *bp, void *mem, size_t len) return 0; } +/* + * Allocate an uncached buffer that points nowhere. The refcount will be 1, + * and the cache node hash list will be empty to indicate that it's uncached. + */ +static inline struct xfs_buf * +xfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags) +{ + struct xfs_buf *bp; + + bp = libxfs_getbufr(targ, XFS_BUF_DADDR_NULL, bblen); + if (!bp) + return NULL; + + INIT_LIST_HEAD(&bp->b_node.cn_hash); + bp->b_node.cn_count = 1; + return bp; +} + #endif /* __LIBXFS_IO_H__ */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index 9004ff0c..eb92942a 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -378,8 +378,6 @@ roundup_64(uint64_t x, uint32_t y) (len) = __bar; /* no set-but-unused warning */ \ NULL; \ }) -#define xfs_buf_get_uncached(t,n,f) \ - libxfs_getbufr((t), XFS_BUF_DADDR_NULL, (n)); #define xfs_buf_relse(bp) libxfs_putbuf(bp) #define xfs_buf_get(devp,blkno,len) (libxfs_getbuf((devp), (blkno), (len))) #define xfs_bwrite(bp) libxfs_writebuf((bp), 0) diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 998862af..9c6c93a7 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -866,7 +866,10 @@ libxfs_putbuf(xfs_buf_t *bp) } } - cache_node_put(libxfs_bcache, (struct cache_node *)bp); + if (!list_empty(&bp->b_node.cn_hash)) + cache_node_put(libxfs_bcache, (struct cache_node *)bp); + else if (--bp->b_node.cn_count == 0) + libxfs_putbufr(bp); } void From patchwork Fri Jun 21 19:57:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11010703 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 802981395 for ; Fri, 21 Jun 2019 19:57:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 718D9289C2 for ; Fri, 21 Jun 2019 19:57:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65DA428BA1; Fri, 21 Jun 2019 19:57:32 +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 1285E289C2 for ; Fri, 21 Jun 2019 19:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726194AbfFUT5b (ORCPT ); Fri, 21 Jun 2019 15:57:31 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43482 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbfFUT5b (ORCPT ); Fri, 21 Jun 2019 15:57:31 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJs6Zh093957; Fri, 21 Jun 2019 19:57:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=5DGpfYEiDueJJNTDXethZFbd5ZEyMsd3fyfvKc3WnLc=; b=gG3X3e80WkVlYG8kTeiLHFQAMsZrtgefWwcM9BuICsCDAagRAnuJRW/hZ3HY+i6kdzZY oKDcV+JNrLwIxSdbDu4Ed5FHz4OXThwANEmrL1FAZF9HKKDZdCxeesHTkS9MutvbVjq/ fHQVCexnCx36HSB9qaU+47fXYC1AX7WHoND1nk/rCFf0PYq9IATEdYw6gHg6CJOS9J5k Vdo1DaY4CKMU/K97a6CGqtigQRckqDQPBSLN2N6Iw8zF7KjlbQ6MoJ+B0p92nP34iP/+ tRNhfhG9l3oXEvpISKWkxrW2+YXIuWZhfSa3aTRFnIfMIXLHsa+ZP5pPBakm+75FFnv/ 3g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2t7809r8gc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:29 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJvJHg049682; Fri, 21 Jun 2019 19:57:28 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2t77ypcetv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:28 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5LJvRjh007310; Fri, 21 Jun 2019 19:57:27 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2019 12:57:27 -0700 Subject: [PATCH 4/6] libxfs: fix buffer refcounting in delwri_queue From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 21 Jun 2019 12:57:24 -0700 Message-ID: <156114704472.1643538.14565976860288969023.stgit@magnolia> In-Reply-To: <156114701371.1643538.316410894576032261.stgit@magnolia> References: <156114701371.1643538.316410894576032261.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1810050000 definitions=main-1906210149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210149 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 From: Darrick J. Wong In the kernel, xfs_buf_delwri_queue increments the buffer reference count before putting the buffer on the buffer list, and the refcount is decremented after the io completes for a net refcount change of zero. In userspace, delwri_queue calls libxfs_writebuf, which puts the buffer. delwri_queue is a no-op, for a net refcount change of -1. This creates problems for any callers that expect a net change of zero, so increment the buffer refcount before calling writebuf. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_io.h | 7 +++++++ libxfs/libxfs_priv.h | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index b6f8756a..c47a435d 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -243,4 +243,11 @@ xfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags) return bp; } +static inline void +xfs_buf_delwri_queue(struct xfs_buf *bp, struct list_head *buffer_list) +{ + bp->b_node.cn_count++; + libxfs_writebuf(bp, 0); +} + #endif /* __LIBXFS_IO_H__ */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index eb92942a..fd420f4f 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -381,7 +381,6 @@ roundup_64(uint64_t x, uint32_t y) #define xfs_buf_relse(bp) libxfs_putbuf(bp) #define xfs_buf_get(devp,blkno,len) (libxfs_getbuf((devp), (blkno), (len))) #define xfs_bwrite(bp) libxfs_writebuf((bp), 0) -#define xfs_buf_delwri_queue(bp, bl) libxfs_writebuf((bp), 0) #define xfs_buf_delwri_submit(bl) (0) #define xfs_buf_oneshot(bp) ((void) 0) From patchwork Fri Jun 21 19:57:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11010705 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 883E21395 for ; Fri, 21 Jun 2019 19:57:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 792AF28BA0 for ; Fri, 21 Jun 2019 19:57:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CC8228BA3; Fri, 21 Jun 2019 19:57:38 +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 0A0F428BA0 for ; Fri, 21 Jun 2019 19:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726145AbfFUT5h (ORCPT ); Fri, 21 Jun 2019 15:57:37 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43600 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbfFUT5h (ORCPT ); Fri, 21 Jun 2019 15:57:37 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJsbQ4094327; Fri, 21 Jun 2019 19:57:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=T6sH6V912fGnTsT5up0BwTbGPhKQqhBi1VHF54DLeOg=; b=e6GNKRjPOGquMQGhdLVAKdKutRsjtuEbMVwx3E9pbRpEEWtIEoi7VQsbzyyCXyqcqxMt 7SKTh5jxB70tOBIEiAi2v5JiZjjZl22djQy3y7sUjxNyt+dMDFWD3xu/cLV/ueVqACZM 4/9ZULzqTyhZXU5htEf7ib9MPUUg1noYrYkYw1DRz0Ua0aPg1uRQd/92n/QhQizqsiAh DNiXrzujtnAo0MOflVTQ8ctOq5zllqcRCXF4crygXSnSYlbxuvB5349z+OBq8NiA1ARV zEx+KP+C+2YT/62HqkTPmxGsWZrnPlAVKRGdU8yoCsvm8O+zG+kSVpGN9NCw14qmNPay 5w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2t7809r8gr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:35 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJthgv178328; Fri, 21 Jun 2019 19:57:35 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2t77ypce5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:34 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5LJvYN0014870; Fri, 21 Jun 2019 19:57:34 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2019 12:57:34 -0700 Subject: [PATCH 5/6] libxfs: make xfs_buf_delwri_submit actually do something From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 21 Jun 2019 12:57:33 -0700 Message-ID: <156114705295.1643538.4760286307932278728.stgit@magnolia> In-Reply-To: <156114701371.1643538.316410894576032261.stgit@magnolia> References: <156114701371.1643538.316410894576032261.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 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-1810050000 definitions=main-1906210149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210149 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 From: Darrick J. Wong xfs_buf_delwri_queue doesn't report errors, which means that if the buffer write fails we have no way of knowing that something bad happened. In the kernel we queue and then submit buffers, and the submit call communicates errors to callers. Do the same here since we're going to start using the AG header initialization functions, which use delwri_{queue,submit} heavily. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- libxfs/libxfs_io.h | 6 +++++- libxfs/libxfs_priv.h | 1 - libxfs/rdwr.c | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h index c47a435d..d033faad 100644 --- a/libxfs/libxfs_io.h +++ b/libxfs/libxfs_io.h @@ -70,6 +70,7 @@ typedef struct xfs_buf { struct xfs_buf_map *b_maps; struct xfs_buf_map __b_map; int b_nmaps; + struct list_head b_list; #ifdef XFS_BUF_TRACING struct list_head b_lock_list; const char *b_func; @@ -243,11 +244,14 @@ xfs_buf_get_uncached(struct xfs_buftarg *targ, size_t bblen, int flags) return bp; } +/* Push a single buffer on a delwri queue. */ static inline void xfs_buf_delwri_queue(struct xfs_buf *bp, struct list_head *buffer_list) { bp->b_node.cn_count++; - libxfs_writebuf(bp, 0); + list_add_tail(&bp->b_list, buffer_list); } +int xfs_buf_delwri_submit(struct list_head *buffer_list); + #endif /* __LIBXFS_IO_H__ */ diff --git a/libxfs/libxfs_priv.h b/libxfs/libxfs_priv.h index fd420f4f..0233393d 100644 --- a/libxfs/libxfs_priv.h +++ b/libxfs/libxfs_priv.h @@ -381,7 +381,6 @@ roundup_64(uint64_t x, uint32_t y) #define xfs_buf_relse(bp) libxfs_putbuf(bp) #define xfs_buf_get(devp,blkno,len) (libxfs_getbuf((devp), (blkno), (len))) #define xfs_bwrite(bp) libxfs_writebuf((bp), 0) -#define xfs_buf_delwri_submit(bl) (0) #define xfs_buf_oneshot(bp) ((void) 0) #define XBRW_READ LIBXFS_BREAD diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 9c6c93a7..dd582a4e 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -1472,3 +1472,28 @@ libxfs_irele( libxfs_idestroy(ip); kmem_zone_free(xfs_inode_zone, ip); } + +/* + * Write out a buffer list synchronously. + * + * This will take the @buffer_list, write all buffers out and wait for I/O + * completion on all of the buffers. @buffer_list is consumed by the function, + * so callers must have some other way of tracking buffers if they require such + * functionality. + */ +int +xfs_buf_delwri_submit( + struct list_head *buffer_list) +{ + struct xfs_buf *bp, *n; + int error = 0, error2; + + list_for_each_entry_safe(bp, n, buffer_list, b_list) { + list_del_init(&bp->b_list); + error2 = libxfs_writebuf(bp, 0); + if (!error) + error = error2; + } + + return error; +} From patchwork Fri Jun 21 19:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11010707 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 20AFF1398 for ; Fri, 21 Jun 2019 19:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CB98289C2 for ; Fri, 21 Jun 2019 19:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F295928BA1; Fri, 21 Jun 2019 19:57:48 +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 01686289C2 for ; Fri, 21 Jun 2019 19:57:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbfFUT5r (ORCPT ); Fri, 21 Jun 2019 15:57:47 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43788 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbfFUT5r (ORCPT ); Fri, 21 Jun 2019 15:57:47 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJsPG3094283; Fri, 21 Jun 2019 19:57:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=cPEYGgjCpNaiewzy/QupMKc7NZzzcEmZ0EWZWm7f5wQ=; b=01FzzoKBusC/1oH2qLGxk6xD1YlKbDLBFWVbGvIYsZmj1vgJZND21eHPCYBAgs+GxrLK nC5j6PjFWCaOdGq0AACYj/taEvRnwBwn1jPcK8OzGTtOwiWjJA1PhJWf1Kr89kI6ziVL 44ywHE3AadMcyjPqElYadxFeFF0MgLJeG1jg00+vDTKT22hTgQEIIzzW/Ve08zpC1YiQ StaIVg/hEqAnbK0mxeQ6LiGZioSdqv9gvYECInYNYkT68m3lty6mUxNuKpex4vzHVpPc h9fJSEF2on8w8VIqJ+lXMlykowWtrOoxxwYlDAJk0mPTVxbQEIoeCzkLhLzG4vGtf/1n mg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2t7809r8h6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5LJvhqZ182433; Fri, 21 Jun 2019 19:57:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2t77ypce73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2019 19:57:43 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5LJverR014879; Fri, 21 Jun 2019 19:57:40 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Jun 2019 12:57:40 -0700 Subject: [PATCH 6/6] mkfs: use libxfs to write out new AGs From: "Darrick J. Wong" To: sandeen@sandeen.net, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Fri, 21 Jun 2019 12:57:39 -0700 Message-ID: <156114705924.1643538.6635085530435538461.stgit@magnolia> In-Reply-To: <156114701371.1643538.316410894576032261.stgit@magnolia> References: <156114701371.1643538.316410894576032261.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 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-1810050000 definitions=main-1906210149 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9295 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906210149 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 From: Darrick J. Wong Use the libxfs AG initialization functions to write out the new filesystem instead of open-coding everything. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- include/libxfs.h | 1 libxfs/libxfs_api_defs.h | 3 mkfs/xfs_mkfs.c | 359 +++------------------------------------------- 3 files changed, 29 insertions(+), 334 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index dd5fe542..3bf7feab 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -63,6 +63,7 @@ extern uint32_t crc32c_le(uint32_t crc, unsigned char const *p, size_t len); #include "xfs_bmap.h" #include "xfs_trace.h" #include "xfs_trans.h" +#include "xfs_ag.h" #include "xfs_rmap_btree.h" #include "xfs_rmap.h" #include "xfs_refcount_btree.h" diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 0ae21318..645c9b1b 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -154,4 +154,7 @@ #define LIBXFS_ATTR_CREATE ATTR_CREATE #define LIBXFS_ATTR_REPLACE ATTR_REPLACE +#define xfs_ag_init_headers libxfs_ag_init_headers +#define xfs_buf_delwri_submit libxfs_buf_delwri_submit + #endif /* __LIBXFS_API_DEFS_H__ */ diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 56ba5379..8a44bb98 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3431,349 +3431,30 @@ initialise_ag_headers( struct xfs_mount *mp, struct xfs_sb *sbp, xfs_agnumber_t agno, - int *worst_freelist) + int *worst_freelist, + struct list_head *buffer_list) { + struct aghdr_init_data id = { + .agno = agno, + .agsize = cfg->agsize, + }; struct xfs_perag *pag = libxfs_perag_get(mp, agno); - struct xfs_agfl *agfl; - struct xfs_agf *agf; - struct xfs_agi *agi; - struct xfs_buf *buf; - struct xfs_btree_block *block; - struct xfs_alloc_rec *arec; - struct xfs_alloc_rec *nrec; - int bucket; - uint64_t agsize = cfg->agsize; - xfs_agblock_t agblocks; - bool is_log_ag = false; - int c; - - if (cfg->loginternal && agno == cfg->logagno) - is_log_ag = true; - - /* - * Superblock. - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AG_DADDR(mp, agno, XFS_SB_DADDR), - XFS_FSS_TO_BB(mp, 1)); - buf->b_ops = &xfs_sb_buf_ops; - memset(buf->b_addr, 0, cfg->sectorsize); - libxfs_sb_to_disk(buf->b_addr, sbp); - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); + int error; - /* - * AG header block: freespace - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), - XFS_FSS_TO_BB(mp, 1)); - buf->b_ops = &xfs_agf_buf_ops; - agf = XFS_BUF_TO_AGF(buf); - memset(agf, 0, cfg->sectorsize); if (agno == cfg->agcount - 1) - agsize = cfg->dblocks - (xfs_rfsblock_t)(agno * agsize); - agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); - agf->agf_versionnum = cpu_to_be32(XFS_AGF_VERSION); - agf->agf_seqno = cpu_to_be32(agno); - agf->agf_length = cpu_to_be32(agsize); - agf->agf_roots[XFS_BTNUM_BNOi] = cpu_to_be32(XFS_BNO_BLOCK(mp)); - agf->agf_roots[XFS_BTNUM_CNTi] = cpu_to_be32(XFS_CNT_BLOCK(mp)); - agf->agf_levels[XFS_BTNUM_BNOi] = cpu_to_be32(1); - agf->agf_levels[XFS_BTNUM_CNTi] = cpu_to_be32(1); - pag->pagf_levels[XFS_BTNUM_BNOi] = 1; - pag->pagf_levels[XFS_BTNUM_CNTi] = 1; - - if (xfs_sb_version_hasrmapbt(sbp)) { - agf->agf_roots[XFS_BTNUM_RMAPi] = cpu_to_be32(XFS_RMAP_BLOCK(mp)); - agf->agf_levels[XFS_BTNUM_RMAPi] = cpu_to_be32(1); - agf->agf_rmap_blocks = cpu_to_be32(1); - } + id.agsize = cfg->dblocks - (xfs_rfsblock_t)(agno * cfg->agsize); - if (xfs_sb_version_hasreflink(sbp)) { - agf->agf_refcount_root = cpu_to_be32(libxfs_refc_block(mp)); - agf->agf_refcount_level = cpu_to_be32(1); - agf->agf_refcount_blocks = cpu_to_be32(1); + INIT_LIST_HEAD(&id.buffer_list); + error = -libxfs_ag_init_headers(mp, &id); + if (error) { + fprintf(stderr, _("AG header init failed, error %d\n"), error); + exit(1); } - agf->agf_flfirst = 0; - agf->agf_fllast = cpu_to_be32(libxfs_agfl_size(mp) - 1); - agf->agf_flcount = 0; - agblocks = (xfs_agblock_t)(agsize - libxfs_prealloc_blocks(mp)); - agf->agf_freeblks = cpu_to_be32(agblocks); - agf->agf_longest = cpu_to_be32(agblocks); - - if (xfs_sb_version_hascrc(sbp)) - platform_uuid_copy(&agf->agf_uuid, &sbp->sb_uuid); + list_splice_tail_init(&id.buffer_list, buffer_list); - if (is_log_ag) { - be32_add_cpu(&agf->agf_freeblks, -(int64_t)cfg->logblocks); - agf->agf_longest = cpu_to_be32(agsize - - XFS_FSB_TO_AGBNO(mp, cfg->logstart) - cfg->logblocks); - } if (libxfs_alloc_min_freelist(mp, pag) > *worst_freelist) *worst_freelist = libxfs_alloc_min_freelist(mp, pag); - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - - /* - * AG freelist header block - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)), - XFS_FSS_TO_BB(mp, 1)); - buf->b_ops = &xfs_agfl_buf_ops; - agfl = XFS_BUF_TO_AGFL(buf); - /* setting to 0xff results in initialisation to NULLAGBLOCK */ - memset(agfl, 0xff, cfg->sectorsize); - if (xfs_sb_version_hascrc(sbp)) { - agfl->agfl_magicnum = cpu_to_be32(XFS_AGFL_MAGIC); - agfl->agfl_seqno = cpu_to_be32(agno); - platform_uuid_copy(&agfl->agfl_uuid, &sbp->sb_uuid); - for (bucket = 0; bucket < libxfs_agfl_size(mp); bucket++) - agfl->agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK); - } - - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - - /* - * AG header block: inodes - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), - XFS_FSS_TO_BB(mp, 1)); - agi = XFS_BUF_TO_AGI(buf); - buf->b_ops = &xfs_agi_buf_ops; - memset(agi, 0, cfg->sectorsize); - agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); - agi->agi_versionnum = cpu_to_be32(XFS_AGI_VERSION); - agi->agi_seqno = cpu_to_be32(agno); - agi->agi_length = cpu_to_be32(agsize); - agi->agi_count = 0; - agi->agi_root = cpu_to_be32(XFS_IBT_BLOCK(mp)); - agi->agi_level = cpu_to_be32(1); - if (xfs_sb_version_hasfinobt(sbp)) { - agi->agi_free_root = cpu_to_be32(XFS_FIBT_BLOCK(mp)); - agi->agi_free_level = cpu_to_be32(1); - } - agi->agi_freecount = 0; - agi->agi_newino = cpu_to_be32(NULLAGINO); - agi->agi_dirino = cpu_to_be32(NULLAGINO); - if (xfs_sb_version_hascrc(sbp)) - platform_uuid_copy(&agi->agi_uuid, &sbp->sb_uuid); - for (c = 0; c < XFS_AGI_UNLINKED_BUCKETS; c++) - agi->agi_unlinked[c] = cpu_to_be32(NULLAGINO); - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - - /* - * BNO btree root block - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), - BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_bnobt_buf_ops; - block = XFS_BUF_TO_BLOCK(buf); - memset(block, 0, cfg->blocksize); - libxfs_btree_init_block(mp, buf, XFS_BTNUM_BNO, 0, 1, agno); - - arec = XFS_ALLOC_REC_ADDR(mp, block, 1); - arec->ar_startblock = cpu_to_be32(libxfs_prealloc_blocks(mp)); - if (is_log_ag) { - xfs_agblock_t start = XFS_FSB_TO_AGBNO(mp, cfg->logstart); - - ASSERT(start >= libxfs_prealloc_blocks(mp)); - if (start != libxfs_prealloc_blocks(mp)) { - /* - * Modify first record to pad stripe align of log - */ - arec->ar_blockcount = cpu_to_be32(start - - libxfs_prealloc_blocks(mp)); - nrec = arec + 1; - /* - * Insert second record at start of internal log - * which then gets trimmed. - */ - nrec->ar_startblock = cpu_to_be32( - be32_to_cpu(arec->ar_startblock) + - be32_to_cpu(arec->ar_blockcount)); - arec = nrec; - be16_add_cpu(&block->bb_numrecs, 1); - } - /* - * Change record start to after the internal log - */ - be32_add_cpu(&arec->ar_startblock, cfg->logblocks); - } - /* - * Calculate the record block count and check for the case where - * the log might have consumed all available space in the AG. If - * so, reset the record count to 0 to avoid exposure of an invalid - * record start block. - */ - arec->ar_blockcount = cpu_to_be32(agsize - - be32_to_cpu(arec->ar_startblock)); - if (!arec->ar_blockcount) - block->bb_numrecs = 0; - - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - - /* - * CNT btree root block - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), - BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_cntbt_buf_ops; - block = XFS_BUF_TO_BLOCK(buf); - memset(block, 0, cfg->blocksize); - libxfs_btree_init_block(mp, buf, XFS_BTNUM_CNT, 0, 1, agno); - - arec = XFS_ALLOC_REC_ADDR(mp, block, 1); - arec->ar_startblock = cpu_to_be32(libxfs_prealloc_blocks(mp)); - if (is_log_ag) { - xfs_agblock_t start = XFS_FSB_TO_AGBNO(mp, cfg->logstart); - - ASSERT(start >= libxfs_prealloc_blocks(mp)); - if (start != libxfs_prealloc_blocks(mp)) { - arec->ar_blockcount = cpu_to_be32(start - - libxfs_prealloc_blocks(mp)); - nrec = arec + 1; - nrec->ar_startblock = cpu_to_be32( - be32_to_cpu(arec->ar_startblock) + - be32_to_cpu(arec->ar_blockcount)); - arec = nrec; - be16_add_cpu(&block->bb_numrecs, 1); - } - be32_add_cpu(&arec->ar_startblock, cfg->logblocks); - } - /* - * Calculate the record block count and check for the case where - * the log might have consumed all available space in the AG. If - * so, reset the record count to 0 to avoid exposure of an invalid - * record start block. - */ - arec->ar_blockcount = cpu_to_be32(agsize - - be32_to_cpu(arec->ar_startblock)); - if (!arec->ar_blockcount) - block->bb_numrecs = 0; - - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - - /* - * refcount btree root block - */ - if (xfs_sb_version_hasreflink(sbp)) { - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, libxfs_refc_block(mp)), - BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_refcountbt_buf_ops; - - block = XFS_BUF_TO_BLOCK(buf); - memset(block, 0, cfg->blocksize); - libxfs_btree_init_block(mp, buf, XFS_BTNUM_REFC, 0, 0, agno); - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - } - - /* - * INO btree root block - */ - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), - BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_inobt_buf_ops; - block = XFS_BUF_TO_BLOCK(buf); - memset(block, 0, cfg->blocksize); - libxfs_btree_init_block(mp, buf, XFS_BTNUM_INO, 0, 0, agno); - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - - /* - * Free INO btree root block - */ - if (xfs_sb_version_hasfinobt(sbp)) { - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, XFS_FIBT_BLOCK(mp)), - BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_finobt_buf_ops; - block = XFS_BUF_TO_BLOCK(buf); - memset(block, 0, cfg->blocksize); - libxfs_btree_init_block(mp, buf, XFS_BTNUM_FINO, 0, 0, agno); - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - } - - /* RMAP btree root block */ - if (xfs_sb_version_hasrmapbt(sbp)) { - struct xfs_rmap_rec *rrec; - - buf = libxfs_getbuf(mp->m_ddev_targp, - XFS_AGB_TO_DADDR(mp, agno, XFS_RMAP_BLOCK(mp)), - BTOBB(cfg->blocksize)); - buf->b_ops = &xfs_rmapbt_buf_ops; - block = XFS_BUF_TO_BLOCK(buf); - memset(block, 0, cfg->blocksize); - - libxfs_btree_init_block(mp, buf, XFS_BTNUM_RMAP, 0, 0, agno); - - /* - * mark the AG header regions as static metadata - * The BNO btree block is the first block after the - * headers, so it's location defines the size of region - * the static metadata consumes. - */ - rrec = XFS_RMAP_REC_ADDR(block, 1); - rrec->rm_startblock = 0; - rrec->rm_blockcount = cpu_to_be32(XFS_BNO_BLOCK(mp)); - rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_FS); - rrec->rm_offset = 0; - be16_add_cpu(&block->bb_numrecs, 1); - - /* account freespace btree root blocks */ - rrec = XFS_RMAP_REC_ADDR(block, 2); - rrec->rm_startblock = cpu_to_be32(XFS_BNO_BLOCK(mp)); - rrec->rm_blockcount = cpu_to_be32(2); - rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_AG); - rrec->rm_offset = 0; - be16_add_cpu(&block->bb_numrecs, 1); - - /* account inode btree root blocks */ - rrec = XFS_RMAP_REC_ADDR(block, 3); - rrec->rm_startblock = cpu_to_be32(XFS_IBT_BLOCK(mp)); - rrec->rm_blockcount = cpu_to_be32(XFS_RMAP_BLOCK(mp) - - XFS_IBT_BLOCK(mp)); - rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_INOBT); - rrec->rm_offset = 0; - be16_add_cpu(&block->bb_numrecs, 1); - - /* account for rmap btree root */ - rrec = XFS_RMAP_REC_ADDR(block, 4); - rrec->rm_startblock = cpu_to_be32(XFS_RMAP_BLOCK(mp)); - rrec->rm_blockcount = cpu_to_be32(1); - rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_AG); - rrec->rm_offset = 0; - be16_add_cpu(&block->bb_numrecs, 1); - - /* account for refcount btree root */ - if (xfs_sb_version_hasreflink(sbp)) { - rrec = XFS_RMAP_REC_ADDR(block, 5); - rrec->rm_startblock = cpu_to_be32(libxfs_refc_block(mp)); - rrec->rm_blockcount = cpu_to_be32(1); - rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_REFC); - rrec->rm_offset = 0; - be16_add_cpu(&block->bb_numrecs, 1); - } - - /* account for the log space */ - if (is_log_ag) { - rrec = XFS_RMAP_REC_ADDR(block, - be16_to_cpu(block->bb_numrecs) + 1); - rrec->rm_startblock = cpu_to_be32( - XFS_FSB_TO_AGBNO(mp, cfg->logstart)); - rrec->rm_blockcount = cpu_to_be32(cfg->logblocks); - rrec->rm_owner = cpu_to_be64(XFS_RMAP_OWN_LOG); - rrec->rm_offset = 0; - be16_add_cpu(&block->bb_numrecs, 1); - } - - libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE); - } - libxfs_perag_put(pag); } @@ -3896,6 +3577,8 @@ main( }, }; + struct list_head buffer_list; + platform_uuid_generate(&cli.uuid); progname = basename(argv[0]); setlocale(LC_ALL, ""); @@ -4087,8 +3770,16 @@ main( /* * Initialise all the static on disk metadata. */ + INIT_LIST_HEAD(&buffer_list); for (agno = 0; agno < cfg.agcount; agno++) - initialise_ag_headers(&cfg, mp, sbp, agno, &worst_freelist); + initialise_ag_headers(&cfg, mp, sbp, agno, &worst_freelist, + &buffer_list); + + if (libxfs_buf_delwri_submit(&buffer_list)) { + fprintf(stderr, _("%s: writing AG headers failed\n"), + progname); + exit(1); + } /* * Initialise the freespace freelists (i.e. AGFLs) in each AG.