From patchwork Sun Mar 17 09:19:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 10856215 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 3F04F17E6 for ; Sun, 17 Mar 2019 09:19:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2441728ACB for ; Sun, 17 Mar 2019 09:19:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13BA828B04; Sun, 17 Mar 2019 09:19:19 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 970EB28ACB for ; Sun, 17 Mar 2019 09:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbfCQJTR (ORCPT ); Sun, 17 Mar 2019 05:19:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45592 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726092AbfCQJTR (ORCPT ); Sun, 17 Mar 2019 05:19:17 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2H9ECro146259 for ; Sun, 17 Mar 2019 05:19:16 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2r9ek3fqcm-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 17 Mar 2019 05:19:15 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Mar 2019 09:19:14 -0000 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 17 Mar 2019 09:19:12 -0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2H9JB2n24379444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Mar 2019 09:19:12 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC0D4AC05E; Sun, 17 Mar 2019 09:19:11 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 111BCAC059; Sun, 17 Mar 2019 09:19:10 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.102.0.140]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Sun, 17 Mar 2019 09:19:09 +0000 (GMT) From: Chandan Rajendra To: linux-xfs@vger.kernel.org Cc: Chandan Rajendra , darrick.wong@oracle.com, sandeen@sandeen.net Subject: [PATCH] mkfs: Round down log device size if aligned value is larger than device size Date: Sun, 17 Mar 2019 14:49:43 +0530 X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19031709-0040-0000-0000-000004D34822 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010772; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01175583; UDB=6.00606765; IPR=6.00956259; MB=3.00026016; MTD=3.00000008; XFM=3.00000015; UTC=2019-03-17 09:19:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031709-0041-0000-0000-000008DE60CE Message-Id: <20190317091943.18222-1-chandan@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-17_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=809 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903170074 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 When using a disk of size 798903808 bytes as the log device and when having a log stripe unit size of 32768, align_log_size() rounds up log device size to 195048 4k blocks i.e. 798916608. This value is larger than the device size. Hence the last call to write(2) inside libxfs_device_zero() would end up returning an error. To fix this bug, we now round down the log device size if the newly computed size is larger than the actual log device size. Signed-off-by: Chandan Rajendra --- mkfs/xfs_mkfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index d1387ddf..bd05d071 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2938,7 +2938,8 @@ _("log size %lld is not a multiple of the log stripe unit %d\n"), /* If the log is too large, round down instead of round up */ if ((tmp_logblocks > XFS_MAX_LOG_BLOCKS) || - ((tmp_logblocks << cfg->blocklog) > XFS_MAX_LOG_BYTES)) { + ((tmp_logblocks << cfg->blocklog) > XFS_MAX_LOG_BYTES) || + (tmp_logblocks > cfg->logblocks)) { tmp_logblocks = (cfg->logblocks / sunit) * sunit; } cfg->logblocks = tmp_logblocks;