File tree Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Expand file tree Collapse file tree 1 file changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -1280,19 +1280,16 @@ int
12801280mdsyncfiletag (const FileTag * ftag , char * path )
12811281{
12821282 SMgrRelation reln = smgropen (ftag -> rnode , InvalidBackendId );
1283- int fd ,
1284- result ,
1285- save_errno ;
1283+ File file ;
12861284 bool need_to_close ;
1285+ int result ,
1286+ save_errno ;
12871287
12881288 /* See if we already have the file open, or need to open it. */
12891289 if (ftag -> segno < reln -> md_num_open_segs [ftag -> forknum ])
12901290 {
1291- File file ;
1292-
12931291 file = reln -> md_seg_fds [ftag -> forknum ][ftag -> segno ].mdfd_vfd ;
12941292 strlcpy (path , FilePathName (file ), MAXPGPATH );
1295- fd = FileGetRawDesc (file );
12961293 need_to_close = false;
12971294 }
12981295 else
@@ -1303,24 +1300,20 @@ mdsyncfiletag(const FileTag *ftag, char *path)
13031300 strlcpy (path , p , MAXPGPATH );
13041301 pfree (p );
13051302
1306- fd = OpenTransientFile (path , O_RDWR );
1307- if (fd < 0 )
1303+ file = PathNameOpenFile (path , O_RDWR | PG_BINARY );
1304+ if (file < 0 )
13081305 return -1 ;
13091306 need_to_close = true;
13101307 }
13111308
13121309 /* Sync the file. */
1313- pgstat_report_wait_start (WAIT_EVENT_DATA_FILE_SYNC );
1314- result = pg_fsync (fd );
1310+ result = FileSync (file , WAIT_EVENT_DATA_FILE_SYNC );
13151311 save_errno = errno ;
1316- pgstat_report_wait_end ();
13171312
1318- if (need_to_close && CloseTransientFile (fd ) != 0 )
1319- ereport (WARNING ,
1320- (errcode_for_file_access (),
1321- errmsg ("could not close file \"%s\": %m" , path )));
1322- errno = save_errno ;
1313+ if (need_to_close )
1314+ FileClose (file );
13231315
1316+ errno = save_errno ;
13241317 return result ;
13251318}
13261319
You can’t perform that action at this time.
0 commit comments