Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore <5.15 kernels support #52

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
28 changes: 28 additions & 0 deletions vdo/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,24 @@ void vdo_bio_copy_data_in(struct bio *bio, char *data_ptr)
struct bio_vec biovec;
struct bvec_iter iter;

// XXX workaround for LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0)
#ifdef __LINUX_BVEC_ITER_H
unsigned long flags;

bio_for_each_segment(biovec, bio, iter) {
void *from = bvec_kmap_irq(&biovec, &flags);

memcpy(data_ptr, from, biovec.bv_len);
data_ptr += biovec.bv_len;
bvec_kunmap_irq(from, &flags);
}
#else

bio_for_each_segment(biovec, bio, iter) {
memcpy_from_bvec(data_ptr, &biovec);
data_ptr += biovec.bv_len;
}
#endif
}

/*
Expand All @@ -36,11 +50,25 @@ void vdo_bio_copy_data_out(struct bio *bio, char *data_ptr)
{
struct bio_vec biovec;
struct bvec_iter iter;
// XXX workaround for LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0)
#ifdef __LINUX_BVEC_ITER_H
unsigned long flags;

bio_for_each_segment(biovec, bio, iter) {
void *dest = bvec_kmap_irq(&biovec, &flags);

memcpy(dest, data_ptr, biovec.bv_len);
data_ptr += biovec.bv_len;
flush_dcache_page(biovec.bv_page);
bvec_kunmap_irq(dest, &flags);
}
#else

bio_for_each_segment(biovec, bio, iter) {
memcpy_to_bvec(&biovec, data_ptr);
data_ptr += biovec.bv_len;
}
#endif
}

void vdo_free_bio(struct bio *bio)
Expand Down
3 changes: 3 additions & 0 deletions vdo/dm-vdo-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,16 @@ static void vdo_status(struct dm_target *ti,
device_config = (struct device_config *) ti->private;
DMEMIT("%s", device_config->original_string);
break;
// XXX workaround for LINUX_VERSION_CODE >= KERNEL_VERSION(5,15,0)
#ifndef __LINUX_BVEC_ITER_H
/*
* FIXME: We ought to print more detailed output here, but this is what
* thin does.
*/
case STATUSTYPE_IMA:
*result = '\0';
break;
#endif // 5.15+
}
}

Expand Down
1 change: 0 additions & 1 deletion vdo/num-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
#include "types.h"

#include <linux/log2.h>
#include <linux/math.h>

#endif /* NUM_UTILS_H */
2 changes: 1 addition & 1 deletion vdo/vio.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "vdo.h"

enum {
MAX_BLOCKS_PER_VIO = (BIO_MAX_VECS << PAGE_SHIFT) / VDO_BLOCK_SIZE,
MAX_BLOCKS_PER_VIO = (BIO_MAX_PAGES << PAGE_SHIFT) / VDO_BLOCK_SIZE,
};

/*
Expand Down