From patchwork Thu Dec 1 13:51:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 9456161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9307A60756 for ; Thu, 1 Dec 2016 13:51:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8708928461 for ; Thu, 1 Dec 2016 13:51:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BF19284D3; Thu, 1 Dec 2016 13:51:34 +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=-6.9 required=2.0 tests=BAYES_00,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 1EACC28495 for ; Thu, 1 Dec 2016 13:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757626AbcLANva (ORCPT ); Thu, 1 Dec 2016 08:51:30 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58643 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757305AbcLANv3 (ORCPT ); Thu, 1 Dec 2016 08:51:29 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uB1DnDsW108822 for ; Thu, 1 Dec 2016 08:51:29 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 272ms2h80k-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 01 Dec 2016 08:51:28 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 1 Dec 2016 06:51:28 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 1 Dec 2016 06:51:25 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id C01E11FF0026; Thu, 1 Dec 2016 06:51:03 -0700 (MST) Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uB1DpOlt16777666; Thu, 1 Dec 2016 06:51:24 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D41A6E03F; Thu, 1 Dec 2016 06:51:24 -0700 (MST) Received: from localhost.in.ibm.com (unknown [9.79.191.13]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 748296E03A; Thu, 1 Dec 2016 06:51:23 -0700 (MST) From: Chandan Rajendra To: linux-btrfs@vger.kernel.org Cc: Chandan Rajendra , dsterba@suse.com Subject: [PATCH V2] btrfs-progs: Use helper function to access btrfs_super_block->sys_chunk_array_size Date: Thu, 1 Dec 2016 19:21:14 +0530 X-Mailer: git-send-email 2.5.5 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16120113-0020-0000-0000-00000A67C1EF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006174; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000193; SDB=6.00787850; UDB=6.00381149; IPR=6.00565527; BA=6.00004935; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013502; XFM=3.00000011; UTC=2016-12-01 13:51:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16120113-0021-0000-0000-000057BBC007 Message-Id: <1480600274-13623-1-git-send-email-chandan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-01_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1612010239 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP btrfs_super_block->sys_chunk_array_size is stored as le32 data on disk. However insert_temp_chunk_item() writes sys_chunk_array_size in host cpu order. This commit fixes this by using super block access helper functions to read and write btrfs_super_block->sys_chunk_array_size field. Signed-off-by: Chandan Rajendra --- utils.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils.c b/utils.c index d0189ad..74dde1e 100644 --- a/utils.c +++ b/utils.c @@ -562,14 +562,18 @@ static int insert_temp_chunk_item(int fd, struct extent_buffer *buf, */ if (type & BTRFS_BLOCK_GROUP_SYSTEM) { char *cur; + u32 array_size; - cur = (char *)sb->sys_chunk_array + sb->sys_chunk_array_size; + cur = (char *)sb->sys_chunk_array + + btrfs_super_sys_array_size(sb); memcpy(cur, &disk_key, sizeof(disk_key)); cur += sizeof(disk_key); read_extent_buffer(buf, cur, (unsigned long int)chunk, btrfs_chunk_item_size(1)); - sb->sys_chunk_array_size += btrfs_chunk_item_size(1) + + array_size = btrfs_super_sys_array_size(sb); + array_size += btrfs_chunk_item_size(1) + sizeof(disk_key); + btrfs_set_super_sys_array_size(sb, array_size); ret = write_temp_super(fd, sb, cfg->super_bytenr); }