Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs Bring in a copy of ffs_quota2_mount() for refere...



details:   https://anonhg.NetBSD.org/src/rev/278ca8d17a43
branches:  trunk
changeset: 788899:278ca8d17a43
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jul 28 01:22:55 2013 +0000

description:
Bring in a copy of ffs_quota2_mount() for reference.
Add stuff to struct lfs that it needs to initialize.
Clear these fields in mount as there's no on-disk support for quota2;
but this increases the chances of being able to add it (or something
like it) in the future.

diffstat:

 sys/ufs/lfs/lfs.h         |   8 ++++-
 sys/ufs/lfs/lfs_vfsops.c  |  12 ++++++-
 sys/ufs/lfs/ulfs_extern.h |   3 +-
 sys/ufs/lfs/ulfs_quota2.c |  77 +++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 94 insertions(+), 6 deletions(-)

diffs (168 lines):

diff -r 445d24570c52 -r 278ca8d17a43 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Sun Jul 28 01:10:49 2013 +0000
+++ b/sys/ufs/lfs/lfs.h Sun Jul 28 01:22:55 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.159 2013/07/28 01:10:49 dholland Exp $       */
+/*     $NetBSD: lfs.h,v 1.160 2013/07/28 01:22:55 dholland Exp $       */
 
 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
 /*  from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp  */
@@ -1006,6 +1006,12 @@
        int um_maxsymlinklen;
        int um_dirblksiz;
        u_int64_t um_maxfilesize;
+
+       /* Stuff used by quota2 code, not currently operable */
+       unsigned lfs_use_quota2 : 1;
+       uint32_t lfs_quota_magic;
+       uint8_t lfs_quota_flags;
+       uint64_t lfs_quotaino[2];
 #endif
 };
 
diff -r 445d24570c52 -r 278ca8d17a43 sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c  Sun Jul 28 01:10:49 2013 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c  Sun Jul 28 01:22:55 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vfsops.c,v 1.310 2013/07/28 01:10:49 dholland Exp $        */
+/*     $NetBSD: lfs_vfsops.c,v 1.311 2013/07/28 01:22:55 dholland Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.310 2013/07/28 01:10:49 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.311 2013/07/28 01:22:55 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_lfs.h"
@@ -1003,6 +1003,14 @@
        fs->um_dirblksiz = LFS_DIRBLKSIZ;
        fs->um_maxfilesize = fs->lfs_maxfilesize;
 
+       /* quota stuff */
+       /* XXX: these need to come from the on-disk superblock to be used */
+       fs->lfs_use_quota2 = 0;
+       fs->lfs_quota_magic = 0;
+       fs->lfs_quota_flags = 0;
+       fs->lfs_quotaino[0] = 0;
+       fs->lfs_quotaino[1] = 0;
+
        /* Initialize the mount structure. */
        dev = devvp->v_rdev;
        mp->mnt_data = ump;
diff -r 445d24570c52 -r 278ca8d17a43 sys/ufs/lfs/ulfs_extern.h
--- a/sys/ufs/lfs/ulfs_extern.h Sun Jul 28 01:10:49 2013 +0000
+++ b/sys/ufs/lfs/ulfs_extern.h Sun Jul 28 01:22:55 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_extern.h,v 1.9 2013/07/28 01:10:49 dholland Exp $ */
+/*     $NetBSD: ulfs_extern.h,v 1.10 2013/07/28 01:22:55 dholland Exp $        */
 /*  from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp  */
 
 /*-
@@ -158,6 +158,7 @@
 
 /* ulfs_quota2.c */
 int    lfsquota2_umount(struct mount *, int);
+int    lfs_quota2_mount(struct mount *);
 
 /* ulfs_vfsops.c */
 void   ulfs_init(void);
diff -r 445d24570c52 -r 278ca8d17a43 sys/ufs/lfs/ulfs_quota2.c
--- a/sys/ufs/lfs/ulfs_quota2.c Sun Jul 28 01:10:49 2013 +0000
+++ b/sys/ufs/lfs/ulfs_quota2.c Sun Jul 28 01:22:55 2013 +0000
@@ -1,5 +1,6 @@
-/*     $NetBSD: ulfs_quota2.c,v 1.9 2013/07/28 01:10:49 dholland Exp $ */
+/*     $NetBSD: ulfs_quota2.c,v 1.10 2013/07/28 01:22:55 dholland Exp $        */
 /*  from NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer Exp  */
+/*  from NetBSD: ffs_quota2.c,v 1.4 2011/06/12 03:36:00 rmind Exp  */
 
 /*-
   * Copyright (c) 2010 Manuel Bouyer
@@ -28,7 +29,7 @@
   */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.9 2013/07/28 01:10:49 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.10 2013/07/28 01:22:55 dholland Exp $");
 
 #include <sys/buf.h>
 #include <sys/param.h>
@@ -1560,3 +1561,75 @@
 {
        return 0;
 }
+
+int
+lfs_quota2_mount(struct mount *mp)
+{
+       struct ulfsmount *ump = VFSTOULFS(mp);
+       struct lfs *fs = ump->um_lfs;
+       int error = 0;
+       struct vnode *vp;
+       struct lwp *l = curlwp;
+
+       if ((fs->lfs_use_quota2) == 0)
+               return 0;
+
+       fs->um_flags |= ULFS_QUOTA2;
+       ump->umq2_bsize = fs->lfs_bsize;
+       ump->umq2_bmask = fs->lfs_bmask;
+       if (fs->lfs_quota_magic != Q2_HEAD_MAGIC) {
+               printf("%s: Invalid quota magic number\n",
+                   mp->mnt_stat.f_mntonname);
+               return EINVAL;
+       }
+        if ((fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_USRQUOTA)) &&
+            fs->lfs_quotaino[ULFS_USRQUOTA] == 0) {
+                printf("%s: no user quota inode\n",
+                   mp->mnt_stat.f_mntonname); 
+                error = EINVAL;
+        }
+        if ((fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_GRPQUOTA)) &&
+            fs->lfs_quotaino[ULFS_GRPQUOTA] == 0) {
+                printf("%s: no group quota inode\n",
+                   mp->mnt_stat.f_mntonname);
+                error = EINVAL;
+        }
+       if (error)
+               return error;
+
+        if (fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_USRQUOTA) &&
+           ump->um_quotas[ULFS_USRQUOTA] == NULLVP) {
+               error = VFS_VGET(mp, fs->lfs_quotaino[ULFS_USRQUOTA], &vp);
+               if (error) {
+                       printf("%s: can't vget() user quota inode: %d\n",
+                           mp->mnt_stat.f_mntonname, error);
+                       return error;
+               }
+               ump->um_quotas[ULFS_USRQUOTA] = vp;
+               ump->um_cred[ULFS_USRQUOTA] = l->l_cred;
+               mutex_enter(vp->v_interlock);
+               vp->v_writecount++;
+               mutex_exit(vp->v_interlock);
+               VOP_UNLOCK(vp);
+       }
+        if (fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_GRPQUOTA) &&
+           ump->um_quotas[ULFS_GRPQUOTA] == NULLVP) {
+               error = VFS_VGET(mp, fs->lfs_quotaino[ULFS_GRPQUOTA], &vp);
+               if (error) {
+                       vn_close(ump->um_quotas[ULFS_USRQUOTA],
+                           FREAD|FWRITE, l->l_cred);
+                       printf("%s: can't vget() group quota inode: %d\n",
+                           mp->mnt_stat.f_mntonname, error);
+                       return error;
+               }
+               ump->um_quotas[ULFS_GRPQUOTA] = vp;
+               ump->um_cred[ULFS_GRPQUOTA] = l->l_cred;
+               mutex_enter(vp->v_interlock);
+               vp->v_vflag |= VV_SYSTEM;
+               vp->v_writecount++;
+               mutex_exit(vp->v_interlock);
+               VOP_UNLOCK(vp);
+       }
+       mp->mnt_flag |= MNT_QUOTA;
+       return 0;
+}



Home | Main Index | Thread Index | Old Index