WARNING: dfree is broken on this system

James Mathiesen James_Mathiesen at ml.com
Fri Jun 25 13:57:55 GMT 1999


I'm running Samba 2.0.4b on Solaris for quite some time.  For as long as I
can remember I've been getting hundreds of messages like this per day:

	WARNING: dfree is broken on this system

I finally got around to tracking down the cause.  The message is generated
in disk_free() when fsusage() indicates that the size of the underlying
filesystem is zero blocks.

Well, I also have am-utils installed.  The amd mount points look like this:

	f_bsize      1024
	f_frsize     1024
	f_blocks     0
	f_bfree      0
	f_bavail     0
	f_files      4294967295
	f_ffree      4294967295
	f_favail     4294967295
	f_fsid       51118081
	f_basetype   'nfs'
	f_flag       0
	f_namemax    4294967295
	f_fstr       ''

So there's at least one example of the total number of blocks on a filesystem
validly being zero.  Attached is the patch I made, which adds to the statvfs
version of the code a check to set the size of the filesystem to 20MB if it
happens to be zero -- ie assume that statvfs will never succeed and return
incorrect information.  I haven't really convinced myself that this is the
correct solution.  Maybe it would be better to raise warnings in this area
iff underlying systems calls have failed -- otherwise take the returned data
as gospel and massage only as necessary to meet CIFS semantics.

james

Index: dfree.c
===================================================================
RCS file: /src/local/repository/usr/local/pkg/samba/source/smbd/dfree.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- dfree.c	1999/03/09 19:25:04	1.1.1.2
+++ dfree.c	1999/06/25 13:46:33	1.3
@@ -162,15 +162,32 @@
 	adjust_blocks ((SMB_BIG_UINT)(B), fsd.f_frsize ? (SMB_BIG_UINT)fsd.f_frsize : (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512)
 
 #ifdef STAT_STATVFS64
-	struct statvfs64 fsd;
-	if (statvfs64(path, &fsd) < 0) return -1;
+# define STATVFS statvfs64
 #else
-	struct statvfs fsd;
-	if (statvfs(path, &fsd) < 0) return -1;
+# define STATVFS statvfs
 #endif
 
+	struct STATVFS fsd;
+	if ( STATVFS(path, &fsd) < 0 ) return -1;
+
+	/*
+	** amd from am-utils typically returns
+	**
+	**	 f_blocks == f_bfree == f_bavail == 0
+	**
+	** on automount points.  This gets flagged as sign of a broken
+	** dfree implementation in disk_free, but in this case it isn't.
+	** So if we notice we have a zero size filesystem, pretend it
+	** is 20MB.
+	*/
+	if ( fsd.f_blocks == 0 ) {
+		fsd.f_bsize = fsd.f_frsize = 1024;
+		fsd.f_blocks = 20*1024;
+	}
+
 	/* f_frsize isn't guaranteed to be supported.  */
 
+# undef STATVFS
 #endif /* STAT_STATVFS */
 
 #ifndef CONVERT_BLOCKS


More information about the samba-technical mailing list