Preallocation bug?

Ask for help and report issues with the Windows version of Transmission
Post Reply
STEPHANVS
Posts: 4
Joined: Sun Dec 27, 2020 1:18 pm

Preallocation bug?

Post by STEPHANVS »

running in daemon mode, preallocation is set to 0, still skipped files are filled with 0-s. In my case file starts with 0-s then at the end of the file a little data is written resulting in full file size.
STEPHANVS
Posts: 4
Joined: Sun Dec 27, 2020 1:18 pm

Re: Preallocation bug?

Post by STEPHANVS »

Using Windows version, latest release transmission-3.00-x64.msi
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Preallocation bug?

Post by mike.dld »

For partially downloaded files *not* to occupy their full size you need to set preallocation to 1 (sparse), which is the default. What 0 means is that there'll be no preallocation attempts on Transmission side, but writing bytes past the end of any file (and in this case at the end of a non-existent or effectively 0-length file) means that OS will decide how to fill the preceding rest of the file to fill the gap, which usually means non-sparse allocation.

When set to 1, despite the appearance that the file has its full size and is mostly filled with zeroes, you'll see the difference in sizes when viewing file properties, like e.g. in this screenshot:
Image
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Preallocation bug?

Post by mike.dld »

It could be that copying files from incomplete to complete directory makes them non-sparse, will need to look into this. In case you're copying yourself, tools like ntfscopy might be useful.
STEPHANVS
Posts: 4
Joined: Sun Dec 27, 2020 1:18 pm

Re: Preallocation bug?

Post by STEPHANVS »

Stopped the Windows service changed preallocation back to 1, removed skipped part files, did a Verify and downloaded the remaining chunks. File size on the file properties page is still shows full size. I do not use directory for incomplete files.
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Preallocation bug?

Post by mike.dld »

What's the filesystem on the volume where you store torrents? Sparse preallocation would only work for NTFS. Also, check if sparse allocation is enabled for any given file(s) (as admin):

Code: Select all

> fsutil file layout test.dat

********* File 0x000200000018f2cc *********
File reference number   : 0x000200000018f2cc
File attributes         : 0x00000220: Archive | Sparse                                  <--- note Sparse here
File entry flags        : 0x00000000
Link (ParentID: Name)   : 0x000c000000033f6b: NTFS+DOS Name: \path\to\test.dat
Creation Time           : 12/29/2020 17:07:47
Last Access Time        : 12/29/2020 17:08:59
Last Write Time         : 12/29/2020 17:08:59
Change Time             : 12/29/2020 17:08:59
LastUsn                 : 11,817,169,888
OwnerId                 : 0
SecurityId              : 5206
StorageReserveId        : 0
Stream                  : 0x010  ::$STANDARD_INFORMATION
    Attributes          : 0x00000000: *NONE*
    Flags               : 0x0000000c: Resident | No clusters allocated
    Size                : 72
    Allocated Size      : 72
Stream                  : 0x030  ::$FILE_NAME
    Attributes          : 0x00000000: *NONE*
    Flags               : 0x0000000c: Resident | No clusters allocated
    Size                : 82
    Allocated Size      : 88
Stream                  : 0x080  ::$DATA
    Attributes          : 0x00000200: Sparse                                            <--- note Sparse here
    Flags               : 0x00000018: No clusters allocated | Has Parsed Information
    Size                : 1,000,000,000 (953.7 MB)                                      <--- note full size here
    Allocated Size      :             0 (  0.0 KB)                                      <--- note way smaller size here
    Vdl                 :             0 (  0.0 KB)
    Extents             : 1 Extents
STEPHANVS
Posts: 4
Joined: Sun Dec 27, 2020 1:18 pm

Re: Preallocation bug?

Post by STEPHANVS »

Filesystem is NTFS. Checked the file, had only

Code: Select all

File attributes         : 0x00000020: Archive
After running

Code: Select all

fsutil.exe sparse setflag filename.part
attributes are

Code: Select all

File attributes         : 0x00000220: Archive | Sparse
...
Stream                  : 0x080  ::$DATA
    Attributes          : 0x00000200: Sparse
    Flags               : 0x00000010: Has Parsed Information
    Size                : 1,251,616,362 (1.2 GB)
    Allocated Size      : 1,251,672,064 (1.2 GB)
    Vdl                 : 1,251,616,362 (1.2 GB)
    Extents             : 2 Extents
Post Reply