[PATCH]Fix disk free reporting if quota returns a block size other than 512
Jeremy Allison
jra at samba.org
Wed Jan 27 21:02:10 UTC 2016
On Tue, Jan 26, 2016 at 09:12:00PM +0200, Uri Simchoni wrote:
> Now that the patch-set that this fix is built upon is in master, can
> I get a review please?
>
> Re-attaching the patch for convenience...
LGTM. Pushed !
> On 01/19/2016 03:06 PM, Uri Simchoni wrote:
> >This is a fix for https://bugzilla.samba.org/show_bug.cgi?id=11681
> >
> >The fix is based on my submitted quota/dfree refactoring.
> >
> >Review appreciated.
> >
> >Thanks,
> >Uri
> >
>
> From 346244cb35444ab61414b0a5000149090949a931 Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Tue, 19 Jan 2016 14:57:16 +0200
> Subject: [PATCH 1/2] smbd: show correct disk size for different quota and
> dfree block sizes
>
> When file system stats (VFS disk_free_fn) and quota (VFS get_quota_fn)
> return different block sizes, normalize values before comparing.
>
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=11681
>
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
> source3/smbd/dfree.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
> index 62d2ea4..765fbe6 100644
> --- a/source3/smbd/dfree.c
> +++ b/source3/smbd/dfree.c
> @@ -124,7 +124,14 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
> }
>
> if (disk_quotas(conn, path, &bsize_q, &dfree_q, &dsize_q)) {
> - (*bsize) = bsize_q;
> + uint64_t min_bsize = MIN(*bsize, bsize_q);
> +
> + (*dfree) = (*dfree) * (*bsize) / min_bsize;
> + (*dsize) = (*dsize) * (*bsize) / min_bsize;
> + dfree_q = dfree_q * bsize_q / min_bsize;
> + dsize_q = dsize_q * bsize_q / min_bsize;
> +
> + (*bsize) = min_bsize;
> (*dfree) = MIN(*dfree,dfree_q);
> (*dsize) = MIN(*dsize,dsize_q);
> }
> --
> 2.4.3
>
>
> From 33be733bb708765e2bcf7abce9e74e176079f49f Mon Sep 17 00:00:00 2001
> From: Uri Simchoni <uri at samba.org>
> Date: Tue, 19 Jan 2016 14:38:03 +0200
> Subject: [PATCH 2/2] selftest: add test case for different quote/dfree block
> size
>
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=11681
>
> Signed-off-by: Uri Simchoni <uri at samba.org>
> ---
> source3/script/tests/test_dfree_quota.sh | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/source3/script/tests/test_dfree_quota.sh b/source3/script/tests/test_dfree_quota.sh
> index 8ae63f9..356fc2b 100755
> --- a/source3/script/tests/test_dfree_quota.sh
> +++ b/source3/script/tests/test_dfree_quota.sh
> @@ -64,6 +64,8 @@ trygrp1:g$gid:block size = 4096:hard limit = 60:soft limit = 60:cur blocks = 55
> trygrp2:df:block size = 4096:disk free = 10:disk size = 80
> trygrp2:u$uid:block size = 4096:hard limit = 0:soft limit = 0:cur blocks = 41
> trygrp2:g$gid:block size = 4096:hard limit = 60:soft limit = 60:cur blocks = 56
> +blksize:df:block size = 512:disk free = 614400:disk size = 614400
> +blksize:u$uid:block size = 1024:hard limit = 512000:soft limit = 0:cur blocks = 0
> ABC
> }
>
> @@ -170,5 +172,8 @@ test_smbclient_dfree "Test quota->dfree inode hard limit" "subdir1" "ihlimit sub
> test_smbclient_dfree "Test quota->dfree err try group" "subdir1" "trygrp1 subdir1" "240 1024. 20" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
> test_smbclient_dfree "Test quota->dfree no-quota try group" "subdir1" "trygrp2 subdir1" "240 1024. 16" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
>
> +#block size different in quota and df systems
> +test_smbclient_dfree "Test quota->dfree different block size" "subdir1" "blksize subdir1" "307200 1024. 307200" -U$USERNAME%$PASSWORD --option=clientmaxprotocol=SMB3 || failed=`expr $failed + 1`
> +
> setup_conf
> exit $failed
> --
> 2.4.3
>
More information about the samba-technical
mailing list