mirror of
https://codeberg.org/shufflecake/shufflecake-c.git
synced 2026-01-05 18:45:29 -05:00
Add max_order to compatibility layer
This commit is contained in:
parent
0a52e7ac29
commit
c5f8c5e966
7 changed files with 32 additions and 24 deletions
1
dm-sflc/bin/lite/compat.h
Symbolic link
1
dm-sflc/bin/lite/compat.h
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../src/lite/compat.h
|
||||
|
|
@ -1 +0,0 @@
|
|||
../../src/lite/dm_io_helper.h
|
||||
|
|
@ -21,12 +21,24 @@
|
|||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _SFLITE_DMIOHELPER_H
|
||||
#define _SFLITE_DMIOHELPER_H
|
||||
#ifndef _SFLITE_COMPAT_H
|
||||
#define _SFLITE_COMPAT_H
|
||||
|
||||
#include <linux/dm-io.h>
|
||||
#include <generated/uapi/linux/version.h>
|
||||
|
||||
|
||||
/**
|
||||
* Compatibility alias for MAX_PAGE_ORDER, which was called
|
||||
* MAX_ORDER until kernel 6.7.x
|
||||
*/
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0)
|
||||
#define SFLC_COMPAT_MAX_PAGE_ORDER MAX_PAGE_ORDER
|
||||
#else
|
||||
#define SFLC_COMPAT_MAX_PAGE_ORDER MAX_ORDER
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* The function dm_io() has changed signature in recent kernels.
|
||||
* Here we provide a version-independent adapter, which uses a default value
|
||||
|
|
@ -35,22 +47,22 @@
|
|||
* 6.7.x with x>=11, 6.8.x with x>=2, 6.x with x>=9
|
||||
*/
|
||||
#if LINUX_VERSION_MAJOR <= 5 // Old
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err)
|
||||
#elif LINUX_VERSION_MAJOR >= 7 // New
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
// Ok LINUX_VERSION_MAJOR is 6
|
||||
#elif LINUX_VERSION_PATCHLEVEL >= 9 // New
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#elif LINUX_VERSION_PATCHLEVEL == 8 && LINUX_VERSION_SUBLEVEL >= 2 // New
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#elif LINUX_VERSION_PATCHLEVEL == 7 && LINUX_VERSION_SUBLEVEL >= 11 // New
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#elif LINUX_VERSION_PATCHLEVEL == 6 && LINUX_VERSION_SUBLEVEL >= 23 // New
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#elif LINUX_VERSION_PATCHLEVEL == 1 && LINUX_VERSION_SUBLEVEL >= 83 // New
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err, IOPRIO_DEFAULT)
|
||||
#else // Old
|
||||
#define sflc_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err)
|
||||
#define sflc_compat_dm_io(ioreq, numreg, region, err) dm_io(ioreq, numreg, region, err)
|
||||
#endif
|
||||
|
||||
#endif /* _SFLITE_DMIOHELPER_H */
|
||||
#endif /* _SFLITE_COMPAT_H */
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "sflc_lite.h"
|
||||
#include "dm_io_helper.h"
|
||||
#include "compat.h"
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/find.h>
|
||||
|
|
@ -163,7 +163,7 @@ static int send_posmap_cwbs(struct sflite_volume *svol, gfp_t gfp)
|
|||
atomic_inc(&pending);
|
||||
|
||||
/* Writing via async dm-io (implied by notify.fn above) won't return an error */
|
||||
(void) sflc_dm_io(&req, 1, ®ion, NULL);
|
||||
(void) sflc_compat_dm_io(&req, 1, ®ion, NULL);
|
||||
|
||||
/* Advance counters for next iteration */
|
||||
i = j;
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
* If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/minmax.h>
|
||||
#include "dm_io_helper.h"
|
||||
#include "sflc_lite.h"
|
||||
#include "compat.h"
|
||||
#include <linux/minmax.h>
|
||||
|
||||
|
||||
/* Helpers */
|
||||
|
|
@ -177,7 +177,7 @@ static int __read_encrypted_posmap(struct sflite_volume *svol)
|
|||
.count = svol->sdev->posmap_size_sectors
|
||||
};
|
||||
|
||||
return sflc_dm_io(&io_req, 1, &io_region, NULL);
|
||||
return sflc_compat_dm_io(&io_req, 1, &io_region, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/version.h>
|
||||
#include <generated/uapi/linux/version.h>
|
||||
#include "sflc_lite.h"
|
||||
#include "sflc.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,14 +22,10 @@
|
|||
*/
|
||||
|
||||
#include "sflc_lite.h"
|
||||
#include "compat.h"
|
||||
#include <linux/delay.h>
|
||||
|
||||
|
||||
/* Linux 6.8 renamed MAX_ORDER to MAX_PAGE_ORDER. */
|
||||
#ifndef MAX_PAGE_ORDER
|
||||
#define MAX_PAGE_ORDER MAX_ORDER
|
||||
#endif
|
||||
|
||||
static void sflite_write_endio(struct bio *phys_bio);
|
||||
|
||||
|
||||
|
|
@ -65,7 +61,7 @@ static struct bio *allocate_phys_bio(struct sflite_io *io)
|
|||
|
||||
/* Allocate pages in loop */
|
||||
unsigned remaining_size = size;
|
||||
unsigned order = MAX_PAGE_ORDER;
|
||||
unsigned order = SFLC_COMPAT_MAX_PAGE_ORDER;
|
||||
while (remaining_size) {
|
||||
struct page *pages;
|
||||
unsigned size_to_add;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue