1

I am working on implementing address space operations in WrapFS and I tried to imitate the code from existing ecryptfs filesystem source as my aim is to ultimately implement an encrypted filesystem. The code implementation given below is working perfectly for readpage(),write_begin() and write_end() but writepage() is not getting executed and as a result when I try to copy large files through this filesystem it gets stuck after copying around 300 MB of file.

static int wrapfs_writepage(struct page *page, struct writeback_control *wbc)
{
        int err = -EIO;
        struct inode *inode;
        struct inode *lower_inode;
        struct page *lower_page;
        struct address_space *lower_mapping; /* lower inode mapping */
        gfp_t mask;

        printk(KERN_INFO "in wrapfs_writepage");

        BUG_ON(!PageUptodate(page));
        inode = page->mapping->host;
        /* if no lower inode, nothing to do */
        if (!inode || !WRAPFS_I(inode) || WRAPFS_I(inode)->lower_inode) {
                err = 0;
                goto out;
        }
        lower_inode = wrapfs_lower_inode(inode);
        lower_mapping = lower_inode->i_mapping;

        mask = mapping_gfp_mask(lower_mapping) & ~(__GFP_FS);
        lower_page = find_or_create_page(lower_mapping, page->index, mask);
        if (!lower_page) {
                err = 0;
                set_page_dirty(page);
                goto out;
        }

        /* copy page data from our upper page to the lower page */
        copy_highpage(lower_page, page);
        flush_dcache_page(lower_page);
        SetPageUptodate(lower_page);
        set_page_dirty(lower_page);

        if (wbc->for_reclaim) {
                unlock_page(lower_page);
                goto out_release;
        }

        BUG_ON(!lower_mapping->a_ops->writepage);
        wait_on_page_writeback(lower_page); /* prevent multiple writers */
        clear_page_dirty_for_io(lower_page); /* emulate VFS behavior */
        err = lower_mapping->a_ops->writepage(lower_page, wbc);
        if (err < 0)
                goto out_release;

        if (err == AOP_WRITEPAGE_ACTIVATE) {
                err = 0;
                unlock_page(lower_page);
        }

out_release:
        /* b/c find_or_create_page increased refcnt */
        page_cache_release(lower_page);
out:
        /*
         * We unlock our page unconditionally, because we never return
         * AOP_WRITEPAGE_ACTIVATE.
         */
        unlock_page(page);
        return err;
}

I have declared the address_space_operation object correctly.

bawejakunal
  • 1,678
  • 2
  • 25
  • 54
  • So "in wrapfs_writepage" is not being printed? In that case you need to figure out who is supposed to call `wrapfs_writepage` and why it's not calling it. If that is printed, then sprinkle this function with `printk`s and see how it gets executed and what are the variable values. – Shahbaz Jan 21 '15 at 16:33
  • Did you figure it out? I am working on wrapfs and do not see a call for writepage.. thanks. – user1253073 Oct 18 '15 at 16:43

0 Answers0