Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118228
b: refs/heads/master
c: a996031
h: refs/heads/master
v: v3
  • Loading branch information
Eric Sandeen authored and Theodore Ts'o committed Oct 28, 2008
1 parent 688baeb commit ac2a649
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 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: 8c3bf8a01c005385e9be0bc992e10abfb355278c
refs/heads/master: a996031c87e093017c0763326a08896a3a4817f4
26 changes: 14 additions & 12 deletions trunk/fs/ext4/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,18 +599,13 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
*/
int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks)
{
s64 free_blocks, dirty_blocks;
s64 root_blocks = 0;
s64 free_blocks, dirty_blocks, root_blocks;
struct percpu_counter *fbc = &sbi->s_freeblocks_counter;
struct percpu_counter *dbc = &sbi->s_dirtyblocks_counter;

free_blocks = percpu_counter_read_positive(fbc);
dirty_blocks = percpu_counter_read_positive(dbc);

if (!capable(CAP_SYS_RESOURCE) &&
sbi->s_resuid != current->fsuid &&
(sbi->s_resgid == 0 || !in_group_p(sbi->s_resgid)))
root_blocks = ext4_r_blocks_count(sbi->s_es);
root_blocks = ext4_r_blocks_count(sbi->s_es);

if (free_blocks - (nblocks + root_blocks + dirty_blocks) <
EXT4_FREEBLOCKS_WATERMARK) {
Expand All @@ -623,13 +618,20 @@ int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks)
}
}
/* Check whether we have space after
* accounting for current dirty blocks
* accounting for current dirty blocks & root reserved blocks.
*/
if (free_blocks < ((root_blocks + nblocks) + dirty_blocks))
/* we don't have free space */
return 0;
if (free_blocks >= ((root_blocks + nblocks) + dirty_blocks))
return 1;

return 1;
/* Hm, nope. Are (enough) root reserved blocks available? */
if (sbi->s_resuid == current->fsuid ||
((sbi->s_resgid != 0) && in_group_p(sbi->s_resgid)) ||
capable(CAP_SYS_RESOURCE)) {
if (free_blocks >= (nblocks + dirty_blocks))
return 1;
}

return 0;
}

int ext4_claim_free_blocks(struct ext4_sb_info *sbi,
Expand Down

0 comments on commit ac2a649

Please sign in to comment.