summaryrefslogtreecommitdiff
path: root/fs/ufs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-06-14 15:41:17 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-06-14 15:46:05 -0400
commitb451cec4bbd913688f5381efad407762a64a92ce (patch)
tree8e1c25ca448818b0541675b84242b9117810bf90 /fs/ufs
parentfffd70f58864f5a48b2c17d02730a460f86d4254 (diff)
downloadlwn-b451cec4bbd913688f5381efad407762a64a92ce.tar.gz
lwn-b451cec4bbd913688f5381efad407762a64a92ce.zip
ufs: fix reserved blocks check
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 <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/balloc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index d642cc0a8271..52d1ef415f6f 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -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)