Corrected oversight in ZERO_RANGE behavior

It turns out, no, in fact, ZERO_RANGE and PUNCH_HOLE do
have differing semantics in some ways - in particular,
one requires KEEP_SIZE, and the other does not.

Also added a zero-range test to catch this, corrected a flaw
that made the punch-hole test succeed vacuously, and a typo
in file_write.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #13329 
Closes #13338
This commit is contained in:
Rich Ercolani
2022-04-20 19:07:03 -04:00
committed by Brian Behlendorf
parent 361dc138b1
commit c220771a47
8 changed files with 171 additions and 21 deletions
+6 -4
View File
@@ -781,11 +781,13 @@ zpl_fallocate_common(struct inode *ip, int mode, loff_t offset, loff_t len)
if (mode & (test_mode)) {
flock64_t bf;
if (offset > olen)
goto out_unmark;
if (mode & FALLOC_FL_KEEP_SIZE) {
if (offset > olen)
goto out_unmark;
if (offset + len > olen)
len = olen - offset;
if (offset + len > olen)
len = olen - offset;
}
bf.l_type = F_WRLCK;
bf.l_whence = SEEK_SET;
bf.l_start = offset;