From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jaegeuk Kim Subject: [PATCH] libf2fs: reset wanted_total_sectors by new sector_size Date: Tue, 27 Mar 2018 10:19:08 -0700 Message-ID: <20180327171908.15092-1-jaegeuk@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1f0sFn-0003Mo-FZ for linux-f2fs-devel@lists.sourceforge.net; Tue, 27 Mar 2018 17:19:23 +0000 Received: from sfi-lb-mx.v20.lw.sourceforge.com ([172.30.20.201] helo=mail.kernel.org) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1f0sFl-00ACgQ-Mh for linux-f2fs-devel@lists.sourceforge.net; Tue, 27 Mar 2018 17:19:23 +0000 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: linux-f2fs-devel@lists.sourceforge.net Cc: katao , Jaegeuk Kim From: katao The args of wanted_total_sectors is calculated based on the DEFAULT_SECTOR_SIZE(512Bytes).get_device_info(i) may be reset dev_sector_size, we should reset the number of wanted_total_sectors. This bug was reported to Google Issue Tracker. Link: https://issuetracker.google.com/issues/76407663 Signed-off-by: katao Signed-off-by: Jaegeuk Kim --- lib/libf2fs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/libf2fs.c b/lib/libf2fs.c index 0c684d5..5f11796 100644 --- a/lib/libf2fs.c +++ b/lib/libf2fs.c @@ -799,8 +799,15 @@ int get_device_info(int i) #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) + else if (dev->sector_size < sector_size){ + /* + * wanted_total_sectors need to be reset by new + * sector_size. + */ + c.wanted_total_sectors = (c.wanted_total_sectors * + dev->sector_size) / sector_size; dev->sector_size = sector_size; + } #endif #ifdef BLKGETSIZE64 if (ioctl(fd, BLKGETSIZE64, &dev->total_sectors) < 0) { -- 2.15.0.531.g2ccb3012c9-goog ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot