Messages in this thread | | | Date | Fri, 22 Jan 1999 18:28:30 -0500 (EST) | From | "Adam D. Bradley" <> | Subject | Re: How is quota implemented? |
| |
On Fri, 22 Jan 1999, Steen Suder wrote:
> I'm trying to find out how quota is implemented. > I know about kernel options and such, but can find out if the kernel > maintains some sort of table in mem or if it's a file...
If I remember correctly, the Linux quota system works (in principle anyway) a lot like the 4.4BSD quota system. See "The Design and Implementation of the 4.4BSD Operating System" by McKusick et al [1] if you want a technical discussion.
Short version: there are two files, "quota.user" and "quota.group" that store per-user and per-group (respectively) allocated block counts along with the hard and soft limits. Since updating these every time a user allocates or frees a block would be slow, the kernel maintains a cache in memory using the "dquot" structure. This works like any other cache - when someone's actively allocating/freeing blocks, their dquot is in memory; after some time passes and/or other people busy the quota system, the record gets flushed out to the disk files. This is why shutdown scripts have to disable quotas before they unmount filesystems - disabling the quota system forces the "cache" to be flushed.
It is, of course, also important that the quota.* files be correct before the quota subsystem is started, so it knows how much each user/group already has allocated; if your system crashes without a clean quota shutdown, the on-disk values may be inconsistent and need to be regenerated (which is time-consuming for a traditional FS, although a JFS or LFS can handle this much faster).
Hope that helps! Adam
[1] - if you want to help out a starving graduate student, buy it from Amazon.com through my "recommended reading" page: http://www.cs.bu.edu/students/grads/artdodge/books/ -- Your lives aren't small, but \\ Adam Davenport Bradley, Grad Student you're living them in a small \\ Boston University Computer Science way. Live openly and expansively! \\ artdodge@cs.bu.edu 353-8921/MCS211 II Cor 6:12-13 (The Message) <>< \\ http://www.netwinder.org/~artdodge
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |