Displaying 10 results from an estimated 10 matches for "new_bm".
Did you mean:
new_bh
2018 Jan 26
2
[PATCH nbdkit] filters: cache, cow: Handle bitmap overflow on 32 bit architectures.
...cache.c
+++ b/filters/cache/cache.c
@@ -72,7 +72,7 @@ static int fd = -1;
static uint8_t *bitmap;
/* Size of the bitmap in bytes. */
-static uint64_t bm_size;
+static size_t bm_size;
enum bm_entry {
BLOCK_NOT_CACHED = 0,
@@ -167,7 +167,14 @@ blk_set_size (uint64_t new_size)
{
uint8_t *new_bm;
const size_t old_bm_size = bm_size;
- size_t new_bm_size = DIV_ROUND_UP (new_size, BLKSIZE*8/2);
+ uint64_t new_bm_size_u64 = DIV_ROUND_UP (new_size, BLKSIZE*8/2);
+ size_t new_bm_size;
+
+ if (new_bm_size_u64 > SIZE_MAX) {
+ nbdkit_error ("bitmap too large for this architecture&...
2018 Dec 01
0
[PATCH nbdkit] common: Move shared bitmap code to a common library.
...+#include <string.h>
+#include <stdint.h>
+
+#include <nbdkit-plugin.h>
+
+#include "bitmap.h"
+#include "rounding.h"
+
+int
+bitmap_resize (struct bitmap *bm, uint64_t new_size)
+{
+ uint8_t *new_bitmap;
+ const size_t old_bm_size = bm->size;
+ uint64_t new_bm_size_u64;
+ size_t new_bm_size;
+
+ new_bm_size_u64 = DIV_ROUND_UP (new_size, bm->blksize * 8 / bm->bpb);
+ if (new_bm_size_u64 > SIZE_MAX) {
+ nbdkit_error ("bitmap too large for this architecture");
+ return -1;
+ }
+ new_bm_size = (size_t) new_bm_size_u64;
+
+ new_...
2018 Dec 02
0
[PATCH nbdkit v2] common: Move shared bitmap code to a common library.
...+#include <string.h>
+#include <stdint.h>
+
+#include <nbdkit-plugin.h>
+
+#include "bitmap.h"
+#include "rounding.h"
+
+int
+bitmap_resize (struct bitmap *bm, uint64_t new_size)
+{
+ uint8_t *new_bitmap;
+ const size_t old_bm_size = bm->size;
+ uint64_t new_bm_size_u64;
+ size_t new_bm_size;
+
+ new_bm_size_u64 = DIV_ROUND_UP (new_size, bm->blksize * 8 / bm->bpb);
+ if (new_bm_size_u64 > SIZE_MAX) {
+ nbdkit_error ("bitmap too large for this architecture");
+ return -1;
+ }
+ new_bm_size = (size_t) new_bm_size_u64;
+
+ new_...
2018 Dec 03
0
[PATCH nbdkit v3] common: Move shared bitmap code to a common library.
...+#include <string.h>
+#include <stdint.h>
+
+#include <nbdkit-plugin.h>
+
+#include "bitmap.h"
+#include "rounding.h"
+
+int
+bitmap_resize (struct bitmap *bm, uint64_t new_size)
+{
+ uint8_t *new_bitmap;
+ const size_t old_bm_size = bm->size;
+ uint64_t new_bm_size_u64;
+ size_t new_bm_size;
+
+ new_bm_size_u64 = DIV_ROUND_UP (new_size,
+ bm->blksize * UINT64_C(8) / bm->bpb);
+ if (new_bm_size_u64 > SIZE_MAX) {
+ nbdkit_error ("bitmap too large for this architecture");
+ return -1;
+ }
+ new_...
2018 Dec 01
2
[PATCH nbdkit] common: Move shared bitmap code to a common library.
I have some patches I'm working on to fix the cache filter.
However this is a prelude. It should be simply pure refactoring.
All tests pass still.
Rich.
2018 Dec 03
3
[PATCH nbdkit v3] common: Move shared bitmap code to a common library.
v2:
https://www.redhat.com/archives/libguestfs/2018-December/msg00039.html
v2 -> v3:
- Fix all the issues raised in Eric's review.
- Precompute some numbers to make the calculations easier.
- Calculations now use bitshifts and masks in preference to division
and modulo.
- Clear existing bits before setting (which fixes a bug in the cache
filter).
Rich.
2018 Dec 02
2
[PATCH nbdkit v2] common: Move shared bitmap code to a common library.
This is exactly the same as v1:
https://www.redhat.com/archives/libguestfs/2018-December/msg00004.html
except that it now frees the bitmap on unload (which the old code did
not - there was always a memory leak).
Rich.
2018 Jan 21
2
Re: [PATCH nbdkit] filters: Add copy-on-write filter.
...("cow: filesystem block size: %d", blksize);
}
static void
@@ -147,6 +147,34 @@ cow_open (nbdkit_next_open *next, void *nxdata, int readonly)
return &handle;
}
+/* Allocate or resize the overlay file and bitmap. */
+static int
+blk_set_size (uint64_t new_size)
+{
+ uint8_t *new_bm;
+ const size_t old_bm_size = bm_size;
+ size_t new_bm_size = DIV_ROUND_UP (new_size, BLKSIZE*8);
+
+ new_bm = realloc (bitmap, new_bm_size);
+ if (new_bm == NULL) {
+ nbdkit_error ("realloc: %m");
+ return -1;
+ }
+ bitmap = new_bm;
+ bm_size = new_bm_size;
+ if (old_bm_siz...
2018 Jan 22
1
[PATCH nbdkit] filters: Add caching filter.
This adds a cache filter, which works like the COW filter in reverse.
For realistic use it needs a bit more work, especially to add limits
on the size of the cache, a more sensible cache replacement policy,
and perhaps some kind of background worker to write dirty blocks out.
Rich.
2018 Jan 20
4
[PATCH nbdkit] filters: Add copy-on-write filter.
Eric, you'll probably find the design "interesting" ...
It does work, for me at least.
Rich.