Module Name:    src
Committed By:   tkusumi
Date:           Wed Sep 23 14:39:23 UTC 2020

Modified Files:
        src/usr.sbin/fstyp: hammer2.c hammer2_disk.h

Log Message:
fstyp: Sync hammer2_disk.h with DragonFly BSD

taken-from: DragonFly BSD


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/fstyp/hammer2.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/fstyp/hammer2_disk.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/fstyp/hammer2.c
diff -u src/usr.sbin/fstyp/hammer2.c:1.5 src/usr.sbin/fstyp/hammer2.c:1.6
--- src/usr.sbin/fstyp/hammer2.c:1.5	Fri Aug 14 18:35:57 2020
+++ src/usr.sbin/fstyp/hammer2.c	Wed Sep 23 14:39:23 2020
@@ -1,4 +1,4 @@
-/*        $NetBSD: hammer2.c,v 1.5 2020/08/14 18:35:57 tkusumi Exp $      */
+/*        $NetBSD: hammer2.c,v 1.6 2020/09/23 14:39:23 tkusumi Exp $      */
 
 /*-
  * Copyright (c) 2017-2019 The DragonFly Project
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.5 2020/08/14 18:35:57 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hammer2.c,v 1.6 2020/09/23 14:39:23 tkusumi Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -79,10 +79,10 @@ read_media(FILE *fp, const hammer2_block
 	}
 
 	io_off = bref->data_off & ~HAMMER2_OFF_MASK_RADIX;
-	io_base = io_off & ~(hammer2_off_t)(HAMMER2_MINIOSIZE - 1);
+	io_base = io_off & ~(hammer2_off_t)(HAMMER2_LBUFSIZE - 1);
 	boff = (size_t)(io_off - io_base);
 
-	io_bytes = HAMMER2_MINIOSIZE;
+	io_bytes = HAMMER2_LBUFSIZE;
 	while (io_bytes + boff < bytes)
 		io_bytes <<= 1;
 

Index: src/usr.sbin/fstyp/hammer2_disk.h
diff -u src/usr.sbin/fstyp/hammer2_disk.h:1.1 src/usr.sbin/fstyp/hammer2_disk.h:1.2
--- src/usr.sbin/fstyp/hammer2_disk.h:1.1	Wed Jan  1 08:56:41 2020
+++ src/usr.sbin/fstyp/hammer2_disk.h	Wed Sep 23 14:39:23 2020
@@ -1,4 +1,4 @@
-/*        $NetBSD: hammer2_disk.h,v 1.1 2020/01/01 08:56:41 tkusumi Exp $      */
+/*        $NetBSD: hammer2_disk.h,v 1.2 2020/09/23 14:39:23 tkusumi Exp $      */
 
 /*
  * Copyright (c) 2011-2019 The DragonFly Project.  All rights reserved.
@@ -35,7 +35,7 @@
  * SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hammer2_disk.h,v 1.1 2020/01/01 08:56:41 tkusumi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hammer2_disk.h,v 1.2 2020/09/23 14:39:23 tkusumi Exp $");
 
 #ifndef _VFS_HAMMER2_DISK_H_
 #define _VFS_HAMMER2_DISK_H_
@@ -96,15 +96,6 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk
 #define HAMMER2_RADIX_KEY	64	/* number of bits in key */
 
 /*
- * MINALLOCSIZE		- The minimum allocation size.  This can be smaller
- *		  	  or larger than the minimum physical IO size.
- *
- *			  NOTE: Should not be larger than 1K since inodes
- *				are 1K.
- *
- * MINIOSIZE		- The minimum IO size.  This must be less than
- *			  or equal to HAMMER2_LBUFSIZE.
- *
  * HAMMER2_LBUFSIZE	- Nominal buffer size for I/O rollups.
  *
  * HAMMER2_PBUFSIZE	- Topological block size used by files for all
@@ -122,12 +113,6 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk
 #define HAMMER2_LBUFRADIX	14	/* logical buf (1<<14) bytes */
 #define HAMMER2_LBUFSIZE	16384
 
-/*
- * Generally speaking we want to use 16K and 64K I/Os
- */
-#define HAMMER2_MINIORADIX	HAMMER2_LBUFRADIX
-#define HAMMER2_MINIOSIZE	HAMMER2_LBUFSIZE
-
 #define HAMMER2_IND_BYTES_MIN	4096
 #define HAMMER2_IND_BYTES_NOM	HAMMER2_LBUFSIZE
 #define HAMMER2_IND_BYTES_MAX	HAMMER2_PBUFSIZE
@@ -149,9 +134,6 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk
  * resulting in highly efficient storage for files <= 512 bytes and for files
  * <= 512KB.  Up to 4 directory entries can be referenced from a directory
  * without requiring an indirect block.
- *
- * Indirect blocks are typically either 4KB (64 blockrefs / ~4MB represented),
- * or 64KB (1024 blockrefs / ~64MB represented).
  */
 #define HAMMER2_SET_RADIX		2	/* radix 2 = 4 entries */
 #define HAMMER2_SET_COUNT		(1 << HAMMER2_SET_RADIX)
@@ -171,10 +153,9 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk
 #define HAMMER2_UUID_STRING	"5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
 
 /*
- * A 4MB segment is reserved at the beginning of each 2GB zone.  This segment
+ * A 4MB segment is reserved at the beginning of each 1GB.  This segment
  * contains the volume header (or backup volume header), the free block
- * table, and possibly other information in the future.  A 4MB segment for
- * freemap is reserved at the beginning of every 1GB.
+ * table, and possibly other information in the future.
  *
  * 4MB = 64 x 64K blocks.  Each 4MB segment is broken down as follows:
  *
@@ -286,7 +267,7 @@ __KERNEL_RCSID(0, "$NetBSD: hammer2_disk
 #define HAMMER2_VOLUME_ALIGN		(8 * 1024 * 1024)
 #define HAMMER2_VOLUME_ALIGN64		((hammer2_off_t)HAMMER2_VOLUME_ALIGN)
 #define HAMMER2_VOLUME_ALIGNMASK	(HAMMER2_VOLUME_ALIGN - 1)
-#define HAMMER2_VOLUME_ALIGNMASK64     ((hammer2_off_t)HAMMER2_VOLUME_ALIGNMASK)
+#define HAMMER2_VOLUME_ALIGNMASK64	((hammer2_off_t)HAMMER2_VOLUME_ALIGNMASK)
 
 #define HAMMER2_NEWFS_ALIGN		(HAMMER2_VOLUME_ALIGN)
 #define HAMMER2_NEWFS_ALIGN64		((hammer2_off_t)HAMMER2_VOLUME_ALIGN)
@@ -439,9 +420,9 @@ typedef uint64_t			hammer2_bitmap_t;
 #define HAMMER2_BOOT_NOM_BYTES		(64*1024*1024)
 #define HAMMER2_BOOT_MAX_BYTES		(256*1024*1024)
 
-#define HAMMER2_REDO_MIN_BYTES		HAMMER2_VOLUME_ALIGN
-#define HAMMER2_REDO_NOM_BYTES		(256*1024*1024)
-#define HAMMER2_REDO_MAX_BYTES		(1024*1024*1024)
+#define HAMMER2_AUX_MIN_BYTES		HAMMER2_VOLUME_ALIGN
+#define HAMMER2_AUX_NOM_BYTES		(256*1024*1024)
+#define HAMMER2_AUX_MAX_BYTES		(1024*1024*1024)
 
 /*
  * Most HAMMER2 types are implemented as unsigned 64-bit integers.
@@ -482,12 +463,10 @@ typedef uint32_t hammer2_crc32_t;
  *	    case which means no data associated with the blockref, and
  *	    not the '1 byte' it would otherwise calculate to.
  */
-#define HAMMER2_OFF_BAD		((hammer2_off_t)-1)
 #define HAMMER2_OFF_MASK	0xFFFFFFFFFFFFFFC0ULL
 #define HAMMER2_OFF_MASK_LO	(HAMMER2_OFF_MASK & HAMMER2_PBUFMASK64)
 #define HAMMER2_OFF_MASK_HI	(~HAMMER2_PBUFMASK64)
 #define HAMMER2_OFF_MASK_RADIX	0x000000000000003FULL
-#define HAMMER2_MAX_COPIES	6
 
 /*
  * HAMMER2 directory support and pre-defined keys
@@ -748,7 +727,7 @@ typedef struct hammer2_blockref hammer2_
 #define HAMMER2_BREF_TYPE_VOLUME	255	/* pseudo-type */
 
 #define HAMMER2_BREF_FLAG_PFSROOT	0x01	/* see also related opflag */
-#define HAMMER2_BREF_FLAG_ZERO		0x02
+#define HAMMER2_BREF_FLAG_ZERO		0x02	/* NO LONGER USED */
 #define HAMMER2_BREF_FLAG_EMERG_MIP	0x04	/* emerg modified-in-place */
 
 /*
@@ -819,9 +798,6 @@ typedef struct hammer2_blockref hammer2_
  * until the set actually becomes full (that is, the entries in the set can
  * shortcut the indirect blocks when the set is not full).  Depending on how
  * things are filled multiple indirect blocks will eventually be created.
- *
- * Indirect blocks are typically 4KB (64 entres) or 64KB (1024 entries) and
- * are also treated as fully set-associative.
  */
 struct hammer2_blockset {
 	hammer2_blockref_t	blockref[HAMMER2_SET_COUNT];
@@ -905,12 +881,7 @@ struct hammer2_bmap_data {
 typedef struct hammer2_bmap_data hammer2_bmap_data_t;
 
 /*
- * XXX "Inodes ARE directory entries" is no longer the case.  Hardlinks are
- * dirents which refer to the same inode#, which is how filesystems usually
- * implement hardlink.  The following comments need to be updated.
- *
- * In HAMMER2 inodes ARE directory entries, with a special exception for
- * hardlinks.  The inode number is stored in the inode rather than being
+ * The inode number is stored in the inode rather than being
  * based on the location of the inode (since the location moves every time
  * the inode or anything underneath the inode is modified).
  *
@@ -934,18 +905,6 @@ typedef struct hammer2_bmap_data hammer2
  *
  * The compression mode can be changed at any time in the inode and is
  * recorded on a blockref-by-blockref basis.
- *
- * Hardlinks are supported via the inode map.  Essentially the way a hardlink
- * works is that all individual directory entries representing the same file
- * are special cased and specify the same inode number.  The actual file
- * is placed in the nearest parent directory that is parent to all instances
- * of the hardlink.  If all hardlinks to a file are in the same directory
- * the actual file will also be placed in that directory.  This file uses
- * the inode number as the directory entry key and is invisible to normal
- * directory scans.  Real directory entry keys are differentiated from the
- * inode number key via bit 63.  Access to the hardlink silently looks up
- * the real file and forwards all operations to that file.  Removal of the
- * last hardlink also removes the real file.
  */
 #define HAMMER2_INODE_BYTES		1024	/* (asserted by code) */
 #define HAMMER2_INODE_MAXNAME		256	/* maximum name in bytes */
@@ -1134,37 +1093,8 @@ typedef struct hammer2_inode_data hammer
 #define HAMMER2_PFSMODE_RW		0x02
 
 /*
- *				Allocation Table
- *
- */
-
-
-/*
- * Flags (8 bits) - blockref, for freemap only
- *
- * Note that the minimum chunk size is 1KB so we could theoretically have
- * 10 bits here, but we might have some future extension that allows a
- * chunk size down to 256 bytes and if so we will need bits 8 and 9.
- */
-#define HAMMER2_AVF_SELMASK		0x03	/* select group */
-#define HAMMER2_AVF_ALL_ALLOC		0x04	/* indicate all allocated */
-#define HAMMER2_AVF_ALL_FREE		0x08	/* indicate all free */
-#define HAMMER2_AVF_RESERVED10		0x10
-#define HAMMER2_AVF_RESERVED20		0x20
-#define HAMMER2_AVF_RESERVED40		0x40
-#define HAMMER2_AVF_RESERVED80		0x80
-#define HAMMER2_AVF_AVMASK32		((uint32_t)0xFFFFFF00LU)
-#define HAMMER2_AVF_AVMASK64		((uint64_t)0xFFFFFFFFFFFFFF00LLU)
-
-#define HAMMER2_AV_SELECT_A		0x00
-#define HAMMER2_AV_SELECT_B		0x01
-#define HAMMER2_AV_SELECT_C		0x02
-#define HAMMER2_AV_SELECT_D		0x03
-
-/*
- * The volume header eats a 64K block.  There is currently an issue where
- * we want to try to fit all nominal filesystem updates in a 512-byte section
- * but it may be a lost cause due to the need for a blockset.
+ * The volume header eats a 64K block at the beginning of each 2GB zone
+ * up to four copies.
  *
  * All information is stored in host byte order.  The volume header's magic
  * number may be checked to determine the byte order.  If you wish to mount
@@ -1191,7 +1121,7 @@ typedef struct hammer2_inode_data hammer
  *	 allow HAMMER2 to pick up the others when it checks the copyinfo[]
  *	 array on mount.
  *
- * NOTE: root_blockref points to the super-root directory, not the root
+ * NOTE: sroot_blockset points to the super-root directory, not the root
  *	 directory.  The root directory will be a subdirectory under the
  *	 super-root.
  *
@@ -1199,13 +1129,6 @@ typedef struct hammer2_inode_data hammer
  *	 snapshots (readonly or writable).  It is possible to do a
  *	 null-mount of the super-root using special path constructions
  *	 relative to your mounted root.
- *
- * NOTE: HAMMER2 allows any subdirectory tree to be managed as if it were
- *	 a PFS, including mirroring and storage quota operations, and this is
- *	 prefered over creating discrete PFSs in the super-root.  Instead
- *	 the super-root is most typically used to create writable snapshots,
- *	 alternative roots, and so forth.  The super-root is also used by
- *	 the automatic snapshotting mechanism.
  */
 #define HAMMER2_VOLUME_ID_HBO	0x48414d3205172011LLU
 #define HAMMER2_VOLUME_ID_ABO	0x11201705324d4148LLU
@@ -1234,7 +1157,7 @@ struct hammer2_volume_data {
 
 	/*
 	 * allocator_size is precalculated at newfs time and does not include
-	 * reserved blocks, boot, or redo areas.
+	 * reserved blocks, boot, or aux areas.
 	 *
 	 * Initial non-reserved-area allocations do not use the freemap
 	 * but instead adjust alloc_iterator.  Dynamic allocations take
@@ -1358,7 +1281,7 @@ typedef struct hammer2_volume_data hamme
 
 #define HAMMER2_VOL_VERSION_MIN		1
 #define HAMMER2_VOL_VERSION_DEFAULT	1
-#define HAMMER2_VOL_VERSION_WIP 	2
+#define HAMMER2_VOL_VERSION_WIP		2
 
 #define HAMMER2_NUM_VOLHDRS		4
 

Reply via email to