default quota limits in linux (via quotactl())
Hi Alexander and *,
I would like linux to handle default quota limits like NTFS 5 do it.
So if a new user is added to the system and start to own disk space on a filesystem he should get the default quotas for the specified FS as his own quotas.
Now a new user has unlimited disk space until root explicit sets quota limits for this user.
I have searched in google to find another unix witch allready implements this feature, but I didn't find any. So I decided to add two (four) new cmd's to quotactl(),
Q_SETDEFQUOTAQ_GETDEFQUOTA
and for the XFS Quotas
Q_XSETDEFQLIMQ_XGETDEFQUOTA
this call should take the same paramter's as the Q_GETQUOTA /Q_XGETQUOTA .. cmd's but the uid/gid should be ignored here and the filesystem defaults should be get or set.
I think this should be an easy task to be implemented in the filesystems witch allready support quotas.
I attach a patch witch modify the quotactl system call for this.
the implemetation inside the filesystems, should be done by the maintainers:-)
PS: I'm currently using XFS and it would be very cool if the default quota limits could implemented very fast...:-)
I hope I will get feedback :)
thanks anyway...
please cc me: in all replies:-)
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <[email protected]>
include/linux/dqblk_xfs.h +2 -1
@@ -46,7 +46,8 @@#define Q_XSETQLIM XQM_CMD(0x4)/* set disk limits */ #define Q_XGETQSTAT XQM_CMD(0x5)/* get quota subsystem status */ #define Q_XQUOTARM XQM_CMD(0x6)/* free disk space used by dquots */ - +#define Q_XGETDEFQUOTA XQM_CMD(0x7)/* get default disk limits and usage */ +#define Q_XSETDEFQLIM XQM_CMD(0x8)/* set default disk limits */ /* * fs_disk_quota structure: *
include/linux/quota.h +14 -8
@@ -80,14 +80,16 @@ extern spinlock_t dq_data_lock;#define SUBCMDSHIFT 8#define QCMD (cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) -#define Q_SYNC 0x800001/* sync disk copy of a filesystems quotas */ -#define Q_QUOTAON 0x800002/* turn quotas on */ -#define Q_QUOTAOFF 0x800003/* turn quotas off */ -#define Q_GETFMT 0x800004/* get quota format used on given filesystem */ -#define Q_GETINFO 0x800005/* get information about quota files */ -#define Q_SETINFO 0x800006/* set information about quota files */ -#define Q_GETQUOTA 0x800007/* get user quota structure */ -#define Q_SETQUOTA 0x800008/* set user quota structure */ +#define Q_SYNC 0x800001/* sync disk copy of a filesystems quotas */ +#define Q_QUOTAON 0x800002/* turn quotas on */ +#define Q_QUOTAOFF 0x800003/* turn quotas off */ +#define Q_GETFMT 0x800004/* get quota format used on given filesystem */ +#define Q_GETINFO 0x800005/* get information about quota files */ +#define Q_SETINFO 0x800006/* set information about quota files */ +#define Q_GETQUOTA 0x800007/* get user quota structure */ +#define Q_SETQUOTA 0x800008/* set user quota structure */ +#define Q_GETDEFQUOTA 0x800009/* get default user quota structure */ +#define Q_SETDEFQUOTA 0x80000A/* set default user quota structure */ /* * Quota structure used for communication with userspace via quotactl
@@ -261,10 +263,14 @@ struct quotactl_ops {int (*set_info)(struct super_block *,int ,struct if_dqinfo *);int (*get_dqblk)(struct super_block *,int ,qid_t ,struct if_dqblk *);int (*set_dqblk)(struct super_block *,int ,qid_t ,struct if_dqblk *); +int (*get_defdqblk)(struct super_block *,int ,struct if_dqblk *); +int (*set_defdqblk)(struct super_block *,int ,struct if_dqblk *);int (*get_xstate)(struct super_block *,struct fs_quota_stat *);int (*set_xstate)(struct super_block *,unsigned int ,int );int (*get_xquota)(struct super_block *,int ,qid_t ,struct fs_disk_quota *);int (*set_xquota)(struct super_block *,int ,qid_t ,struct fs_disk_quota *); +int (*get_xdefquota)(struct super_block *,int ,struct fs_disk_quota *); +int (*set_xdefquota)(struct super_block *,int ,struct fs_disk_quota *); };struct quota_format_type {
fs/quota.c +50 -0
80 lines not on this page · raw message
Hi,
Quoted 5 lines · Stefan (metze) Metzmacher
I would like linux to handle default quota limits like NTFS 5 do it.
So if a new user is added to the system and start to own disk space on a filesystem he
should get the default quotas for the specified FS as his own quotas.
That's a user-space problem. A new user typically won't have a writable area within /home until the sysadmin has created the new home directory, so it's really up to the sysadmin to make sure that the quota for the home filesystem has been set at the same time.
Quoted 3 lines
I have searched in google to find another unix witch allready implements this feature,
but I didn't find any.
The kernel doesn't need it --- just do it in the user-space user config tool.
Cheers,
Stephen
Quoted 6 lines · Stephen C. Tweedie
Hi,
Quoted 2 lines · Stefan (metze) Metzmacher
I would like linux to handle default quota limits like NTFS 5 do it.
Quoted 8 lines
Quoted 3 lines
So if a new user is added to the system and start to own disk space on a filesystem he
should get the default quotas for the specified FS as his own quotas.That's a user-space problem. A new user typically won't have a writable area within /home until the sysadmin has created the new home directory, so it's really up to the sysadmin to make sure that the quota for the home filesystem has been set at the same time.
what is with a filesystem in witch the user has write access because of group memberships.
or/and the user's/group's are stored in LDAP:
then user are added directly to the LDAP diretory and they maybe available on a large amount of servers and it's a pain to manage the quotas for each filesystem on each server.
also it's hard to handle changed group memberships...
I think there's a good reason that NTFS 5 support default quota limits.
And it would be cool if linux would support them too.
it's not hard to implement and it would make thinks much easier to handle in large environments!
Quoted 6 lines
Quoted 3 lines
I have searched in google to find another unix witch allready implements this feature,
but I didn't find any.The kernel doesn't need it --- just do it in the user-space user config tool
There're many things, witch are not inevitable needed in the kernel, but they all make the life easier.
Would it really hurt that much if the kernel would support it?
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <[email protected]>
Quoted 4 lines · Stephen C. Tweedie
That's a user-space problem. A new user typically won't have a writable area within /home until the sysadmin has created the new home directory, so it's really up to the sysadmin to make sure that the quota for the home filesystem has been set at the same time.
What is if we have 500.000 users and 300.000 group in LDAP
and set up a new server, witch is intended to store data from ~1000 users 500 group
should the admin really run setquota ... for each of the 500.000 users and 300.000 group
that's are 800.000 quota entries in the filesystem and only 1500 are really used
ans this entries cost disk space too, so if we have two default entries (one for users and one for groups) then only every user witch really uses this filesystem would get a quota entry when he starts to own diskspace on this filesystem and we would have only 1502 quota entries stored on disk!
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <[email protected]>
Quoted 14 lines · Stefan (metze) Metzmacher
Quoted 4 lines · Stephen C. Tweedie
That's a user-space problem. A new user typically won't have a writable area within /home until the sysadmin has created the new home directory, so it's really up to the sysadmin to make sure that the quota for the home filesystem has been set at the same time.
What is if we have 500.000 users and 300.000 group in LDAP
and set up a new server, witch is intended to store data from ~1000 users 500 group
should the admin really run setquota ... for each of the 500.000 users and 300.000 group
Quoted 7 lines
that's are 800.000 quota entries in the filesystem and only 1500 are really used
ans this entries cost disk space too, so if we have two default entries (one for users and one for groups) then only every user witch really uses this filesystem would get a quota entry when he starts to own diskspace on this filesystem and we would have only 1502 quota entries stored on disk!
It still isn't a kernel problem, but a user-space one. You need to get or write a PAM module, that will check wether quotas are set for user being authenticated and if not, set them. You could even store the qutoas in the LDAP (or some other) database and check them when a user logs in...
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Chris Wedgwood
Quoted 5 lines · Jan Hudec
It still isn't a kernel problem, but a user-space one. You need to get or write a PAM module, that will check wether quotas are set for user being authenticated and if not, set them. You could even store the qutoas in the LDAP (or some other) database and check them when a user logs in...
consider 1 million users where only a small percentage of them will ever write to the fs ... why even store 1 million quota values needlessly at all?
While all the 1 milion users actualy ever LOG IN that site?
And... do they ever log into that site AT THE SAME MOMENT?
Quoted 1 line
surely the argument for a default here isn't a terrible one?
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Chris Wedgwood
Quoted 1 line · Jan Hudec
While all the 1 milion users actualy ever LOG IN that site?
what?
So you can only setquota for the users that actualy log in.
Quoted 1 line
consider a mail server (or series thereof) and quota for mail...
Well, it get's complicated, but you still can setquota in the local delivery process... I know it get's a bit complicated...
Quoted 4 lines
Quoted 1 line
And... do they ever log into that site AT THE SAME MOMENT?
presumably not ... most machines only allow 995,000 simultaneous logins unless you have an extra 2M in your 386
Because you could remove the quotas again for users, that logged in, but their quota is still the default...
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · Chris Wedgwood
Quoted 1 line · Jan Hudec
So you can only setquota for the users that actualy log in
the API allows you to set quota for any valid uid/gid
Yes, it does. But since there is many more valid users than those actualy using the system, you don't want to... And a logged in user is sure valid, so no problem there, right?
Quoted 5 lines
Quoted 2 lines
Well, it get's complicated, but you still can setquota in the local delivery process... I know it get's a bit complicated...
sure, this is a perfectly legitimate argument and a fairly reasonable solution to this case
If it finaly got too complicated, you could add a simple code to kernel, that would run_usermodehelper and provide a user mode program to fix things up. That might even get a chance of being accepted. (And it would be more flexible since it can get the default quota from LDAP etc...)
However as long as it's manageable in userspace, do it in userspace... All services that log in users can use PAM nowadays, so there it is quite easy and all services that can run on behalf of users have some hooks where the fixup command can be run too.
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>
Quoted 14 lines · Jan Hudec
Quoted 5 lines · Chris Wedgwood
Quoted 1 line · Jan Hudec
So you can only setquota for the users that actualy log in
the API allows you to set quota for any valid uid/gid
Yes, it does. But since there is many more valid users than those actualy using the system, you don't want to... And a logged in user is sure valid, so no problem there, right?
Quoted 3 lines
Quoted 2 lines
Well, it get's complicated, but you still can setquota in the local delivery process... I know it get's a bit complicated...
Quoted 7 lines
Quoted 2 lines
sure, this is a perfectly legitimate argument and a fairly reasonable solution to this case
If it finaly got too complicated, you could add a simple code to kernel, that would
run_usermodehelperand provide a user mode program to fix things up. That might even get a chance of being accepted. (And it would be more flexible since it can get the default quota from LDAP etc...)
is there an example( another place in the kernel where the kernel callback a userspace tool)
can you point me to the place (the function) where the quota entry/object will be created for new users, so this should be the location where the userspace tool should be callback...
that would be a cool solution, witch I could accept too:-)
metze
-----------------------------------------------------------------------------
Stefan "metze" Metzmacher <[email protected]>
I believe that the hotplug stuff does this. When a new hotpluggable pci, usb etc... device is plugged into the system, it triggers /sbin/hotplug to run to look for the appropriate kernel module to provide a driver.
-Walt
Quoted 40 lines · Stefan (metze) Metzmacher
Quoted 14 lines · Jan Hudec
Quoted 5 lines · Chris Wedgwood
Quoted 1 line · Jan Hudec
So you can only setquota for the users that actualy log in
the API allows you to set quota for any valid uid/gid
Yes, it does. But since there is many more valid users than those actualy using the system, you don't want to... And a logged in user is sure valid, so no problem there, right?
Quoted 3 lines
Quoted 2 lines
Well, it get's complicated, but you still can setquota in the local delivery process... I know it get's a bit complicated...
Quoted 7 lines
Quoted 2 lines
sure, this is a perfectly legitimate argument and a fairly reasonable solution to this case
If it finaly got too complicated, you could add a simple code to kernel, that would
run_usermodehelperand provide a user mode program to fix things up. That might even get a chance of being accepted. (And it would be more flexible since it can get the default quota from LDAP etc...)is there an example( another place in the kernel where the kernel callback a userspace tool)
can you point me to the place (the function) where the quota entry/object will be created for new users, so this should be the location where the userspace tool should be callback...
that would be a cool solution, witch I could accept too:-)
metze
-----------------------------------------------------------------------------Stefan "metze" Metzmacher <[email protected]>
Quoted 1 line · Walt H
I believe that the hotplug stuff does this. When a new hotpluggable pci, usb etc... device is plugged into the system, it triggers
/sbin/hotplugto run to look for the appropriate kernel module to provide a driver.
I'll look at this...
is get_empty_dquot() or dqget() the right place to callback the user space tool?
Quoted 11 lines
Quoted 11 lines
Quoted 4 lines
If it finaly got too complicated, you could add a simple code to kernel, that would
run_usermodehelperand provide a user mode program to fix things up. That might even get a chance of being accepted. (And it would be more flexible since it can get the default quota from LDAP etc...)is there an example( another place in the kernel where the kernel callback a userspace tool) can you point me to the place (the function) where the quota entry/object will be created for new users, so this should be the location where the userspace tool should be callback...
that would be a cool solution, witch I could accept too:-)
Quoted 4 lines
Quoted 4 lines
metze
-----------------------------------------------------------------------------Stefan "metze" Metzmacher <[email protected]>
-----------------------------------------------
Stefan Metzmacher
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"stefan" == Stefan (metze) Metzmacher <[email protected]> writes:
Quoted 14 lines · Jan Hudec
Quoted 14 lines · Chris Wedgwood
Quoted 5 lines · Jan Hudec
Quoted 2 lines
So you can only setquota for the users that actualy log in
the API allows you to set quota for any valid uid/gid
Yes, it does. But since there is many more valid users than those actualy using the system, you don't want to... And a logged in user is sure valid, so no problem there, right?
Quoted 3 lines
Quoted 2 lines
Well, it get's complicated, but you still can setquota in the local delivery process... I know it get's a bit complicated...
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
sure, this is a perfectly legitimate argument and a fairly reasonable solution to this case
If it finaly got too complicated, you could add a simple code to kernel, that would
run_usermodehelperand provide a user mode program to fix things up. That might even get a chance of being accepted. (And it would be more flexible since it can get the default quota from LDAP etc...)
stefan> is there an example( another place in the kernel where the kernel stefan> callback a userspace tool)
devfsd <-> devfs
/me runs
Later, Juan.
Signature · 2 lines
In theory, practice and theory are the same, but in practice they are different -- Larry McVoy