[PATCH] Do not ignore the block size of the dfree command - brc #11403

Andreas Schneider asn at samba.org
Fri Jul 17 07:54:38 UTC 2015


Hi,

attached find a patch to fix https://bugzilla.samba.org/show_bug.cgi?id=11403

Please review and push ...


Thanks,


	-- andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
>From ac65998dd7928d2fda2446c25c1558d9fa123cf4 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Fri, 17 Jul 2015 09:35:11 +0200
Subject: [PATCH 1/2] s3-smbd: Leave sys_disk_free() if dfree command is used

If we have a broken system which reports incorrect sizes we provide the
'dfree command'. This command makes sure Samba gets the correct values.
However after that we call the quota command which then reports the
broken values. The dfree command should take care to provide the correct
values and in case of quota's it should also calculate the quote
correctly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11403

Pair-Programmed-With: Michael Adam <obnox at samba.org>
Signed-off-by: Andreas Schneider <asn at samba.org>
Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/smbd/dfree.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index bcefea5..7b462e4 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -117,12 +117,14 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 				return (uint64_t)-1;
 			}
 		}
-	} else {
-		if (sys_fsusage(path, dfree, dsize) != 0) {
-			DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
-				strerror(errno) ));
-			return (uint64_t)-1;
-		}
+
+		goto dfree_done;
+	}
+
+	if (sys_fsusage(path, dfree, dsize) != 0) {
+		DEBUG (0, ("disk_free: sys_fsusage() failed. Error was : %s\n",
+			strerror(errno) ));
+		return (uint64_t)-1;
 	}
 
 	if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {
@@ -146,6 +148,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 		*dfree = MAX(1,*dfree);
 	}
 
+dfree_done:
 	disk_norm(bsize, dfree, dsize);
 
 	if ((*bsize) < 1024) {
-- 
2.4.5


>From 14c3168343aefb982deba64ed097ede0c7ca1838 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Fri, 17 Jul 2015 09:37:52 +0200
Subject: [PATCH 2/2] s3-smbd: Remove the global dfree_broken variable

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
---
 source3/smbd/dfree.c   | 1 +
 source3/smbd/globals.c | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c
index 7b462e4..0b89a29 100644
--- a/source3/smbd/dfree.c
+++ b/source3/smbd/dfree.c
@@ -57,6 +57,7 @@ uint64_t sys_disk_free(connection_struct *conn, const char *path,
 	uint64_t bsize_q = 0;
 	uint64_t dsize_q = 0;
 	const char *dfree_command;
+	static bool dfree_broken = false;
 
 	(*dfree) = (*dsize) = 0;
 	(*bsize) = 512;
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 03339b7..a501234 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -31,9 +31,6 @@ int outstanding_aio_calls = 0;
 struct smbd_dmapi_context *dmapi_ctx = NULL;
 #endif
 
-
-bool dfree_broken = false;
-
 /* how many write cache buffers have been allocated */
 unsigned int allocated_write_caches = 0;
 
-- 
2.4.5



More information about the samba-technical mailing list