public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Request for export of truncate_complete_page
Date: Tue, 21 Feb 2006 13:30:26 +0200	[thread overview]
Message-ID: <20060221113026.GE5733@linuxhacker.ru> (raw)
In-Reply-To: <20060220215410.5990c612.akpm@osdl.org>

Hello!

On Mon, Feb 20, 2006 at 09:54:10PM -0800, Andrew Morton wrote:
> >    Can I ask for truncate_complete_page() to be exported?
> >    For Lustre filesystem it is necessary to poke out pages in the middle of
> >    a file, but truncate_inode_pages() is not very suitable, because we
> >    poke those pages one at a time when locks on those pages are cancelled, but
> >    we cannot kill entire set of pages as a group, because there might be some
> >    other lock that covers a subset of those pages, so we still need to iterate
> >    through all of them, and while we are at it, it is easier to kill pages
> >    as we check them one by one.
> Isn't truncate_inode_pages_range() suitable?

No, for the reason I specified above. We still walk entire region on page by
page basis, checking that page is not covered by other locks that might warrant
its exclusion from truncating, pushing writing of the page if it is still dirty
and needs to be written (or clearing its dirty flag if it needs to be
discarded).
So we have sort of reimplemented truncate_inode_pages_range() with extra logic
specific to Lustre and calling truncate_inode_pages_range() for every page
we want to get rid of is overkill.

> > +EXPORT_SYMBOL(truncate_complete_page);
> _GPL would be nicer.   Plus a comment to keep people from "cleaning it up".

Not that I mind if it is GPL or not, but currently truncate_complete_page()
can be reimplemented with EXPORT_SYMBOL stuff only. Here's how:

static inline void ll_remove_from_page_cache(struct page *page)
{
        struct address_space *mapping = page->mapping;

        BUG_ON(!PageLocked(page));

        write_lock_irq(&mapping->tree_lock);
        radix_tree_delete(&mapping->page_tree, page->index);
        page->mapping = NULL;
        mapping->nrpages--;
        atomic_add(-1, &nr_pagecache); // XXX pagecache_acct(-1);
        write_unlock_irq(&mapping->tree_lock);
}

static inline void
truncate_complete_page(struct address_space *mapping, struct page *page)
{
        if (page->mapping != mapping)
                return;

        if (PagePrivate(page))
                page->mapping->a_ops->invalidatepage(page, 0);

        clear_page_dirty(page);
        ClearPageUptodate(page);
        ClearPageMappedToDisk(page);
        ll_remove_from_page_cache(page);
        page_cache_release(page);       /* pagecache ref */
}

Bye,
    Oleg

  reply	other threads:[~2006-02-21 11:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-20 22:38 Request for export of truncate_complete_page Oleg Drokin
2006-02-21  5:54 ` Andrew Morton
2006-02-21 11:30   ` Oleg Drokin [this message]
2006-02-21 10:39 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060221113026.GE5733@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox