Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109717
b: refs/heads/master
c: 4b5f276
h: refs/heads/master
i:
  109715: 702d657
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Aug 31, 2008
1 parent e8ce227 commit 35b44f0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8aabb75017291ba68c09ff5fdb998ef0a1fdaaf9
refs/heads/master: 4b5f2762ec914c9dfd0e9d2377c0574f2ee9a8f9
45 changes: 45 additions & 0 deletions trunk/fs/ubifs/budget.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,51 @@ void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
ubifs_release_budget(c, &req);
}

/**
* ubifs_reported_space - calculate reported free space.
* @c: the UBIFS file-system description object
* @free: 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 indexind nodes as well. This introduces additional
* overhead, and UBIFS it has to report sligtly less free space to meet the
* above expectetion.
*
* 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.
*/
long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free)
{
int divisor, factor;

/*
* Reported space size is @free * X, where X is UBIFS block size
* divided by UBIFS block size + all overhead one data block
* introduces. The overhead is the node header + indexing overhead.
*
* Indexing overhead is calculations are based on the following
* formula: I = N/(f - 1) + 1, where I - number of indexing nodes, N -
* number of data nodes, f - fanout. Because effective UBIFS fanout is
* twice as less than maximum fanout, we assume that each data node
* introduces 3 * @c->max_idx_node_sz / (@c->fanout/2 - 1) bytes.
* Note, the multiplier 3 is because UBIFS reseves thrice as more space
* for the index.
*/
factor = UBIFS_BLOCK_SIZE;
divisor = UBIFS_MAX_DATA_NODE_SZ;
divisor += (c->max_idx_node_sz * 3) / ((c->fanout >> 1) - 1);
free *= factor;
do_div(free, divisor);
return free;
}

/**
* ubifs_budg_get_free_space - return amount of free space.
* @c: UBIFS file-system description object
Expand Down
32 changes: 0 additions & 32 deletions trunk/fs/ubifs/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,38 +283,6 @@ static inline void *ubifs_idx_key(const struct ubifs_info *c,
return (void *)((struct ubifs_branch *)idx->branches)->key;
}

/**
* ubifs_reported_space - calculate reported free space.
* @c: the UBIFS file-system description object
* @free: 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 indexind nodes as well. This introduces additional
* overhead, and UBIFS it has to report sligtly less free space to meet the
* above expectetion.
*
* This function assumes free space is made up of uncompressed data nodes and
* full index nodes (one per data node, doubled because we always allow enough
* space to write the index twice).
*
* Note, the calculation is pessimistic, which means that most of the time
* UBIFS reports less space than it actually has.
*/
static inline long long ubifs_reported_space(const struct ubifs_info *c,
uint64_t free)
{
int divisor, factor;

divisor = UBIFS_MAX_DATA_NODE_SZ + (c->max_idx_node_sz * 3);
factor = UBIFS_MAX_DATA_NODE_SZ - UBIFS_DATA_NODE_SZ;
do_div(free, divisor);

return free * factor;
}

/**
* ubifs_current_time - round current time to time granularity.
* @inode: inode
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/ubifs/ubifs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ void ubifs_cancel_ino_op(struct ubifs_info *c, struct inode *inode,
long long ubifs_budg_get_free_space(struct ubifs_info *c);
int ubifs_calc_min_idx_lebs(struct ubifs_info *c);
void ubifs_convert_page_budget(struct ubifs_info *c);
long long ubifs_reported_space(const struct ubifs_info *c, uint64_t free);
long long ubifs_calc_available(const struct ubifs_info *c, int min_idx_lebs);

/* find.c */
Expand Down

0 comments on commit 35b44f0

Please sign in to comment.