0

What I understand about it is its "Zero fill on demand" extent. That means file system doesn't allocate write data to the file but it just gives us ZFOD extent and when an application tries to read/write the data it just fills out data zeros and then performs read/write [source].

My questions are:

  1. Is my above understanding correct?
  2. If it just doesn't allocate the data, does that mean is it a HOLE?

1 Answer 1

2

You must consider two things:

  • whether or not there is space allocated for the data, and
  • whether or not there is data actually written.

If a file has no data and no space allocated for it, you get an end-of-file indication if you attempt to read it. If you write to it, the filesystem must allocate space at the time of write: in other words, the write operation may fail with an ENOSPC error if there is no free disk space to allocate.

A hole in a sparse file has no space allocated for it, and if you attempt to read that part of the file, you get back data which is all zeroes. If you write to that part of the file, the filesystem must again allocate space for it at the time of the write operation, so the write operation may fail with an ENOSPC error if the disk is full.

A ZFOD extent is nominally allocated to a file, but there is no data written to it yet. If you read it, you get back all-zeroes; if you write to it, the space is already allocated so there is no risk for an ENOSPC error condition.

And finally, there is a normal data extent: if you read it, you get back the actual data, and if you write to it, you replace the existing data with new data.

In other words, the ZFOD extent is an optimization for situations where an application may allocate a large file, won't use all of it immediately, and still needs a guarantee that the space will be available when needed. For SSD storage, erasing existing data from a block is the slowest operation, so ZFOD extents allow the system to quickly create a large by allocating it initially as ZFOD extents: then the filesystem can do the actual erasing & filling with zeroes on-demand for each block that is actually used.

If a SSD storage is used for storing something like disk images for virtual machines, ZFOD extents can help in minimizing the number of times the actual disk blocks need to be erased, and so improve the usable lifetime of the SSD.

1
  • 1
    ZFODs also help reduce fragmentation, which is useful on spinning rust. Apr 11, 2018 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .