Received: by 10.192.165.148 with SMTP id m20csp580726imm; Fri, 4 May 2018 02:58:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqQSuCw+Y7zDbciBljKgXZAO42VdUxSmehdZZuawvKdFk0FnzQwgAhZew2B60Yoomi8L5s+ X-Received: by 2002:a65:5786:: with SMTP id b6-v6mr16779483pgr.241.1525427919440; Fri, 04 May 2018 02:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525427919; cv=none; d=google.com; s=arc-20160816; b=Zg8TcKK+v0Z/6QEVDpoflO8ZEr2mwXUu0BN5PF2WzyvMtaZDp7iimwJoR5saLB7mwi G39NStf9sBjQzmeAGoyYcgkZB2MOVKACuBws9FvdJCY/eR/UpTqwHEGDfxiev2WzqTG9 MeIjvRh7dS5A6Ju+Tq+Ldak/MzNTp1UkNgqfUzqv3k2a19dfxCb/tXmOvlEyZl7MXjO+ QYvTct7S6tywHRxI/prBJTLbwGPIktrlE4pCQXfM3iQYwJ4nXfcI0iToiDRdgUxfQSLN Bu5mybsCr2a4uvw5YdtY/F7o3pL1ClYLhUw0gt1Hz33wp/JzVrtUkdlD6ypJQrtJAwLE ANKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=H8EoMNFI8xl7d4iDeDWa+GnWGmqQlkF6UTegtNxPCl4=; b=r/Nhn9yUvxr8b3EL9Qfpv2Fgff8KLhw3EWzHL02s16f5fI55qh7eYA24C9TNr/4Lln JeFhigxypGk43GSWm3ig5e3WeLcHrwb/EbPfEbdrFHlSxEC4mJaleU1DJ5a99KAbsbRO hUSHlMTC+P4ed7PvVv9kMYeVOJQ9DlDf+P/Gbv46BwZNtFo5oaLuvZJAf4224RkESceU Q9jt6C8wERtX8ZlZ2A7ddnL3Af27rcoSmLhz+ieE7URdQLZb939u60cE0C23NfIJs8kP 4PtrV527Z15tCBA4aQmQ6d2ifKfBKrpVAWYt9XMUbf3O2zjxgccP3c5Off0qId0CsPF4 sY3w== 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 z8-v6si8431611pgc.693.2018.05.04.02.58.25; Fri, 04 May 2018 02:58:39 -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 S1751880AbeEDJ5B (ORCPT + 99 others); Fri, 4 May 2018 05:57:01 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:37230 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751592AbeEDJ47 (ORCPT ); Fri, 4 May 2018 05:56:59 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 5A6E4C5440CD5; Fri, 4 May 2018 17:56:57 +0800 (CST) Received: from [127.0.0.1] (10.134.22.195) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.361.1; Fri, 4 May 2018 17:56:48 +0800 Subject: Re: [PATCH] f2fs-tools: fix the sector_size to default value To: Yunlong Song , , , CC: , , , , , References: <1525425645-127945-1-git-send-email-yunlong.song@huawei.com> From: Chao Yu Message-ID: Date: Fri, 4 May 2018 17:56:48 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1525425645-127945-1-git-send-email-yunlong.song@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/5/4 17:20, 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 set > the sector_size to the default value 512. Please check below discussion: https://sourceforge.net/p/linux-f2fs/mailman/message/36282479/ Anyway, we will not set sector_size to 512 by default for backward compatibility, since some users may calculated total_sector_number by theirselves via BLKSSZGET. Usage: mkfs.f2fs [options] device [sectors]: sectors: number of sectors. [default: determined by device size] So how about changing as below? zone_align_start_offset = (c.start_sector * DEFAULT_SECTOR_SIZE + 2 * F2FS_BLKSIZE + zone_size_bytes - 1) / zone_size_bytes * zone_size_bytes - c.start_sector * DEFAULT_SECTOR_SIZE; Thanks, > > Signed-off-by: Yunlong Song > --- > lib/libf2fs.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/lib/libf2fs.c b/lib/libf2fs.c > index 102e579..e160f2a 100644 > --- a/lib/libf2fs.c > +++ b/lib/libf2fs.c > @@ -768,7 +768,6 @@ void get_kernel_uname_version(__u8 *version) > int get_device_info(int i) > { > int32_t fd = 0; > - uint32_t sector_size; > #ifndef BLKGETSIZE64 > uint32_t total_sectors; > #endif > @@ -822,12 +821,6 @@ int get_device_info(int i) > } else if (S_ISREG(stat_buf->st_mode)) { > dev->total_sectors = stat_buf->st_size / dev->sector_size; > } else if (S_ISBLK(stat_buf->st_mode)) { > -#ifdef BLKSSZGET > - if (ioctl(fd, BLKSSZGET, §or_size) < 0) > - MSG(0, "\tError: Using the default sector size\n"); > - else if (dev->sector_size < sector_size) > - dev->sector_size = sector_size; > -#endif > #ifdef BLKGETSIZE64 > if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) { > MSG(0, "\tError: Cannot get the device size\n"); >