[PATCH] fallocate returned values on failure
Jeremy Allison
jra at samba.org
Wed Dec 3 23:15:59 MST 2014
On Thu, Dec 04, 2014 at 02:02:38PM +0800, Jones wrote:
> 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.
Very good catch ! Thanks.
I think the best way to fix this is to
standardize the return from SMB_VFS_FALLOCATE()
to be -1,set errno on error, and then convert
the lower level to do this if it uses posix_fallocate().
We should also fix vfs_slow_fallocate() to
do the same - and then fix all the callers
to expect -1,errno returns instead of errno.
Can you log a bug so we can track this and
get it fixed in 4.0.x and above ?
I'll code a fix up for master, I'd appreciate
it if you could test it !
Thanks,
Jeremy.
More information about the samba-technical
mailing list