Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
truncate.c File Reference
#include <linux/kernel.h>
#include <linux/backing-dev.h>
#include <linux/gfp.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/export.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
#include <linux/pagevec.h>
#include <linux/task_io_accounting_ops.h>
#include <linux/buffer_head.h>
#include <linux/cleancache.h>
#include "internal.h"

Go to the source code of this file.

Functions

void do_invalidatepage (struct page *page, unsigned long offset)
 
void cancel_dirty_page (struct page *page, unsigned int account_size)
 
 EXPORT_SYMBOL (cancel_dirty_page)
 
int truncate_inode_page (struct address_space *mapping, struct page *page)
 
int generic_error_remove_page (struct address_space *mapping, struct page *page)
 
 EXPORT_SYMBOL (generic_error_remove_page)
 
int invalidate_inode_page (struct page *page)
 
void truncate_inode_pages_range (struct address_space *mapping, loff_t lstart, loff_t lend)
 
 EXPORT_SYMBOL (truncate_inode_pages_range)
 
void truncate_inode_pages (struct address_space *mapping, loff_t lstart)
 
 EXPORT_SYMBOL (truncate_inode_pages)
 
unsigned long invalidate_mapping_pages (struct address_space *mapping, pgoff_t start, pgoff_t end)
 
 EXPORT_SYMBOL (invalidate_mapping_pages)
 
int invalidate_inode_pages2_range (struct address_space *mapping, pgoff_t start, pgoff_t end)
 
 EXPORT_SYMBOL_GPL (invalidate_inode_pages2_range)
 
int invalidate_inode_pages2 (struct address_space *mapping)
 
 EXPORT_SYMBOL_GPL (invalidate_inode_pages2)
 
void truncate_pagecache (struct inode *inode, loff_t oldsize, loff_t newsize)
 
 EXPORT_SYMBOL (truncate_pagecache)
 
void truncate_setsize (struct inode *inode, loff_t newsize)
 
 EXPORT_SYMBOL (truncate_setsize)
 
int vmtruncate (struct inode *inode, loff_t newsize)
 
 EXPORT_SYMBOL (vmtruncate)
 
void truncate_pagecache_range (struct inode *inode, loff_t lstart, loff_t lend)
 
 EXPORT_SYMBOL (truncate_pagecache_range)
 

Function Documentation

void cancel_dirty_page ( struct page page,
unsigned int  account_size 
)

Definition at line 74 of file truncate.c.

void do_invalidatepage ( struct page page,
unsigned long  offset 
)

Definition at line 40 of file truncate.c.

EXPORT_SYMBOL ( cancel_dirty_page  )
EXPORT_SYMBOL ( generic_error_remove_page  )
EXPORT_SYMBOL ( truncate_inode_pages_range  )
EXPORT_SYMBOL ( truncate_inode_pages  )
EXPORT_SYMBOL ( invalidate_mapping_pages  )
EXPORT_SYMBOL ( truncate_pagecache  )
EXPORT_SYMBOL ( truncate_setsize  )
EXPORT_SYMBOL ( vmtruncate  )
EXPORT_SYMBOL ( truncate_pagecache_range  )
EXPORT_SYMBOL_GPL ( invalidate_inode_pages2_range  )
EXPORT_SYMBOL_GPL ( invalidate_inode_pages2  )
int generic_error_remove_page ( struct address_space mapping,
struct page page 
)

Definition at line 152 of file truncate.c.

int invalidate_inode_page ( struct page page)

Definition at line 172 of file truncate.c.

int invalidate_inode_pages2 ( struct address_space mapping)

invalidate_inode_pages2 - remove all pages from an address_space : the address_space

Any pages which are found to be mapped into pagetables are unmapped prior to invalidation.

Returns -EBUSY if any pages could not be invalidated.

Definition at line 514 of file truncate.c.

int invalidate_inode_pages2_range ( struct address_space mapping,
pgoff_t  start,
pgoff_t  end 
)

invalidate_inode_pages2_range - remove range of pages from an address_space : the address_space : the page offset 'from' which to invalidate : the page offset 'to' which to invalidate (inclusive)

Any pages which are found to be mapped into pagetables are unmapped prior to invalidation.

Returns -EBUSY if any pages could not be invalidated.

Definition at line 434 of file truncate.c.

unsigned long invalidate_mapping_pages ( struct address_space mapping,
pgoff_t  start,
pgoff_t  end 
)

invalidate_mapping_pages - Invalidate all the unlocked pages of one inode : the address_space which holds the pages to invalidate : the offset 'from' which to invalidate : the offset 'to' which to invalidate (inclusive)

This function only removes the unlocked pages, if you want to remove all the pages of one inode, you must call truncate_inode_pages.

invalidate_mapping_pages() will not block on IO activity. It will not invalidate pages which are dirty, locked, under writeback or mapped into pagetables.

Definition at line 328 of file truncate.c.

int truncate_inode_page ( struct address_space mapping,
struct page page 
)

Definition at line 139 of file truncate.c.

void truncate_inode_pages ( struct address_space mapping,
loff_t  lstart 
)

truncate_inode_pages - truncate all the pages from an offset : mapping to truncate : offset from which to truncate

Called under (and serialised by) inode->i_mutex.

Note: When this function returns, there can be a page in the process of deletion (inside __delete_from_page_cache()) in the specified range. Thus mapping->nrpages can be non-zero when this function returns even after truncation of the whole mapping.

Definition at line 309 of file truncate.c.

void truncate_inode_pages_range ( struct address_space mapping,
loff_t  lstart,
loff_t  lend 
)

truncate_inode_pages_range - truncate range of pages specified by start & end byte offsets : mapping to truncate : offset from which to truncate : offset to which to truncate

Truncate the page cache, removing the pages that are between specified offsets (and zeroing out partial page (if lstart is not page aligned)).

Truncate takes two passes - the first pass is nonblocking. It will not block on page locks and it will not block on writeback. The second pass will wait. This is to prevent as much IO as possible in the affected region. The first pass will remove most pages, so the search cost of the second pass is low.

We pass down the cache-hot hint to the page freeing code. Even if the mapping is large, it is probably the case that the final pages are the most recently touched, and freeing happens in ascending file offset order.

Definition at line 204 of file truncate.c.

void truncate_pagecache ( struct inode inode,
loff_t  oldsize,
loff_t  newsize 
)

truncate_pagecache - unmap and remove pagecache that has been truncated : inode : old file size : new file size

inode's new i_size must already be written before truncate_pagecache is called.

This function should typically be called before the filesystem releases resources associated with the freed range (eg. deallocates blocks). This way, pagecache will always stay logically coherent with on-disk format, and the filesystem would not have to deal with situations such as writepage being called for a page that has already had its underlying blocks deallocated.

Definition at line 536 of file truncate.c.

void truncate_pagecache_range ( struct inode inode,
loff_t  lstart,
loff_t  lend 
)

truncate_pagecache_range - unmap and remove pagecache that is hole-punched : inode : offset of beginning of hole : offset of last byte of hole

This function should typically be called before the filesystem releases resources associated with the freed range (eg. deallocates blocks). This way, pagecache will always stay logically coherent with on-disk format, and the filesystem would not have to deal with situations such as writepage being called for a page that has already had its underlying blocks deallocated.

Definition at line 615 of file truncate.c.

void truncate_setsize ( struct inode inode,
loff_t  newsize 
)

truncate_setsize - update inode and pagecache for a new file size : inode : new file size

truncate_setsize updates i_size and performs pagecache truncation (if necessary) to . It will be typically be called from the filesystem's setattr function when ATTR_SIZE is passed in.

Must be called with inode_mutex held and before all filesystem specific block truncation has been performed.

Definition at line 568 of file truncate.c.

int vmtruncate ( struct inode inode,
loff_t  newsize 
)

vmtruncate - unmap mappings "freed" by truncate() syscall : inode of the file used : file offset to start truncating

This function is deprecated and truncate_setsize or truncate_pagecache should be used instead, together with filesystem specific block truncation.

Definition at line 587 of file truncate.c.