--- linux-2.6-tmp/mm/msync.c.=K0000=.orig +++ linux-2.6-tmp/mm/msync.c @@ -127,13 +127,10 @@ static int filemap_sync(struct vm_area_s /* * MS_SYNC syncs the entire file - including mappings. * - * MS_ASYNC does not start I/O (it used to, up to 2.5.67). Instead, it just - * marks the relevant pages dirty. The application may now run fsync() to - * write out the dirty pages and wait on the writeout and check the result. - * Or the application may run fadvise(FADV_DONTNEED) against the fd to start - * async writeout immediately. - * So my _not_ starting I/O in MS_ASYNC we provide complete flexibility to - * applications. + * MS_ASYNC once again starts I/O (it did not between 2.5.68 and 2.6.4.) + * SingleUnix requires it. If an application wants to queue dirty pages + * for normal asychronous writeback, msync with flags==0 should achieve + * that on all kernels at least as far back as 2.4. */ static int msync_interval(struct vm_area_struct * vma, unsigned long start, unsigned long end, int flags) @@ -147,20 +144,22 @@ static int msync_interval(struct vm_area if (file && (vma->vm_flags & VM_SHARED)) { ret = filemap_sync(vma, start, end-start, flags); - if (!ret && (flags & MS_SYNC)) { + if (!ret && (flags & (MS_SYNC|MS_ASYNC))) { struct address_space *mapping = file->f_mapping; int err; down(&mapping->host->i_sem); ret = filemap_fdatawrite(mapping); - if (file->f_op && file->f_op->fsync) { - err = file->f_op->fsync(file,file->f_dentry,1); - if (err && !ret) + if (flags & MS_SYNC) { + if (file->f_op && file->f_op->fsync) { + err = file->f_op->fsync(file, file->f_dentry, 1); + if (err && !ret) + ret = err; + } + err = filemap_fdatawait(mapping); + if (!ret) ret = err; } - err = filemap_fdatawait(mapping); - if (!ret) - ret = err; up(&mapping->host->i_sem); } }