> >
> >
> > > + spinlock_t *ptl;
> > > + pgd_t *pgd = pgd_offset(vma->vm_mm, addr);
> > > + pud_t *pud = pud_offset(pgd, addr);
> > > + pmd_t *pmd = pmd_offset(pud, addr);
> > > + pte_t *pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
> > > +
> > > + if (pte_dirty(*pte) && pte_write(*pte)) {
> > > + pte_t entry = ptep_clear_flush(vma, addr, pte);
> > > +
> > > + entry = pte_wrprotect(entry);
> > > + set_pte_at(vma->vm_mm, addr, pte, entry);
> > > + }
> > > + pte_unmap_unlock(pte, ptl);
> > > + }
> > > +}
> > > +
> > > +/*
> > > * MS_SYNC syncs the entire file - including mappings.
> > > *
> > > - * MS_ASYNC does not start I/O (it used to, up to 2.5.67).
> > > - * Nor does it mark the relevant pages dirty (it used to up to 2.6.17).
> > > - * Now it doesn't do anything, since dirty pages are properly tracked.
> >
> > I think keeping some version of the "up to ..." comments makes sense.
> > It documents that we previously had different behaviour.
>
> Earlier I had a request to remove any "changelog-style" comments from the code.
>
> >
> > > + * MS_ASYNC does not start I/O. Instead, it marks the relevant pages
> > > + * read-only by calling vma_wrprotect(). This is needed to catch the next
> > > + * write reference to the mapped region and update the file times
> > > + * accordingly.
> > > *
> > > * 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
> > > @@ -77,16 +104,20 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
> > > error = 0;
> > > start = vma->vm_end;
> > > file = vma->vm_file;
> > > - if (file && (vma->vm_flags & VM_SHARED) && (flags & MS_SYNC)) {
> > > - get_file(file);
> > > - up_read(&mm->mmap_sem);
> > > - error = do_fsync(file, 0);
> > > - fput(file);
> > > - if (error || start >= end)
> > > - goto out;
> > > - down_read(&mm->mmap_sem);
> > > - vma = find_vma(mm, start);
> > > - continue;
> > > + if (file && (vma->vm_flags & VM_SHARED)) {
> > > + if (flags & MS_ASYNC)
> > > + vma_wrprotect(vma);
> > > + if (flags & MS_SYNC) {
> >
> > "else if" ??
>
> The MS_ASYNC and MS_SYNC flags are mutually exclusive, that is why I
> did not use the "else-if" here. Moreover, this function itself checks
> that they never come together.
>
> >
> > > + get_file(file);
> > > + up_read(&mm->mmap_sem);
> > > + error = do_fsync(file, 0);
> > > + fput(file);
> > > + if (error || start >= end)
> > > + goto out;
> > > + down_read(&mm->mmap_sem);
> > > + vma = find_vma(mm, start);
> > > + continue;
> > > + }
> > > }
> > >
> > > vma = vma->vm_next;
> >
> > --
> > Jesper Juhl <jesper.juhl@gmail.com>
> > Don't top-post
http://www.catb.org/~esr/jargon/html/T/top-post.html
> > Plain text mails only, please
http://www.expita.com/nomime.html
> >
>