Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
filesystems
lustre_2_15
0031-LU-16202-build-bio_alloc-takes-struct-bloc...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0031-LU-16202-build-bio_alloc-takes-struct-block_device.patch of Package lustre_2_15
From 737737562e463d3608b4b6f044b2e170a3fd80e7 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff <shaun.tancheff@hpe.com> Date: Mon, 14 Nov 2022 03:30:23 -0600 Subject: [PATCH] LU-16202 build: bio_alloc takes struct block_device Linux commit v5.17-rc2-21-g07888c665b40 block: pass a block_device and opf to bio_alloc Create a compatible bio_alloc wrapper to handle the change in arguments and behavior. HPE-bug-id: LUS-11267 Test-Parameters: trivial Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com> Signed-off-by: Jian Yu <yujian@whamcloud.com> Change-Id: I060229b25785f46a9749fcdb18727af292a940ac Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48820 Tested-by: jenkins <devops@whamcloud.com> Tested-by: Maloo <maloo@whamcloud.com> Reviewed-by: Oleg Drokin <green@whamcloud.com> Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com> Reviewed-by: Andreas Dilger <adilger@whamcloud.com> --- libcfs/autoconf/lustre-libcfs.m4 | 27 ++++++++++++++++++++++++++ libcfs/include/libcfs/linux/linux-fs.h | 2 - lustre/include/lustre_compat.h | 34 +++++++++++++++++++++++++++++++++ lustre/osd-ldiskfs/osd_internal.h | 18 ----------------- lustre/osd-ldiskfs/osd_io.c | 16 +++++++-------- 5 files changed, 71 insertions(+), 26 deletions(-) --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -2006,6 +2006,31 @@ AC_DEFUN([LIBCFS_NLA_STRLCPY], [ ]) # LIBCFS_NLA_STRLCPY # +# 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_SRC_BIO_ALLOC_WITH_BDEV],[ + LB2_LINUX_TEST_SRC([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_DEFUN([LIBCFS_BIO_ALLOC_WITH_BDEV],[ + AC_MSG_CHECKING([does bio_alloc() takes a struct block_device]) + LB2_LINUX_TEST_RESULT([bio_alloc_with_bdev], [ + AC_DEFINE(HAVE_BIO_ALLOC_WITH_BDEV, 1, + [bio_alloc() takes a struct block_device]) + ]) +]) # LIBCFS_BIO_ALLOC_WITH_BDEV + +# # LIBCFS_LINUX_FORTIFY_STRING_HEADER # # Linux v5.11-11104-ga28a6e860c6c @@ -2318,6 +2343,7 @@ AC_DEFUN([LIBCFS_PROG_LINUX_SRC], [ LIBCFS_SRC_PARAM_SET_UINT_MINMAX # 5.17 LIBCFS_SRC_PDE_DATA_EXISTS + LIBCFS_SRC_BIO_ALLOC_WITH_BDEV # 6.2 LIBCFS_SRC_TIMER_DELETE_SYNC LIBCFS_SRC_TIMER_DELETE @@ -2512,6 +2538,7 @@ AC_DEFUN([LIBCFS_PROG_LINUX_RESULTS], [ LIBCFS_PARAM_SET_UINT_MINMAX # 5.17 LIBCFS_PDE_DATA_EXISTS + LIBCFS_BIO_ALLOC_WITH_BDEV # 6.2 LIBCFS_TIMER_DELETE_SYNC LIBCFS_TIMER_DELETE --- a/libcfs/include/libcfs/linux/linux-fs.h +++ b/libcfs/include/libcfs/linux/linux-fs.h @@ -84,4 +84,4 @@ static inline void mapping_clear_exiting #endif } -#endif +#endif /* __LIBCFS_LINUX_CFS_FS_H__ */ --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -71,6 +71,40 @@ #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 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -52,6 +52,7 @@ #include <linux/file.h> #include <ldiskfs/ldiskfs.h> #include <ldiskfs/ldiskfs_jbd2.h> +#include <lustre_compat.h> /* LUSTRE_OSD_NAME */ #include <obd.h> @@ -1498,19 +1499,6 @@ static inline struct buffer_head *__ldis 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)) @@ -1615,10 +1603,6 @@ void osd_execute_truncate(struct osd_obj #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)) --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -612,21 +612,21 @@ static int osd_do_bio(struct osd_device 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) {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor