Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
balloc.c File Reference
#include "ext2.h"
#include <linux/quotaops.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/buffer_head.h>
#include <linux/capability.h>

Go to the source code of this file.

Macros

#define in_range(b, first, len)   ((b) >= (first) && (b) <= (first) + (len) - 1)
 
#define rsv_window_dump(root, verbose)   __rsv_window_dump((root), (verbose), __func__)
 

Functions

struct ext2_group_descext2_get_group_desc (struct super_block *sb, unsigned int block_group, struct buffer_head **bh)
 
void ext2_rsv_window_add (struct super_block *sb, struct ext2_reserve_window_node *rsv)
 
void ext2_init_block_alloc_info (struct inode *inode)
 
void ext2_discard_reservation (struct inode *inode)
 
void ext2_free_blocks (struct inode *inode, unsigned long block, unsigned long count)
 
ext2_fsblk_t ext2_new_blocks (struct inode *inode, ext2_fsblk_t goal, unsigned long *count, int *errp)
 
ext2_fsblk_t ext2_new_block (struct inode *inode, unsigned long goal, int *errp)
 
unsigned long ext2_count_free_blocks (struct super_block *sb)
 
int ext2_bg_has_super (struct super_block *sb, int group)
 
unsigned long ext2_bg_num_gdb (struct super_block *sb, int group)
 

Macro Definition Documentation

#define in_range (   b,
  first,
  len 
)    ((b) >= (first) && (b) <= (first) + (len) - 1)

Definition at line 37 of file balloc.c.

#define rsv_window_dump (   root,
  verbose 
)    __rsv_window_dump((root), (verbose), __func__)

Definition at line 250 of file balloc.c.

Function Documentation

int ext2_bg_has_super ( struct super_block sb,
int  group 
)

ext2_bg_has_super - number of blocks used by the superblock in group : superblock for filesystem : group number to check

Return the number of blocks used by the superblock (primary or backup) in this group. Currently this will be only 0 or 1.

Definition at line 1523 of file balloc.c.

unsigned long ext2_bg_num_gdb ( struct super_block sb,
int  group 
)

ext2_bg_num_gdb - number of blocks used by the group table in group : superblock for filesystem : group number to check

Return the number of blocks used by the group descriptor table (primary or backup) in this group. In the future there may be a different number of descriptor blocks in each group.

Definition at line 1540 of file balloc.c.

unsigned long ext2_count_free_blocks ( struct super_block sb)

Definition at line 1454 of file balloc.c.

void ext2_discard_reservation ( struct inode inode)

ext2_discard_reservation() : inode

Discard(free) block reservation window on last file close, or truncate or at last iput().

It is being called in three cases: ext2_release_file(): last writer closes the file ext2_clear_inode(): last iput(), when nobody links to this file. ext2_truncate(): when the block indirect map is about to change.

Definition at line 460 of file balloc.c.

void ext2_free_blocks ( struct inode inode,
unsigned long  block,
unsigned long  count 
)

ext2_free_blocks() – Free given blocks and update quota and i_blocks : inode : start physical block to free : number of blocks to free

Definition at line 485 of file balloc.c.

struct ext2_group_desc* ext2_get_group_desc ( struct super_block sb,
unsigned int  block_group,
struct buffer_head **  bh 
)
read

Definition at line 39 of file balloc.c.

void ext2_init_block_alloc_info ( struct inode inode)

ext2_init_block_alloc_info() : file inode structure

Allocate and initialize the reservation window structure, and link the window to the ext2 inode structure at last

The reservation window structure is only dynamically allocated and linked to ext2 inode the first time the open file needs a new block. So, before every ext2_new_block(s) call, for regular files, we should check whether the reservation window structure exists or not. In the latter case, this function is called. Fail to do so will result in block reservation being turned off for that open file.

This function is called from ext2_get_blocks_handle(), also called when setting the reservation window size through ioctl before the file is open for write (needs block allocation).

Needs truncate_mutex protection prior to calling this function.

Definition at line 419 of file balloc.c.

ext2_fsblk_t ext2_new_block ( struct inode inode,
unsigned long  goal,
int errp 
)

Definition at line 1438 of file balloc.c.

ext2_fsblk_t ext2_new_blocks ( struct inode inode,
ext2_fsblk_t  goal,
unsigned long count,
int errp 
)

Definition at line 1216 of file balloc.c.

void ext2_rsv_window_add ( struct super_block sb,
struct ext2_reserve_window_node rsv 
)

Definition at line 338 of file balloc.c.