Re: [V4 PATCH 1/2] tmpfs: add fallocate support

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

 



On Tue, 29 Nov 2011 15:23:58 +0800
Cong Wang <amwang@xxxxxxxxxx> wrote:

> 于 2011年11月29日 14:02, KAMEZAWA Hiroyuki 写道:
> >
> > You can't know whether the 'page' is allocated by alloc_page() in fallocate()
> > or just found as exiting one.
> > Then, yourwill corrupt existing pages in error path.
> > Is it allowed ?
> >
> 
> According to the comment,
> 
> /*
>   * shmem_getpage_gfp - find page in cache, or get from swap, or allocate
>   *
>   * If we allocate a new one we do not mark it dirty. That's up to the
>   * vm. If we swap it in we mark it dirty since we also free the swap
>   * entry since a page cannot live in both the swap and page cache
>   */
> 
> so we can know if the page is newly allocated by checking page dirty bit.
> Or am I missing something?
> 

If swap-in doesn't happen and  a page is found...

==
       page = find_lock_page(mapping, index); <=============== you find a page
       if (radix_tree_exceptional_entry(page)) {
                swap = radix_to_swp_entry(page);
                page = NULL;
        }

        if (sgp != SGP_WRITE &&
            ((loff_t)index << PAGE_CACHE_SHIFT) >= i_size_read(inode)) {
                error = -EINVAL;
                goto failed;
        }

        if (page || (sgp == SGP_READ && !swap.val)) {
                /*
                 * Once we can get the page lock, it must be uptodate:
                 * if there were an error in reading back from swap,
                 * the page would not be inserted into the filecache.
                 */
                BUG_ON(page && !PageUptodate(page));
                *pagep = page; <========================= return here.
                return 0;
        }
==
Page will not be marked as dirty.

Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]