mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Correct handling of fsync failures with tar mode of walmethods.c
This file has been missing the fact that it needs to report back to callers a proper failure on fsync calls. I have spotted the one in tar_finish() while Kuntal has spotted the one in tar_close(). Backpatch down to 10 where this code has been introduced. Reported by: Michael Paquier, Kuntal Ghosh Author: Michael Paquier Reviewed-by: Kuntal Ghosh, Magnus Hagander Discussion: https://postgr.es/m/20180625024356.GD1146@paquier.xyz
This commit is contained in:
@ -863,7 +863,8 @@ tar_close(Walfile f, WalCloseMethod method)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Always fsync on close, so the padding gets fsynced */
|
/* Always fsync on close, so the padding gets fsynced */
|
||||||
tar_sync(f);
|
if (tar_sync(f) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Clean up and done */
|
/* Clean up and done */
|
||||||
pg_free(tf->pathname);
|
pg_free(tf->pathname);
|
||||||
@ -894,7 +895,7 @@ tar_finish(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A tarfile always ends with two empty blocks */
|
/* A tarfile always ends with two empty blocks */
|
||||||
MemSet(zerobuf, 0, sizeof(zerobuf));
|
MemSet(zerobuf, 0, sizeof(zerobuf));
|
||||||
if (!tar_data->compression)
|
if (!tar_data->compression)
|
||||||
{
|
{
|
||||||
@ -955,7 +956,10 @@ tar_finish(void)
|
|||||||
|
|
||||||
/* sync the empty blocks as well, since they're after the last file */
|
/* sync the empty blocks as well, since they're after the last file */
|
||||||
if (tar_data->sync)
|
if (tar_data->sync)
|
||||||
fsync(tar_data->fd);
|
{
|
||||||
|
if (fsync(tar_data->fd) != 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (close(tar_data->fd) != 0)
|
if (close(tar_data->fd) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user