linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Yunlong Song <yunlong.song@huawei.com>
To: jaegeuk@kernel.org, chao@kernel.org, yuchao0@huawei.com,
	yunlong.song@icloud.com, yunlong.song@huawei.com
Cc: miaoxie@huawei.com, bintian.wang@huawei.com,
	shengyong1@huawei.com, heyunlei@huawei.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: [PATCH] f2fs-tools: fix the sector_size to default value
Date: Fri, 4 May 2018 17:20:45 +0800	[thread overview]
Message-ID: <1525425645-127945-1-git-send-email-yunlong.song@huawei.com> (raw)

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.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 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, &sector_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");
-- 
1.8.5.2

             reply	other threads:[~2018-05-04  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-04  9:20 Yunlong Song [this message]
2018-05-04  9:56 ` [PATCH] f2fs-tools: fix the sector_size to default value Chao Yu
2018-05-07  2:15 ` [PATCH v2] f2fs-tools: fix to match with the start_sector Yunlong Song
2018-05-26  8:13   ` Yunlong Song
2018-05-28  7:11   ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1525425645-127945-1-git-send-email-yunlong.song@huawei.com \
    --to=yunlong.song@huawei.com \
    --cc=bintian.wang@huawei.com \
    --cc=chao@kernel.org \
    --cc=heyunlei@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=shengyong1@huawei.com \
    --cc=yuchao0@huawei.com \
    --cc=yunlong.song@icloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).