Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
inode.c File Reference
#include <linux/export.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/backing-dev.h>
#include <linux/hash.h>
#include <linux/swap.h>
#include <linux/security.h>
#include <linux/cdev.h>
#include <linux/bootmem.h>
#include <linux/fsnotify.h>
#include <linux/mount.h>
#include <linux/posix_acl.h>
#include <linux/prefetch.h>
#include <linux/buffer_head.h>
#include <linux/ratelimit.h>
#include "internal.h"

Go to the source code of this file.

Macros

#define LAST_INO_BATCH   1024
 

Functions

__cacheline_aligned_in_smp DEFINE_SPINLOCK (inode_sb_list_lock)
 
 EXPORT_SYMBOL (empty_aops)
 
int get_nr_dirty_inodes (void)
 
int inode_init_always (struct super_block *sb, struct inode *inode)
 
 EXPORT_SYMBOL (inode_init_always)
 
void free_inode_nonrcu (struct inode *inode)
 
 EXPORT_SYMBOL (free_inode_nonrcu)
 
void __destroy_inode (struct inode *inode)
 
 EXPORT_SYMBOL (__destroy_inode)
 
void drop_nlink (struct inode *inode)
 
 EXPORT_SYMBOL (drop_nlink)
 
void clear_nlink (struct inode *inode)
 
 EXPORT_SYMBOL (clear_nlink)
 
void set_nlink (struct inode *inode, unsigned int nlink)
 
 EXPORT_SYMBOL (set_nlink)
 
void inc_nlink (struct inode *inode)
 
 EXPORT_SYMBOL (inc_nlink)
 
void address_space_init_once (struct address_space *mapping)
 
 EXPORT_SYMBOL (address_space_init_once)
 
void inode_init_once (struct inode *inode)
 
 EXPORT_SYMBOL (inode_init_once)
 
void __iget (struct inode *inode)
 
void ihold (struct inode *inode)
 
 EXPORT_SYMBOL (ihold)
 
void inode_add_lru (struct inode *inode)
 
void inode_sb_list_add (struct inode *inode)
 
 EXPORT_SYMBOL_GPL (inode_sb_list_add)
 
void __insert_inode_hash (struct inode *inode, unsigned long hashval)
 
 EXPORT_SYMBOL (__insert_inode_hash)
 
void __remove_inode_hash (struct inode *inode)
 
 EXPORT_SYMBOL (__remove_inode_hash)
 
void clear_inode (struct inode *inode)
 
 EXPORT_SYMBOL (clear_inode)
 
void evict_inodes (struct super_block *sb)
 
int invalidate_inodes (struct super_block *sb, bool kill_dirty)
 
void prune_icache_sb (struct super_block *sb, int nr_to_scan)
 
unsigned int get_next_ino (void)
 
 EXPORT_SYMBOL (get_next_ino)
 
struct inodenew_inode_pseudo (struct super_block *sb)
 
struct inodenew_inode (struct super_block *sb)
 
 EXPORT_SYMBOL (new_inode)
 
void unlock_new_inode (struct inode *inode)
 
 EXPORT_SYMBOL (unlock_new_inode)
 
struct inodeiget5_locked (struct super_block *sb, unsigned long hashval, int(*test)(struct inode *, void *), int(*set)(struct inode *, void *), void *data)
 
 EXPORT_SYMBOL (iget5_locked)
 
struct inodeiget_locked (struct super_block *sb, unsigned long ino)
 
 EXPORT_SYMBOL (iget_locked)
 
ino_t iunique (struct super_block *sb, ino_t max_reserved)
 
 EXPORT_SYMBOL (iunique)
 
struct inodeigrab (struct inode *inode)
 
 EXPORT_SYMBOL (igrab)
 
struct inodeilookup5_nowait (struct super_block *sb, unsigned long hashval, int(*test)(struct inode *, void *), void *data)
 
 EXPORT_SYMBOL (ilookup5_nowait)
 
struct inodeilookup5 (struct super_block *sb, unsigned long hashval, int(*test)(struct inode *, void *), void *data)
 
 EXPORT_SYMBOL (ilookup5)
 
struct inodeilookup (struct super_block *sb, unsigned long ino)
 
 EXPORT_SYMBOL (ilookup)
 
int insert_inode_locked (struct inode *inode)
 
 EXPORT_SYMBOL (insert_inode_locked)
 
int insert_inode_locked4 (struct inode *inode, unsigned long hashval, int(*test)(struct inode *, void *), void *data)
 
 EXPORT_SYMBOL (insert_inode_locked4)
 
int generic_delete_inode (struct inode *inode)
 
 EXPORT_SYMBOL (generic_delete_inode)
 
void iput (struct inode *inode)
 
 EXPORT_SYMBOL (iput)
 
sector_t bmap (struct inode *inode, sector_t block)
 
 EXPORT_SYMBOL (bmap)
 
void touch_atime (struct path *path)
 
 EXPORT_SYMBOL (touch_atime)
 
int should_remove_suid (struct dentry *dentry)
 
 EXPORT_SYMBOL (should_remove_suid)
 
int file_remove_suid (struct file *file)
 
 EXPORT_SYMBOL (file_remove_suid)
 
int file_update_time (struct file *file)
 
 EXPORT_SYMBOL (file_update_time)
 
int inode_needs_sync (struct inode *inode)
 
 EXPORT_SYMBOL (inode_needs_sync)
 
int inode_wait (void *word)
 
 EXPORT_SYMBOL (inode_wait)
 
 __setup ("ihash_entries=", set_ihash_entries)
 
void __init inode_init_early (void)
 
void __init inode_init (void)
 
void init_special_inode (struct inode *inode, umode_t mode, dev_t rdev)
 
 EXPORT_SYMBOL (init_special_inode)
 
void inode_init_owner (struct inode *inode, const struct inode *dir, umode_t mode)
 
 EXPORT_SYMBOL (inode_init_owner)
 
bool inode_owner_or_capable (const struct inode *inode)
 
 EXPORT_SYMBOL (inode_owner_or_capable)
 
void inode_dio_wait (struct inode *inode)
 
 EXPORT_SYMBOL (inode_dio_wait)
 
void inode_dio_done (struct inode *inode)
 
 EXPORT_SYMBOL (inode_dio_done)
 

Variables

struct address_space_operations empty_aops
 
struct inodes_stat_t inodes_stat
 

Macro Definition Documentation

#define LAST_INO_BATCH   1024

Definition at line 873 of file inode.c.

Function Documentation

void __destroy_inode ( struct inode inode)

Definition at line 231 of file inode.c.

void __iget ( struct inode inode)

Definition at line 386 of file inode.c.

void __insert_inode_hash ( struct inode inode,
unsigned long  hashval 
)

__insert_inode_hash - hash an inode : unhashed inode : unsigned long value used to locate this object in the inode_hashtable.

Add an inode to the inode hash for this superblock.

Definition at line 474 of file inode.c.

void __remove_inode_hash ( struct inode inode)

__remove_inode_hash - remove an inode from the hash : inode to unhash

Remove an inode from the superblock.

Definition at line 492 of file inode.c.

__setup ( )
void address_space_init_once ( struct address_space mapping)

Definition at line 343 of file inode.c.

sector_t bmap ( struct inode inode,
sector_t  block 
)

bmap - find a block number in a file : inode of file : block to find

Returns the block number on the device holding the inode that is the disk block number for the block of the file requested. That is, asked for block 4 of inode 1 the function will return the disk block relative to the disk start that holds that block of the file.

Definition at line 1459 of file inode.c.

void clear_inode ( struct inode inode)

Definition at line 502 of file inode.c.

void clear_nlink ( struct inode inode)

clear_nlink - directly zero an inode's link count : inode

This is a low-level filesystem helper to replace any direct filesystem manipulation of i_nlink. See drop_nlink() for why we care about i_nlink hitting zero.

Definition at line 295 of file inode.c.

void drop_nlink ( struct inode inode)

drop_nlink - directly drop an inode's link count : inode

This is a low-level filesystem helper to replace any direct filesystem manipulation of i_nlink. In cases where we are attempting to track writes to the filesystem, a decrement to zero means an imminent write when the file is truncated and actually unlinked on the filesystem.

Definition at line 278 of file inode.c.

void evict_inodes ( struct super_block sb)

evict_inodes - evict all evictable inodes for a superblock : superblock to operate on

Make sure that no inodes with zero refcount are retained. This is called by superblock shutdown after having MS_ACTIVE flag removed, so any inode reaching zero refcount during or after that call will be immediately evicted.

Definition at line 604 of file inode.c.

EXPORT_SYMBOL ( empty_aops  )
EXPORT_SYMBOL ( inode_init_always  )
EXPORT_SYMBOL ( free_inode_nonrcu  )
EXPORT_SYMBOL ( __destroy_inode  )
EXPORT_SYMBOL ( drop_nlink  )
EXPORT_SYMBOL ( clear_nlink  )
EXPORT_SYMBOL ( set_nlink  )
EXPORT_SYMBOL ( inc_nlink  )
EXPORT_SYMBOL ( address_space_init_once  )
EXPORT_SYMBOL ( inode_init_once  )
EXPORT_SYMBOL ( ihold  )
EXPORT_SYMBOL ( __insert_inode_hash  )
EXPORT_SYMBOL ( __remove_inode_hash  )
EXPORT_SYMBOL ( clear_inode  )
EXPORT_SYMBOL ( get_next_ino  )
EXPORT_SYMBOL ( new_inode  )
EXPORT_SYMBOL ( unlock_new_inode  )
EXPORT_SYMBOL ( iget5_locked  )
EXPORT_SYMBOL ( iget_locked  )
EXPORT_SYMBOL ( iunique  )
EXPORT_SYMBOL ( igrab  )
EXPORT_SYMBOL ( ilookup5_nowait  )
EXPORT_SYMBOL ( ilookup5  )
EXPORT_SYMBOL ( ilookup  )
EXPORT_SYMBOL ( insert_inode_locked  )
EXPORT_SYMBOL ( insert_inode_locked4  )
EXPORT_SYMBOL ( generic_delete_inode  )
EXPORT_SYMBOL ( iput  )
EXPORT_SYMBOL ( bmap  )
EXPORT_SYMBOL ( touch_atime  )
EXPORT_SYMBOL ( should_remove_suid  )
EXPORT_SYMBOL ( file_remove_suid  )
EXPORT_SYMBOL ( file_update_time  )
EXPORT_SYMBOL ( inode_needs_sync  )
EXPORT_SYMBOL ( inode_wait  )
EXPORT_SYMBOL ( init_special_inode  )
EXPORT_SYMBOL ( inode_init_owner  )
EXPORT_SYMBOL ( inode_owner_or_capable  )
EXPORT_SYMBOL ( inode_dio_wait  )
EXPORT_SYMBOL ( inode_dio_done  )
EXPORT_SYMBOL_GPL ( inode_sb_list_add  )
int file_remove_suid ( struct file file)

Definition at line 1615 of file inode.c.

int file_update_time ( struct file file)

Definition at line 1656 of file inode.c.

void free_inode_nonrcu ( struct inode inode)

Definition at line 225 of file inode.c.

int generic_delete_inode ( struct inode inode)

Definition at line 1375 of file inode.c.

unsigned int get_next_ino ( void  )

Definition at line 876 of file inode.c.

int get_nr_dirty_inodes ( void  )

Definition at line 96 of file inode.c.

struct inode* iget5_locked ( struct super_block sb,
unsigned long  hashval,
int(*)(struct inode *, void *)  test,
int(*)(struct inode *, void *)  set,
void data 
)
read

iget5_locked - obtain an inode from a mounted file system : super block of file system : hash value (usually inode number) to get

Test:

: callback used for comparisons between inodes : callback used to initialize a new struct inode : opaque data pointer to pass to

and

Search for the inode specified by and in the inode cache, and if present it is return it with an increased reference count. This is a generalized version of iget_locked() for file systems where the inode number is not sufficient for unique identification of an inode.

If the inode is not in cache, allocate a new inode and return it locked, hashed, and with the I_NEW flag set. The file system gets to fill it in before unlocking it via unlock_new_inode().

Note both

Test:
and are called with the inode_hash_lock held, so can't sleep.

Definition at line 1004 of file inode.c.

struct inode* iget_locked ( struct super_block sb,
unsigned long  ino 
)
read

iget_locked - obtain an inode from a mounted file system : super block of file system : inode number to get

Search for the inode specified by in the inode cache and if present return it with an increased reference count. This is for file systems where the inode number is sufficient for unique identification of an inode.

If the inode is not in cache, allocate a new inode and return it locked, hashed, and with the I_NEW flag set. The file system gets to fill it in before unlocking it via unlock_new_inode().

Definition at line 1076 of file inode.c.

struct inode* igrab ( struct inode inode)
read

Definition at line 1187 of file inode.c.

void ihold ( struct inode inode)

Definition at line 394 of file inode.c.

struct inode* ilookup ( struct super_block sb,
unsigned long  ino 
)
read

ilookup - search for an inode in the inode cache : super block of file system to search : inode number to search for

Search for the inode in the inode cache, and if the inode is in the cache, the inode is returned with an incremented reference count.

Definition at line 1272 of file inode.c.

struct inode* ilookup5 ( struct super_block sb,
unsigned long  hashval,
int(*)(struct inode *, void *)  test,
void data 
)
read

ilookup5 - search for an inode in the inode cache : super block of file system to search : hash value (usually inode number) to search for

Test:
: callback used for comparisons between inodes : opaque data pointer to pass to

Search for the inode specified by and in the inode cache, and if the inode is in the cache, return the inode with an incremented reference count. Waits on I_NEW before returning the inode. returned with an incremented reference count.

This is a generalized version of ilookup() for file systems where the inode number is not sufficient for unique identification of an inode.

Note:

Test:
is called with the inode_hash_lock held, so can't sleep.

Definition at line 1253 of file inode.c.

struct inode* ilookup5_nowait ( struct super_block sb,
unsigned long  hashval,
int(*)(struct inode *, void *)  test,
void data 
)
read

ilookup5_nowait - search for an inode in the inode cache : super block of file system to search : hash value (usually inode number) to search for

Test:
: callback used for comparisons between inodes : opaque data pointer to pass to

Search for the inode specified by and in the inode cache. If the inode is in the cache, the inode is returned with an incremented reference count.

Note: I_NEW is not waited upon so you have to be very careful what you do with the returned inode. You probably should be using ilookup5() instead.

Note2:

Test:
is called with the inode_hash_lock held, so can't sleep.

Definition at line 1222 of file inode.c.

void inc_nlink ( struct inode inode)

inc_nlink - directly increment an inode's link count : inode

This is a low-level filesystem helper to replace any direct filesystem manipulation of i_nlink. Currently, it is only here for parity with dec_nlink().

Definition at line 334 of file inode.c.

void init_special_inode ( struct inode inode,
umode_t  mode,
dev_t  rdev 
)

Definition at line 1801 of file inode.c.

void inode_add_lru ( struct inode inode)

Definition at line 416 of file inode.c.

void inode_dio_done ( struct inode inode)

Definition at line 1898 of file inode.c.

void inode_dio_wait ( struct inode inode)

inode_dio_wait - wait for outstanding DIO requests to finish : inode to wait for

Waits for all pending direct I/O requests to finish so that we can proceed with a truncate or equivalent operation.

Must be called under a lock that serializes taking new references to i_dio_count, usually by inode->i_mutex.

Definition at line 1884 of file inode.c.

void __init inode_init ( void  )

Definition at line 1770 of file inode.c.

int inode_init_always ( struct super_block sb,
struct inode inode 
)

inode_init_always - perform inode structure intialisation : superblock inode belongs to : inode to initialise

These are initializations that need to be done on every inode allocation as the fields are not initialised by slab allocation.

Definition at line 124 of file inode.c.

void __init inode_init_early ( void  )

Definition at line 1745 of file inode.c.

void inode_init_once ( struct inode inode)

Definition at line 361 of file inode.c.

void inode_init_owner ( struct inode inode,
const struct inode dir,
umode_t  mode 
)

Definition at line 1827 of file inode.c.

int inode_needs_sync ( struct inode inode)

Definition at line 1691 of file inode.c.

bool inode_owner_or_capable ( const struct inode inode)

inode_owner_or_capable - check current task permissions to inode : inode being checked

Return true if current either has CAP_FOWNER to the inode, or owns the file.

Definition at line 1848 of file inode.c.

void inode_sb_list_add ( struct inode inode)

inode_sb_list_add - add inode to the superblock list of inodes : inode to add

Definition at line 439 of file inode.c.

int inode_wait ( void word)

Definition at line 1701 of file inode.c.

int insert_inode_locked ( struct inode inode)

Definition at line 1287 of file inode.c.

int insert_inode_locked4 ( struct inode inode,
unsigned long  hashval,
int(*)(struct inode *, void *)  test,
void data 
)

Definition at line 1330 of file inode.c.

int invalidate_inodes ( struct super_block sb,
bool  kill_dirty 
)

invalidate_inodes - attempt to free all inodes on a superblock : superblock to operate on : flag to guide handling of dirty inodes

Attempts to free all inodes for a given superblock. If there were any busy inodes return a non-zero value, else zero. If is set, discard dirty inodes too, otherwise treat them as busy.

Definition at line 640 of file inode.c.

void iput ( struct inode inode)

iput - put an inode : inode to put

Puts an inode, dropping its usage count. If the inode use count hits zero, the inode is then freed and may also be destroyed.

Consequently, iput() can sleep.

Definition at line 1437 of file inode.c.

ino_t iunique ( struct super_block sb,
ino_t  max_reserved 
)

iunique - get a unique inode number : superblock : highest reserved inode number

Obtain an inode number that is unique on the system for a given superblock. This is used by file systems that have no natural permanent inode numbering system. An inode number is returned that is higher than the reserved limit but unique.

BUGS: With a large number of inodes live on the file system this function currently becomes quite slow.

Definition at line 1164 of file inode.c.

struct inode* new_inode ( struct super_block sb)
read

new_inode - obtain an inode : superblock

Allocates a new inode for given superblock. The default gfp_mask for allocations related to inode->i_mapping is GFP_HIGHUSER_MOVABLE. If HIGHMEM pages are unsuitable or it is known that pages allocated for the page cache are not reclaimable or migratable, mapping_set_gfp_mask() must be called with suitable flags on the newly created inode's mapping

Definition at line 931 of file inode.c.

struct inode* new_inode_pseudo ( struct super_block sb)
read

new_inode_pseudo - obtain an inode : superblock

Allocates a new inode for given superblock. Inode wont be chained in superblock s_inodes list This means :

  • fs can't be unmount
  • quotas, fsnotify, writeback can't work

Definition at line 906 of file inode.c.

void prune_icache_sb ( struct super_block sb,
int  nr_to_scan 
)

Definition at line 707 of file inode.c.

void set_nlink ( struct inode inode,
unsigned int  nlink 
)

set_nlink - directly set an inode's link count : inode : new nlink (should be non-zero)

This is a low-level filesystem helper to replace any direct filesystem manipulation of i_nlink.

Definition at line 312 of file inode.c.

int should_remove_suid ( struct dentry dentry)

Definition at line 1584 of file inode.c.

void touch_atime ( struct path path)

touch_atime - update the access time : the &struct path to update

Update the accessed time on an inode and mark it for writeback. This function automatically handles read only file systems and media, as well as the "noatime" flag and inode specific "noatime" markers.

Definition at line 1531 of file inode.c.

void unlock_new_inode ( struct inode inode)

unlock_new_inode - clear the I_NEW state and wake up any waiters : new inode to unlock

Called when the inode is fully initialised to clear the new state of the inode and wake up anyone waiting for the inode to finish initialisation.

Definition at line 972 of file inode.c.

Variable Documentation

Initial value:
= {
}

Definition at line 64 of file inode.c.

struct inodes_stat_t inodes_stat

Definition at line 71 of file inode.c.