Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/makefs Believe the datablocks predictor when determ...



details:   https://anonhg.NetBSD.org/src/rev/cef63012609c
branches:  trunk
changeset: 930939:cef63012609c
user:      reinoud <reinoud%NetBSD.org@localhost>
date:      Sat Apr 18 09:45:45 2020 +0000

description:
Believe the datablocks predictor when determining if data on a node gets
stored internal or not. Also make a note that the datablocks predictor takes
NO extended attributes stored in the node into account

In rare cases it could lead to confusion where the predictor would say it
wouldn't fit internally when it could just have fitted. This would trigger the
assertion. Now it will on rare accasions create a datablock even though it
might have fitted.

diffstat:

 usr.sbin/makefs/udf.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r 7c4509a7bcff -r cef63012609c usr.sbin/makefs/udf.c
--- a/usr.sbin/makefs/udf.c     Sat Apr 18 07:10:28 2020 +0000
+++ b/usr.sbin/makefs/udf.c     Sat Apr 18 09:45:45 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.19 2019/02/03 03:19:31 mrg Exp $ */
+/* $NetBSD: udf.c,v 1.20 2020/04/18 09:45:45 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: udf.c,v 1.19 2019/02/03 03:19:31 mrg Exp $");
+__RCSID("$NetBSD: udf.c,v 1.20 2020/04/18 09:45:45 reinoud Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -514,6 +514,7 @@
 udf_datablocks(off_t sz)
 {
        /* predictor if it can be written inside the node */
+       /* XXX the predictor assumes NO extended attributes in the node */
        if (sz < context.sector_size - UDF_EXTFENTRY_SIZE - 16)
                return 0;
 
@@ -561,7 +562,7 @@
        struct extfile_entry *efe;
        uint64_t inf_len, obj_size;
        uint32_t l_ea, l_ad;
-       uint32_t free_space, desc_size;
+       uint32_t desc_size;
        uint16_t crclen;
        uint8_t *data, *pos;
 
@@ -590,10 +591,9 @@
        }
        crclen = udf_rw16(dscr->tag.desc_crc_len);
 
-       /* calculate free space */
-       free_space = context.sector_size - (l_ea + l_ad) - desc_size;
+       /* check if it will fit internally */
        if (udf_datablocks(size)) {
-               assert(free_space < size);
+               /* the predictor tells it won't fit internally */
                return 1;
        }
 
@@ -602,7 +602,6 @@
        assert((udf_rw16(icb->flags) & UDF_ICB_TAG_FLAGS_ALLOC_MASK) ==
                        UDF_ICB_INTERN_ALLOC);
 
-       // assert(free_space >= size);
        pos = data + l_ea + l_ad;
        memcpy(pos, blob, size);
        l_ad   += size;



Home | Main Index | Thread Index | Old Index