SOLARIS_2.6: Quotas

Douglas K. Fischer skeet at Bridgewater.EDU
Fri Feb 12 20:42:16 GMT 1999

I noticed some unusual behavior out of the quota support in 2.0.2. 

There are two issues I've found. The first one I have not had the chance
to investigate. The second, I have narrowed down the culprit I think, but
I lack sufficient C knowledge to properly correct it.

Issue One: Under previous versions (specifically 1.9.18p10) users were
allowed to exceed their soft limit as long as they did not exceed their
hard limit. Under 2.0.2, if a write operation begins below the soft limit
but then partway through reaches the soft limit (the hard limit is well
beyond reach), it stops right in the middle with the error:

Cannot create or replace FILENAME: The specified network resource or
device is no longer available.

If the soft limit is exceeded on the UNIX side, file operations will
continue as normal under samba until the hard limit is reached. The issue
seems to be crossing the soft limit boundary under samba.

Issue two: Under previous versions, if someone had disk utilization
between their soft and hard quota limits the disk space report would show
the true amount of disk space used and would show zero disk space free. In
2.0.2 in this situation, the disk space used reverts to a negative number
and space free shows the total partition space free.

Here's an example:
On 1.9.18p10 a user has soft limit of 100000 and hard limit of 125000.
With utilization at 93599, samba reports the following (obtained through
Win95 Explorer):

Disk space used: 95,846,400 bytes (91.4MB)  
Disk space free: 6,553,600 bytes (6.25MB)
Capacity:        102,400,000 bytes (97.6MB)

With utilization of 104711, we see:

Disk space used: 107,223,040 bytes (102MB)
Disk space free: 0 bytes (0 bytes)
Capacity:        107,223,040 bytes (102MB)

That is the correct behavior. Now, let's look at a system running 2.0.2
under a similar scenario. With soft limit of 1024 and hard limit of 1512
we see the following with utilization of 449:

Disk space used: 405,504 bytes (396KB)
Disk space free: 643,072 bytes (628KB)
Capacity:        1,048,576 bytes (1.00MB)

Now for the strangeness. If we have a utilization of 1212 here's what we

Disk space used: Q bytes (-225202176)
Disk space free: 226,250,752 bytes (215MB)
Capacity:        1,048,576 btyes (1.00MB)

None of these three values are correct.

Here's the debugging on the errored condition:
[1999/02/12 15:20:56, 5] smbd/quotas.c:disk_quotas(363)
  disk_quotas for path "." returning  bsize 512, dfree 4294966920, dsize

The problem is clearly in dfree. When I looked at quotas.c in the Solaris
code (starts around line 245) I see that dfree is calculated as:

*dfree = D.dqb_bsoftlimit - D.dqb_curblocks;   (line 351)

I added a debug right after this of:

DEBUG(5,("Soft limit is %.0f and current use is %.0f making free space

This produced an output of:

[1999/02/12 15:20:56, 5] smbd/quotas.c:disk_quotas(352)
  Soft limit is 2048 and current use is 2424 making free space 4294966920

The soft limit and current use are correct. For some reason the
calculation of dfree is messed up. Perhaps the reason is obvious, but I
don't know very much C. I do know that in 1.9.18p10 dfree was defined as
type int and is now defined as type SMB_BIG_UINT.

  Douglas K. Fischer    DFischer at Bridgewater.EDU      (540) 828 - 5343
  Network Systems Engineer   C. E. Shull Information Technology Center
  College Box 36        Bridgewater College      Bridgewater, VA 22812

More information about the samba mailing list