]) # LIBCFS_PDE_DATA_EXISTS
#
+# LIBCFS_BIO_ALLOC_WITH_BDEV
+#
+# Linux commit v5.17-rc2-21-g07888c665b40
+# block: pass a block_device and opf to bio_alloc
+#
+AC_DEFUN([LIBCFS_BIO_ALLOC_WITH_BDEV],[
+LB_CHECK_COMPILE([does bio_alloc() takes a struct block_device],
+bio_alloc_with_bdev, [
+ #include <linux/bio.h>
+ ],[
+ struct block_device *bdev = NULL;
+ unsigned short nr_vecs = 1;
+ gfp_t gfp = GFP_KERNEL;
+ struct bio *bio = bio_alloc(bdev, nr_vecs, REQ_OP_WRITE, gfp);
+ (void) bio;
+ ],[
+ AC_DEFINE(HAVE_BIO_ALLOC_WITH_BDEV, 1,
+ [bio_alloc() takes a struct block_device])
+ ])
+]) # LIBCFS_BIO_ALLOC_WITH_BDEV
+
+#
# LIBCFS_PROG_LINUX
#
# LibCFS linux kernel checks
LIBCFS_LINUX_BLK_INTEGRITY_HEADER
# 5.17
LIBCFS_PDE_DATA_EXISTS
+LIBCFS_BIO_ALLOC_WITH_BDEV
]) # LIBCFS_PROG_LINUX
#
#endif
}
-#endif
+#endif /* __LIBCFS_LINUX_CFS_FS_H__ */
#include <linux/module.h>
#include <linux/bio.h>
#include <linux/namei.h>
+#include <lustre_compat.h>
#include "llcrypt_private.h"
static void __llcrypt_decrypt_bio(struct bio *bio, bool done)
if (err)
goto errout;
- bio = bio_alloc(GFP_NOWAIT, 1);
+ bio = cfs_bio_alloc(inode->i_sb->s_bdev, 1, REQ_OP_WRITE,
+ GFP_NOWAIT);
if (!bio) {
err = -ENOMEM;
goto errout;
}
- bio_set_dev(bio, inode->i_sb->s_bdev);
bio->bi_iter.bi_sector = pblk << (blockbits - 9);
- bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
ret = bio_add_page(bio, ciphertext_page, blocksize, 0);
if (WARN_ON(ret != blocksize)) {
/* should never happen! */
#define bio_start_sector(bio) (bio->bi_sector)
#endif
+#ifdef HAVE_BI_BDEV
+# define bio_get_dev(bio) ((bio)->bi_bdev)
+# define bio_get_disk(bio) (bio_get_dev(bio)->bd_disk)
+# define bio_get_queue(bio) bdev_get_queue(bio_get_dev(bio))
+
+# ifndef HAVE_BIO_SET_DEV
+# define bio_set_dev(bio, bdev) (bio_get_dev(bio) = (bdev))
+# endif
+#else
+# define bio_get_disk(bio) ((bio)->bi_disk)
+# define bio_get_queue(bio) (bio_get_disk(bio)->queue)
+#endif
+
+#ifndef HAVE_BI_OPF
+#define bi_opf bi_rw
+#endif
+
+static inline struct bio *cfs_bio_alloc(struct block_device *bdev,
+ unsigned short nr_vecs,
+ __u32 op, gfp_t gfp_mask)
+{
+ struct bio *bio;
+#ifdef HAVE_BIO_ALLOC_WITH_BDEV
+ bio = bio_alloc(bdev, nr_vecs, op, gfp_mask);
+#else
+ bio = bio_alloc(gfp_mask, nr_vecs);
+ if (bio) {
+ bio_set_dev(bio, bdev);
+ bio->bi_opf = op;
+ }
+#endif /* HAVE_BIO_ALLOC_WITH_BDEV */
+ return bio;
+}
+
#ifndef HAVE_DENTRY_D_CHILD
#define d_child d_u.d_child
#endif
#include <linux/file.h>
#include <ldiskfs/ldiskfs.h>
#include <ldiskfs/ldiskfs_jbd2.h>
+#include <lustre_compat.h>
/* LUSTRE_OSD_NAME */
#include <obd.h>
bool bio_integrity_enabled(struct bio *bio);
#endif
-#ifdef HAVE_BI_BDEV
-# define bio_get_dev(bio) ((bio)->bi_bdev)
-# define bio_get_disk(bio) (bio_get_dev(bio)->bd_disk)
-# define bio_get_queue(bio) bdev_get_queue(bio_get_dev(bio))
-
-# ifndef HAVE_BIO_SET_DEV
-# define bio_set_dev(bio, bdev) (bio_get_dev(bio) = (bdev))
-# endif
-#else
-# define bio_get_disk(bio) ((bio)->bi_disk)
-# define bio_get_queue(bio) (bio_get_disk(bio)->queue)
-#endif
-
#ifdef HAVE_EXT4_JOURNAL_GET_WRITE_ACCESS_4ARGS
# define osd_ldiskfs_journal_get_write_access(handle, sb, bh, flags) \
ldiskfs_journal_get_write_access((handle), (sb), (bh), (flags))
#define __bi_cnt bi_cnt
#endif
-#ifndef HAVE_BI_OPF
-#define bi_opf bi_rw
-#endif
-
#ifndef HAVE_CLEAN_BDEV_ALIASES
#define clean_bdev_aliases(bdev, block, len) \
unmap_underlying_metadata((bdev), (block))
bio_start_page_idx = page_idx;
/* allocate new bio */
- bio = bio_alloc(GFP_NOIO, min_t(unsigned short,
- BIO_MAX_VECS,
- (block_idx_end - block_idx +
- blocks_left_page - 1)));
- if (bio == NULL) {
+ bio = cfs_bio_alloc(bdev,
+ min_t(unsigned short, BIO_MAX_VECS,
+ (block_idx_end - block_idx +
+ blocks_left_page - 1)),
+ iobuf->dr_rw ? REQ_OP_WRITE
+ : REQ_OP_READ,
+ GFP_NOIO);
+ if (!bio) {
CERROR("Can't allocate bio %u pages\n",
block_idx_end - block_idx +
blocks_left_page - 1);
rc = -ENOMEM;
goto out;
}
-
- bio_set_dev(bio, bdev);
bio_set_sector(bio, sector);
- bio->bi_opf = iobuf->dr_rw ? WRITE : READ;
rc = osd_bio_init(bio, iobuf, integrity_enabled,
bio_start_page_idx, &bio_private);
if (rc) {