Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

fallocate issue #25

Closed
changyp6 opened this issue Jul 15, 2020 · 6 comments
Closed

fallocate issue #25

changyp6 opened this issue Jul 15, 2020 · 6 comments

Comments

@changyp6
Copy link

exfat linux doesn't support fallocate
When running command fallocate -l 1G test1G
command failed with output

fallocate -l 1G test1g
fallocate: fallocate failed: Operation not supported
@arter97
Copy link
Owner

arter97 commented Jul 15, 2020

Unfortunately, this is the intended behavior.

Unlike NTFS, exFAT doesn't support sparse files, which renders fallocate broken or useless(zero'ing out all ranges, which takes a lot of time).

EDIT: Update below

@arter97 arter97 closed this as completed Jul 15, 2020
@changyp6
Copy link
Author

@arter97
I'm not familar with the defination of fallocate.
My understanding is that fallocate just pre-allocate a continous block of storage for a large file.
If on exFAT, fallocate just allocates a large file block without zero'ing out all ranges, is this behaviour still called fallocate ?

@2259361174
Copy link

Unfortunately, this is the intended behavior.

Unlike NTFS, exFAT doesn't support sparse files, which renders fallocate broken or useless(zero'ing out all ranges, which takes a lot of time).

We just want to use fallocate to occupy free space with minimal overhead, to reduce exFAT fragmentation. while writing several video files constantly to the SD card at same time. If we don't use fallocate the free space for every file, then all of the video files will be stored to interleaved clusters, and huge video file will be in many pieces. then if one of the video file is deleted, it will create many small free spaces and high fragmentation.

One of the ideas is to use fallocate to occupy (eg. 256MB) size for each of the video file, but without real data written to SD card when we call fallocate, then we assume every file will be stored to contiguous 256MB space, and there will be no fragmentation at all. even if we finish writing the file and found it is only 180MB, we can ftruncate the file to 180MB and the left (256-180=76 MB) is still a very big free space and not fragmentation.

We can use ftruncate() or lseek() to create a 256MB file but it will write a lot of data to SD card but not just simplify "mark the space" in exFAT table without writing data.

VFAT in Linux can support fallocate() so we hope exfat can support it also.

We don't need to create any Holes on exfat. just want contiguous file on SD card.

any ideas ?

thanks for your help.

@arter97
Copy link
Owner

arter97 commented Jul 17, 2020

Unfortunately, this is the intended behavior.
Unlike NTFS, exFAT doesn't support sparse files, which renders fallocate broken or useless(zero'ing out all ranges, which takes a lot of time).

We just want to use fallocate to occupy free space with minimal overhead, to reduce exFAT fragmentation. while writing several video files constantly to the SD card at same time. If we don't use fallocate the free space for every file, then all of the video files will be stored to interleaved clusters, and huge video file will be in many pieces. then if one of the video file is deleted, it will create many small free spaces and high fragmentation.

One of the ideas is to use fallocate to occupy (eg. 256MB) size for each of the video file, but without real data written to SD card when we call fallocate, then we assume every file will be stored to contiguous 256MB space, and there will be no fragmentation at all. even if we finish writing the file and found it is only 180MB, we can ftruncate the file to 180MB and the left (256-180=76 MB) is still a very big free space and not fragmentation.

We can use ftruncate() or lseek() to create a 256MB file but it will write a lot of data to SD card but not just simplify "mark the space" in exFAT table without writing data.

VFAT in Linux can support fallocate() so we hope exfat can support it also.

We don't need to create any Holes on exfat. just want contiguous file on SD card.

any ideas ?

thanks for your help.

torvalds/linux@b13bb33eacb7
torvalds/linux@28016128d37a

Looks like exFAT needs similar implementation.
I suggest writing an email detailing the needs to fallocate to:
Namjae Jeon namjae.jeon@samsung.com, Cc: linux-fsdevel@vger.kernel.org

Given that exFAT driver is also made by Namjae, this could be done.

@Thor-x86
Copy link

Thor-x86 commented Apr 8, 2022

This command is working for me

fallocate -xl 1G test1g

For some reason -x flag which means "allocate in POSIX way" is working on non-Linux filesystem including NTFS-3G

@tsingakbar
Copy link

This command is working for me

fallocate -xl 1G test1g

For some reason -x flag which means "allocate in POSIX way" is working on non-Linux filesystem including NTFS-3G

"the posix way" will fallback to something like plain zero man 2 write for un-supported filesystem, which is slow.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants