On 12 May 2014 02:26, "Paul Eggert" <eggert@cs.ucla.edu> wrote:
>
> Azat Khuzhin wrote:
>
>> + fd = mkstemp (file);
>> +
>> + if (errno != ENOSPC || temp_dir_index == start_dir_index)
>
>
> This assumes that when mkstemp succeeds then errno != ENOSPC, which is not necessarily true.
Why that could be, only if there will be an old value?
End even if it is true it will not go to the next iteration because fd >= 0
>
> More generally, it appears that with the patch 'sort' checks whether one can create a file, but 'sort' will still respond poorly if a write to a temp file fails due to filesystem space exhaustion.
The only thing that will slow down 'sort' is going through tmp dirs where there is no enough space, and I personally don't think that this will meaningful, since most generic use case to use tmp dirs is to sort data that will not fit into memory and if this sort will fail because of enospc you must to restart the sort, which can be running for day or weak already, and this is more expensive.
Or I misunderstood something?
And now I realize that this is not enough, since we only checking on creation, and unfortunately I didn't check how write(2) handle errors, if it try to create another file than it will work.
We also could use fallocate here.
Thanks.
Azat.