Skip to content

Commit

Permalink
Pushing 4.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoutoupis committed May 21, 2016
1 parent 2351ee2 commit fded380
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 45 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
@@ -1,3 +1,10 @@
*** Release 4.2 ***

- kernel: Added Write-Around support to rapiddisk-cache.
- kernel: Fixed LINUX_VERSION check for rapiddisk-cache to accommodate changes in 3.8.3.
- utility: Added a NOCRYPT build flag.
- utility: Added user definable keys for encryption setup.

*** Release 4.1-2 ***

- kernel: Readjusted misaligned discard request check to build on kernels older than 4.3.
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -33,3 +33,9 @@ tools-uninstall:
cd ../conf; make uninstall; \
cd ../doc; make uninstall; \
cd ../www; make install; cd ..

.PHONY: nocrypt
nocrypt:
cd src; make nocrypt; \
cd ../module; make; \
cd ../test; make; cd ..
5 changes: 5 additions & 0 deletions README
Expand Up @@ -55,6 +55,11 @@ Uninstalling:
# make tools-uninstall


Build without encryption support
================================================================
# make nocrypt


Installing modules for DKMS support
================================================================
# make dkms
Expand Down
9 changes: 7 additions & 2 deletions doc/rapiddisk.1
Expand Up @@ -2,7 +2,7 @@
.SH NAME
rapiddisk \- An administration tool to manage the RapidDisk RAM disk devices and RapidDisk-Cache mappings.
.SH SYNOPSIS
rapiddisk [ -h | -v ] function [parameters: unit | size | src & dest | cache & source ]
rapiddisk [ -h | -v ] function [ parameters: unit | size | src & dest | cache & source | mode ]
.SH DESCRIPTION
rapiddisk is a RapidDisk module management tool. The tool allows the user to list all attached RapidDisk devices, with the ability to dynamically attach a new RapidDisk block devices and detach existing ones. It also is capable of mapping and unmapping an RapidDisk volumes as a Write-Through cache to any block device via the RapidDisk-Cache kernel module.
.SS Options
Expand Down Expand Up @@ -51,7 +51,7 @@ Obtain RapidDisk-Cache Mappings statistics.
Initialize a storage volume for data encryption.
.TP
--activate-crypt
Activate an encryption volume.
Activate an encryption volume. For user defined keys. Please store them in /etc/rapiddisk/key, otherwise it will default to the built DES key provided by the utility.
.TP
--deactivate-crypt
Deactivate an encryption volume.
Expand All @@ -74,6 +74,9 @@ Specify RapidDisk node to use as caching volume.
.TP
[source]
Specify block device to map cache to.
.TP
[mode]
Write Through (wt) or Write Around (wa) for cache.
.SH EXAMPLES
.TP
rapiddisk --list
Expand All @@ -90,6 +93,8 @@ rapiddisk --restore rd-052911.dat rd0
.TP
rapiddisk --cache-map rd1 /dev/sdb
.TP
rapiddisk --cache-map rd1 /dev/sdb wt
.TP
rapiddisk --cache-unmap rc_sdb
.TP
rapiddisk --stat-cache rc_sdb
Expand Down
5 changes: 3 additions & 2 deletions module/Makefile
@@ -1,4 +1,4 @@
VERSION = 4.1
VERSION = 4.2

ifeq ($(KSRC),)
KSRC := /lib/modules/$(shell uname -r)/build
Expand Down Expand Up @@ -28,7 +28,8 @@ uninstall:
depmod -a

clean:
rm -rf *.o *.ko *.symvers *.mod.c .*.cmd Module.markers modules.order .tmp_versions .rapiddisk.o.d *.unsigned
rm -rf *.o *.ko *.symvers *.mod.c .*.cmd Module.markers modules.order
rm -rf .tmp_versions .rapiddisk.o.d *.unsigned *.sdtinfo.c .ctf/

.PHONY: dkms
dkms:
Expand Down
2 changes: 1 addition & 1 deletion module/dkms.conf
@@ -1,5 +1,5 @@
PACKAGE_NAME="rapiddisk"
PACKAGE_VERSION="4.1"
PACKAGE_VERSION="4.2"
BUILT_MODULE_NAME[0]="rapiddisk"
BUILT_MODULE_NAME[1]="rapiddisk-cache"
DEST_MODULE_LOCATION[0]="/kernel/rapiddisk/"
Expand Down
36 changes: 27 additions & 9 deletions module/rapiddisk-cache.c
Expand Up @@ -47,7 +47,7 @@
} \
} while (0)

#define VERSION_STR "4.1"
#define VERSION_STR "4.2"
#define DM_MSG_PREFIX "rapiddisk-cache"

#define READCACHE 1
Expand All @@ -56,6 +56,9 @@
#define WRITESOURCE 4
#define READCACHE_DONE 5

#define WRITETHROUGH 0
#define WRITEAROUND 1

#define GENERIC_ERROR -1
#define BYTES_PER_BLOCK 512
/* Default cache parameters */
Expand Down Expand Up @@ -92,6 +95,7 @@ struct cache_context {
struct cache_block *cache;
u8 *cache_state;
u32 *set_lru_next;
int mode; /* Write Through / Around */

struct dm_io_client *io_client;
sector_t size;
Expand Down Expand Up @@ -791,10 +795,12 @@ int rc_map(struct dm_target *ti, struct bio *bio, union map_info *map_context)
dmc->writes++;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
if (to_sector(bio->bi_iter.bi_size) != dmc->block_size) {
if (to_sector(bio->bi_iter.bi_size) != dmc->block_size ||
#else
if (to_sector(bio->bi_size) != dmc->block_size) {
if (to_sector(bio->bi_size) != dmc->block_size ||
#endif
(dmc->mode && (bio_data_dir(bio) == WRITE))) {

spin_lock_bh(&dmc->cache_spin_lock);
(void)cache_invalidate_blocks(dmc, bio);
spin_unlock_bh(&dmc->cache_spin_lock);
Expand Down Expand Up @@ -888,7 +894,8 @@ static inline int rc_get_dev(struct dm_target *ti, char *pth,
* arg[0]: path to source device
* arg[1]: path to cache device
* arg[2]: cache size (in blocks)
* arg[3]: cache associativity */
* arg[3]: mode: write through / around
* arg[4]: cache associativity */
static int cache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{
struct cache_context *dmc;
Expand Down Expand Up @@ -964,7 +971,17 @@ static int cache_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}

if (argc >= 4) {
if (kstrtoint(argv[3], 10, &dmc->assoc)) {
if (sscanf(argv[3], "%d", &dmc->mode) != 1) {
ti->error = "rapiddisk-cache: Invalid mode";
r = -EINVAL;
goto construct_fail5;
}
} else {
dmc->mode = WRITETHROUGH;
}

if (argc >= 5) {
if (kstrtoint(argv[4], 10, &dmc->assoc)) {
ti->error = "rapiddisk-cache: Invalid cache associativity";
r = -EINVAL;
goto construct_fail5;
Expand Down Expand Up @@ -1132,13 +1149,14 @@ static void rc_status_table(struct cache_context *dmc, status_type_t type,
DMEMIT("conf:\n\tRapidDisk dev (%s), disk dev (%s) mode (%s)\n"
"\tcapacity(%luM), associativity(%u), block size(%uK)\n"
"\ttotal blocks(%lu), cached blocks(%lu)\n",
dmc->cache_devname, dmc->disk_devname, "WRITETHROUGH",
dmc->cache_devname, dmc->disk_devname,
((dmc->mode) ? "WRITE_AROUND" : "WRITETHROUGH"),
(unsigned long)dmc->size * dmc->block_size >> 11, dmc->assoc,
dmc->block_size >> (10 - SECTOR_SHIFT),
(unsigned long)dmc->size, dmc->cached_blocks);
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,3)
static int
#else
static void
Expand All @@ -1161,14 +1179,14 @@ cache_status(struct dm_target *ti, status_type_t type, unsigned status_flags,
rc_status_table(dmc, type, result, maxlen);
break;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,3)
return 0;
#endif
}

static struct target_type cache_target = {
.name = "rapiddisk-cache",
.version = {4, 1, 0},
.version = {4, 2, 0},
.module = THIS_MODULE,
.ctr = cache_ctr,
.dtr = cache_dtr,
Expand Down
2 changes: 1 addition & 1 deletion module/rapiddisk.c
Expand Up @@ -29,7 +29,7 @@
#include <linux/radix-tree.h>
#include <linux/io.h>

#define VERSION_STR "4.1"
#define VERSION_STR "4.2"
#define PREFIX "rapiddisk"
#define BYTES_PER_SECTOR 512
#define MAX_RDSKS 128
Expand Down
7 changes: 7 additions & 0 deletions pkg-mgmt/debian/changelog
@@ -1,3 +1,10 @@
rapiddisk (4.2-1) released; urgency=medium

* kernel: Added Write-Around support to rapiddisk-cache.
* kernel: Fixed LINUX_VERSION check for rapiddisk-cache to accommodate changes in 3.8.3.
* utility: Added a NOCRYPT build flag.
* utility: Added user definable keys for encryption setup.

rapiddisk (4.1-2) released; urgency=medium

* kernel: Readjusted misaligned discard request check to build on kernels older than 4.3.
Expand Down
2 changes: 1 addition & 1 deletion pkg-mgmt/debian/control
@@ -1,5 +1,5 @@
Package: rapiddisk
Version: 4.1-2
Version: 4.2-1
Section: base
Priority: optional
Architecture: amd64
Expand Down
6 changes: 3 additions & 3 deletions pkg-mgmt/debian/postinst
Expand Up @@ -16,9 +16,9 @@ fi
case "$1" in

configure)
dkms add -m rapiddisk -v 4.1
dkms build -m rapiddisk -v 4.1
dkms install -m rapiddisk -v 4.1
dkms add -m rapiddisk -v 4.2
dkms build -m rapiddisk -v 4.2
dkms install -m rapiddisk -v 4.2
echo "rapiddisk max_sectors=2048 nr_requests=1024" >> /etc/modules
echo "rapiddisk-cache" >> /etc/modules
echo "dm_mod" >> /etc/modules
Expand Down
2 changes: 1 addition & 1 deletion pkg-mgmt/debian/prerm
Expand Up @@ -14,7 +14,7 @@ fi

case "$1" in
remove|upgrade|deconfigure)
dkms remove -m rapiddisk -v 4.1 --all
dkms remove -m rapiddisk -v 4.2 --all
;;

failed-upgrade)
Expand Down
9 changes: 7 additions & 2 deletions pkg-mgmt/spec/rapiddisk.spec.opensuse
@@ -1,7 +1,7 @@
Summary: The RapidDisk software defined advanced RAM drive and storage caching solution.
Name: rapiddisk
Version: 4.1
Release: 2
Version: 4.2
Release: 1
License: General Public License Version 2
Group: Applications/System
Source: %{name}-%{version}.tar.gz
Expand Down Expand Up @@ -85,6 +85,11 @@ rm -rf %{buildroot}
%doc %attr(0444,root,root) /usr/share/man/man1/*

%changelog
* Tue May 17 2016 Petros Koutoupis <petros@petroskoutoupis.com>
- kernel: Added Write-Around support to rapiddisk-cache.
- kernel: Fixed LINUX_VERSION check for rapiddisk-cache to accommodate changes in 3.8.3.
- utility: Added a NOCRYPT build flag.
- utility: Added user definable keys for encryption setup.
* Tue May 10 2016 Petros Koutoupis <petros@petroskoutoupis.com>
- kernel: Readjusted misaligned discard request check to build on kernels older than 4.3.
* Mon May 9 2016 Petros Koutoupis <petros@petroskoutoupis.com>
Expand Down
9 changes: 7 additions & 2 deletions pkg-mgmt/spec/rapiddisk.spec.rhel
@@ -1,7 +1,7 @@
Summary: The RapidDisk software defined advanced RAM drive and storage caching solution.
Name: rapiddisk
Version: 4.1
Release: 2
Version: 4.2
Release: 1
License: General Public License Version 2
Group: Applications/System
Source: %{name}-%{version}.tar.gz
Expand Down Expand Up @@ -85,6 +85,11 @@ rm -rf %{buildroot}
%doc %attr(0444,root,root) /usr/share/man/man1/*

%changelog
* Tue May 17 2016 Petros Koutoupis <petros@petroskoutoupis.com>
- kernel: Added Write-Around support to rapiddisk-cache.
- kernel: Fixed LINUX_VERSION check for rapiddisk-cache to accommodate changes in 3.8.3.
- utility: Added a NOCRYPT build flag.
- utility: Added user definable keys for encryption setup.
* Tue May 10 2016 Petros Koutoupis <petros@petroskoutoupis.com>
- kernel: Readjusted misaligned discard request check to build on kernels older than 4.3.
* Mon May 9 2016 Petros Koutoupis <petros@petroskoutoupis.com>
Expand Down
12 changes: 12 additions & 0 deletions src/Makefile
Expand Up @@ -20,6 +20,10 @@ DIR := /sbin
all: rapiddisk
@echo Make has completed.

.PHONY: nocrypt
nocrypt: rapiddisk-nocrypt
@echo Make has completed.

.PHONY: install
install: all
@echo Installing all binary files.
Expand Down Expand Up @@ -47,11 +51,19 @@ else
$(CC) -c crypt.c -o crypt.o
endif

crypt-nocrypt.o: crypt.c
$(CC) -c crypt.c -DNO_CRYPT -o crypt-nocrypt.o

main.o: core.o archive.o crypt.o
$(CC) main.c -o rapiddisk core.o archive.o crypt.o -lz -lcryptsetup

main-nocrypt.o: core.o archive.o crypt-nocrypt.o
$(CC) main.c -DNO_CRYPT -o rapiddisk core.o archive.o crypt-nocrypt.o -lz

rapiddisk: main.o

rapiddisk-nocrypt: main-nocrypt.o

.PHONY: clean
clean:
rm -f *.o $(BIN)
7 changes: 5 additions & 2 deletions src/common.h
Expand Up @@ -26,13 +26,16 @@

#define UTIL "rapiddisk"
#define COPYRIGHT "Copyright 2011-2016 Petros Koutoupis"
#define VERSION_NUM "4.1"
#define VERSION_NUM "4.2"
#define SUCCESS 0x0
#define NAMELEN 0x100
#define BYTES_PER_SECTOR 0x200
#define BUFSZ 0x10000
#define DES_KEY "05291983"
#define DEFAULT_DES_KEY "05291983"
#define SYS_RDSK "/sys/kernel/rapiddisk/mgmt"
#define KEY_FILE "/etc/rapiddisk/key"
#define WRITETHROUGH 0
#define WRITEAROUND 1

typedef struct RD_PROFILE{ /* For RapidDisk device list */
unsigned char device[16];
Expand Down
21 changes: 13 additions & 8 deletions src/core.c
Expand Up @@ -170,8 +170,10 @@ int list_devices(struct RD_PROFILE *rd_prof, struct RC_PROFILE *rc_prof)
}
num = 1;
while (rc_prof != NULL) {
printf(" RapidDisk-Cache Target %d: %s\tCache: %s Target: %s (WRITETHROUGH)\n",
num, rc_prof->device, rc_prof->cache, rc_prof->source);
printf(" RapidDisk-Cache Target %d: %s\tCache: %s Target: %s (%s)\n",
num, rc_prof->device, rc_prof->cache, rc_prof->source,
(strncmp(rc_prof->device, "rc-wt_", 5) == 0) ? \
"WRITE THROUGH" : "WRITE AROUND");
num++;
rc_prof = rc_prof->next;
}
Expand Down Expand Up @@ -344,7 +346,7 @@ int resize_device(struct RD_PROFILE *prof, unsigned char *string, unsigned long
}

int cache_map(struct RD_PROFILE *rd_prof, struct RC_PROFILE * rc_prof,
unsigned char *cache, unsigned char *source)
unsigned char *cache, unsigned char *source, int mode)
{
int err = -1, node, fd;
unsigned long long source_sz = 0, cache_sz = 0;
Expand Down Expand Up @@ -428,15 +430,18 @@ int cache_map(struct RD_PROFILE *rd_prof, struct RC_PROFILE * rc_prof,
sprintf(str, "%s", token);
token = strtok(NULL, "/");
}
sprintf(name, "rc_%s", str);
if (mode == WRITETHROUGH)
sprintf(name, "rc-wt_%s", str);
else
sprintf(name, "rc-wa_%s", str);

memset(string, 0x0, BUFSZ);
/* echo 0 4194303 rapiddisk-cache /dev/sdb /dev/rd0 0 196608|dmsetup create rc_sdb */
/* echo 0 4194303 rapiddisk-cache /dev/sdb /dev/rd0 0 196608|dmsetup create rc-wt_sdb */
/* Param after echo 0 & 1: starting and ending offsets of source device *
* Param 3: always rapiddisk-cache; Param 4 & 5: path to source device and RapidDisk dev *
* Param 6: is the size of the cache */
sprintf(string, "echo 0 %llu rapiddisk-cache %s /dev/%s %llu|dmsetup create %s\n",
source_sz, source, cache, cache_sz, name);
sprintf(string, "echo 0 %llu rapiddisk-cache %s /dev/%s %llu %d|dmsetup create %s\n",
source_sz, source, cache, cache_sz, mode, name);

if ((err = system(string)) == 0) {
printf("Command to map %s with %s and %s has been sent.\nVerify with \"--list\"\n\n",
Expand All @@ -454,7 +459,7 @@ int cache_unmap(struct RC_PROFILE *prof, unsigned char *string)
unsigned char *buf;
unsigned char cmd[NAMELEN] = {0};

/* dmsetup remove rc_sdb */
/* dmsetup remove rc-wt_sdb */
while (prof != NULL) {
if (strcmp(string, prof->device) == SUCCESS) err = 0;
prof = prof->next;
Expand Down

0 comments on commit fded380

Please sign in to comment.