[PATCH] fallocate returned values on failure

Jeremy Allison jra at samba.org
Thu Dec 4 23:04:39 MST 2014

On Fri, Dec 05, 2014 at 11:36:28AM +0800, Jones wrote:
> Hello Jeremy,
> After test this look.txt it works!
> And one more concern,
> upload a file named test.img to my linux box,
> once if fallocate() returns -1 with errno = ENOSPC,
> the file test.img is left in the linux box and its size is 0 Bytes,
> hmm not quite sure if this is okay just left a file test.img with 0 Bytes,
> or perhaps we could delete it in close_file() ?
> 1. vfs_allocate_file_space():
> return -1 and errno = ENOSPC,
> back to earlier frame create_file_unixpath().
> 2. create_file_unixpath():
> goto fail;
> 3. close_file(req, fsp, ERROR_CLOSE);
> Hmm looks like the 0KB 10GB.img file is not delete at this api.

That is actually expected behavior.

We can call close_file() with type ERROR_CLOSE
under many different circumstances so deleting
the file is not always the correct thing to

We'd need to special case the DISK_FULL
case in create_file_unixpath() and set
the delete on close bit only if we created
the file, and do a NORMAL_CLOSE here.

More information about the samba-technical mailing list