• Andrew Morton's avatar
    [PATCH] Remove fail_writepage, redux · 3e9afe4c
    Andrew Morton authored
    fail_writepage() does not work.  Its activate_page() call cannot
    activate the page because it is not on the LRU.
    
    So perform that function (more efficiently) in the VM.  Remove
    fail_writepage() and, if the filesystem does not implement
    ->writepage() then activate the page from shrink_list().
    
    A special case is tmpfs, which does have a writepage, but which
    sometimes wants to activate the pages anyway.  The most important case
    is when there is no swap online and we don't want to keep all those
    pages on the inactive list.  So just as a tmpfs special-case, allow
    writepage() to return WRITEPAGE_ACTIVATE, and handle that in the VM.
    
    Also, the whole idea of allowing ->writepage() to return -EAGAIN, and
    handling that in the caller has been reverted.  If a writepage()
    implementation wants to back out and not write the page, it must
    redirty the page, unlock it and return zero.  (This is Hugh's preferred
    way).
    
    And remove the now-unneeded shmem_writepages() - shmem inodes are
    marked as `memory backed' so it will not be called.
    
    And remove the test for non-null ->writepage() in generic_file_mmap().
    Memory-backed files _are_ mmappable, and they do not have a
    writepage().  It just isn't called.
    
    So the locking rules for writepage() are unchanged.  They are:
    
    - Called with the page locked
    - Returns with the page unlocked
    - Must redirty the page itself if it wasn't all written.
    
    But there is a new, special, hidden, undocumented, secret hack for
    tmpfs: writepage may return WRITEPAGE_ACTIVATE to tell the VM to move
    the page to the active list.  The page must be kept locked in this one
    case.
    3e9afe4c
rd.c 12.9 KB