Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp373513imm; Sat, 26 May 2018 01:16:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpsdvJ+HJVy3IDO2Q3KJX97RFXqB4sbMfIERIISrqjssuSWDa3GawkjoZX0hgI27hZo8bJy X-Received: by 2002:a17:902:bd0a:: with SMTP id p10-v6mr5755519pls.69.1527322578816; Sat, 26 May 2018 01:16:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527322578; cv=none; d=google.com; s=arc-20160816; b=Ow0trp2wFxACPXEZePcDG6+Fef6Actd6hsd/CRaKqTRB6idvLrhRRWhcT9w8miXrE1 k+pi6u87ZqIKNdghIBFfgffStDbgKn0ZT9L7wgnvUJpJF+fJq3MkYvBjm+Ymu4GR24Jl vCtjiJvYbExgpCe4qGvETj184P9dPf0UNpiHu0wK+Kop4JuhGsHU2DLzZpgd8wCdjUiw 2QwHTpVc8kiOx/OiFTLe+BaOhpmcGJ8pmF9E0zV6wVvr4ozoqPECX3ob38Xs34P1vqBJ fcUZyHEZwkJFPoD0Pdp+YvfjwiMnYpb9LgKofC8YkRZRsS0LGrJOB3Nj7MbHyPeu0W+X P2sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=ZTO+Cb6GXIcjqH3gzNZFMMUexxa8r2BuvjN/xzylKgg=; b=FR9sN64sYxNEPp0q482yegTlwM8EpgzZNZB/9pPQ0AZE6PJs5d1Qn80B3ViqKv2wrF pP40XVoy3oNVnOYec2Ev8QNBjwGS5BNXu0USbqHPxgxF1IsFSFNSe6otDc9KZy6LZFrP Xx0WPhu34ELhy4hJ1guv8P6atXW5i2Y4/sTGyMkVr4SEMFT4ZOpqd6gKulEVZMHERPs9 T45nABbAOp3qGTj4zwevi5N6tb+m4K6xme89PDBB2SbqKjxK+L2gwgQBc5ypv+KzzsIP d5INhqXLMXNSGpUn2j3YzPn+eaJ7oz/T04iRtFDvxbtJNak1JIV9I4zgnLyWO0XTEdEV QQZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1-v6si1606072pgu.52.2018.05.26.01.16.03; Sat, 26 May 2018 01:16:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031334AbeEZIPu (ORCPT + 99 others); Sat, 26 May 2018 04:15:50 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:40456 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1031292AbeEZIPs (ORCPT ); Sat, 26 May 2018 04:15:48 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id AA5B96E00DB79; Sat, 26 May 2018 16:15:45 +0800 (CST) Received: from [127.0.0.1] (10.111.220.140) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Sat, 26 May 2018 16:15:40 +0800 Subject: Re: [PATCH v2] f2fs-tools: fix to match with the start_sector To: , , , CC: , , , , , References: <1525425645-127945-1-git-send-email-yunlong.song@huawei.com> <1525659336-145433-1-git-send-email-yunlong.song@huawei.com> From: Yunlong Song Message-ID: Date: Sat, 26 May 2018 16:13:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1525659336-145433-1-git-send-email-yunlong.song@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.111.220.140] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping... On 2018/5/7 10:15, Yunlong Song wrote: > f2fs-tools uses ioctl BLKSSZGET to get sector_size, however, this ioctl > will return a value which may be larger than 512 (according to the value > of q->limits.logical_block_size), then this will be inconsistent with > the start_sector, since start_sector is got from ioctl HDIO_GETGEO and > is always in 512 size unit for a sector. To fix this problem, just > change the sector_size to the default value when computing with > start_sector. And fix sectors_per_blk as well. > > Signed-off-by: Yunlong Song > --- > fsck/resize.c | 4 ++-- > mkfs/f2fs_format.c | 12 ++++++------ > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fsck/resize.c b/fsck/resize.c > index d285dd7..ada2155 100644 > --- a/fsck/resize.c > +++ b/fsck/resize.c > @@ -27,10 +27,10 @@ static int get_new_sb(struct f2fs_super_block *sb) > > zone_size_bytes = segment_size_bytes * segs_per_zone; > zone_align_start_offset = > - (c.start_sector * c.sector_size + > + (c.start_sector * DEFAULT_SECTOR_SIZE + > 2 * F2FS_BLKSIZE + zone_size_bytes - 1) / > zone_size_bytes * zone_size_bytes - > - c.start_sector * c.sector_size; > + c.start_sector * DEFAULT_SECTOR_SIZE; > > set_sb(segment_count, (c.target_sectors * c.sector_size - > zone_align_start_offset) / segment_size_bytes / > diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c > index 0a99a77..ced5fea 100644 > --- a/mkfs/f2fs_format.c > +++ b/mkfs/f2fs_format.c > @@ -212,18 +212,18 @@ static int f2fs_prepare_super_block(void) > set_sb(block_count, c.total_sectors >> log_sectors_per_block); > > zone_align_start_offset = > - (c.start_sector * c.sector_size + > + (c.start_sector * DEFAULT_SECTOR_SIZE + > 2 * F2FS_BLKSIZE + zone_size_bytes - 1) / > zone_size_bytes * zone_size_bytes - > - c.start_sector * c.sector_size; > + c.start_sector * DEFAULT_SECTOR_SIZE; > > - if (c.start_sector % c.sectors_per_blk) { > + if (c.start_sector % DEFAULT_SECTORS_PER_BLOCK) { > MSG(1, "\t%s: Align start sector number to the page unit\n", > c.zoned_mode ? "FAIL" : "WARN"); > MSG(1, "\ti.e., start sector: %d, ofs:%d (sects/page: %d)\n", > c.start_sector, > - c.start_sector % c.sectors_per_blk, > - c.sectors_per_blk); > + c.start_sector % DEFAULT_SECTORS_PER_BLOCK, > + DEFAULT_SECTORS_PER_BLOCK); > if (c.zoned_mode) > return -1; > } > @@ -235,7 +235,7 @@ static int f2fs_prepare_super_block(void) > get_sb(segment0_blkaddr)); > > if (c.zoned_mode && (get_sb(segment0_blkaddr) + c.start_sector / > - c.sectors_per_blk) % c.zone_blocks) { > + DEFAULT_SECTORS_PER_BLOCK) % c.zone_blocks) { > MSG(1, "\tError: Unaligned segment0 block address %u\n", > get_sb(segment0_blkaddr)); > return -1; -- Thanks, Yunlong Song