Re: fdatasync(2) on macOS - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: fdatasync(2) on macOS
Date
Msg-id CA+hUKGLn-FtpFna3xLVzFohRWhFGV+VOK+AQbU6=by1fiXHUqA@mail.gmail.com
Whole thread Raw
In response to Re: fdatasync(2) on macOS  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
On Mon, Jan 18, 2021 at 4:39 PM Thomas Munro <thomas.munro@gmail.com> wrote:
> On Sat, Jan 16, 2021 at 6:55 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > So it's not a no-op, but on the other hand it's not succeeding in getting
> > bits down to the platter.  I'm not inclined to dike it out, but it does
> > seem problematic that we're defaulting to open_datasync, which is also
> > not getting bits down to the platter.
>
> Hmm, OK, from these times it does appear that O_SYNC and O_DSYNC
> actually do something then.  It's baffling that they are undocumented.

I was digging through Apple sources again trying to learn something
about bug report #16827, and I spotted one extra detail that I wanted
to share in this thread about these undocumented system interfaces,
just for the record.  It appears that as of macOS 11.2/XNU 7195.83.3,
their vn_write() doesn't treat O_DSYNC any differently than O_SYNC:

    /*
     * Treat synchronous mounts and O_FSYNC on the fd as equivalent.
     *
     * XXX We treat O_DSYNC as O_FSYNC for now, since we can not delay
     * XXX the non-essential metadata without some additional VFS work;
     * XXX the intent at this point is to plumb the interface for it.
     */
    if ((fp->fp_glob->fg_flag & (O_FSYNC | O_DSYNC)) ||
        (vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS))) {
        ioflag |= IO_SYNC;
    }



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: new heapcheck contrib module
Next
From: John Naylor
Date:
Subject: Re: [POC] verifying UTF-8 using SIMD instructions