forked from snu-csl/nvmevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappend_only.c
41 lines (33 loc) · 842 Bytes
/
append_only.c
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
// SPDX-License-Identifier: GPL-2.0-only
#include "nvmev.h"
#include <linux/bitmap.h>
#include <linux/types.h>
#include <asm/bitops.h>
#include <linux/log2.h>
#include <linux/hashtable.h>
#include <linux/kernel.h>
static unsigned long long latest;
static unsigned long long dev_size;
static unsigned long long total_written;
int append_only_allocator_init(u64 size)
{
dev_size = size;
latest = 0;
total_written = 0;
NVMEV_INFO("Initialized an append memory pool with size %llu", size);
return 1;
}
size_t append_only_allocate(u64 length, void *args)
{
size_t ret = latest;
latest += length;
total_written += length;
NVMEV_DEBUG("Returning offset %llu for length %llu", ret, length);
if (latest + 65536 >= dev_size) {
NVMEV_ERROR("append-only allocator is nearly full!!");
}
return ret;
}
void append_only_kill(void)
{
}