lkml.org 
[lkml]   [2005]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: How to reclaim inode pages on demand
    Mel Gorman <mel@csn.ul.ie> wrote:
    >
    > Hi,
    >
    > I am working on a direct reclaim strategy to free up large blocks of
    > contiguous pages. The part I have is working fine, but I am finding a
    > hundreds of pages that are being used for inodes that I need to reclaim. I
    > tried purging the inode lists using a variation of prune_icache() but it
    > is not working out.
    >
    > Given a struct page, that one knows is an inode, can anyone suggest the
    > best way to find the inode using it and free it?

    Simple answer: invalidate_mapping_pages(page->mapping, start, end).

    Problem: races. If you pick a random page up off the LRU and start playing
    with its mapping, what stops that mapping from getting freed under your
    feet?

    If the caller has a ref on the inode (say, you came in via a syscall
    against an fd) then fine.

    But if you picked the page up off the LRU then to avoid super-rare oopses
    you'll need to pin the address_space somehow. One way is to

    a) lock the page, which pins the address_space.

    b) check that page->mapping is still non-NULL. Bale if it is.

    c) bump page->mapping->host->i_count

    d) unlock the page

    e) diddle away with the address_space.

    f) iput() the inode.

    But beware that iput() can do a *ton* of stuff, so you need to be not
    holding any locks and to not be called from any fancy contexts.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-08-09 01:12    [W:5.131 / U:0.764 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site