Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
budget.c File Reference
#include "ubifs.h"
#include <linux/writeback.h>
#include <linux/math64.h>

Go to the source code of this file.

Macros

#define MAX_MKSPC_RETRIES   3
 
#define NR_TO_WRITE   16
 

Functions

int ubifs_calc_min_idx_lebs (struct ubifs_info *c)
 
long long ubifs_calc_available (const struct ubifs_info *c, int min_idx_lebs)
 
int ubifs_budget_space (struct ubifs_info *c, struct ubifs_budget_req *req)
 
void ubifs_release_budget (struct ubifs_info *c, struct ubifs_budget_req *req)
 
void ubifs_convert_page_budget (struct ubifs_info *c)
 
void ubifs_release_dirty_inode_budget (struct ubifs_info *c, struct ubifs_inode *ui)
 
long long ubifs_reported_space (const struct ubifs_info *c, long long free)
 
long long ubifs_get_free_space_nolock (struct ubifs_info *c)
 
long long ubifs_get_free_space (struct ubifs_info *c)
 

Macro Definition Documentation

#define MAX_MKSPC_RETRIES   3

Definition at line 43 of file budget.c.

#define NR_TO_WRITE   16

Definition at line 49 of file budget.c.

Function Documentation

int ubifs_budget_space ( struct ubifs_info c,
struct ubifs_budget_req req 
)

ubifs_budget_space - ensure there is enough space to complete an operation. : UBIFS file-system description object : budget request

This function allocates budget for an operation. It uses pessimistic approximation of how much flash space the operation needs. The goal of this function is to make sure UBIFS always has flash space to flush all dirty pages, dirty inodes, and dirty znodes (liability). This function may force commit, garbage-collection or write-back. Returns zero in case of success, %-ENOSPC if there is no free space and other negative error codes in case of failures.

Definition at line 438 of file budget.c.

long long ubifs_calc_available ( const struct ubifs_info c,
int  min_idx_lebs 
)

ubifs_calc_available - calculate available FS space. : UBIFS file-system description object : minimum number of LEBs reserved for the index

This function calculates and returns amount of FS space available for use.

Definition at line 209 of file budget.c.

int ubifs_calc_min_idx_lebs ( struct ubifs_info c)

ubifs_calc_min_idx_lebs - calculate amount of LEBs for the index. : UBIFS file-system description object

This function calculates and returns the number of LEBs which should be kept for index usage.

Definition at line 178 of file budget.c.

void ubifs_convert_page_budget ( struct ubifs_info c)

ubifs_convert_page_budget - convert budget of a new page. : UBIFS file-system description object

This function converts budget which was allocated for a new page of data to the budget of changing an existing page of data. The latter is smaller than the former, so this function only does simple re-calculation and does not involve any write-back.

Definition at line 584 of file budget.c.

long long ubifs_get_free_space ( struct ubifs_info c)

ubifs_get_free_space - return amount of free space. : UBIFS file-system description object

This function calculates and returns amount of free space to report to user-space.

Definition at line 722 of file budget.c.

long long ubifs_get_free_space_nolock ( struct ubifs_info c)

ubifs_get_free_space_nolock - return amount of free space. : UBIFS file-system description object

This function calculates amount of free space to report to user-space.

Because UBIFS may introduce substantial overhead (the index, node headers, alignment, wastage at the end of LEBs, etc), it cannot report real amount of free flash space it has (well, because not all dirty space is reclaimable, UBIFS does not actually know the real amount). If UBIFS did so, it would bread user expectations about what free space is. Users seem to accustomed to assume that if the file-system reports N bytes of free space, they would be able to fit a file of N bytes to the FS. This almost works for traditional file-systems, because they have way less overhead than UBIFS. So, to keep users happy, UBIFS tries to take the overhead into account.

Definition at line 679 of file budget.c.

void ubifs_release_budget ( struct ubifs_info c,
struct ubifs_budget_req req 
)

ubifs_release_budget - release budgeted free space. : UBIFS file-system description object : budget request

This function releases the space budgeted by 'ubifs_budget_space()'. Note, since the index changes (which were budgeted for in ->idx_growth) will only be written to the media on commit, this function moves the index budget from ->bi.idx_growth to ->bi.uncommitted_idx. The latter will be zeroed by the commit operation.

Definition at line 528 of file budget.c.

void ubifs_release_dirty_inode_budget ( struct ubifs_info c,
struct ubifs_inode ui 
)

ubifs_release_dirty_inode_budget - release dirty inode budget. : UBIFS file-system description object : UBIFS inode to release the budget for

This function releases budget corresponding to a dirty inode. It is usually called when after the inode has been written to the media and marked as clean. It also causes the "no space" flags to be cleared.

Definition at line 607 of file budget.c.

long long ubifs_reported_space ( const struct ubifs_info c,
long long  free 
)

ubifs_reported_space - calculate reported free space. : the UBIFS file-system description object : amount of free space

This function calculates amount of free space which will be reported to user-space. User-space application tend to expect that if the file-system (e.g., via the 'statfs()' call) reports that it has N bytes available, they are able to write a file of size N. UBIFS attaches node headers to each data node and it has to write indexing nodes as well. This introduces additional overhead, and UBIFS has to report slightly less free space to meet the above expectations.

This function assumes free space is made up of uncompressed data nodes and full index nodes (one per data node, tripled because we always allow enough space to write the index thrice).

Note, the calculation is pessimistic, which means that most of the time UBIFS reports less space than it actually has.

Definition at line 638 of file budget.c.