* default quota limits in linux (via quotactl())
@ 2003-01-27 14:41 Stefan (metze) Metzmacher
2003-01-27 16:22 ` Stephen C. Tweedie
0 siblings, 1 reply; 12+ messages in thread
From: Stefan (metze) Metzmacher @ 2003-01-27 14:41 UTC (permalink / raw)
To: viro
Cc: linux-fsdevel, sct, akpm, adilger, ext2-devel, jfs-discussion,
linux-xfs
[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]
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_SETDEFQUOTA
Q_GETDEFQUOTA
and for the XFS Quotas
Q_XSETDEFQLIM
Q_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 <metze@metzemix.de>
[-- Attachment #2: 2.5.59-defquota.diff --]
[-- Type: application/octet-stream, Size: 5785 bytes --]
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* --exclude=.* linux-2.5.59/include/linux/dqblk_xfs.h linux-2.5.59-MX/include/linux/dqblk_xfs.h
--- linux-2.5.59/include/linux/dqblk_xfs.h Fri Jan 17 03:22:26 2003
+++ linux-2.5.59-MX/include/linux/dqblk_xfs.h Thu Jan 23 12:57:31 2003
@@ -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:
*
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* --exclude=.* linux-2.5.59/include/linux/quota.h linux-2.5.59-MX/include/linux/quota.h
--- linux-2.5.59/include/linux/quota.h Fri Jan 17 03:22:25 2003
+++ linux-2.5.59-MX/include/linux/quota.h Thu Jan 23 12:56:23 2003
@@ -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 {
diff -Npur --exclude=CVS --exclude=*.bak --exclude=*.o --exclude=*.po --exclude=.#* --exclude=.* linux-2.5.59/fs/quota.c linux-2.5.59-MX/fs/quota.c
--- linux-2.5.59/fs/quota.c Fri Jan 17 03:22:48 2003
+++ linux-2.5.59-MX/fs/quota.c Thu Jan 23 12:43:40 2003
@@ -50,6 +50,14 @@ static int check_quotactl_valid(struct s
if (!sb->s_qcop->get_dqblk)
return -ENOSYS;
break;
+ case Q_SETDEFQUOTA:
+ if (!sb->s_qcop->set_defdqblk)
+ return -ENOSYS;
+ break;
+ case Q_GETDEFQUOTA:
+ if (!sb->s_qcop->get_defdqblk)
+ return -ENOSYS;
+ break;
case Q_SYNC:
if (!sb->s_qcop->quota_sync)
return -ENOSYS;
@@ -72,6 +80,14 @@ static int check_quotactl_valid(struct s
if (!sb->s_qcop->get_xquota)
return -ENOSYS;
break;
+ case Q_XSETDEFQLIM:
+ if (!sb->s_qcop->set_xdefquota)
+ return -ENOSYS;
+ break;
+ case Q_XGETDEFQUOTA:
+ if (!sb->s_qcop->get_xdefquota)
+ return -ENOSYS;
+ break;
default:
return -EINVAL;
}
@@ -84,6 +100,8 @@ static int check_quotactl_valid(struct s
case Q_SETINFO:
case Q_SETQUOTA:
case Q_GETQUOTA:
+ case Q_SETDEFQUOTA:
+ case Q_GETDEFQUOTA:
/* This is just informative test so we are satisfied without a lock */
if (!sb_has_quota_enabled(sb, type))
return -ESRCH;
@@ -166,6 +184,22 @@ static int do_quotactl(struct super_bloc
return -EFAULT;
return sb->s_qcop->set_dqblk(sb, type, id, &idq);
}
+ case Q_GETDEFQUOTA: {
+ struct if_dqblk idq;
+
+ if ((ret = sb->s_qcop->get_defdqblk(sb, type, &idq)))
+ return ret;
+ if (copy_to_user(addr, &idq, sizeof(idq)))
+ return -EFAULT;
+ return 0;
+ }
+ case Q_SETDEFQUOTA: {
+ struct if_dqblk idq;
+
+ if (copy_from_user(&idq, addr, sizeof(idq)))
+ return -EFAULT;
+ return sb->s_qcop->set_defdqblk(sb, type, &idq);
+ }
case Q_SYNC:
return sb->s_qcop->quota_sync(sb, type);
@@ -198,6 +232,22 @@ static int do_quotactl(struct super_bloc
struct fs_disk_quota fdq;
if ((ret = sb->s_qcop->get_xquota(sb, type, id, &fdq)))
+ return ret;
+ if (copy_to_user(addr, &fdq, sizeof(fdq)))
+ return -EFAULT;
+ return 0;
+ }
+ case Q_XSETDEFQLIM: {
+ struct fs_disk_quota fdq;
+
+ if (copy_from_user(&fdq, addr, sizeof(fdq)))
+ return -EFAULT;
+ return sb->s_qcop->set_xdefquota(sb, type, &fdq);
+ }
+ case Q_XGETDEFQUOTA: {
+ struct fs_disk_quota fdq;
+
+ if ((ret = sb->s_qcop->get_xdefquota(sb, type, &fdq)))
return ret;
if (copy_to_user(addr, &fdq, sizeof(fdq)))
return -EFAULT;
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: default quota limits in linux (via quotactl())
2003-01-27 14:41 default quota limits in linux (via quotactl()) Stefan (metze) Metzmacher
@ 2003-01-27 16:22 ` Stephen C. Tweedie
2003-01-28 6:43 ` Stefan (metze) Metzmacher
2003-01-28 6:54 ` Stefan (metze) Metzmacher
0 siblings, 2 replies; 12+ messages in thread
From: Stephen C. Tweedie @ 2003-01-27 16:22 UTC (permalink / raw)
To: Stefan (metze) Metzmacher
Cc: viro, linux-fsdevel, akpm, Andreas Dilger, ext2-devel,
jfs-discussion, linux-xfs
Hi,
On Mon, 2003-01-27 at 14:41, Stefan (metze) Metzmacher wrote:
> 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.
> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: default quota limits in linux (via quotactl())
2003-01-27 16:22 ` Stephen C. Tweedie
@ 2003-01-28 6:43 ` Stefan (metze) Metzmacher
2003-01-28 6:54 ` Stefan (metze) Metzmacher
1 sibling, 0 replies; 12+ messages in thread
From: Stefan (metze) Metzmacher @ 2003-01-28 6:43 UTC (permalink / raw)
To: Stephen C. Tweedie
Cc: viro, linux-fsdevel, akpm, Andreas Dilger, ext2-devel,
jfs-discussion, linux-xfs, Alexander Bokovoy
At 16:22 27.01.2003 +0000, Stephen C. Tweedie wrote:
>Hi,
>
>On Mon, 2003-01-27 at 14:41, Stefan (metze) Metzmacher wrote:
>
> > 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.
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!
> > 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 <metze@metzemix.de>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: default quota limits in linux (via quotactl())
2003-01-27 16:22 ` Stephen C. Tweedie
2003-01-28 6:43 ` Stefan (metze) Metzmacher
@ 2003-01-28 6:54 ` Stefan (metze) Metzmacher
2003-01-28 9:32 ` Jan Hudec
1 sibling, 1 reply; 12+ messages in thread
From: Stefan (metze) Metzmacher @ 2003-01-28 6:54 UTC (permalink / raw)
To: Stephen C. Tweedie, Stefan (metze) Metzmacher
Cc: viro, linux-fsdevel, akpm, Andreas Dilger, ext2-devel,
jfs-discussion, linux-xfs, Alexander Bokovoy
At 16:22 27.01.2003 +0000, Stephen C. Tweedie wrote:
>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 <metze@metzemix.de>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: default quota limits in linux (via quotactl())
2003-01-28 6:54 ` Stefan (metze) Metzmacher
@ 2003-01-28 9:32 ` Jan Hudec
[not found] ` <20030128094014.GA23257@f00f.org>
0 siblings, 1 reply; 12+ messages in thread
From: Jan Hudec @ 2003-01-28 9:32 UTC (permalink / raw)
To: Stefan (metze) Metzmacher
Cc: Stephen C. Tweedie, viro, linux-fsdevel, akpm, Andreas Dilger,
ext2-devel, jfs-discussion, linux-xfs, Alexander Bokovoy
On Tue, Jan 28, 2003 at 07:54:08AM +0100, Stefan (metze) Metzmacher wrote:
> At 16:22 27.01.2003 +0000, Stephen C. Tweedie wrote:
> >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!
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 <bulb@ucw.cz>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2003-01-29 16:34 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-27 14:41 default quota limits in linux (via quotactl()) Stefan (metze) Metzmacher
2003-01-27 16:22 ` Stephen C. Tweedie
2003-01-28 6:43 ` Stefan (metze) Metzmacher
2003-01-28 6:54 ` Stefan (metze) Metzmacher
2003-01-28 9:32 ` Jan Hudec
[not found] ` <20030128094014.GA23257@f00f.org>
2003-01-28 9:46 ` Jan Hudec
[not found] ` <20030128101310.GA23320@f00f.org>
2003-01-28 10:57 ` Jan Hudec
[not found] ` <20030128112034.GA23731@f00f.org>
2003-01-28 12:37 ` Jan Hudec
2003-01-28 13:32 ` Stefan (metze) Metzmacher
2003-01-28 15:18 ` Walt H
2003-01-28 15:27 ` Stefan Metzmacher
2003-01-29 16:34 ` Juan Quintela
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox