Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Dec 2014 06:13:32 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r275721 - head/usr.bin/mkimg
Message-ID:  <201412120613.sBC6DWeG042053@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Fri Dec 12 06:13:31 2014
New Revision: 275721
URL: https://svnweb.freebsd.org/changeset/base/275721

Log:
  The size of the first level reference count table is given in terms of the
  number of clusters it occupies. It's not the number of entries in the table,
  as it is for the L1 cluster table.
  
  For small images, the two are the same. With the unit tests based on small
  images, this change has therefore no effect on the unit test.  For larger
  images (like the FreeBSD 10.1-RELEASE image), this gives a discrepancy that
  actually shows up when running "qemu-img check".
  
  Bump the version number of mkimg.
  
  While here, fix a white-space bug.
  
  MFC after: 1 week

Modified:
  head/usr.bin/mkimg/Makefile
  head/usr.bin/mkimg/qcow.c

Modified: head/usr.bin/mkimg/Makefile
==============================================================================
--- head/usr.bin/mkimg/Makefile	Fri Dec 12 04:12:18 2014	(r275720)
+++ head/usr.bin/mkimg/Makefile	Fri Dec 12 06:13:31 2014	(r275721)
@@ -6,7 +6,7 @@ PROG=	mkimg
 SRCS=	format.c image.c mkimg.c scheme.c
 MAN=	mkimg.1
 
-MKIMG_VERSION=20141003
+MKIMG_VERSION=20141211
 mkimg.o: Makefile
 
 CFLAGS+=-DMKIMG_VERSION=${MKIMG_VERSION}

Modified: head/usr.bin/mkimg/qcow.c
==============================================================================
--- head/usr.bin/mkimg/qcow.c	Fri Dec 12 04:12:18 2014	(r275720)
+++ head/usr.bin/mkimg/qcow.c	Fri Dec 12 06:13:31 2014	(r275721)
@@ -71,7 +71,7 @@ struct qcow_header {
 			uint32_t	l1_entries;
 			uint64_t	l1_offset;
 			uint64_t	refcnt_offset;
-			uint32_t	refcnt_entries;
+			uint32_t	refcnt_clstrs;
 			uint32_t	snapshot_count;
 			uint64_t	snapshot_offset;
 		} v2;
@@ -139,7 +139,7 @@ qcow_write(int fd, u_int version)
 	uint64_t n, imagesz, nclstrs, ofs, ofsflags;
 	lba_t blk, blkofs, blk_imgsz;
 	u_int l1clno, l2clno, rcclno;
-	u_int blk_clstrsz;
+	u_int blk_clstrsz, refcnt_clstrs;
 	u_int clstrsz, l1idx, l2idx;
 	int error;
 
@@ -199,14 +199,15 @@ qcow_write(int fd, u_int version)
 		be32enc(&hdr->u.v2.l1_entries, clstr_l2tbls);
 		be64enc(&hdr->u.v2.l1_offset, clstrsz * l1clno);
 		be64enc(&hdr->u.v2.refcnt_offset, clstrsz * rcclno);
-		be32enc(&hdr->u.v2.refcnt_entries, clstr_rcblks);
+		refcnt_clstrs = round_clstr(clstr_rcblks * 8) >> clstr_log2sz;
+		be32enc(&hdr->u.v2.refcnt_clstrs, refcnt_clstrs);
 		break;
 	default:
 		return (EDOOFUS);
 	}
 
 	if (sparse_write(fd, hdr, clstrsz) < 0) {
-                error = errno;
+		error = errno;
 		goto out;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412120613.sBC6DWeG042053>