<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Aug 3, 2018 at 10:28 PM Nir Soffer <<a href="mailto:nirsof@gmail.com">nirsof@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is the third version to support efficient zero for block devices<br>
on older kernels (e.g. RHEL 7.5), and file systems that do not support<br>
yet FALLOC_FS_ZERO_RANGE (e.g. NFS 4.2).<br>
<br>
Changes since v2:<br>
- Revert file_can_trim change, since it is too late to change the value<br>
  after negotiation. Changing the capability dinamically may be useful<br>
  internally, but it should be done via other means.<br>
- Do not depend on FALLOC_FL_* when including <linux/fs.h>.<br>
- Add common/includes/isaligned.h for is_aligned helper, implemented<br>
  in a more efficient way with bitwise math.<br>
- If getting sector size fail, fall back to safe guess instead of<br>
  hard failure.<br>
- More efficient alignment check using bitwise math.<br>
- For BLKZEROOUT, treat ENOTTY as EOPNOTSUPP. Theoretically possible<br>
  with a mix of new headers and old or strangely configured kernel.<br>
- Use default multi line comment style.<br>
- Fix few typos in comments and commit message<br>
<br>
Issues to explore later:<br>
- Eric suggested to use the new FALLOC_FL_NO_HIDE_STALE. Requires<br>
  benchmarking with a system supporting this flag.<br>
- Eric suggested to use tri-state for can_* flags. I don't see a need at<br>
  this point.<br>
- Eric suggested to add can_zero. I'm not sure about the semantics of<br>
  this, and it has the same issue of can_trim, reporting dynamic value.<br>
<br>
v2 was here:<br>
<a href="https://www.redhat.com/archives/libguestfs/2018-August/msg00025.html" rel="noreferrer" target="_blank">https://www.redhat.com/archives/libguestfs/2018-August/msg00025.html</a><br>
<br>
Changes since v1:<br>
- Split to smaller patches<br>
- Skip linux only includes on other systems<br>
- Skip code using BLKZEROOUT if the macro is not defined<br>
- Try BLKZEROOUT only if the offset and count are aligned to device<br>
  sector size.<br>
- initialize h->can_* properly. Before they were uninitialized if<br>
  FALLOC_FL_* macros were not defined.<br>
- Use new h->can_punch_hole in file_can_trim, so now we report the<br>
  actual capability once we detected it.<br>
- Use h->can_punch_hole in file_trim, so we try only once if the<br>
  operation is not supported.<br>
<br>
v1 was here:<br>
<a href="https://www.redhat.com/archives/libguestfs/2018-July/msg00084.html" rel="noreferrer" target="_blank">https://www.redhat.com/archives/libguestfs/2018-July/msg00084.html</a><br>
<br>
Nir Soffer (4):<br>
  file: Avoid unsupported fallocate() calls<br>
  file: Support zero without ZERO_RANGE<br>
  common: Add isaligned helper module<br>
  file: Zero for block devices on old kernels<br>
<br>
 common/include/isaligned.h |  50 ++++++++++<br>
 plugins/file/Makefile.am   |   3 +-<br>
 plugins/file/file.c        | 182 +++++++++++++++++++++++++++++--------<br>
 3 files changed, 196 insertions(+), 39 deletions(-)<br>
 create mode 100644 common/include/isaligned.h<br>
<br>
-- <br>
2.17.1<br>
<br></blockquote><div><br></div><div>Ping? </div></div></div>