Created attachment 10480 [details] 1st round patch Hello list, There is samba-4.0.5 in the linux box, and set 'strict allocate = yes' to go through fallocate api. Found if fallocate() returns -1 with errno = ENOSPC, cannot catch by error handling as followings: ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, offset, num_to_write); if (ret == ENOSPC) { errno = ENOSPC; ret = -1; goto out; } Per man pages said, posix_fallocate() returns an error number on failure, fallocate() returns -1 on failure. Patch as attached could handle -1 returned from fallocate() on failure, please help review and any suggestions are appreciated, thanks.
Created attachment 10485 [details] Proposed patchset for master. Here's what I think should work - please confirm !
Hello Jeremy, Yep this patch works for me! And one more thing, returns -1 between contend_level2_oplock_{begin,end} pairs looks a bit concern to me, perhaps move them after contend_level2_oplocks_end() ? contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_GROW); if (lp_strict_allocate(SNUM(fsp->conn))) { /* See if we have a syscall that will allocate beyond end-of-file without changing EOF. */ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_KEEP_SIZE, 0, len); } else { ret = 0; } contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_ALLOC_GROW); + if (ret == -1 && errno == ENOSPC) { + return -1; + } if (ret == 0) { /* We changed the allocation size on disk, but not EOF - exactly as required. We're done ! */ return 0; }
Created attachment 10496 [details] git-am patch for master.
(In reply to Jeremy Allison from comment #3) As mentioned via mail: - sys_posix_fallocate() may still return an errno value - smb_time_audit_fallocate() should save errno before calling clock_gettime() Otherwise looks good.
Created attachment 10499 [details] Cherry-pick of patches that went into master for 4.2.0
Created attachment 10500 [details] Back-port of master fix for 4.1.next.
Created attachment 10501 [details] Back-port of master fix for 4.0.next.
Ready for maintenance branches. @Karo, please merge.
Pushed to autobuild-v4-[0|1|2]-test.
(In reply to Karolin Seeger from comment #9) Pushed to v4-2-test and v4-1-test. autobuild-v4-0-test failed, re-trying
(In reply to Karolin Seeger from comment #10) Pushed. Closing out bug report. Thanks!