Skip to content

Commit

Permalink
Merge pull request #18 from pkoutoupis/staging/release_5.0
Browse files Browse the repository at this point in the history
Release 5.0
  • Loading branch information
pkoutoupis authored Nov 29, 2016
2 parents 05b7751 + 7e9a7db commit e74fedd
Show file tree
Hide file tree
Showing 63 changed files with 337 additions and 12,841 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### Release 5.0 ###

- kernel: Remove kernel mainline specific code (intended for brd replacement).
- kernel: Change spinlock types to work better with virtio (github issue #13).
- test: Updated tests to a work with the modern version of RapidDisk.
- utility: Add JSON output for RapidDisk configuration (requires libjansson).
- www: remove fat-free (f3) RESTful API.

### Release 4.5 ###

- kernel: cache - Fixed I/O handler bug for 4.8+ kernels
Expand Down
11 changes: 4 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SUBDIRS = src conf doc module test www
SUBDIRS = src conf doc module test

.PHONY: all
all:
Expand All @@ -24,15 +24,13 @@ dkms:
tools-install:
cd src; make; make install; \
cd ../conf; make install; \
cd ../doc; make install; \
cd ../www; make install; cd ..
cd ../doc; make install; cd ..

.PHONY: tools-uninstall
tools-uninstall:
cd src; make uninstall; \
cd ../conf; make uninstall; \
cd ../doc; make uninstall; \
cd ../www; make install; cd ..
cd ../doc; make uninstall; cd ..

.PHONY: nocrypt
nocrypt:
Expand All @@ -45,5 +43,4 @@ nocrypt-install:
cd src; make nocrypt-install; \
cd ../module; make install; \
cd ../conf; make install; \
cd ../doc; make install; \
cd ../www; make install; cd ..
cd ../doc; make install; cd ..
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Building and Installing the rapiddisk kernel modules and utilities

Change into the project's parent directory path.

> To build the rapiddisk management utility, you will need to have the `zlib`
> and `libcryptsetup` libraries and zlib development files installed on your
> To build the rapiddisk management utility, you will need to have the `zlib`,
> `libcryptsetup` and `libjansson` development library files installed on your
> host system.
>
> You are required to having either the full kernel source or the kernel
Expand Down
13 changes: 9 additions & 4 deletions doc/rapiddisk.1
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ Dynamically attach new RapidDisk devices.
--detach
Dynamically detach RapidDisk devices.
.TP
--list
--list
List all attached RapidDisk devices.
.TP
--list-json
List all attached RapidDisk devices in JSON format (only if enabled during compilation).
.TP
--short-list
List all attached RapidDisk devices in script friendly format.
.TP
Expand All @@ -48,13 +51,13 @@ Map an RapidDisk device as a caching node to another block device.
Obtain RapidDisk-Cache Mappings statistics.
.TP
--enable-crypt
Initialize a storage volume for data encryption. Please store user defined keys in /etc/rapiddisk/key, otherwise it will default to the built-in DES key provided by the utility.
Initialize a storage volume for data encryption. Please store user defined keys in /etc/rapiddisk/key, otherwise it will default to the built-in DES key provided by the utility (only if enabled during compilation).
.TP
--activate-crypt
Activate an encryption volume. Please store user defined keys in /etc/rapiddisk/key, otherwise it will default to the built-in DES key provided by the utility.
Activate an encryption volume. Please store user defined keys in /etc/rapiddisk/key, otherwise it will default to the built-in DES key provided by the utility (only if enabled during compilation).
.TP
--deactivate-crypt
Deactivate an encrypted volume.
Deactivate an encrypted volume (only if enabled during compilation).
.SS Parameters (if applicable)
.TP
[size]
Expand All @@ -81,6 +84,8 @@ Write Through (wt) or Write Around (wa) for cache.
.TP
rapiddisk --list
.TP
rapiddisk --list-json
.TP
rapiddisk --attach 64
.TP
rapiddisk --detach rd2
Expand Down
4 changes: 2 additions & 2 deletions module/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

VERSION = 4.5
VERSION = 5.0

ifeq ($(KSRC),)
KSRC := /lib/modules/$(shell uname -r)/build
Expand All @@ -29,7 +29,7 @@ obj-m += rapiddisk.o
obj-m += rapiddisk-cache.o

all:
KCPPFLAGS="-DNOTMAINLINE" $(MAKE) -C$(KSRC) M=$(PWD)
$(MAKE) -C$(KSRC) M=$(PWD)

install:
$(MKDIR) $(DESTDIR)/lib/modules/$(KVER)/kernel/drivers/block/
Expand Down
2 changes: 1 addition & 1 deletion module/dkms.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE_NAME="rapiddisk"
PACKAGE_VERSION="4.5"
PACKAGE_VERSION="5.0"
BUILT_MODULE_NAME[0]="rapiddisk"
BUILT_MODULE_NAME[1]="rapiddisk-cache"
DEST_MODULE_LOCATION[0]="/kernel/rapiddisk/"
Expand Down
73 changes: 40 additions & 33 deletions module/rapiddisk-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
} \
} while (0)

#define VERSION_STR "4.5"
#define VERSION_STR "5.0"
#define DM_MSG_PREFIX "rapiddisk-cache"

#define READCACHE 1
Expand Down Expand Up @@ -254,6 +254,7 @@ void rc_io_callback(unsigned long error, void *context)
struct kcached_job *job = (struct kcached_job *)context;
struct cache_context *dmc = job->dmc;
struct bio *bio;
unsigned long flags;
int invalid = 0;

ASSERT(job);
Expand All @@ -262,12 +263,12 @@ void rc_io_callback(unsigned long error, void *context)
if (error)
DMERR("%s: io error %ld", __func__, error);
if (job->rw == READSOURCE || job->rw == WRITESOURCE) {
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
if (dmc->cache_state[job->index] != INPROG) {
ASSERT(dmc->cache_state[job->index] == INPROG_INVALID);
invalid++;
}
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
if (error || invalid) {
if (invalid)
DMERR("%s: cache fill invalidation, sector %lu, size %u",
Expand All @@ -285,9 +286,9 @@ void rc_io_callback(unsigned long error, void *context)
bio->bi_error = error;
bio_io_error(bio);
#endif
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
dmc->cache_state[job->index] = INVALID;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
goto out;
} else {
job->rw = WRITECACHE;
Expand All @@ -296,21 +297,21 @@ void rc_io_callback(unsigned long error, void *context)
return;
}
} else if (job->rw == READCACHE) {
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
ASSERT(dmc->cache_state[job->index] == INPROG_INVALID ||
dmc->cache_state[job->index] == CACHEREADINPROG);
if (dmc->cache_state[job->index] == INPROG_INVALID)
invalid++;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
if (!invalid && !error) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
bio_endio(bio, 0);
#else
bio_endio(bio);
#endif
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
dmc->cache_state[job->index] = VALID;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
goto out;
}
/* error || invalid || bounce back to source device */
Expand All @@ -325,7 +326,7 @@ void rc_io_callback(unsigned long error, void *context)
#else
bio_endio(bio);
#endif
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
ASSERT((dmc->cache_state[job->index] == INPROG) ||
(dmc->cache_state[job->index] == INPROG_INVALID));
if (error || dmc->cache_state[job->index] == INPROG_INVALID) {
Expand All @@ -334,7 +335,7 @@ void rc_io_callback(unsigned long error, void *context)
dmc->cache_state[job->index] = VALID;
dmc->cached_blocks++;
}
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
}
out:
mempool_free(job, job_pool);
Expand Down Expand Up @@ -364,12 +365,13 @@ int rc_do_complete(struct kcached_job *job)
{
struct bio *bio = job->bio;
struct cache_context *dmc = job->dmc;
unsigned long flags;

ASSERT(job->rw == READCACHE_DONE);
/* error || block invalidated while reading from cache */
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
dmc->cache_state[job->index] = INVALID;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
mempool_free(job, job_pool);
if (atomic_dec_and_test(&dmc->nr_jobs))
wake_up(&dmc->destroyq);
Expand Down Expand Up @@ -557,13 +559,14 @@ static void cache_read_miss(struct cache_context *dmc,
struct bio *bio, int index)
{
struct kcached_job *job;
unsigned long flags;

job = new_kcached_job(dmc, bio, index);
if (unlikely(!job)) {
DMERR("%s: Cannot allocate job\n", __func__);
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
dmc->cache_state[index] = INVALID;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
bio_endio(bio, -EIO);
#else
Expand All @@ -588,8 +591,9 @@ static void cache_read(struct cache_context *dmc, struct bio *bio)
{
int index;
int res;
unsigned long flags;

spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
res = cache_lookup(dmc, bio, &index);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,14,0)
if ((res == VALID) &&
Expand All @@ -602,13 +606,13 @@ static void cache_read(struct cache_context *dmc, struct bio *bio)

dmc->cache_state[index] = CACHEREADINPROG;
dmc->cache_hits++;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
job = new_kcached_job(dmc, bio, index);
if (unlikely(!job)) {
DMERR("cache_read(_hit): Cannot allocate job\n");
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
dmc->cache_state[index] = VALID;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
bio_endio(bio, -EIO);
#else
Expand All @@ -632,15 +636,15 @@ static void cache_read(struct cache_context *dmc, struct bio *bio)
}
if (cache_invalidate_blocks(dmc, bio) > 0) {
/* A non zero return indicates an inprog invalidation */
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
rc_start_uncached_io(dmc, bio);
return;
}
if (res == -1 || res >= INPROG) {
/* We either didn't find a cache slot in the set we were
* looking at or the block we are trying to read is being
* refilled into cache. */
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
rc_start_uncached_io(dmc, bio);
return;
}
Expand All @@ -656,7 +660,7 @@ static void cache_read(struct cache_context *dmc, struct bio *bio)
#else
dmc->cache[index].dbn = bio->bi_sector;
#endif
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
cache_read_miss(dmc, bio, index);
}

Expand Down Expand Up @@ -725,19 +729,20 @@ static void cache_write(struct cache_context *dmc, struct bio *bio)
{
int index;
int res;
unsigned long flags;
struct kcached_job *job;

spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
if (cache_invalidate_blocks(dmc, bio) > 0) {
/* A non zero return indicates an inprog invalidation */
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
rc_start_uncached_io(dmc, bio);
return;
}
res = cache_lookup(dmc, bio, &index);
ASSERT(res == -1 || res == INVALID);
if (res == -1) {
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
rc_start_uncached_io(dmc, bio);
return;
}
Expand All @@ -751,13 +756,13 @@ static void cache_write(struct cache_context *dmc, struct bio *bio)
#else
dmc->cache[index].dbn = bio->bi_sector;
#endif
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
job = new_kcached_job(dmc, bio, index);
if (unlikely(!job)) {
DMERR("%s: Cannot allocate job\n", __func__);
spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
dmc->cache_state[index] = INVALID;
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
bio_endio(bio, -EIO);
#else
Expand Down Expand Up @@ -799,6 +804,7 @@ int rc_map(struct dm_target *ti, struct bio *bio, union map_info *map_context)
#endif
{
struct cache_context *dmc = (struct cache_context *)ti->private;
unsigned long flags;

if (bio_barrier(bio))
return -EOPNOTSUPP;
Expand All @@ -820,9 +826,9 @@ int rc_map(struct dm_target *ti, struct bio *bio, union map_info *map_context)
#endif
(dmc->mode && (bio_data_dir(bio) == WRITE))) {

spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
(void)cache_invalidate_blocks(dmc, bio);
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
rc_start_uncached_io(dmc, bio);
} else {
if (bio_data_dir(bio) == READ)
Expand All @@ -838,14 +844,15 @@ static void rc_uncached_io_callback(unsigned long error, void *context)
{
struct kcached_job *job = (struct kcached_job *)context;
struct cache_context *dmc = job->dmc;
unsigned long flags;

spin_lock_bh(&dmc->cache_spin_lock);
spin_lock_irqsave(&dmc->cache_spin_lock, flags);
if (bio_data_dir(job->bio) == READ)
dmc->uncached_reads++;
else
dmc->uncached_writes++;
(void)cache_invalidate_blocks(dmc, job->bio);
spin_unlock_bh(&dmc->cache_spin_lock);
spin_unlock_irqrestore(&dmc->cache_spin_lock, flags);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,3,0)
bio_endio(job->bio, error);
#else
Expand Down Expand Up @@ -1205,7 +1212,7 @@ cache_status(struct dm_target *ti, status_type_t type, unsigned status_flags,

static struct target_type cache_target = {
.name = "rapiddisk-cache",
.version = {4, 5, 0},
.version = {5, 0, 0},
.module = THIS_MODULE,
.ctr = cache_ctr,
.dtr = cache_dtr,
Expand Down
Loading

0 comments on commit e74fedd

Please sign in to comment.