Skip to contentSkip to conversation

qemu-img check: format allocation info

PATCH In review Vladimir Sementsov-Ogievskiy 3 participants 8 messages Jul 29, 2017 – Aug 14, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

v4 cover qemu-img check: format allocation info

Hi all.

See 01 patch for the doc.

Question to discuss.
If I understand correctly get_block_status flags allocated, zero, and data actually provide 5 possible combinations, which I combine into three.

allocated data zero

1         1    1    \__ data
1         1    0    /
1         0    1    \__ zero
0         0    1    /
0         0    0    ___ discarded

This division looks not bad, but it is not the only one possible. Separating data is really useful - it shows leaked clusters.. So the question is, don't we want to adjust the division? I'm ok with the current one.

v4: - reword docs in 01
- s/2.10/2.11/ for qapi

v3: - improve docs
- rename fields
- add 'zero' type of underlying file portions status. It as these areas cannot be presented as 'discarded', but they are not occupying real space, so we don't want to present them as 'allocated data' too.
- remove last patch. It is not needed after introducing new naming for the fields

v2: fix build error, gcc things that some variables may be used
uninitialized (actually they didn't).

v1:

These series is a replacement for "qemu-img check: unallocated size" series.

There was a question, should we account allocated clusters in qcow2 but actually holes in underalying file as allocated or not. Instead of hiding this information in one-number statistic I've decided to print the whole information, 5 numbers:

For allocated by top-level format driver (qcow2 for ex.) clusters, 3
numbers: number of bytes, which are:
- allocated in underlying file
- holes in underlying file
- after end of underlying file

To account other areas of underlying file, 2 more numbers of bytes:
- unallocated by top-level driver but allocated in underlying file
- unallocated by top-level driver and holes in underlying file

Vladimir Sementsov-Ogievskiy (3):
block: add bdrv_get_format_alloc_stat format interface
qcow2: add .bdrv_get_format_alloc_stat qemu-img check: add format allocation info

 block.c                   |  16 +++++
 block/qcow2-refcount.c    | 152 ++++++++++++++++++++++++++++++++++++++++++++++
 block/qcow2.c             |   2 +
 block/qcow2.h             |   2 +
 include/block/block.h     |   3 +
 include/block/block_int.h |   2 +
 qapi/block-core.json      |  78 +++++++++++++++++++++++-
 qemu-img.c                |  42 +++++++++++++
 8 files changed, 296 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.1
#1 lore raw

PATCH v4 1/3 block: add bdrv_get_format_alloc_stat format interface

The function should collect statistics, about used/unused by top-level format driver space (in its .file) and allocation status (data/zero/discarded/after-eof) of corresponding areas in this .file.

---
 block.c                   | 16 +++++++++++
 include/block/block.h     |  3 ++
 include/block/block_int.h |  2 ++
 qapi/block-core.json      | 72 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 93 insertions(+)
block.c +16 -0
index 50ba264143..7d720ae0c2 100644
@@ -3407,6 +3407,22 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
 }
 
 /**
+ * Collect format allocation info. See BlockFormatAllocInfo definition in
+ * qapi/block-core.json.
+ */
+int bdrv_get_format_alloc_stat(BlockDriverState *bs, BlockFormatAllocInfo *bfai)
+{
+    BlockDriver *drv = bs->drv;
+    if (!drv) {
+        return -ENOMEDIUM;
+    }
+    if (drv->bdrv_get_format_alloc_stat) {
+        return drv->bdrv_get_format_alloc_stat(bs, bfai);
+    }
+    return -ENOTSUP;
+}
+
+/**
  * Return number of sectors on success, -errno on error.
  */
 int64_t bdrv_nb_sectors(BlockDriverState *bs)
include/block/block.h +3 -0
index 9b355e92d8..646376a772 100644
@@ -335,6 +335,9 @@ typedef enum {
 
 int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
 
+int bdrv_get_format_alloc_stat(BlockDriverState *bs,
+                               BlockFormatAllocInfo *bfai);
+
 /* The units of offset and total_work_size may be chosen arbitrarily by the
  * block driver; total_work_size may change during the course of the amendment
  * operation */
include/block/block_int.h +2 -0
index 8d3724cce6..458c715e99 100644
@@ -208,6 +208,8 @@ struct BlockDriver {
     int64_t (*bdrv_getlength)(BlockDriverState *bs);
     bool has_variable_length;
     int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs);
+    int (*bdrv_get_format_alloc_stat)(BlockDriverState *bs,
+                                      BlockFormatAllocInfo *bfai);
 
     int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs,
         uint64_t offset, uint64_t bytes, QEMUIOVector *qiov);
qapi/block-core.json +72 -0

78 lines not on this page · raw message

Signature · 1 line
2.11.1
#2 lore raw

Re: [Qemu-devel] [PATCH v4 1/3] block: add bdrv_get_format_alloc_stat format interface

Cc Eric Blake for additional schema review expertise.
Quoted 17 lines · Vladimir Sementsov-Ogievskiy

The function should collect statistics, about used/unused by top-level format driver space (in its .file) and allocation status (data/zero/discarded/after-eof) of corresponding areas in this .file.

---
 block.c                   | 16 +++++++++++
 include/block/block.h     |  3 ++
 include/block/block_int.h |  2 ++
 qapi/block-core.json      | 72 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 93 insertions(+)
block.c +0 -0
index 50ba264143..7d720ae0c2 100644

block.c int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) · line 3412

Quoted 6 lines
block.c +3 -0
@@ -3407,6 +3407,22 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
 }
 
 /**
+ * Collect format allocation info. See BlockFormatAllocInfo definition in
+ * qapi/block-core.json.
+ */

I'd prefer

/**
* Collect format allocation info.
* See BlockFormatAllocInfo definition in qapi/block-core.json. */

Admittedly a matter of taste.

block.c int64_t bdrv_get_allocated_file_size(BlockDriverState *bs) · line 3413

Quoted 1 line
block.c +1 -0
+int bdrv_get_format_alloc_stat(BlockDriverState *bs, BlockFormatAllocInfo *bfai)

bdrv_get_format_alloc_info(), please, for symmetry with BlockFormatAllocInfo.

Quoted 47 lines
block.c +12 -0
+{
+    BlockDriver *drv = bs->drv;
+    if (!drv) {
+        return -ENOMEDIUM;
+    }
+    if (drv->bdrv_get_format_alloc_stat) {
+        return drv->bdrv_get_format_alloc_stat(bs, bfai);
+    }
+    return -ENOTSUP;
+}
+
+/**
  * Return number of sectors on success, -errno on error.
  */
 int64_t bdrv_nb_sectors(BlockDriverState *bs)
include/block/block.h +3 -0
index 9b355e92d8..646376a772 100644
@@ -335,6 +335,9 @@ typedef enum {
 
 int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
 
+int bdrv_get_format_alloc_stat(BlockDriverState *bs,
+                               BlockFormatAllocInfo *bfai);
+
 /* The units of offset and total_work_size may be chosen arbitrarily by the
  * block driver; total_work_size may change during the course of the amendment
  * operation */
include/block/block_int.h +2 -0
index 8d3724cce6..458c715e99 100644
@@ -208,6 +208,8 @@ struct BlockDriver {
     int64_t (*bdrv_getlength)(BlockDriverState *bs);
     bool has_variable_length;
     int64_t (*bdrv_get_allocated_file_size)(BlockDriverState *bs);
+    int (*bdrv_get_format_alloc_stat)(BlockDriverState *bs,
+                                      BlockFormatAllocInfo *bfai);
 
     int coroutine_fn (*bdrv_co_pwritev_compressed)(BlockDriverState *bs,
         uint64_t offset, uint64_t bytes, QEMUIOVector *qiov);
qapi/block-core.json +0 -0
index ea0b3e8b13..93f6995381 100644

qapi/block-core.json line 144

Quoted 6 lines
qapi/block-core.json +3 -0
@@ -139,6 +139,78 @@
            '*format-specific': 'ImageInfoSpecific' } }
 
 ##
+# @BlockFormatAllocInfo:
+#
+#

Just one blank like, please.

qapi/block-core.json line 151

Quoted 7 lines
qapi/block-core.json +7 -0
+# Allocation information of an underlying protocol file, as partitioned by a
+# format driver's utilization of said allocations.
+# All fields are in bytes.
+#
+# Regions of the underlying protocol file may be considered used or unused by
+# the format driver interpreting these regions. It is at the discretion of the
+# format driver (e.g. qcow2) which regions of its backing storage are considered

Long line. Please wrap your comment lines around column 70 for legibility.

qapi/block-core.json line 154

Quoted 3 lines
qapi/block-core.json +3 -0
+# in-use or not.
+#
+# For now, the only format driver supporting this feature is Qcow2 which is a

"is QCow2, which"

qapi/block-core.json line 162

Quoted 8 lines
qapi/block-core.json +8 -0
+# cluster based format. Clusters considered in-use by qcow2 are those with a
+# non-zero refcount in the format metadata. All other clusters, if present, are
+# considered unused. Examples of unused allocations for the Qcow2 format are
+# leaked clusters, pre-allocated clusters, and recently freed clusters.
+#
+# Note: the whole underlying protocol file is described as well as all format
+# file allocations, not only virtual disk data (metadata, internal snapshots,
+# etc. are included).

I'm not sure I get this note.

qapi/block-core.json line 165

Quoted 3 lines
qapi/block-core.json +3 -0
+#
+# For the underlying protocol file there are native block-status types of the
+# regions:

Comma after "protocol file"? The sentence doesn't feel right to me even with the comma, though. What's a "native block-status type"?

qapi/block-core.json line 173

Quoted 8 lines
qapi/block-core.json +8 -0
+#  - data: allocated data
+#  - zero: reported as zero (for example, this type corresponds to holes for
+#          POSIX files on sparce file-system)
+#  - discarded: not allocated
+# 4th additional type is 'overrun', is data referenced by the format driver
+# located beyond EOF of the underlying protocol file. For example, a partially
+# allocated cluster at the end of a QCOW2 file, where Qcow2 generally operates
+# on complete clusters.

Explaining three of four types in a list, and the fourth in the paragraph following the list feels awkward. Turn it into a fourth list item?

qapi/block-core.json line 184

Quoted 11 lines
qapi/block-core.json +11 -0
+#
+# So, the fields are:
+#
+# @used-data: used by the format file and backed by data in the underlying
+#             protocol file
+#
+# @used-zero: used by the format file and backed by zeroes in the underlying
+#             protocol file; which may be a filesystem hole for POSIX files.
+#
+# @used-discarded: used by the format file but actually unallocated in the
+#                  underlying protocol file

Are discarded clusters normal or some kind of problem?

qapi/block-core.json line 187

Quoted 3 lines
qapi/block-core.json +3 -0
+#
+# @used-overrun: used by the format file beyond the end of the underlying
+#                protocol file

Are overruns normal or some kind of problem?

Quoted 14 lines
qapi/block-core.json +14 -0
+#
+# @unused-data: allocated data in the underlying protocol file not used by the
+#               format file
+#
+# @unused-zero: reported-as-zero regions in the underlying protocol file not
+#               used by the format file
+#
+# @unused-discarded: unallocated areas in the underlying protocol file not used
+#                    by the format file
+#
+# Note: sum of 6 fields {used,unused}-{data,zero,discarded} is equal to the
+#       length of the underlying protocol file.
+#
+# Since: 2.11

qapi/block-core.json line 211

Quoted 10 lines
qapi/block-core.json +10 -0
+#
+##
+{ 'struct': 'BlockFormatAllocInfo',
+  'data': {'used-data':        'uint64',
+           'used-zero':        'uint64',
+           'used-discarded':   'uint64',
+           'used-overrun':     'uint64',
+           'unused-data':      'uint64',
+           'unused-zero':      'uint64',
+           'unused-discarded': 'uint64' } }

Please use 'size' for byte counts. See also "[RFC PATCH 00/56] qapi:
Use 'size' for byte counts & offsets".

Quoted 5 lines
qapi/block-core.json +2 -0
+
+##
 # @ImageCheck:
 #
 # Information about a QEMU image file check
#3 lore raw

PATCH v4 2/3 qcow2: add .bdrv_get_format_alloc_stat

In reply to Vladimir Sementsov-Ogievskiy

Realize .bdrv_get_format_alloc_stat interface.

---
 block/qcow2-refcount.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++
 block/qcow2.c          |   2 +
 block/qcow2.h          |   2 +
 3 files changed, 156 insertions(+)
block/qcow2-refcount.c +152 -0
index 7c06061aae..fd6027f0c2 100644
@@ -2931,3 +2931,155 @@ done:
     qemu_vfree(new_refblock);
     return ret;
 }
+
+typedef struct FormatAllocStatCo {
+    BlockDriverState *bs;
+    BlockFormatAllocInfo *bfai;
+    int64_t ret;
+} FormatAllocStatCo;
+
+static void coroutine_fn qcow2_get_format_alloc_stat_entry(void *opaque)
+{
+    int ret = 0;
+    FormatAllocStatCo *nbco = opaque;
+    BlockDriverState *bs = nbco->bs;
+    BDRVQcow2State *s = bs->opaque;
+    BlockFormatAllocInfo *bfai = nbco->bfai;
+    int64_t cluster, file_sectors, sector;
+    int refcount_block_offset;
+    uint32_t i;
+    bool used = false, f_data = false, f_zero = false;
+    int dif, num = 0, f_num = 0;
+
+    memset(bfai, 0, sizeof(*bfai));
+
+    file_sectors = bdrv_nb_sectors(bs->file->bs);
+    if (file_sectors < 0) {
+        nbco->ret = file_sectors;
+        return;
+    }
+
+    qemu_co_mutex_lock(&s->lock);
+
+    for (sector = 0; sector < file_sectors; sector += dif) {
+        if (f_num == 0) {
+            BlockDriverState *file;
+            ret = bdrv_get_block_status(bs->file->bs, sector,
+                                        file_sectors - sector, &f_num, &file);
+            if (ret < 0) {
+                goto fail;
+            }
+            f_data = ret & BDRV_BLOCK_DATA;
+            f_zero = ret & BDRV_BLOCK_ZERO;
+        }
+
+        if (num == 0) {
+            uint64_t refcount;
+            assert(((sector << BDRV_SECTOR_BITS) & (s->cluster_size - 1)) == 0);
+            ret = qcow2_get_refcount(
+                bs, (sector << BDRV_SECTOR_BITS) >> s->cluster_bits, &refcount);
+            if (ret < 0) {
+                goto fail;
+            }
+            used = refcount > 0;
+            num = s->cluster_size >> BDRV_SECTOR_BITS;
+        }
+
+        dif = MIN(f_num, MIN(num, file_sectors - sector));
+        if (used) {
+            if (f_data) {
+                bfai->used_data += dif;
+            } else if (f_zero) {
+                bfai->used_zero += dif;
+            } else {
+                bfai->used_discarded += dif;
+            }
+        } else {
+            if (f_data) {
+                bfai->unused_data += dif;
+            } else if (f_zero) {
+                bfai->unused_zero += dif;
+            } else {
+                bfai->unused_discarded += dif;
+            }
+        }
+        f_num -= dif;
+        num -= dif;
+    }
+
+    assert(f_num == 0);
+
+    if (used) {
+        bfai->used_overrun += num;
+    }
+
+    cluster = size_to_clusters(s, sector << BDRV_SECTOR_BITS);
+    refcount_block_offset = cluster & (s->refcount_block_size - 1);
+    for (i = cluster >> s->refcount_block_bits;
+         i <= s->max_refcount_table_index; i++)
+    {
+        int j;
+
+        if (!(s->refcount_table[i] & REFT_OFFSET_MASK)) {
+            refcount_block_offset = 0;
+            continue;
+        }
+
+        for (j = refcount_block_offset; j < s->refcount_block_size; j++) {
+            uint64_t refcount;
+            cluster = (i << s->refcount_block_bits) + j;
+
+            ret = qcow2_get_refcount(bs, cluster, &refcount);
+            if (ret < 0) {
+                goto fail;
+            }
+            if (refcount > 0) {
+                bfai->used_overrun++;
+            }
+        }
+
+        refcount_block_offset = 0;
+    }
+
+    qemu_co_mutex_unlock(&s->lock);
+
+    bfai->used_data = bfai->used_data << BDRV_SECTOR_BITS;
+    bfai->used_zero = bfai->used_zero << BDRV_SECTOR_BITS;
+    bfai->used_discarded = bfai->used_discarded << BDRV_SECTOR_BITS;
+    bfai->used_overrun = bfai->used_overrun << BDRV_SECTOR_BITS;
+
+    bfai->unused_data = bfai->unused_data << BDRV_SECTOR_BITS;
+    bfai->unused_zero = bfai->unused_zero << BDRV_SECTOR_BITS;
+    bfai->unused_discarded = bfai->unused_discarded << BDRV_SECTOR_BITS;
+
+    nbco->ret = 0;
+    return;
+
+fail:
+    nbco->ret = ret;
+    qemu_co_mutex_unlock(&s->lock);
+}
+
+/* qcow2_get_format_alloc_stat()
+ * Fills @bfai struct. In case of failure @bfai content is unpredicted.
+ */
+int qcow2_get_format_alloc_stat(BlockDriverState *bs,
+                                BlockFormatAllocInfo *bfai)
+{
+    FormatAllocStatCo nbco = {
+        .bs = bs,
+        .bfai = bfai,
+        .ret = -EINPROGRESS
+    };
+
+    if (qemu_in_coroutine()) {
+        qcow2_get_format_alloc_stat_entry(&nbco);
+    } else {
+        Coroutine *co =
+            qemu_coroutine_create(qcow2_get_format_alloc_stat_entry, &nbco);
+        qemu_coroutine_enter(co);
+        BDRV_POLL_WHILE(bs, nbco.ret == -EINPROGRESS);
+    }
+
+    return nbco.ret;
+}
block/qcow2.c +2 -0
index a8d61f0981..0e26b548fd 100644
@@ -3469,6 +3469,8 @@ BlockDriver bdrv_qcow2 = {
 
     .bdrv_detach_aio_context  = qcow2_detach_aio_context,
     .bdrv_attach_aio_context  = qcow2_attach_aio_context,
+
+    .bdrv_get_format_alloc_stat = qcow2_get_format_alloc_stat,
 };
 
 static void bdrv_qcow2_init(void)
block/qcow2.h +2 -0
index 1801dc30dc..16d31a8624 100644
@@ -598,4 +598,6 @@ int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
     void **table);
 void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table);
 
+int qcow2_get_format_alloc_stat(BlockDriverState *bs,
+                                BlockFormatAllocInfo *bfai);
 #endif
Signature · 1 line
2.11.1
#4 lore raw

PATCH v4 3/3 qemu-img check: add format allocation info

In reply to Vladimir Sementsov-Ogievskiy
---
 qapi/block-core.json |  6 +++++-
 qemu-img.c           | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
qapi/block-core.json +5 -1
index 93f6995381..d662786261 100644
@@ -249,6 +249,9 @@
 #                       field is present if the driver for the image format
 #                       supports it
 #
+# @format-alloc-info: Format-allocation information, see
+#                     BlockFormatAllocInfo description. (Since: 2.11)
+#
 # Since: 1.4
 #
 ##
@@ -257,7 +260,8 @@
            '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
            '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
            '*total-clusters': 'int', '*allocated-clusters': 'int',
-           '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
+           '*fragmented-clusters': 'int', '*compressed-clusters': 'int',
+           '*format-alloc-info': 'BlockFormatAllocInfo' } }
 
 ##
 # @MapEntry:
qemu-img.c +42 -0

66 lines not on this page · raw message

Signature · 1 line
2.11.1
#5 lore raw

Re: [Qemu-devel] [PATCH v4 3/3] qemu-img check: add format allocation info

Quoted 11 lines · Vladimir Sementsov-Ogievskiy
---
 qapi/block-core.json |  6 +++++-
 qemu-img.c           | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
qapi/block-core.json +0 -0
index 93f6995381..d662786261 100644

qapi/block-core.json line 253

Quoted 5 lines
qapi/block-core.json +2 -0
@@ -249,6 +249,9 @@
 #                       field is present if the driver for the image format
 #                       supports it
 #
+# @format-alloc-info: Format-allocation information, see
+#                     BlockFormatAllocInfo description. (Since: 2.11)

We don't usually add 'see the type'. Would just

# @format-alloc-info: Format allocation information

suffice?

Quoted 14 lines
qapi/block-core.json +3 -1
+#
 # Since: 1.4
 #
 ##
@@ -257,7 +260,8 @@
            '*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
            '*corruptions-fixed': 'int', '*leaks-fixed': 'int',
            '*total-clusters': 'int', '*allocated-clusters': 'int',
-           '*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
+           '*fragmented-clusters': 'int', '*compressed-clusters': 'int',
+           '*format-alloc-info': 'BlockFormatAllocInfo' } }
 
 ##
 # @MapEntry:

[...]

#6 lore raw
In reply to Vladimir Sementsov-Ogievskiy
Quoted 7 lines · Vladimir Sementsov-Ogievskiy

Hi all.

See 01 patch for the doc.

Question to discuss.
If I understand correctly get_block_status flags allocated, zero, and data actually provide 5 possible combinations, which I combine into three.

There are actually 8 possible bit combinations, but you are right that some of them are in practice impossible (since the allocated bit can only be set in cases where the underlying driver set the data or zero bit).

Quoted 3 lines

allocated data zero
1 1 1 \__ data

This one is interesting - it means we know the contents read as zero, but that it occupies space on the disk instead of being a hole; reporting it as zero may make it easier to punch a hole.

Quoted 1 line

1 1 0 /

Yes, definitely data, and no clue if it can be turned into a hole.

Quoted 2 lines
1         0    1    \__ zero
0         0    1    /

Yes, definitely zero. (The former happens when a format layer directly reports that the current layer reads as zero; the latter is possible when a format layer doesn't have an allocation, but where we know unallocated clusters read as zero, perhaps because there is no backing file to further fall back to).

Quoted 1 line

0 0 0 ___ discarded

Could also mean hasn't been touched yet (discarded sort of implies that it has been touched at some point in the past)

The other bit patterns:

0 1 0 - not possible: if a driver sets data, then the
block layer sets allocated

  0         1    1    - ditto
  1         0    0    - not possible: nothing sets the allocated bit in

isolation

Quoted 6 lines

This division looks not bad, but it is not the only one possible. Separating data is really useful - it shows leaked clusters.. So the question is, don't we want to adjust the division? I'm ok with the current one.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#7 lore raw
Quoted 29 lines · Eric Blake
Quoted 7 lines · Vladimir Sementsov-Ogievskiy

Hi all.

See 01 patch for the doc.

Question to discuss.
If I understand correctly get_block_status flags allocated, zero, and data actually provide 5 possible combinations, which I combine into three.

There are actually 8 possible bit combinations, but you are right that some of them are in practice impossible (since the allocated bit can only be set in cases where the underlying driver set the data or zero bit).

Quoted 2 lines

allocated data zero
1 1 1 \__ data

This one is interesting - it means we know the contents read as zero, but that it occupies space on the disk instead of being a hole; reporting it as zero may make it easier to punch a hole.

Quoted 1 line

1 1 0 /

Yes, definitely data, and no clue if it can be turned into a hole.

Quoted 2 lines
1         0    1    \__ zero
0         0    1    /

Yes, definitely zero. (The former happens when a format layer directly reports that the current layer reads as zero; the latter is possible when a format layer doesn't have an allocation, but where we know unallocated clusters read as zero, perhaps because there is no backing file to further fall back to).

Quoted 3 lines
Quoted 1 line

0 0 0 ___ discarded

Could also mean hasn't been touched yet (discarded sort of implies that it has been touched at some point in the past)

last time I don't like it too. What about renaming it to just 'unallocated'?

Quoted 15 lines

The other bit patterns:

0 1 0 - not possible: if a driver sets data, then the
block layer sets allocated

   0         1    1    - ditto
   1         0    0    - not possible: nothing sets the allocated bit in

isolation

Quoted 5 lines

This division looks not bad, but it is not the only one possible. Separating data is really useful - it shows leaked clusters.. So the question is, don't we want to adjust the division? I'm ok with the current one.

Signature · 2 lines
Best regards,
Vladimir