public void sync(final boolean sync) throws IOException {
        MappedByteBuffer buf = null;
        this.writeLock.lock();
        try {
            if (this.committedPos >= this.wrotePos) {
                return;
            }
            this.committedPos = this.wrotePos;
            buf = this.buffer;
            LOG.debug("Commit segment file {} at pos {}.", this.path, this.committedPos);
        } finally {
            this.writeLock.unlock();
        }
        if (sync) {
            fsync(buf);
        }
    }
Forces any changes made to this segment file's content to be written to the
storage device containing the mapped file.
jraft-core/src/main/java/com/alipay/sofa/jraft/storage/log/SegmentFile.java