Bug 1899

Summary: Invalid data on used disk space with NTFS
Product: File System Reporter: Haakon Riiser (bugzilla)
Component: OtherAssignee: Anton Altaparmakov (aia21)
Status: CLOSED CODE_FIX    
Severity: normal    
Priority: P2    
Hardware: i386   
OS: Linux   
Kernel Version: 2.6.1 Subsystem:
Regression: --- Bisected commit-id:

Description Haakon Riiser 2004-01-17 16:49:50 UTC
Distribution: Slackware 9.1
Hardware Environment: Athlon XP2500+, nForce2
Software Environment:
Problem Description:
Reported disk usage under NTFS is often different from what
is returned under 2.4, and by Windows itself.  The number of
allocated blocks is especially far off on the directory containing
the Windows operating system (i.e., C:\WINDOWS).  In my case,
Linux 2.6.1 reports the disk space used by C:\WINDOWS to be 20%
larger than the total size of the file system!

Here's an example (du is run in the root of what is my C: drive):

  0       AUTOEXEC.BAT
  0       CONFIG.SYS
  43M     Documents and Settings
  0       IO.SYS
  0       MSDOS.SYS
  48K     NTDETECT.COM
  366M    Program Files
  0       RECYCLER
  20K     System Volume Information
  12G     WINDOWS
  0       boot.ini
  232K    ntldr
  768M    pagefile.sys

Same command under 2.4:

  0       AUTOEXEC.BAT
  0       CONFIG.SYS
  41M     Documents and Settings
  0       IO.SYS
  0       MSDOS.SYS
  48K     NTDETECT.COM
  366M    Program Files
  2.0K    RECYCLER
  21K     System Volume Information
  1.4G    WINDOWS
  1.0K    boot.ini
  230K    ntldr
  770M    pagefile.sys

Steps to reproduce:
Mount the parition containing C:\WINDOWS and run "du -s".
Compare with what is reported under 2.4 or by Windows itself.
(Note that I am using Windows XP;  I don't know if this is
reproducible with other versions of Windows.)
Comment 1 Anton Altaparmakov 2004-01-19 06:20:58 UTC
Hi,

Thanks for the bug report.  I have fixed this in NTFS 2.1.6 release which I just
submitted to Linus.  Until it is accepted, you can fix it in your source tree by
editing fs/ntfs/inode.c and changing line 1049 from:

if (!NInoCompressed(ni))
       vi->i_blocks = ni->allocated_size >> 9;
...

to

if (S_ISDIR(vi->i_mode) || !NInoCompressed(ni))
       vi->i_blocks = ni->allocated_size >> 9;
...

Best regards,

Anton Altaparmakov
NTFS maintainer