Bug 895946 - Got incorrect block count number when resize ntfs file system via "ntfsresize_opts"
Got incorrect block count number when resize ntfs file system via "ntfsresize...
Status: NEW
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks: 895006
  Show dependency treegraph
 
Reported: 2013-01-16 05:45 EST by Richard W.M. Jones
Modified: 2014-09-07 19:02 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 895006
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
ntfsresize reproducer script (437 bytes, text/plain)
2013-01-22 03:41 EST, Richard W.M. Jones
no flags Details

  None (edit)
Description Richard W.M. Jones 2013-01-16 05:45:08 EST
+++ This bug was initially created as a clone of Bug #895006 +++

Created attachment 678138 [details]
command "nftfsersize" result

Description of problem:
1. When resize the ntfs filesystem, get the actually block count number is one less than expected. eg. filesystem size specified is 2147344384 bytes, which are 524254 blocks. But get 524253 blocks after resize
2."ntfsresize_opts" without option "size", it should resize to fit the container, but get the number of block count is not the origin's


Version-Release number of selected component (if applicable):
><fs> version
libguestfs: trace: version
libguestfs: trace: version = <struct guestfs_version *>
major: 1
minor: 16
release: 34
extra: rhel=6,release=2.el6


How reproducible:
100%


Steps to Reproduce:
1. make ntfs filesystem and check block count ( total 524256 blocks)
><fs> mkfs ntfs /dev/vda1
libguestfs: trace: mkfs "ntfs" "/dev/vda1"
libguestfs: trace: mkfs = 0
><fs> mount /dev/vda1 /
libguestfs: trace: mount "/dev/vda1" "/"
libguestfs: trace: mount = 0
><fs> statvfs /
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
bsize: 4096
frsize: 4096
blocks: 524256
bfree: 521507
bavail: 521507
files: 2118796
ffree: 2118777
favail: 2118777
fsid: 0
flag: 4102
namemax: 255

2. resize file system (want 524254 blocks, so file system size if 4096 * 524254 = 2147344384)
><fs> umount /
libguestfs: trace: umount "/"
libguestfs: trace: umount = 0
><fs> ntfsresize-opts /dev/vda1 size:2147344384 force:true
libguestfs: trace: ntfsresize_opts "/dev/vda1" "size:2147344384" "force:true"
libguestfs: trace: ntfsresize_opts = 0

3. check blocks again (actually, get 524253 blocks)
><fs> mount /dev/vda1 /
libguestfs: trace: mount "/dev/vda1" "/"
libguestfs: trace: mount = 0
><fs> statvfs /
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
bsize: 4096
frsize: 4096
blocks: 524253
bfree: 521504
bavail: 521504
files: 2118784
ffree: 2118765
favail: 2118765
fsid: 0
flag: 4102
namemax: 255

4. resize file system size to origin (omit "size" option)
><fs> umount /
libguestfs: trace: umount "/"
libguestfs: trace: umount = 0
><fs> ntfsresize-opts /dev/vda1 force:true
libguestfs: trace: ntfsresize_opts "/dev/vda1" "force:true"
libguestfs: trace: ntfsresize_opts = 0

5. check blocks again (should be 524256 blocks, but get 524255 blocks)
><fs> mount /dev/vda1 /
libguestfs: trace: mount "/dev/vda1" "/"
libguestfs: trace: mount = 0
><fs> statvfs /
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
bsize: 4096
frsize: 4096
blocks: 524255
bfree: 521506
bavail: 521506
files: 2118792
ffree: 2118773
favail: 2118773
fsid: 0
flag: 4102
namemax: 255


Actual results:
can't get the correct blocks which are expected


Expected results:
get the correct blocks which our specified


Additional info:
has the same issue with linux command "ntfsresize" (version from ntfsprogs-2.0.0-13.el6.x86_64.rpm)
this log is attached

--- Additional comment from RHEL Product and Program Management on 2013-01-14 04:54:06 EST ---

Since this bug report was entered in bugzilla and this package is
not scheduled to be updated in the current release, the release
flag has been set to ? to ensure that it is properly evaluated
for the next release.
Comment 1 Richard W.M. Jones 2013-01-22 03:41:08 EST
Created attachment 684944 [details]
ntfsresize reproducer script

This is a self-contained test script.

When run on Fedora 18:

$ /tmp/ntfsresize.sh 
blocks: 25568
Resizing filesystem to 10000 blocks ...
blocks: 9999
Resizing filesystem to original (full) size ...
blocks: 25567

$ guestfish --version
guestfish 1.20.1fedora=18,release=3.fc18,libvirt
Comment 2 Richard W.M. Jones 2013-01-22 03:43:17 EST
I changed the script so it skips the middle resize-to-10000-blocks
step:

$ /tmp/ntfsresize.sh 
blocks: 25568
Resizing filesystem to original (full) size ...
blocks: 25568

BTW if this is a bug then it is a bug in ntfs-3g.
Comment 3 Richard W.M. Jones 2013-01-22 03:51:20 EST
Bug report sent upstream.  We will have to retry with
a more recent version of ntfs-3g.
Comment 4 Richard W.M. Jones 2013-01-22 06:40:01 EST
Upstream report:
http://sourceforge.net/mailarchive/message.php?msg_id=30383471

FWIW I get the same result with ntfs-3g 2013.1.13.
Comment 5 Richard W.M. Jones 2013-02-04 08:39:33 EST
I got a good explanation of exactly what is going on here:

http://sourceforge.net/mailarchive/message.php?msg_id=30440594

Essentially this is not a bug.  The QA test will have to
be adjusted to allow for the possibility of a small number
of unused sectors.

Note You need to log in before you can comment on or make changes to this bug.