From patchwork Fri May 3 03:53:13 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: 10927883 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 1B92992A for ; Fri, 3 May 2019 03:53:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E336627CEE for ; Fri, 3 May 2019 03:53:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D088027E01; Fri, 3 May 2019 03:53:36 +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 5DC0227CEE for ; Fri, 3 May 2019 03:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbfECDxf (ORCPT ); Thu, 2 May 2019 23:53:35 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:43864 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfECDxf (ORCPT ); Thu, 2 May 2019 23:53:35 -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 x433nwKN115097; Fri, 3 May 2019 03:53:18 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=IpOlqm9OEKkN1lSIEZN+nT3P4KtdSOvGcNqLdAoD0ZM=; b=gXrC/01ut4v6Jl8G2747hlGov2iBr0pB3yWKtEyquD+4k+R+oenzx/W30SVS9yK1qZ6u jiiltEpMrNWXbSuO3ebqpTfobS2Tsc8MF8zGCNXg7iFVoFwixO3LCW/Bt/Gky/iFww83 pha7miInfMi7Kpvd7HG27wkFvv8wnnP8pSGbPqHUK1Tpl5fqFb8Jp8mAVvg41sTLwUqh WUFIWzmwHjFPvFIhLdyrCvc+p02iTgemuzXhJvyg6Kly8cKcORUXvPHuJOWxo9vdyIEv mlU4F5wJAl35F8WZWs2pOevRbV3XF+flx4a2qjKKhrB0ZI14iPg+KdH6PJzhqqdUcPyh 7Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2s6xhyvc8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 May 2019 03:53:18 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x433r5RK081418; Fri, 3 May 2019 03:53:17 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2s6xhh5xfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 03 May 2019 03:53:17 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x433rGk7024678; Fri, 3 May 2019 03:53:16 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 May 2019 20:53:16 -0700 Date: Thu, 2 May 2019 20:53:13 -0700 From: "Darrick J. Wong" To: Eric Sandeen Cc: xfs Subject: [RFC PATCH] mkfs: validate start and end of aligned logs Message-ID: <20190503035312.GP5207@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=9245 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=927 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905030023 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9245 signatures=668685 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=951 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905030023 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 Validate that the start and end of the log stay within a single AG if we adjust either end to align to stripe units. Signed-off-by: Darrick J. Wong --- mkfs/xfs_mkfs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 3ca8c9dc..0862621a 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -3070,11 +3070,20 @@ align_internal_log( if ((cfg->logstart % sunit) != 0) cfg->logstart = ((cfg->logstart + (sunit - 1)) / sunit) * sunit; + /* if our log start rounds into the next AG we're done */ + if (!xfs_verify_fsbno(mp, cfg->logstart)) { + fprintf(stderr, +_("Due to stripe alignment, the internal log start (%lld) cannot be aligned\n" + "within an allocation group.\n"), + (long long) cfg->logstart); + usage(); + } + /* round up/down the log size now */ align_log_size(cfg, sunit); /* check the aligned log still fits in an AG. */ - if (cfg->logblocks > cfg->agsize - XFS_FSB_TO_AGBNO(mp, cfg->logstart)) { + if (!xfs_verify_fsbno(mp, cfg->logstart + cfg->logblocks - 1)) { fprintf(stderr, _("Due to stripe alignment, the internal log size (%lld) is too large.\n" "Must fit within an allocation group.\n"),