mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-18 05:06:31 +00:00
scst_vdisk: Port to Linux kernel v5.18
Support for the following block/fs changes in the Linux Kernel v5.18:
- 609be1066731 ("block: pass a block_device and opf to bio_alloc_bioset")
- 07888c665b40 ("block: pass a block_device and opf to bio_alloc")
- cbcc268bb1ce ("fs: Move many prototypes to pagemap.h")
This commit is contained in:
@@ -109,6 +109,54 @@ static inline void bio_set_dev(struct bio *bio, struct block_device *bdev)
|
||||
#define BIO_MAX_VECS BIO_MAX_PAGES
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
|
||||
/*
|
||||
* See also commit 609be1066731 ("block: pass a block_device and opf to
|
||||
* bio_alloc_bioset") # v5.18
|
||||
*/
|
||||
static inline
|
||||
struct bio *bio_alloc_bioset_backport(struct block_device *bdev,
|
||||
unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask,
|
||||
struct bio_set *bs)
|
||||
{
|
||||
/*
|
||||
* Check that @bdev and @opf parameters are zeros.
|
||||
*
|
||||
* The old API expects these parameters to be set implicitly.
|
||||
* Therefore, warn about using an explicit setting that would
|
||||
* cause these parameters to be lost.
|
||||
*/
|
||||
WARN_ON_ONCE(bdev || opf);
|
||||
|
||||
return bio_alloc_bioset(gfp_mask, nr_vecs, bs);
|
||||
}
|
||||
|
||||
#define bio_alloc_bioset bio_alloc_bioset_backport
|
||||
|
||||
/*
|
||||
* See also commit 07888c665b40 ("block: pass a block_device and opf to
|
||||
* bio_alloc") # v5.18
|
||||
*/
|
||||
static inline
|
||||
struct bio *bio_alloc_backport(struct block_device *bdev,
|
||||
unsigned short nr_vecs, unsigned int opf, gfp_t gfp_mask)
|
||||
{
|
||||
/*
|
||||
* Check that @bdev and @opf parameters are zeros.
|
||||
*
|
||||
* The old API expects these parameters to be set implicitly.
|
||||
* Therefore, warn about using an explicit setting that would
|
||||
* cause these parameters to be lost.
|
||||
*/
|
||||
WARN_ON_ONCE(bdev || opf);
|
||||
|
||||
return bio_alloc(gfp_mask, nr_vecs);
|
||||
}
|
||||
|
||||
#define bio_alloc bio_alloc_backport
|
||||
|
||||
#endif
|
||||
|
||||
/* <linux/blk_types.h> */
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <linux/aio.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/unistd.h>
|
||||
@@ -428,15 +429,19 @@ static int vdisk_blockio_flush(struct block_device *bdev, gfp_t gfp_mask,
|
||||
TRACE_ENTRY();
|
||||
|
||||
if (async) {
|
||||
struct bio *bio = bio_alloc(gfp_mask, 0);
|
||||
struct bio *bio;
|
||||
|
||||
bio = bio_alloc(/*bdev=*/NULL, 0, /*opf=*/0, gfp_mask);
|
||||
if (bio == NULL) {
|
||||
res = -ENOMEM;
|
||||
goto out_rep;
|
||||
}
|
||||
|
||||
bio->bi_end_io = vdev_flush_end_io;
|
||||
bio->bi_private = cmd;
|
||||
|
||||
bio_set_dev(bio, bdev);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) || \
|
||||
(defined(CONFIG_SUSE_KERNEL) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
|
||||
@@ -2836,8 +2841,8 @@ static ssize_t blockio_read_sync(struct scst_vdisk_dev *virt_dev, void *buf,
|
||||
max_nr_vecs = min(bio_get_nr_vecs(bdev), BIO_MAX_VECS);
|
||||
#endif
|
||||
|
||||
bio = bio_alloc_bioset(GFP_KERNEL, max_nr_vecs, virt_dev->vdisk_bioset);
|
||||
|
||||
bio = bio_alloc_bioset(/*bdev=*/NULL, max_nr_vecs, /*opf=*/0,
|
||||
GFP_KERNEL, virt_dev->vdisk_bioset);
|
||||
if (!bio)
|
||||
goto out;
|
||||
|
||||
@@ -5958,8 +5963,8 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua)
|
||||
int rc;
|
||||
|
||||
if (need_new_bio) {
|
||||
bio = bio_alloc_bioset(gfp_mask, max_nr_vecs, bs);
|
||||
|
||||
bio = bio_alloc_bioset(/*bdev=*/NULL, max_nr_vecs, /*opf=*/0,
|
||||
gfp_mask, bs);
|
||||
if (!bio) {
|
||||
PRINT_ERROR("Failed to create bio "
|
||||
"for data segment %d (cmd %p)",
|
||||
|
||||
Reference in New Issue
Block a user