Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/lfs Add lfs_ioctl vnode op, with ioctls to take over...



details:   https://anonhg.NetBSD.org/src/rev/12cf70791c13
branches:  trunk
changeset: 543387:12cf70791c13
user:      perseant <perseant%NetBSD.org@localhost>
date:      Mon Feb 24 08:42:49 2003 +0000

description:
Add lfs_ioctl vnode op, with ioctls to take over cleaner system call
functionality (not including segment clean, since that is now done
automatically as checkpoints happen).

diffstat:

 sys/ufs/lfs/lfs.h          |  15 ++++++++-
 sys/ufs/lfs/lfs_extern.h   |   8 ++++-
 sys/ufs/lfs/lfs_syscalls.c |  75 +++++++++++++++++++++++--------------------
 sys/ufs/lfs/lfs_vnops.c    |  78 ++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 136 insertions(+), 40 deletions(-)

diffs (truncated from 346 to 300 lines):

diff -r 76e6406a8a88 -r 12cf70791c13 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Mon Feb 24 08:34:30 2003 +0000
+++ b/sys/ufs/lfs/lfs.h Mon Feb 24 08:42:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.50 2003/02/23 00:22:33 perseant Exp $        */
+/*     $NetBSD: lfs.h,v 1.51 2003/02/24 08:42:49 perseant Exp $        */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -98,6 +98,8 @@
 #ifndef LFS_ATIME_IFILE
 # define LFS_ATIME_IFILE 0
 #endif
+/* Max block count for lfs_markv() */
+#define LFS_MARKV_MAXBLKCNT             65536
 
 /* Local definition for LFS's usage of PG_PAGER1 */
 #define PG_DELWRI      PG_PAGER1
@@ -932,4 +934,15 @@
 extern struct lfs_stats lfs_stats;
 #endif
 
+/* Ioctls to take the place of the lfs syscalls */
+struct lfs_ioctl_markv {
+       BLOCK_INFO *blkiov;     /* blocks to relocate */
+       int blkcnt;             /* number of blocks */
+};
+
+#define LIOCSEGWAITALL  _IOW('L', 0, struct timeval)
+#define LIOCSEGWAIT     _IOW('L', 1, struct timeval)
+#define LIOCBMAPV      _IOWR('L', 2, struct lfs_ioctl_markv)
+#define LIOCMARKV      _IOWR('L', 3, struct lfs_ioctl_markv)
+
 #endif /* !_UFS_LFS_LFS_H_ */
diff -r 76e6406a8a88 -r 12cf70791c13 sys/ufs/lfs/lfs_extern.h
--- a/sys/ufs/lfs/lfs_extern.h  Mon Feb 24 08:34:30 2003 +0000
+++ b/sys/ufs/lfs/lfs_extern.h  Mon Feb 24 08:42:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_extern.h,v 1.42 2003/02/23 00:22:34 perseant Exp $ */
+/*     $NetBSD: lfs_extern.h,v 1.43 2003/02/24 08:42:49 perseant Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -115,6 +115,7 @@
 struct lfs;
 struct segment;
 struct ucred;
+struct block_info;
 
 extern int lfs_allclean_wakeup;
 extern struct pool lfs_inode_pool;     /* memory pool for inodes */
@@ -182,6 +183,7 @@
 
 /* lfs_subr.c */
 void lfs_setup_resblks(struct lfs *);
+void lfs_pad_check(unsigned char *, int, char *, int);
 void lfs_free_resblks(struct lfs *);
 void *lfs_malloc(struct lfs *, size_t, int);
 void lfs_free(struct lfs *, void *, int);
@@ -193,6 +195,9 @@
 struct buf *lfs_fakebuf(struct lfs *, struct vnode *, int, size_t, caddr_t);
 int lfs_do_segclean(struct lfs *, unsigned long);
 void lfs_fakebuf_iodone(struct buf *);
+int lfs_segwait(fsid_t *, struct timeval *);
+int lfs_bmapv(struct proc *, fsid_t *, struct block_info *, int);
+int lfs_markv(struct proc *, fsid_t *, struct block_info *, int);
 
 /* lfs_vfsops.c */
 void lfs_init(void);
@@ -240,6 +245,7 @@
 int lfs_close   (void *);
 int lfsspec_close(void *);
 int lfsfifo_close(void *);
+int lfs_ioctl   (void *);
 int lfs_inactive (void *);
 int lfs_reclaim         (void *);
 int lfs_write   (void *);
diff -r 76e6406a8a88 -r 12cf70791c13 sys/ufs/lfs/lfs_syscalls.c
--- a/sys/ufs/lfs/lfs_syscalls.c        Mon Feb 24 08:34:30 2003 +0000
+++ b/sys/ufs/lfs/lfs_syscalls.c        Mon Feb 24 08:42:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_syscalls.c,v 1.83 2003/02/23 03:32:55 simonb Exp $ */
+/*     $NetBSD: lfs_syscalls.c,v 1.84 2003/02/24 08:42:49 perseant Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.83 2003/02/23 03:32:55 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.84 2003/02/24 08:42:49 perseant Exp $");
 
 #define LFS            /* for prototypes in syscallargs.h */
 
@@ -94,9 +94,6 @@
 #include <ufs/lfs/lfs.h>
 #include <ufs/lfs/lfs_extern.h>
 
-/* Max block count for lfs_markv() */
-#define MARKV_MAXBLKCNT                65536
-
 struct buf *lfs_fakebuf(struct lfs *, struct vnode *, int, size_t, caddr_t);
 int lfs_fasthashget(dev_t, ino_t, struct vnode **);
 
@@ -126,9 +123,6 @@
 
 #define LFS_VREF_THRESHOLD 128
 
-static int lfs_bmapv(struct proc *, fsid_t *, BLOCK_INFO *, int);
-static int lfs_markv(struct proc *, fsid_t *, BLOCK_INFO *, int);
-
 /*
  * sys_lfs_markv:
  *
@@ -162,7 +156,7 @@
                return (error);
 
        blkcnt = SCARG(uap, blkcnt);
-       if ((u_int) blkcnt > MARKV_MAXBLKCNT)
+       if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
                return (EINVAL);
 
        blkiov = malloc(blkcnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
@@ -198,7 +192,7 @@
                return (error);
 
        blkcnt = SCARG(uap, blkcnt);
-       if ((u_int) blkcnt > MARKV_MAXBLKCNT)
+       if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
                return (EINVAL);
 
        blkiov = malloc(blkcnt * sizeof(BLOCK_INFO), M_SEGMENT, M_WAITOK);
@@ -239,7 +233,7 @@
 
 #define        LFS_MARKV_MAX_BLOCKS    (LFS_MAX_BUFS)
 
-static int
+int
 lfs_markv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
 {
        BLOCK_INFO *blkp;
@@ -709,7 +703,7 @@
 }
 #endif
 
-static int
+int
 lfs_bmapv(struct proc *p, fsid_t *fsidp, BLOCK_INFO *blkiov, int blkcnt)
 {
        BLOCK_INFO *blkp;
@@ -967,11 +961,38 @@
 }
 
 /*
- * sys_lfs_segwait:
- *
  * This will block until a segment in file system fsid is written.  A timeout
  * in milliseconds may be specified which will awake the cleaner automatically.
  * An fsid of -1 means any file system, and a timeout of 0 means forever.
+ */
+int
+lfs_segwait(fsid_t *fsidp, struct timeval *tv)
+{
+       struct mount *mntp;
+       void *addr;
+       u_long timeout;
+       int error, s;
+
+       if ((mntp = vfs_getvfs(fsidp)) == NULL)
+               addr = &lfs_allclean_wakeup;
+       else
+               addr = &VFSTOUFS(mntp)->um_lfs->lfs_nextseg;
+       /*
+        * XXX THIS COULD SLEEP FOREVER IF TIMEOUT IS {0,0}!
+        * XXX IS THAT WHAT IS INTENDED?
+        */
+       s = splclock();
+       timeradd(tv, &time, tv);
+       timeout = hzto(tv);
+       splx(s);
+       error = tsleep(addr, PCATCH | PUSER, "segment", timeout);
+       return (error == ERESTART ? EINTR : 0);
+}
+
+/*
+ * sys_lfs_segwait:
+ *
+ * System call wrapper around lfs_segwait().
  *
  *  0 on success
  *  1 on timeout
@@ -985,22 +1006,16 @@
                syscallarg(struct timeval *) tv;
        } */ *uap = v;
        struct proc *p = l->l_proc;
-       struct mount *mntp;
        struct timeval atv;
        fsid_t fsid;
-       void *addr;
-       u_long timeout;
-       int error, s;
+       int error;
        
+       /* XXX need we be su to segwait? */
        if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) {
                return (error);
        }
        if ((error = copyin(SCARG(uap, fsidp), &fsid, sizeof(fsid_t))) != 0)
                return (error);
-       if ((mntp = vfs_getvfs(&fsid)) == NULL)
-               addr = &lfs_allclean_wakeup;
-       else
-               addr = &VFSTOUFS(mntp)->um_lfs->lfs_nextseg;
        
        if (SCARG(uap, tv)) {
                error = copyin(SCARG(uap, tv), &atv, sizeof(struct timeval));
@@ -1008,19 +1023,9 @@
                        return (error);
                if (itimerfix(&atv))
                        return (EINVAL);
-               /*
-                * XXX THIS COULD SLEEP FOREVER IF TIMEOUT IS {0,0}!
-                * XXX IS THAT WHAT IS INTENDED?
-                */
-               s = splclock();
-               timeradd(&atv, &time, &atv);
-               timeout = hzto(&atv);
-               splx(s);
-       } else
-               timeout = 0;
-       
-       error = tsleep(addr, PCATCH | PUSER, "segment", timeout);
-       return (error == ERESTART ? EINTR : 0);
+       } else /* NULL or invalid */
+               atv.tv_sec = atv.tv_usec = 0;
+       return lfs_segwait(&fsid, &atv);
 }
 
 /*
diff -r 76e6406a8a88 -r 12cf70791c13 sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Mon Feb 24 08:34:30 2003 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Mon Feb 24 08:42:49 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vnops.c,v 1.88 2003/02/23 00:22:35 perseant Exp $  */
+/*     $NetBSD: lfs_vnops.c,v 1.89 2003/02/24 08:42:49 perseant Exp $  */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.88 2003/02/23 00:22:35 perseant Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.89 2003/02/24 08:42:49 perseant Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -126,7 +126,7 @@
        { &vop_read_desc, lfs_read },                   /* read */
        { &vop_write_desc, lfs_write },                 /* write */
        { &vop_lease_desc, ufs_lease_check },           /* lease */
-       { &vop_ioctl_desc, ufs_ioctl },                 /* ioctl */
+       { &vop_ioctl_desc, lfs_ioctl },                 /* ioctl */
        { &vop_fcntl_desc, ufs_fcntl },                 /* fcntl */
        { &vop_poll_desc, ufs_poll },                   /* poll */
        { &vop_kqfilter_desc, genfs_kqfilter },         /* kqfilter */
@@ -1011,6 +1011,78 @@
        return (0);
 }
 
+/*
+ * Provide an ioctl interface to sys_lfs_{segwait,bmapv,markv}.
+ */
+int
+lfs_ioctl(void *v)
+{
+        struct vop_ioctl_args /* {
+                struct vnode *a_vp;
+                u_long a_command;
+                caddr_t  a_data;
+                int  a_fflag;
+                struct ucred *a_cred;
+                struct proc *a_p;
+        } */ *ap = v;
+       struct timeval *tvp;
+       BLOCK_INFO *blkiov;
+       int blkcnt, error;
+       struct lfs_ioctl_markv blkvp;
+       fsid_t *fsidp;
+
+       /* Only respect LFS ioctls on fs root or Ifile */
+       if (VTOI(ap->a_vp)->i_number != ROOTINO &&
+           VTOI(ap->a_vp)->i_number != LFS_IFILE_INUM) {
+               return ufs_ioctl(v);
+       }
+
+       fsidp = &ap->a_vp->v_mount->mnt_stat.f_fsid;
+
+       switch(ap->a_command) {



Home | Main Index | Thread Index | Old Index