public void write(long pos, byte[] buf) {
        file.write(pos, buf);
        synchronized (mutex) { 
            if (pageTimestamps != null) { 
                int pageNo = (int)(pos >> Page.pageSizeLog);
                if (pageNo >= pageTimestamps.length) { 
                    int newLength = pageNo >= pageTimestamps.length*2 ? pageNo+1 : pageTimestamps.length*2;

                    int[] newPageTimestamps = new int[newLength];
                    System.arraycopy(pageTimestamps, 0, newPageTimestamps, 0, pageTimestamps.length);
                    pageTimestamps = newPageTimestamps;

                    int[] newDirtyPageTimestampMap = new int[(((newLength*4 + Page.pageSize - 1) >> Page.pageSizeLog) + 31) >> 5];
                    System.arraycopy(dirtyPageTimestampMap, 0, newDirtyPageTimestampMap, 0, dirtyPageTimestampMap.length);
                    dirtyPageTimestampMap = newDirtyPageTimestampMap;                    
                }
                pageTimestamps[pageNo] = ++timestamp;
                dirtyPageTimestampMap[pageNo >> (Page.pageSizeLog - 2 + 5)] |= 1 << ((pageNo >> (Page.pageSizeLog - 2)) & 31);
            }
        }
        for (int i = 0; i < out.length; i++) { 
            if (out[i] != null) {                
                byte[] data = new byte[8 + buf.length];
                Bytes.pack8(data, 0, pos);
                System.arraycopy(buf, 0, data, 8, buf.length);
                Parcel p = new Parcel();
                p.data = data;
                p.pos = pos;
                p.host = i;
                try { 
                    synchronized(async) { 
                        buffered += data.length;
                        while (buffered > asyncBufSize && buffered != data.length) { 
                            async.wait();
                        }
                    }
                } catch (InterruptedException x) {}
                    
                synchronized(go) { 
                    if (head == null) { 
                        head = tail = p;
                    } else { 
                        tail = tail.next = p;
                    }
                    go.notify();
                }
            }
        }
    }