From: Al Viro Date: Wed, 14 Jun 2017 19:41:17 +0000 (-0400) Subject: ufs: fix reserved blocks check X-Git-Tag: v5.15~11092^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b451cec4bbd913688f5381efad407762a64a92ce;p=platform%2Fkernel%2Flinux-starfive.git 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 --- diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index d642cc0..52d1ef4 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)