NetworkBlockDevice / nbd

Network Block Device
GNU General Public License v2.0
459 stars 120 forks source link

Support trim on Cygwin #29

Closed Fanael closed 9 years ago

Fanael commented 9 years ago

It's done by using Win32's FSCTL_SET_ZERO_DATA ioctl.


Despite the name, FSCTL_SET_ZERO_DATA is the right API to punch holes on Windows, even on non-sparse files: I can easily punch a 10 GB hole in milliseconds, which wouldn't be achievable if this ioctl were just writing zeros in a loop.

This ioctl is supported since (I think) Windows 2000, so basically available everywhere.

yoe commented 9 years ago

This seems like a worthy thing to add. However, even so, there's a few style issues I'd like to see resolved before I'll merge this:

Other than that, looks good.

Fanael commented 9 years ago

In keeping with the autoconf philosophy of testing for features, not operating systems, I'd prefer if you could add a configure test for this API call.

Done.

I'm thinking it would be easier to follow the code if we call this punch_hole function unconditionally, having it do nothing if we have no API

Sure.