Skip to content

Commit

Permalink
ufs: fix reserved blocks check
Browse files Browse the repository at this point in the history
a) honour ->s_minfree; don't just go with default (5)
b) don't bother with capability checks until we know we'll need them

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jun 14, 2017
1 parent fffd70f commit b451cec
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/ufs/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,12 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
/*
* There is not enough space for user on the device
*/
if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(uspi, UFS_MINFREE) <= 0) {
mutex_unlock(&UFS_SB(sb)->s_lock);
UFSD("EXIT (FAILED)\n");
return 0;
if (unlikely(ufs_freespace(uspi, uspi->s_minfree) <= 0)) {
if (!capable(CAP_SYS_RESOURCE)) {
mutex_unlock(&UFS_SB(sb)->s_lock);
UFSD("EXIT (FAILED)\n");
return 0;
}
}

if (goal >= uspi->s_size)
Expand Down

0 comments on commit b451cec

Please sign in to comment.