forked from daos-stack/spdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0003-blob-chunk-clear-operations-in-IU-aligned-chunks.patch
48 lines (41 loc) · 1.75 KB
/
0003-blob-chunk-clear-operations-in-IU-aligned-chunks.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From 2364d9202ff67e66017f260c1656e525a9d957e7 Mon Sep 17 00:00:00 2001
From: Sydney Vanda <sydney.m.vanda@intel.com>
Date: Fri, 8 Oct 2021 19:10:20 +0000
Subject: [PATCH] blob: chunk clear operations in IU-aligned chunks
SSDs typically have 4KiB (sometimes 64KiB) indirection
units, meaning that unmap operations only work if all
logical blocks associated with an IU are unmapped.
But UINT32_MAX is not an aligned to IU (sometimes
called physical block) size when the SSD has 512B
logical format. This can result in the unmap
operation being ignored by the SSD, not even
unmapping the range of IUs that were fully in the
range of logical blocks requested to be unmapped.
Fixes issue #2190.
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I51bc2d3cddcd44a930088e904b3732e7f42ca2c8
---
lib/blob/blobstore.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c
index ecdc0a455..493ef7803 100644
--- a/lib/blob/blobstore.c
+++ b/lib/blob/blobstore.c
@@ -4947,7 +4947,15 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
lba = num_md_lba;
while (lba < ctx->bs->dev->blockcnt) {
- lba_count = spdk_min(UINT32_MAX, ctx->bs->dev->blockcnt - lba);
+ /* Clear operations have a uint32_t lba_count maximum, but we
+ * can't just use UINT32_MAX. We want the number of blocks
+ * in each chunk to be evenly aligned on a physical block
+ * boundary. Worst case is 512B logical with a 64KiB physical,
+ * which means it needs to be a multiple of 128.
+ */
+ const uint32_t max_lba_count = UINT32_MAX - 127;
+
+ lba_count = spdk_min(max_lba_count, ctx->bs->dev->blockcnt - lba);
switch (opts.clear_method) {
case BS_CLEAR_WITH_UNMAP:
/* Trim data clusters */
--
2.27.0