Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/lfs Widen several of the fields of BLOCK_INFO to 64 ...



details:   https://anonhg.NetBSD.org/src/rev/a4b525403cbb
branches:  trunk
changeset: 809967:a4b525403cbb
user:      dholland <dholland%NetBSD.org@localhost>
date:      Wed Aug 12 18:24:14 2015 +0000

description:
Widen several of the fields of BLOCK_INFO to 64 bits.

Keep the old BLOCK_INFO as BLOCK_INFO_70, and version the fcntls that
use it.

Note that BLOCK_INFO_70 has 64-bit padding issues so that it's
different on 32-bit and 64-bit machines. This has been fixed. However,
BLOCK_INFO also contains a pointer, so compat32 stuff for 32-on-64 is
still needed and doesn't currently exist.

diffstat:

 sys/ufs/lfs/lfs.h        |  19 ++++++++--
 sys/ufs/lfs/lfs_kernel.h |   9 ++++-
 sys/ufs/lfs/lfs_vnops.c  |  83 +++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 101 insertions(+), 10 deletions(-)

diffs (213 lines):

diff -r 09ed102fbc3f -r a4b525403cbb sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Wed Aug 12 18:23:59 2015 +0000
+++ b/sys/ufs/lfs/lfs.h Wed Aug 12 18:24:14 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.173 2015/08/12 18:23:16 dholland Exp $       */
+/*     $NetBSD: lfs.h,v 1.174 2015/08/12 18:24:14 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  */
@@ -867,6 +867,17 @@
  * about inodes and data blocks.
  */
 typedef struct block_info {
+       u_int64_t bi_inode;             /* inode # */
+       int64_t bi_lbn;                 /* logical block w/in file */
+       int64_t bi_daddr;               /* disk address of block */
+       u_int64_t bi_segcreate;         /* origin segment create time */
+       int     bi_version;             /* file version number */
+       int     bi_size;                /* size of the block (if fragment) */
+       void    *bi_bp;                 /* data buffer */
+} BLOCK_INFO;
+
+/* Compatibility for 7.0 binaries */
+typedef struct block_info_70 {
        u_int32_t bi_inode;             /* inode # */
        int32_t bi_lbn;                 /* logical block w/in file */
        int32_t bi_daddr;               /* disk address of block */
@@ -874,7 +885,7 @@
        int     bi_version;             /* file version number */
        void    *bi_bp;                 /* data buffer */
        int     bi_size;                /* size of the block (if fragment) */
-} BLOCK_INFO;
+} BLOCK_INFO_70;
 
 /* Compatibility for 1.5 binaries */
 typedef struct block_info_15 {
@@ -946,8 +957,8 @@
 
 #define LFCNSEGWAITALL _FCNR_FSPRIV('L', 14, struct timeval)
 #define LFCNSEGWAIT    _FCNR_FSPRIV('L', 15, struct timeval)
-#define LFCNBMAPV      _FCNRW_FSPRIV('L', 2, struct lfs_fcntl_markv)
-#define LFCNMARKV      _FCNRW_FSPRIV('L', 3, struct lfs_fcntl_markv)
+#define LFCNBMAPV      _FCNRW_FSPRIV('L', 16, struct lfs_fcntl_markv)
+#define LFCNMARKV      _FCNRW_FSPRIV('L', 17, struct lfs_fcntl_markv)
 #define LFCNRECLAIM     _FCNO_FSPRIV('L', 4)
 
 struct lfs_fhandle {
diff -r 09ed102fbc3f -r a4b525403cbb sys/ufs/lfs/lfs_kernel.h
--- a/sys/ufs/lfs/lfs_kernel.h  Wed Aug 12 18:23:59 2015 +0000
+++ b/sys/ufs/lfs/lfs_kernel.h  Wed Aug 12 18:24:14 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_kernel.h,v 1.1 2013/07/28 01:05:52 dholland Exp $  */
+/*     $NetBSD: lfs_kernel.h,v 1.2 2015/08/12 18:24:14 dholland Exp $  */
 
 /*  from NetBSD: lfs.h,v 1.157 2013/06/28 16:14:06 matt Exp  */
 
@@ -100,6 +100,11 @@
  */
 #include <compat/sys/time_types.h>
 
+struct lfs_fcntl_markv_70 {
+       BLOCK_INFO_70 *blkiov;  /* blocks to relocate */
+       int blkcnt;             /* number of blocks (limited to 65536) */
+};
+
 #define LFCNSEGWAITALL_COMPAT   _FCNW_FSPRIV('L', 0, struct timeval50)
 #define LFCNSEGWAIT_COMPAT      _FCNW_FSPRIV('L', 1, struct timeval50)
 #define LFCNIFILEFH_COMPAT      _FCNW_FSPRIV('L', 5, struct lfs_fhandle)
@@ -108,6 +113,8 @@
 #define LFCNWRAPGO_COMPAT       _FCNO_FSPRIV('L', 10)
 #define LFCNSEGWAITALL_COMPAT_50 _FCNR_FSPRIV('L', 0, struct timeval50)
 #define LFCNSEGWAIT_COMPAT_50   _FCNR_FSPRIV('L', 1, struct timeval50)
+#define LFCNBMAPV_COMPAT_70    _FCNRW_FSPRIV('L', 2, struct lfs_fcntl_markv_70)
+#define LFCNMARKV_COMPAT_70    _FCNRW_FSPRIV('L', 3, struct lfs_fcntl_markv_70)
 
 
 #endif /* _UFS_LFS_LFS_KERNEL_H_ */
diff -r 09ed102fbc3f -r a4b525403cbb sys/ufs/lfs/lfs_vnops.c
--- a/sys/ufs/lfs/lfs_vnops.c   Wed Aug 12 18:23:59 2015 +0000
+++ b/sys/ufs/lfs/lfs_vnops.c   Wed Aug 12 18:24:14 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vnops.c,v 1.282 2015/08/12 18:23:47 dholland Exp $ */
+/*     $NetBSD: lfs_vnops.c,v 1.283 2015/08/12 18:24:14 dholland Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.282 2015/08/12 18:23:47 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.283 2015/08/12 18:24:14 dholland Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1721,6 +1721,33 @@
 }
 
 /*
+ * Conversion for compat.
+ */
+static void
+block_info_from_70(BLOCK_INFO *bi, const BLOCK_INFO_70 *bi70)
+{
+       bi->bi_inode = bi70->bi_inode;
+       bi->bi_lbn = bi70->bi_lbn;
+       bi->bi_daddr = bi70->bi_daddr;
+       bi->bi_segcreate = bi70->bi_segcreate;
+       bi->bi_version = bi70->bi_version;
+       bi->bi_bp = bi70->bi_bp;
+       bi->bi_size = bi70->bi_size;
+}
+
+static void
+block_info_to_70(BLOCK_INFO_70 *bi70, const BLOCK_INFO *bi)
+{
+       bi70->bi_inode = bi->bi_inode;
+       bi70->bi_lbn = bi->bi_lbn;
+       bi70->bi_daddr = bi->bi_daddr;
+       bi70->bi_segcreate = bi->bi_segcreate;
+       bi70->bi_version = bi->bi_version;
+       bi70->bi_bp = bi->bi_bp;
+       bi70->bi_size = bi->bi_size;
+}
+
+/*
  * Provide a fcntl interface to sys_lfs_{segwait,bmapv,markv}.
  */
 int
@@ -1736,11 +1763,13 @@
        struct timeval tv;
        struct timeval *tvp;
        BLOCK_INFO *blkiov;
+       BLOCK_INFO_70 *blkiov70;
        CLEANERINFO *cip;
        SEGUSE *sup;
-       int blkcnt, error;
+       int blkcnt, i, error;
        size_t fh_size;
        struct lfs_fcntl_markv blkvp;
+       struct lfs_fcntl_markv_70 blkvp70;
        struct lwp *l;
        fsid_t *fsidp;
        struct lfs *fs;
@@ -1775,7 +1804,7 @@
            case LFCNSEGWAITALL_COMPAT_50:
            case LFCNSEGWAITALL_COMPAT:
                fsidp = NULL;
-               /* FALLSTHROUGH */
+               /* FALLTHROUGH */
            case LFCNSEGWAIT_COMPAT_50:
            case LFCNSEGWAIT_COMPAT:
                {
@@ -1787,7 +1816,7 @@
                goto segwait_common;
            case LFCNSEGWAITALL:
                fsidp = NULL;
-               /* FALLSTHROUGH */
+               /* FALLTHROUGH */
            case LFCNSEGWAIT:
                tvp = (struct timeval *)ap->a_data;
 segwait_common:
@@ -1803,6 +1832,50 @@
                mutex_exit(&lfs_lock);
                return error;
 
+           case LFCNBMAPV_COMPAT_70:
+           case LFCNMARKV_COMPAT_70:
+               blkvp70 = *(struct lfs_fcntl_markv_70 *)ap->a_data;
+
+               blkcnt = blkvp70.blkcnt;
+               if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
+                       return (EINVAL);
+               blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
+               blkiov70 = lfs_malloc(fs, sizeof(BLOCK_INFO_70), LFS_NB_BLKIOV);
+               for (i = 0; i < blkcnt; i++) {
+                       error = copyin(&blkvp70.blkiov[i], blkiov70,
+                                      sizeof(*blkiov70));
+                       if (error) {
+                               lfs_free(fs, blkiov70, LFS_NB_BLKIOV);
+                               lfs_free(fs, blkiov, LFS_NB_BLKIOV);
+                               return error;
+                       }
+                       block_info_from_70(&blkiov[i], blkiov70);
+               }
+
+               mutex_enter(&lfs_lock);
+               ++fs->lfs_sleepers;
+               mutex_exit(&lfs_lock);
+               if (ap->a_command == LFCNBMAPV)
+                       error = lfs_bmapv(l, fsidp, blkiov, blkcnt);
+               else /* LFCNMARKV */
+                       error = lfs_markv(l, fsidp, blkiov, blkcnt);
+               if (error == 0) {
+                       for (i = 0; i < blkcnt; i++) {
+                               block_info_to_70(blkiov70, &blkiov[i]);
+                               error = copyout(blkiov70, &blkvp70.blkiov[i],
+                                               sizeof(*blkiov70));
+                               if (error) {
+                                       break;
+                               }
+                       }
+               }
+               mutex_enter(&lfs_lock);
+               if (--fs->lfs_sleepers == 0)
+                       wakeup(&fs->lfs_sleepers);
+               mutex_exit(&lfs_lock);
+               lfs_free(fs, blkiov, LFS_NB_BLKIOV);
+               return error;
+
            case LFCNBMAPV:
            case LFCNMARKV:
                blkvp = *(struct lfs_fcntl_markv *)ap->a_data;



Home | Main Index | Thread Index | Old Index