A query on page cache and writepage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello All,

I am working on a file system, that uses page cache only if a file is
memory mapped. This is how the code is designed

write()
{
    write the data onto the disk

    if (file not memory mapped)
           return;

    /* file is memory mapped */
    while (till all data is not syced with page cache) {
        if (data at current file offset held in page) {
            update the page
        }
    }
}

The code that updates a page is something like this
        page = find_lock_page(mapping, index);
        if (likely(!page)) {
           /* page not cached */
                  continue;
        }

        if (mapping_writably_mapped(mapping))
            flush_dcache_page(page);

        pagefault_disable();

        /* copy the data */
        BUG_ON(!in_atomic());
        page_buf = kmap_atomic(page, KM_USER0);
        if (__copy_from_user_inatomic(page_buf+offset, user_buf, size)) {
            kunmap(page);
            unlock_page(page);
            err = -EFAULT;
            goto out_error;
        }
        kunmap_atomic(page_buf, KM_USER0);
        pagefault_enable();

        flush_dcache_page(page);
        mark_page_accessed(page);

        SetPageUptodate(page);
        ClearPageError(page);
        unlock_page(page);
        page_cache_release(page);

If a fops->write() is called the data in page cache is already on to
the disk. I don't want a page update from this function to trigger
writepage() function.

The writepage() function should only be called if an user updates a
memory mapped page.

Would calling page_clear_dirty() from the write() code be sufficient?

I need to call flush_dcache_page() as a page should be coherent with
other mappings. Does calling flush_dcache_page() result in call to
writepage()?

Thanks and Regards,
Prasad

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux