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 @@ -1258,19 +1258,16 @@ int
1258
1258
mdsyncfiletag (const FileTag * ftag , char * path )
1259
1259
{
1260
1260
SMgrRelation reln = smgropen (ftag -> rnode , InvalidBackendId );
1261
- int fd ,
1262
- result ,
1263
- save_errno ;
1261
+ File file ;
1264
1262
bool need_to_close ;
1263
+ int result ,
1264
+ save_errno ;
1265
1265
1266
1266
/* See if we already have the file open, or need to open it. */
1267
1267
if (ftag -> segno < reln -> md_num_open_segs [ftag -> forknum ])
1268
1268
{
1269
- File file ;
1270
-
1271
1269
file = reln -> md_seg_fds [ftag -> forknum ][ftag -> segno ].mdfd_vfd ;
1272
1270
strlcpy (path , FilePathName (file ), MAXPGPATH );
1273
- fd = FileGetRawDesc (file );
1274
1271
need_to_close = false;
1275
1272
}
1276
1273
else
@@ -1281,24 +1278,20 @@ mdsyncfiletag(const FileTag *ftag, char *path)
1281
1278
strlcpy (path , p , MAXPGPATH );
1282
1279
pfree (p );
1283
1280
1284
- fd = OpenTransientFile (path , O_RDWR );
1285
- if (fd < 0 )
1281
+ file = PathNameOpenFile (path , O_RDWR | PG_BINARY );
1282
+ if (file < 0 )
1286
1283
return -1 ;
1287
1284
need_to_close = true;
1288
1285
}
1289
1286
1290
1287
/* Sync the file. */
1291
- pgstat_report_wait_start (WAIT_EVENT_DATA_FILE_SYNC );
1292
- result = pg_fsync (fd );
1288
+ result = FileSync (file , WAIT_EVENT_DATA_FILE_SYNC );
1293
1289
save_errno = errno ;
1294
- pgstat_report_wait_end ();
1295
1290
1296
- if (need_to_close && CloseTransientFile (fd ) != 0 )
1297
- ereport (WARNING ,
1298
- (errcode_for_file_access (),
1299
- errmsg ("could not close file \"%s\": %m" , path )));
1300
- errno = save_errno ;
1291
+ if (need_to_close )
1292
+ FileClose (file );
1301
1293
1294
+ errno = save_errno ;
1302
1295
return result ;
1303
1296
}
1304
1297
You can’t perform that action at this time.
0 commit comments