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 an IINFO struct, which is like the FINFO str...



details:   https://anonhg.NetBSD.org/src/rev/3d835ebbe70d
branches:  trunk
changeset: 810952:3d835ebbe70d
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Oct 03 08:27:38 2015 +0000

description:
Add an IINFO struct, which is like the FINFO struct but for the inode
blocks portion of the segment summary.

A segment summary block begins with a header (SEGSUM); the rest of the
block contains FINFO structures describing file blocks growing upward
from the bottom (after the header), and IINFO structures describing
inode blocks grown downward from the end of the block. (When they meet
the segment is full regardless of how many blocks might be left.)

IINFO contains just a block number, and until now this information was
handled by just using uint32_t*; switching to a structure will make
the code a lot easier to read, and also make it easier to have 32-bit
and 64-bit versions without making a mess.

This commit just adds the structures and accessors; they'll be
deployed into the code in subsequent commits.

diffstat:

 sys/ufs/lfs/lfs.h           |  23 ++++++++++++++++++++++-
 sys/ufs/lfs/lfs_accessors.h |  35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 2 deletions(-)

diffs (86 lines):

diff -r d40c3d9d7769 -r 3d835ebbe70d sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Fri Oct 02 22:17:22 2015 +0000
+++ b/sys/ufs/lfs/lfs.h Sat Oct 03 08:27:38 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.192 2015/09/21 01:24:39 dholland Exp $       */
+/*     $NetBSD: lfs.h,v 1.193 2015/10/03 08:27:38 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  */
@@ -577,6 +577,27 @@
 } FINFO;
 
 /*
+ * inode info (part of the segment summary)
+ *
+ * Each one of these is just a block number; wrapping the structure
+ * around it gives more contextual information in the code about
+ * what's going on.
+ */
+
+typedef struct iinfo64 {
+       uint64_t ii_block;              /* block number */
+} IINFO64;
+
+typedef struct iinfo32 {
+       uint32_t ii_block;              /* block number */
+} IINFO32;
+
+typedef union iinfo {
+       struct iinfo64 u_64;
+       struct iinfo32 u_32;
+} IINFO;
+
+/*
  * Index file inode entries.
  */
 
diff -r d40c3d9d7769 -r 3d835ebbe70d sys/ufs/lfs/lfs_accessors.h
--- a/sys/ufs/lfs/lfs_accessors.h       Fri Oct 02 22:17:22 2015 +0000
+++ b/sys/ufs/lfs/lfs_accessors.h       Sat Oct 03 08:27:38 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_accessors.h,v 1.33 2015/09/21 01:24:58 dholland Exp $      */
+/*     $NetBSD: lfs_accessors.h,v 1.34 2015/10/03 08:27:38 dholland Exp $      */
 
 /*  from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp  */
 /*  from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp  */
@@ -767,6 +767,39 @@
 }
 
 /*
+ * inode info entries (in the segment summary)
+ */
+
+#define IINFOSIZE(fs)  ((fs)->lfs_is64 ? sizeof(IINFO64) : sizeof(IINFO32))
+
+/* iinfos scroll backward from the end of the segment summary block */
+#define SEGSUM_IINFOSTART(fs, buf) \
+       ((IINFO *)((char *)buf + lfs_sb_getsumsize(fs) - IINFOSIZE(fs)))
+
+#define NEXTLOWER_IINFO(fs, iip) \
+       ((IINFO *)((char *)(iip) - IINFOSIZE(fs)))
+
+static __unused inline uint64_t
+lfs_ii_getblock(STRUCT_LFS *fs, IINFO *iip)
+{
+       if (fs->lfs_is64) {
+               return iip->u_64.ii_block;
+       } else {
+               return iip->u_32.ii_block;
+       }
+}
+
+static __unused inline void
+lfs_ii_setblock(STRUCT_LFS *fs, IINFO *iip, uint64_t block)
+{
+       if (fs->lfs_is64) {
+               iip->u_64.ii_block = block;
+       } else {
+               iip->u_32.ii_block = block;
+       }
+}
+
+/*
  * Index file inode entries.
  */
 



Home | Main Index | Thread Index | Old Index