mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Rename pg_rewind's copy_file_range() to avoid conflict with new linux syscall.
Upcoming versions of glibc will contain copy_file_range(2), a wrapper
around a new linux syscall for in-kernel copying of data ranges. This
conflicts with pg_rewinds function of the same name.
Therefore rename pg_rewinds version. As our version isn't a generic
copying facility we decided to choose a rewind specific function name.
Per buildfarm animal caiman and subsequent discussion with Tom Lane.
Author: Andres Freund
Discussion:
    https://postgr.es/m/20180103033425.w7jkljth3e26sduc@alap3.anarazel.de
    https://postgr.es/m/31122.1514951044@sss.pgh.pa.us
Backpatch: 9.5-, where pg_rewind was introduced
			
			
This commit is contained in:
		@@ -156,7 +156,7 @@ recurse_dir(const char *datadir, const char *parentpath,
 | 
				
			|||||||
 * If 'trunc' is true, any existing file with the same name is truncated.
 | 
					 * If 'trunc' is true, any existing file with the same name is truncated.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
copy_file_range(const char *path, off_t begin, off_t end, bool trunc)
 | 
					rewind_copy_file_range(const char *path, off_t begin, off_t end, bool trunc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char		buf[BLCKSZ];
 | 
						char		buf[BLCKSZ];
 | 
				
			||||||
	char		srcpath[MAXPGPATH];
 | 
						char		srcpath[MAXPGPATH];
 | 
				
			||||||
@@ -222,7 +222,7 @@ copy_executeFileMap(filemap_t *map)
 | 
				
			|||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case FILE_ACTION_COPY:
 | 
								case FILE_ACTION_COPY:
 | 
				
			||||||
				copy_file_range(entry->path, 0, entry->newsize, true);
 | 
									rewind_copy_file_range(entry->path, 0, entry->newsize, true);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case FILE_ACTION_TRUNCATE:
 | 
								case FILE_ACTION_TRUNCATE:
 | 
				
			||||||
@@ -230,7 +230,8 @@ copy_executeFileMap(filemap_t *map)
 | 
				
			|||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case FILE_ACTION_COPY_TAIL:
 | 
								case FILE_ACTION_COPY_TAIL:
 | 
				
			||||||
				copy_file_range(entry->path, entry->oldsize, entry->newsize, false);
 | 
									rewind_copy_file_range(entry->path, entry->oldsize,
 | 
				
			||||||
 | 
														   entry->newsize, false);
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			case FILE_ACTION_CREATE:
 | 
								case FILE_ACTION_CREATE:
 | 
				
			||||||
@@ -257,7 +258,7 @@ execute_pagemap(datapagemap_t *pagemap, const char *path)
 | 
				
			|||||||
	while (datapagemap_next(iter, &blkno))
 | 
						while (datapagemap_next(iter, &blkno))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		offset = blkno * BLCKSZ;
 | 
							offset = blkno * BLCKSZ;
 | 
				
			||||||
		copy_file_range(path, offset, offset + BLCKSZ, false);
 | 
							rewind_copy_file_range(path, offset, offset + BLCKSZ, false);
 | 
				
			||||||
		/* Ok, this block has now been copied from new data dir to old */
 | 
							/* Ok, this block has now been copied from new data dir to old */
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pg_free(iter);
 | 
						pg_free(iter);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user