Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ wb_dm_io_header := $(srctree)/include/linux/dm-io.h
# added the IO priority parameter in v6.9-rc1.
# The dm-io ioprio argument is also backported to stable kernels.
ccflags-y += -DDM_IO_HAS_IOPRIO=$(if $(shell grep -w ioprio $(wb_dm_io_header)),1,0)

# The dm-io unsupported-error bitmap is also backported to stable kernels.
ccflags-y += -DDM_IO_HAS_UNSUP=$(if $(shell grep -w sync_unsup_bits $(wb_dm_io_header)),1,0)
endif

obj-m := dm-writeboost.o
Expand Down
5 changes: 3 additions & 2 deletions src/dm-writeboost-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static void writeback_endio(unsigned long error, void *context)
if (atomic_dec_and_test(&wb->writeback_io_count))
wake_up(&wb->writeback_io_wait_queue);
}
WB_IO_NOTIFY_COMPAT(writeback_endio);

static void submit_writeback_io(struct wb_device *wb, struct writeback_io *writeback_io)
{
Expand All @@ -174,7 +175,7 @@ static void submit_writeback_io(struct wb_device *wb, struct writeback_io *write
struct dm_io_request io_req_w = {
WB_IO_WRITE,
.client = wb->io_client,
.notify.fn = writeback_endio,
.notify.fn = WB_IO_NOTIFY(writeback_endio),
.notify.context = wb,
.mem.type = DM_IO_VMA,
.mem.ptr.addr = writeback_io->data,
Expand All @@ -199,7 +200,7 @@ static void submit_writeback_io(struct wb_device *wb, struct writeback_io *write
io_req_w = (struct dm_io_request) {
WB_IO_WRITE,
.client = wb->io_client,
.notify.fn = writeback_endio,
.notify.fn = WB_IO_NOTIFY(writeback_endio),
.notify.context = wb,
.mem.type = DM_IO_VMA,
.mem.ptr.addr = writeback_io->data + (i << 9),
Expand Down
3 changes: 2 additions & 1 deletion src/dm-writeboost-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ static void format_segmd_endio(unsigned long error, void *__context)
context->err = 1;
atomic64_dec(&context->count);
}
WB_IO_NOTIFY_COMPAT(format_segmd_endio);

struct zeroing_context {
int error;
Expand Down Expand Up @@ -479,7 +480,7 @@ static int format_all_segment_headers(struct wb_device *wb)
struct dm_io_request io_req_seg = {
WB_IO_WRITE,
.client = wb->io_client,
.notify.fn = format_segmd_endio,
.notify.fn = WB_IO_NOTIFY(format_segmd_endio),
.notify.context = &context,
.mem.type = DM_IO_KMEM,
.mem.ptr.addr = buf,
Expand Down
19 changes: 17 additions & 2 deletions src/dm-writeboost-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,21 @@

#include "linux/sort.h"

#if DM_IO_HAS_IOPRIO
#if DM_IO_HAS_UNSUP
static int dm_io_compat(struct dm_io_request *io_req, unsigned num_regions,
struct dm_io_region *regions, unsigned long *error_bits)
{
unsigned long io_error_bits = 0, unsup_bits = 0;
int r;

r = dm_io(io_req, num_regions, regions, &io_error_bits, &unsup_bits,
IOPRIO_DEFAULT);
if (error_bits)
*error_bits = io_error_bits | unsup_bits;
return r;
}
#define DM_IO(arg1, arg2, arg3, arg4) dm_io_compat(arg1, arg2, arg3, arg4)
#elif DM_IO_HAS_IOPRIO
#define DM_IO(arg1, arg2, arg3, arg4) dm_io(arg1, arg2, arg3, arg4, IOPRIO_DEFAULT)
#else
#define DM_IO(arg1, arg2, arg3, arg4) dm_io(arg1, arg2, arg3, arg4)
Expand Down Expand Up @@ -1274,6 +1288,7 @@ static void read_backing_async_callback(unsigned long error, void *context)
read_backing_async_callback_onstack(error, ctx);
kfree(ctx);
}
WB_IO_NOTIFY_COMPAT(read_backing_async_callback);

static int read_backing_async(struct wb_device *wb, struct bio *bio)
{
Expand All @@ -1296,7 +1311,7 @@ static int read_backing_async(struct wb_device *wb, struct bio *bio)
.client = wb->io_client,
.mem.type = DM_IO_BIO,
.mem.ptr.bio = bio,
.notify.fn = read_backing_async_callback,
.notify.fn = WB_IO_NOTIFY(read_backing_async_callback),
.notify.context = ctx
};
region = (struct dm_io_region) {
Expand Down
13 changes: 13 additions & 0 deletions src/dm-writeboost.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@
#include <linux/dm-io.h>
#include <linux/dm-kcopyd.h>

/* Preserve the old combined error bitmap for dm-io completion handlers. */
#if DM_IO_HAS_UNSUP
#define WB_IO_NOTIFY(fn) fn##_compat
#define WB_IO_NOTIFY_COMPAT(fn) \
static void fn##_compat(unsigned long error, unsigned long unsup, void *context) \
{ \
fn(error | unsup, context); \
}
#else
#define WB_IO_NOTIFY(fn) fn
#define WB_IO_NOTIFY_COMPAT(fn)
#endif

/*----------------------------------------------------------------------------*/

#define SUB_ID(x, y) ((x) > (y) ? (x) - (y) : 0)
Expand Down
Loading