├── .gitignore ├── .gitlab-ci.yml ├── .gitlab ├── changelog.awk ├── drbd-prepare-release.sh └── kernels-from-vms.py ├── .gitmodules ├── COPYING ├── ChangeLog ├── Documentation └── application-resync-synchronization.rst ├── Makefile ├── README.drbd-utils ├── README.md ├── coccinelle ├── enum_bitops.cocci └── iterator_rcu_suffix.cocci ├── debian ├── README.Debian ├── TODO ├── changelog ├── compat ├── control ├── control.modules.in ├── copyright ├── drbd-dkms.dkms ├── drbd-module-_KVERS_.postinst.modules.in ├── drbd-module-_KVERS_.postrm.modules.in ├── drbd-module-source.dirs ├── drbd-ueficert.install ├── modass.drbd-module-source ├── rules └── watch ├── docker ├── Dockerfile.amzn2 ├── Dockerfile.flatcar ├── Dockerfile.focal ├── Dockerfile.jammy ├── Dockerfile.noble ├── Dockerfile.rhel10 ├── Dockerfile.rhel8 ├── Dockerfile.rhel9 ├── Dockerfile.sles15 ├── entry.sh └── pkgs │ └── .empty ├── drbd-kernel.spec ├── drbd ├── Kbuild ├── Kbuild.drbd ├── Kbuild.drbd-module-sources ├── Kconfig ├── Makefile ├── Makefile.cocci-sources ├── Makefile.spatch ├── README ├── drbd-kernel-compat │ ├── .gitignore │ ├── README.md │ ├── annotate-diff-with-original-file-position-pragmas.pl │ ├── asm │ │ └── barrier.h │ ├── build_cocci_cache.sh │ ├── check_patch_names.cocci │ ├── cocci │ │ ├── __bio_add_page__no_present.cocci │ │ ├── __vmalloc__no_has_2_params.cocci │ │ ├── add_disk__no_returns_int.cocci │ │ ├── allow_kernel_signal__no_present.cocci │ │ ├── bdev_discard_granularity__no_present.cocci │ │ ├── bdev_file_open_by_path__no_present.cocci │ │ ├── bdev_max_discard_sectors__no_present.cocci │ │ ├── bdev_nr_sectors__no_present.cocci │ │ ├── bdev_open_by_path__no_present.cocci │ │ ├── bdevname__yes_present.cocci │ │ ├── bdgrab__yes_present.cocci │ │ ├── bdi_congested__yes_present.cocci │ │ ├── bio_advance_iter_single__no_present.cocci │ │ ├── bio_alloc__no_has_4_params.cocci │ │ ├── bio_alloc_clone__no_present.cocci │ │ ├── bio_bi_bdev__no_present.cocci │ │ ├── bio_max_segs__no_present.cocci │ │ ├── bio_max_vecs__no_present.cocci │ │ ├── bio_split_to_limits__no_present.cocci │ │ ├── bio_start_io_acct__no_present.cocci │ │ ├── bioset_init__no_present.cocci │ │ ├── blk_alloc_disk__no_present.cocci │ │ ├── blk_alloc_disk__no_takes_queue_limits.cocci │ │ ├── blk_alloc_queue_rh__yes_present.cocci │ │ ├── blk_cleanup_disk__yes_present.cocci │ │ ├── blk_mode_t__no_present.cocci │ │ ├── blk_opf_t__no_present.cocci │ │ ├── blk_queue_flag_set__no_present.cocci │ │ ├── blk_queue_make_request__yes_present.cocci │ │ ├── blk_queue_max_write_same_sectors__yes_present.cocci │ │ ├── blk_queue_split__yes_has_two_parameters.cocci │ │ ├── blk_queue_update_readahead__no_present.cocci │ │ ├── blk_queue_write_cache__no_present.cocci │ │ ├── blkdev_get_by_path__no_has_holder_ops.cocci │ │ ├── blkdev_issue_discard__yes_takes_flags.cocci │ │ ├── blkdev_put__no_has_holder.cocci │ │ ├── block_device_operations_open__no_takes_gendisk.cocci │ │ ├── block_device_operations_release__no_takes_single_argument.cocci │ │ ├── bvec_kmap_local__no_present.cocci │ │ ├── congested_fn__yes_present.cocci │ │ ├── counted_by__no_present.cocci │ │ ├── dax_direct_access__no_takes_mode.cocci │ │ ├── debugfs_change_name__no_present.cocci │ │ ├── debugfs_compat_template.cocci.in │ │ ├── disk_update_readahead__no_present.cocci │ │ ├── drbd_wrappers__yes_need.cocci │ │ ├── enum_req_op__no_present.cocci │ │ ├── fallthrough__no_present.cocci │ │ ├── fs_dax_get_by_bdev__no_takes_start_off.cocci │ │ ├── fs_dax_get_by_bdev__no_takes_start_off_and_holder.cocci │ │ ├── gendisk_part0__no_is_block_device.cocci │ │ ├── genhd_fl_no_part__no_present.cocci │ │ ├── genl_info_userhdr__no_present.cocci │ │ ├── get_random_u32__no_present.cocci │ │ ├── get_random_u32_below__no_present.cocci │ │ ├── ib_device__no_has_ops.cocci │ │ ├── ib_post__no_const.cocci │ │ ├── kernel_read__yes_before_4_13.cocci │ │ ├── kmap_local_page__no_present.cocci │ │ ├── kvfree_rcu__no_present.cocci │ │ ├── kvfree_rcu_mightsleep__no_present.cocci │ │ ├── linux_unaligned_h__no_present.cocci │ │ ├── list_is_first__no_present.cocci │ │ ├── lookup_user_key__no_present.cocci │ │ ├── mempool_is_saturated__no_present.cocci │ │ ├── need_recalc_sigpending__yes_need.cocci │ │ ├── nla_nest_start_noflag__no_present.cocci │ │ ├── nla_parse_deprecated__no_present.cocci │ │ ├── part_stat_h__no_present.cocci │ │ ├── part_stat_read__no_takes_block_device.cocci │ │ ├── part_stat_read_accum__no_present.cocci │ │ ├── queue_flag_discard__yes_present.cocci │ │ ├── queue_flag_stable_writes__no_present.cocci │ │ ├── queue_limits__no_has_max_hw_discard_sectors.cocci │ │ ├── queue_limits_features__no_present.cocci │ │ ├── queue_limits_max_hw_zone_append_sectors__no_present.cocci │ │ ├── queue_limits_max_zone_append_sectors__no_present.cocci │ │ ├── queue_limits_start_update__no_present.cocci │ │ ├── rb_declare_callbacks_max__no_present.cocci │ │ ├── rdma_reject__no_4-arguments.cocci │ │ ├── revalidate_disk_size__no_present.cocci │ │ ├── sched_set_fifo__no_present.cocci │ │ ├── sendpage__yes_present.cocci │ │ ├── sendpage_ok__no_present.cocci │ │ ├── set_capacity_and_notify__no_present.cocci │ │ ├── sge_max_send_and_recv__no_present.cocci │ │ ├── sk_use_task_frag__no_present.cocci │ │ ├── sock_ops__no_returns_addr_len.cocci │ │ ├── sock_set_keepalive__no_present.cocci │ │ ├── struct_gendisk__no_has_backing_dev_info.cocci │ │ ├── struct_size__no_present.cocci │ │ ├── submit_bio__no_present.cocci │ │ ├── submit_bio__no_returns_void.cocci │ │ ├── submit_bio_noacct__no_present.cocci │ │ ├── tasklet_setup__no_present.cocci │ │ ├── tcp_sock_set_cork__no_present.cocci │ │ ├── tcp_sock_set_keepcnt__no_present.cocci │ │ ├── tcp_sock_set_keepidle__no_present.cocci │ │ ├── tcp_sock_set_nodelay__no_present.cocci │ │ ├── tcp_sock_set_quickack__no_present.cocci │ │ ├── timer_delete__no_present.cocci │ │ ├── timer_shutdown__no_present.cocci │ │ ├── tls_get_record_type__no_present.cocci │ │ ├── tls_tx_rx__no_present.cocci │ │ └── vermagic_h__yes_can_include.cocci │ ├── cocci_macros.h │ ├── collect_compat_h.sh │ ├── drbd_wrappers.c │ ├── drbd_wrappers.h │ ├── gen_compat_patch.sh │ ├── gen_patch_names.c │ ├── handshake │ │ ├── .gitignore │ │ ├── Kbuild │ │ ├── genl.c │ │ ├── genl.h │ │ ├── handshake.h │ │ ├── netlink.c │ │ ├── request.c │ │ └── tlshd.c │ ├── l │ │ ├── .empty_dir │ │ └── .gitignore │ ├── linux │ │ ├── libnvdimm.h │ │ ├── lru_cache.h │ │ └── overflow.h │ ├── lru_cache.c │ ├── net │ │ └── handshake.h │ ├── nsecs_to_jiffies.c │ ├── patches │ │ ├── genl_policy__no_in_ops.patch │ │ ├── genlmsg_multicast_allns__no_has_4_params.patch │ │ └── nla_strscpy__no_present.patch │ ├── scripts │ │ ├── constant-tests.sh │ │ ├── findunused.py │ │ ├── unused-patches.sh │ │ └── unused-tests.sh │ ├── spatch_works.sh │ ├── splitdiff.pl │ ├── tests │ │ ├── __vmalloc_has_2_params.c │ │ ├── add_disk_returns_int.c │ │ ├── before_4_13_kernel_read.c │ │ ├── bio_alloc_has_4_params.c │ │ ├── blk_alloc_disk_takes_queue_limits.c │ │ ├── blkdev_get_by_path_has_holder_ops.c │ │ ├── blkdev_issue_discard_takes_flags.c │ │ ├── blkdev_issue_zeroout_discard.c │ │ ├── blkdev_put_has_holder.c │ │ ├── block_device_operations_open_takes_gendisk.c │ │ ├── block_device_operations_release_takes_single_argument.c │ │ ├── can_include_vermagic_h.c │ │ ├── dax_direct_access_takes_mode.c │ │ ├── fs_dax_get_by_bdev_takes_start_off.c │ │ ├── fs_dax_get_by_bdev_takes_start_off_and_holder.c │ │ ├── genl_policy_in_ops.c │ │ ├── genlmsg_multicast_allns_has_4_params.c │ │ ├── have_BIO_MAX_VECS.c │ │ ├── have_GENHD_FL_NO_PART.c │ │ ├── have___bio_add_page.c │ │ ├── have_allow_kernel_signal.c │ │ ├── have_bdev_discard_granularity.c │ │ ├── have_bdev_file_open_by_path.c │ │ ├── have_bdev_max_discard_sectors.c │ │ ├── have_bdev_nr_sectors.c │ │ ├── have_bdev_open_by_path.c │ │ ├── have_bdevname.c │ │ ├── have_bdgrab.c │ │ ├── have_bdi_congested.c │ │ ├── have_bdi_congested_fn.c │ │ ├── have_bio_advance_iter_single.c │ │ ├── have_bio_alloc_clone.c │ │ ├── have_bio_bi_bdev.c │ │ ├── have_bio_bi_error.c │ │ ├── have_bio_max_segs.c │ │ ├── have_bio_split_to_limits.c │ │ ├── have_bio_start_io_acct.c │ │ ├── have_bioset_init.c │ │ ├── have_blk_alloc_disk.c │ │ ├── have_blk_alloc_queue_rh.c │ │ ├── have_blk_cleanup_disk.c │ │ ├── have_blk_mode_t.c │ │ ├── have_blk_opf_t.c │ │ ├── have_blk_qc_t_submit_bio.c │ │ ├── have_blk_queue_flag_set.c │ │ ├── have_blk_queue_make_request.c │ │ ├── have_blk_queue_max_write_same_sectors.c │ │ ├── have_blk_queue_split_bio.c │ │ ├── have_blk_queue_split_q_bio.c │ │ ├── have_blk_queue_update_readahead.c │ │ ├── have_blk_queue_write_cache.c │ │ ├── have_bvec_kmap_local.c │ │ ├── have_counted_by.c │ │ ├── have_debugfs_change_name.c │ │ ├── have_disk_update_readahead.c │ │ ├── have_enum_req_op.c │ │ ├── have_fallthrough.c │ │ ├── have_fs_dax_get_by_bdev.c │ │ ├── have_generic_start_io_acct_q_rw_sect_part.c │ │ ├── have_generic_start_io_acct_rw_sect_part.c │ │ ├── have_genl_info_userhdr.c │ │ ├── have_get_random_u32.c │ │ ├── have_get_random_u32_below.c │ │ ├── have_hd_struct.c │ │ ├── have_kmap_local_page.c │ │ ├── have_kvfree_rcu.c │ │ ├── have_kvfree_rcu_mightsleep.c │ │ ├── have_linux_unaligned_h.c │ │ ├── have_list_is_first.c │ │ ├── have_lookup_user_key.c │ │ ├── have_max_send_recv_sge.c │ │ ├── have_mempool_is_saturated.c │ │ ├── have_nla_nest_start_noflag.c │ │ ├── have_nla_parse_deprecated.c │ │ ├── have_nla_strscpy.c │ │ ├── have_part_stat_h.c │ │ ├── have_part_stat_read_accum.c │ │ ├── have_proc_create_single.c │ │ ├── have_queue_flag_discard.c │ │ ├── have_queue_flag_stable_writes.c │ │ ├── have_queue_limits_start_update.c │ │ ├── have_rb_declare_callbacks_max.c │ │ ├── have_req_op_write.c │ │ ├── have_revalidate_disk_size.c │ │ ├── have_sane_test_environment.c │ │ ├── have_sane_test_environment_always_fail.c │ │ ├── have_sched_set_fifo.c │ │ ├── have_sendpage.c │ │ ├── have_sendpage_ok.c │ │ ├── have_set_capacity_and_notify.c │ │ ├── have_sk_use_task_frag.c │ │ ├── have_sock_set_keepalive.c │ │ ├── have_struct_size.c │ │ ├── have_submit_bio_noacct.c │ │ ├── have_tasklet_setup.c │ │ ├── have_tcp_sock_set_cork.c │ │ ├── have_tcp_sock_set_keepcnt.c │ │ ├── have_tcp_sock_set_keepidle.c │ │ ├── have_tcp_sock_set_nodelay.c │ │ ├── have_tcp_sock_set_quickack.c │ │ ├── have_timer_delete.c │ │ ├── have_timer_shutdown.c │ │ ├── have_tls_get_record_type.c │ │ ├── have_tls_tx_rx.c │ │ ├── have_void_submit_bio.c │ │ ├── ib_device_has_ops.c │ │ ├── ib_post_send_const_params.c │ │ ├── need_drbd_wrappers.c │ │ ├── need_make_request_recursion.c │ │ ├── need_recalc_sigpending.c │ │ ├── part_stat_read_takes_block_device.c │ │ ├── queue_limits_has_features.c │ │ ├── queue_limits_has_max_hw_discard_sectors.c │ │ ├── queue_limits_has_max_hw_zone_append_sectors.c │ │ ├── queue_limits_has_max_zone_append_sectors.c │ │ ├── rdma_reject_has_reason_arg.c │ │ ├── sock_ops_returns_addr_len.c │ │ └── struct_gendisk_has_backing_dev_info.c │ └── uapi │ │ └── linux │ │ ├── handshake.h │ │ └── sched │ │ └── types.h ├── drbd_actlog.c ├── drbd_bitmap.c ├── drbd_dax_pmem.c ├── drbd_dax_pmem.h ├── drbd_debugfs.c ├── drbd_debugfs.h ├── drbd_int.h ├── drbd_interval.c ├── drbd_interval.h ├── drbd_kref_debug.c ├── drbd_kref_debug.h ├── drbd_main.c ├── drbd_nl.c ├── drbd_nla.c ├── drbd_nla.h ├── drbd_polymorph_printk.h ├── drbd_proc.c ├── drbd_receiver.c ├── drbd_req.c ├── drbd_req.h ├── drbd_sender.c ├── drbd_state.c ├── drbd_state.h ├── drbd_state_change.h ├── drbd_transport.c ├── drbd_transport_lb-tcp.c ├── drbd_transport_rdma.c ├── drbd_transport_tcp.c ├── drbd_transport_template.c ├── drbd_vli.h ├── kref_debug.c ├── kref_debug.h └── linux │ └── drbd_config.h ├── filelist-redhat ├── filelist-suse ├── misc ├── SECURE-BOOT-KEY-linbit.com.der ├── copy-to-mainline.sh ├── dkms.conf ├── pre-commit └── twopc-graph ├── rpm-macro-fixes ├── README ├── kmodtool.rhel5.diff ├── macros.kernel-source.sles11-sp1.diff ├── macros.kernel-source.sles11.diff ├── macros.rhel5.diff ├── suse_macros.sles10.diff └── symset-table.diff └── sbom ├── Makefile ├── drbd-kmod.cdx.json.in └── drbd-kmod.spdx.json.in /.gitignore: -------------------------------------------------------------------------------- 1 | /drbd-*.tar.gz 2 | /ID 3 | /TODO 4 | /tags 5 | 6 | /.filelist 7 | 8 | *.gcda 9 | *.gcno 10 | *.o 11 | *.o.* 12 | 13 | drbd/tags 14 | drbd/cscope.out 15 | drbd/build-*/ 16 | drbd/compat*.h 17 | drbd/compat*.patch 18 | drbd/.drbd_git_revision 19 | drbd/dummy-for-compat-h.c 20 | drbd/dummy-for-patch.c 21 | 22 | /drbd-kmod_rhel.spdx 23 | /drbd-kmod_sles.spdx 24 | -------------------------------------------------------------------------------- /.gitlab/changelog.awk: -------------------------------------------------------------------------------- 1 | # Can be used to add a release to the ChangeLog 2 | # 3 | # Example: 4 | # awk -f changelog.awk -v REL_VERSION=9.9.9 ChangeLog > ChangeLog.ci 5 | 6 | BEGIN { 7 | if (REL_VERSION == "") 8 | die("REL_VERSION is not set") 9 | } 10 | 11 | !added && /api:/ { 12 | print REL_VERSION " " $2 13 | print "--------" 14 | print "" 15 | print " * bug fixes" 16 | print "" 17 | added = 1 18 | } 19 | 20 | {print} 21 | 22 | function die(msg) { 23 | print(msg) > "/dev/stderr" 24 | exit 1 25 | } 26 | -------------------------------------------------------------------------------- /.gitlab/drbd-prepare-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Replace the drbd version number in all necessary places 4 | # 5 | # Example: 6 | # version=9.1.15+ptf.16.g0a58e61fcd09 7 | # PATH=~/work/projects/build-helpers/build-helpers:"$PATH" ./.gitlab/drbd-prepare-release.sh "$version" 1 "$version" 8 | # 9 | # Example of a real release: 10 | # version=9.1.16 11 | # PATH=~/work/projects/build-helpers/build-helpers:"$PATH" DRBD_SOURCE_ONLINE=yes ./.gitlab/drbd-prepare-release.sh "$version" 1 "$version" 12 | 13 | version="$1" 14 | release="$2" 15 | rel_version="$3" 16 | 17 | DIR="$(dirname "$(readlink -f "$0")")" 18 | 19 | dummy-release.sh drbd "$version" "$release" drbd-kernel.spec --source-online ${DRBD_SOURCE_ONLINE:-no} 20 | 21 | sed -re "s/(#define REL_VERSION) .*/\1 \"$rel_version\"/g" drbd/linux/drbd_config.h > drbd/linux/drbd_config.h.tmp 22 | mv drbd/linux/drbd_config.h{.tmp,} 23 | 24 | for i in 8 9 10; do 25 | sed -re "s/(ENV DRBD_VERSION) .*/\1 $rel_version/g" docker/Dockerfile.rhel${i} > docker/Dockerfile.rhel${i}.tmp 26 | mv docker/Dockerfile.rhel${i}{.tmp,} 27 | done 28 | 29 | awk -f "$DIR/changelog.awk" -v REL_VERSION="$rel_version" ChangeLog > ChangeLog.tmp 30 | mv ChangeLog{.tmp,} 31 | -------------------------------------------------------------------------------- /.gitlab/kernels-from-vms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | 6 | import toml 7 | 8 | # kernels-from-vms.py 9 | # Extract kernel versions to be built from a vmshed vms.toml file supplied on stdin 10 | # Respects the EXCLUDE_BASE_IMAGES environment variable to exclude specific base images 11 | 12 | exclude_base_images = os.getenv("EXCLUDE_BASE_IMAGES", "").split(",") 13 | 14 | vms = toml.load(sys.stdin) 15 | for vm in vms["vms"]: 16 | meta = vm["metadata"] 17 | if vm["base_image"] in exclude_base_images or "BuildDistribution" not in meta: 18 | continue 19 | print(f"{meta['BuildDistribution']} {meta['BuildKernel']}") 20 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "drbd/drbd-headers"] 2 | path = drbd/drbd-headers 3 | url = ../drbd-headers.git 4 | update = rebase 5 | fetchRecurseSubmodules = true 6 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Latest: 2 | ------ 3 | For even more detail, use "git log" or visit https://github.com/LINBIT/drbd/commits/master. 4 | 5 | 9.3.0-rc.1 (api:genl2/proto:86-101,118-123/transport:19) 6 | -------- 7 | * was forked off between 9.2.12 and 9.2.13 8 | * Implemented resync without replication and made it the default; the 9 | previous (drbd-9.2 and earlier) behavior is still available via a 10 | config option. With that, the resync operation begins with 11 | mirroring of application writes disabled, and it performs multiple 12 | resync passes, clearing bits in the bitmap. It enables application 13 | write mirroring when the resync is nearly complete. That reduces 14 | the I/O load during resync, and in most cases, it reduces resync 15 | time. 16 | * Dropped support for RHEL7 and support for kernels older than 3.10. 17 | -------------------------------------------------------------------------------- /README.drbd-utils: -------------------------------------------------------------------------------- 1 | ======================================================================= 2 | With DRBD module version 8.4.5, we split out the management tools 3 | into their own repository at https://github.com/LINBIT/drbd-utils 4 | (tarball at http://links.linbit.com/drbd-download) 5 | 6 | That started out as "drbd-utils version 8.9.0", 7 | has a different release cycle, 8 | and provides compatible drbdadm, drbdsetup and drbdmeta tools 9 | for DRBD module versions 8.3, 8.4 and 9. 10 | 11 | Again: to manage DRBD 9 kernel modules and above, 12 | you want drbd-utils >= 9.3 from above url. 13 | ======================================================================= 14 | -------------------------------------------------------------------------------- /coccinelle/enum_bitops.cocci: -------------------------------------------------------------------------------- 1 | /// Make sure the bitops on drbd_xxx->flags are only used with the right enums 2 | // 3 | // Options: --include-headers 4 | 5 | virtual report 6 | 7 | @initialize:python@ 8 | @@ 9 | enums = {} 10 | 11 | @find_enums@ 12 | identifier id =~ "(device|peer_device|connection|resource)_flag"; 13 | identifier c; 14 | @@ 15 | enum id { ..., c , ... } 16 | 17 | @script:python@ 18 | id << find_enums.id; 19 | c << find_enums.c; 20 | @@ 21 | if id in enums: 22 | enums[id].append(c) 23 | else: 24 | enums[id] = [c] 25 | 26 | @drbd_flag_ops@ 27 | constant F; 28 | type T; 29 | T *var; 30 | position p; 31 | @@ 32 | ( 33 | test_bit(F, &var->flags)@p 34 | | 35 | set_bit(F, &var->flags)@p 36 | | 37 | clear_bit(F, &var->flags)@p 38 | | 39 | test_and_set_bit(F, &var->flags)@p 40 | | 41 | test_and_clear_bit(F, &var->flags)@p 42 | ) 43 | 44 | @script:python depends on report@ 45 | t << drbd_flag_ops.T; 46 | f << drbd_flag_ops.F; 47 | p << drbd_flag_ops.p; 48 | @@ 49 | if t.startswith("struct drbd_"): 50 | enum_name = t[12:] + "_flag"; 51 | if enum_name in enums and not f in enums[enum_name]: 52 | msg = "ERROR: %s used as enum value on %s but it is not a %s" % (f, t, enum_name) 53 | coccilib.report.print_report(p[0], msg) 54 | -------------------------------------------------------------------------------- /coccinelle/iterator_rcu_suffix.cocci: -------------------------------------------------------------------------------- 1 | // Ensure that the correct _rcu variants are used on iterators when appropriate 2 | 3 | virtual report 4 | 5 | @ r exists @ 6 | iterator it =~ "for_each_(peer_device|connection|resource)$"; 7 | position p; 8 | @@ 9 | rcu_read_lock(); 10 | <+... 11 | it(...)@p{ 12 | ... 13 | } 14 | ...+> 15 | rcu_read_unlock(); 16 | 17 | @script:python depends on report@ 18 | p << r.p; 19 | it << r.it; 20 | @@ 21 | msg = "ERROR: %s without rcu suffix used in rcu context" % (it) 22 | coccilib.report.print_report(p[0], msg) 23 | -------------------------------------------------------------------------------- /debian/README.Debian: -------------------------------------------------------------------------------- 1 | drbd for Debian 2 | --------------- 3 | 4 | To make sure the default installation of drbd is non-interactive, I 5 | have set the default value of the inittimeout parameter to be a 6 | negative number. This may not be what you would like for a production 7 | setup. See the drbd.conf man page and pay special attention to the 8 | inittimeout, skip-wait, and load-only options. 9 | 10 | -- David Krovich , Tue May 25 12:47:11 2004 11 | -------------------------------------------------------------------------------- /debian/TODO: -------------------------------------------------------------------------------- 1 | Create lintian overrides to deal with bash not handling extglob 2 | syntax. I'll also contact lintian package maintainers to make sure 3 | this is the correct thing to do. Refer to #247605 in the BTS for 4 | background on this. 5 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | drbd (9.3.0~rc.1-1) unstable; urgency=medium 2 | 3 | * Release candidate 4 | 5 | -- Philipp Reisner Tue, 27 May 2025 16:42:01 +0200 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: drbd 2 | Section: admin 3 | Priority: extra 4 | Maintainer: DRBD dev 5 | Uploaders: Philipp Reisner , 6 | Lars Ellenberg , 7 | Roland Kammerer 8 | Build-Depends: bash, 9 | debhelper (>= 7), 10 | dkms 11 | Standards-Version: 3.6.2.1 12 | 13 | Package: drbd-dkms 14 | Architecture: all 15 | Section: admin 16 | Depends: dkms (>= 1.9.5), 17 | drbd-utils (>= 9.28.0), 18 | curl, 19 | ${misc:Depends} 20 | Conflicts: drbd-module-source, 21 | drbd8-module-source 22 | Provides: drbd-dkms 23 | Replaces: drbd-module-source 24 | Description: RAID 1 over TCP/IP for Linux module source 25 | DRBD is a block device which is designed to build high availability 26 | clusters by providing a virtual shared device which keeps disks in 27 | nodes synchronised using TCP/IP. This simulates RAID 1 but avoiding 28 | the use of uncommon hardware (shared SCSI buses or Fibre Channel). 29 | It is currently limited to fail-over HA clusters. 30 | . 31 | This package contains the source code for the DRBD kernel module. 32 | Homepage: http://www.drbd.org 33 | 34 | Package: drbd-module-source 35 | Architecture: all 36 | Section: admin 37 | Depends: debhelper (>= 7), 38 | ${misc:Depends} 39 | Conflicts: drbd-dkms, 40 | drbd8-module-source 41 | Provides: drbd-module-source 42 | Replaces: drbd-dkms 43 | Recommends: kernel-package | module-assistant 44 | Description: RAID 1 over TCP/IP for Linux module source 45 | DRBD is a block device which is designed to build high availability 46 | clusters by providing a virtual shared device which keeps disks in 47 | nodes synchronised using TCP/IP. This simulates RAID 1 but avoiding 48 | the use of uncommon hardware (shared SCSI buses or Fibre Channel). 49 | It is currently limited to fail-over HA clusters. 50 | . 51 | This package contains the source code for the DRBD kernel module. 52 | Homepage: http://www.drbd.org 53 | 54 | Package: drbd-ueficert 55 | Architecture: all 56 | Section: admin 57 | Depends: ${misc:Depends} 58 | Description: Public key part used for DRBD kernel module signing. 59 | Homepage: https://www.linbit.com 60 | -------------------------------------------------------------------------------- /debian/control.modules.in: -------------------------------------------------------------------------------- 1 | Source: drbd 2 | Section: misc 3 | Priority: extra 4 | Maintainer: DRBD dev 5 | Uploaders: Philipp Reisner , 6 | Lars Ellenberg , 7 | Roland Kammerer 8 | Build-Depends: debhelper (>= 7), 9 | drbd-module-source 10 | Standards-Version: 3.6.1 11 | 12 | Package: drbd-module-_KVERS_ 13 | Architecture: any 14 | Depends: drbd-utils, 15 | drbd-ueficert, 16 | Conflicts: drbd-module-_KVERS_ 17 | Provides: drbd-module-_KVERS_ 18 | Replaces: drbd-module-_KVERS_ 19 | Section: misc 20 | Recommends: linux-image-_KVERS_ 21 | Description: RAID 1 over TCP/IP for Linux kernel module 22 | DRBD is a block device which is designed to build high availability 23 | clusters by providing a virtual shared device which keeps disks in nodes 24 | synchronised using TCP/IP. This simulates RAID 1 but avoiding the 25 | use of uncommon hardware (shared SCSI buses or Fibre Channel). 26 | It is currently limited to fail-over HA clusters. 27 | . 28 | This package contains the DRBD kernel module for the kernel version 29 | _KVERS_ 30 | Homepage: http://www.drbd.org 31 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: drbd-9.0 3 | Source: http://git.linbit.com/drbd-9.0.git/ 4 | 5 | Files: * 6 | Copyright: Copyright (C) 2001-2014, LINBIT Information Technologies GmbH 7 | Copyright (C) 2008-2014, LINBIT HA-Solutions GmbH 8 | Copyright (C) 1999-2014, Philipp Reisner 9 | Copyright (C) 2001-2014, Lars Ellenberg 10 | License: GPL-2+ 11 | This program is free software; you can redistribute it 12 | and/or modify it under the terms of the GNU General Public 13 | License as published by the Free Software Foundation; either 14 | version 2 of the License, or (at your option) any later 15 | version. 16 | . 17 | This program is distributed in the hope that it will be 18 | useful, but WITHOUT ANY WARRANTY; without even the implied 19 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 20 | PURPOSE. See the GNU General Public License for more 21 | details. 22 | . 23 | You should have received a copy of the GNU General Public 24 | License along with this package; if not, write to the Free 25 | Software Foundation, Inc., 51 Franklin St, Fifth Floor, 26 | Boston, MA 02110-1301 USA 27 | . 28 | On Debian systems, the full text of the GNU General Public 29 | License version 2 can be found in the file 30 | `/usr/share/common-licenses/GPL-2'. 31 | 32 | Files: debian/* 33 | Copyright: Copyright 2001 Ard van Breemen 34 | Copyright 2002 Jan Niehusmann 35 | Copyright 2004 David Krovich 36 | Copyright 2004 Bernd Schubert 37 | Copyright 2004-2014 Lars Ellenberg 38 | Copyright 2004-2014 Philipp Reisner 39 | Copyright 2004-2006 Cyril Bouthors 40 | Copyright 2007 Frederik Schüler 41 | Copyright 2009 Iustin Pop 42 | Copyright 2010 Alexander Reichle-Schmehl 43 | Copyright 2008-2010 Norbert Tretkowski 44 | Copyright 2004-2012 Philipp Hug 45 | Copyright 2013-2014 Apollon Oikonomopoulos 46 | Copyright 2014 Roland Kammerer 47 | License: 48 | Copying and distribution of this package, with or without 49 | modification, are permitted in any medium without royalty 50 | provided the copyright notice and this notice are 51 | preserved. 52 | -------------------------------------------------------------------------------- /debian/drbd-dkms.dkms: -------------------------------------------------------------------------------- 1 | ../misc/dkms.conf -------------------------------------------------------------------------------- /debian/drbd-module-_KVERS_.postinst.modules.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | SYSTEMMAP=/boot/System.map-_KVERS_ 5 | 6 | if [ -f $SYSTEMMAP ] 7 | then 8 | depmod -ae -F $SYSTEMMAP _KVERS_ 9 | elif [ "`uname -r`" = "_KVERS_" ] 10 | then 11 | depmod -a 12 | fi 13 | 14 | #DEBHELPER# 15 | -------------------------------------------------------------------------------- /debian/drbd-module-_KVERS_.postrm.modules.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | SYSTEMMAP=/boot/System.map-_KVERS_ 5 | 6 | if [ -f $SYSTEMMAP ] 7 | then 8 | depmod -ae -F $SYSTEMMAP _KVERS_ 9 | elif [ "`uname -r`" = "_KVERS_" ] 10 | then 11 | depmod -a & 12 | fi 13 | 14 | #DEBHELPER# 15 | -------------------------------------------------------------------------------- /debian/drbd-module-source.dirs: -------------------------------------------------------------------------------- 1 | usr/share/modass/overrides 2 | usr/src/modules/drbd/debian 3 | usr/src/modules/drbd/drbd 4 | -------------------------------------------------------------------------------- /debian/drbd-ueficert.install: -------------------------------------------------------------------------------- 1 | misc/SECURE-BOOT-KEY-linbit.com.der etc/pki/linbit 2 | -------------------------------------------------------------------------------- /debian/modass.drbd-module-source: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # (c) Eduard Bloch , 2003 4 | # generic maintainer script for module-assistant controled packages 5 | # to be sourced or copied as example code 6 | 7 | # autodetecting values. They may be overriden by the caller. 8 | 9 | MA_DIR=${MA_DIR:-/usr/share/modass} 10 | 11 | TARBALL=/usr/src/drbd.tar.gz 12 | BUILDDIR=${MODULE_LOC:-/usr/src/modules}/drbd/ 13 | # at least for stretch 14 | MA_BUILDDIR=${BUILDDIR} 15 | 16 | . $MA_DIR/packages/generic.sh 17 | 18 | $1 "$@" 19 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Uncomment this to turn on verbose mode. 4 | # export DH_VERBOSE=1 5 | 6 | VERSION := $(shell dpkg-parsechangelog | sed -rne 's/^Version: ([0-9]+:)?//p') 7 | PACKAGE=drbd-module 8 | DKMSDIR=drbd-dkms 9 | MODSRCDIR=drbd-module-source 10 | 11 | # modifieable for experiments or debugging m-a 12 | MA_DIR ?= /usr/share/modass 13 | # load generic variable handling 14 | -include $(MA_DIR)/include/generic.make 15 | # load default rules, including kdist, kdist_image, ... 16 | -include $(MA_DIR)/include/common-rules.make 17 | 18 | %: 19 | dh $@ --with dkms 20 | 21 | override_dh_auto_clean: ; 22 | override_dh_auto_configure: ; 23 | override_dh_auto_build: ; 24 | override_dh_auto_test: ; 25 | override_dh_auto_install: ; 26 | 27 | override_dh_install: 28 | # dkms 29 | dh_install drbd ../$(DKMSDIR)/usr/src/drbd-$(VERSION)/src 30 | 31 | # m-a 32 | dh_install drbd ../$(MODSRCDIR)/usr/src/modules/drbd/ 33 | dh_install debian/changelog ../$(MODSRCDIR)/usr/src/modules/drbd/debian 34 | dh_install debian/control ../$(MODSRCDIR)/usr/src/modules/drbd/debian 35 | dh_install debian/compat ../$(MODSRCDIR)/usr/src/modules/drbd/debian 36 | dh_install debian/copyright ../$(MODSRCDIR)/usr/src/modules/drbd/debian 37 | dh_install debian/*modules.in ../$(MODSRCDIR)/usr/src/modules/drbd/debian 38 | dh_install debian/rules ../$(MODSRCDIR)/usr/src/modules/drbd/debian 39 | cd debian/$(MODSRCDIR)/usr/src ; tar pzfvc drbd.tar.gz modules ; rm -rf modules 40 | install -m 755 debian/modass.drbd-module-source ./debian/$(MODSRCDIR)/usr/share/modass/overrides/$(MODSRCDIR) 41 | 42 | override_dh_dkms: 43 | dh_dkms -V $(VERSION) 44 | 45 | # some nasty clue code for m-a 46 | kdist_clean: 47 | dh_clean 48 | -$(MAKE) -C drbd clean 49 | 50 | ifneq (,$(filter gcov,$(DEB_BUILD_OPTIONS))) 51 | extra_make_flags = GCOV_PROFILE=y 52 | endif 53 | 54 | deb_build_parallel := $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 55 | ifdef deb_build_parallel 56 | -j := -j$(deb_build_parallel) 57 | endif 58 | 59 | DEB_BUILD_ARCH := $(shell dpkg --print-architecture) 60 | binary-modules: prep-deb-files 61 | dh_testdir 62 | dh_testroot 63 | dh_clean -k 64 | $(MAKE) $(-j) -C drbd KERNEL_SOURCES=$(KSRC) MODVERSIONS=detect KERNEL=linux-$(KVERS) KDIR=$(KSRC) $(extra_make_flags) 65 | $(MAKE) -C $(KSRC) M=$(CURDIR)/drbd/build-current/ modules_install INSTALL_MOD_PATH=$(CURDIR)/debian/$(PKGNAME) INSTALL_MOD_DIR=updates CONFIG_MODULE_SIG_ALL=y CONFIG_MODULE_SIG_KEY=certs/signing_key.pem 66 | install -m644 -b -D drbd/build-current/Module.symvers $(DEB_DESTDIR)/Module.symvers.$(KVERS).$(DEB_BUILD_ARCH) 67 | dh_installdocs 68 | dh_installchangelogs 69 | dh_compress 70 | dh_fixperms 71 | dh_installdeb 72 | dh_gencontrol -- -v$(VERSION) 73 | dh_md5sums 74 | dh_builddeb --destdir=$(DEB_DESTDIR) 75 | 76 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | 3 | opts=dversionmangle=s/\+linbit\d*$// \ 4 | http://plain.oss.linbit.com/drbd/9.0/drbd-(.+)\.tar\.gz 5 | -------------------------------------------------------------------------------- /docker/Dockerfile.amzn2: -------------------------------------------------------------------------------- 1 | FROM amazonlinux:2 2 | 3 | # amazonlinux/eks ships different kernel series, so we install all (i.e., 2) the gccs 4 | RUN yum -y update-minimal --security --sec-severity=Important --sec-severity=Critical && \ 5 | yum install -y \ 6 | cpio \ 7 | diffutils \ 8 | gcc \ 9 | gcc10 \ 10 | gzip \ 11 | kmod \ 12 | make \ 13 | patch \ 14 | perl \ 15 | python2-setuptools \ 16 | tar \ 17 | util-linux \ 18 | && \ 19 | yum clean all -y && \ 20 | cd /tmp && \ 21 | curl -fsSL https://github.com/LINBIT/python-lbdist/archive/master.tar.gz | tar vxz && \ 22 | ( cd python-lbdist-master && python2 setup.py install ) && \ 23 | rm -rf python-lbdist-master 24 | 25 | COPY /drbd.tar.gz / 26 | 27 | COPY /pkgs /pkgs 28 | 29 | COPY /entry.sh / 30 | ENTRYPOINT /entry.sh 31 | -------------------------------------------------------------------------------- /docker/Dockerfile.flatcar: -------------------------------------------------------------------------------- 1 | FROM gentoo/stage3 2 | MAINTAINER Roland Kammerer 3 | 4 | COPY /drbd.tar.gz / 5 | 6 | COPY /entry.sh / 7 | ENTRYPOINT /entry.sh 8 | -------------------------------------------------------------------------------- /docker/Dockerfile.focal: -------------------------------------------------------------------------------- 1 | FROM ubuntu:focal 2 | 3 | # note: py2 setuptools are a bit smaller than the py3 ones 4 | RUN apt-get update && \ 5 | apt-get install -y \ 6 | curl \ 7 | diffutils \ 8 | elfutils \ 9 | gcc \ 10 | gnupg \ 11 | kmod \ 12 | make \ 13 | patch \ 14 | perl \ 15 | python-setuptools \ 16 | && \ 17 | apt-get clean && \ 18 | cd /tmp && \ 19 | curl -fsSL https://github.com/LINBIT/python-lbdist/archive/master.tar.gz | tar vxz && \ 20 | ( cd python-lbdist-master && python2 setup.py install ) && \ 21 | rm -rf python-lbdist-master 22 | 23 | COPY /drbd.tar.gz / 24 | 25 | COPY /pkgs /pkgs 26 | 27 | COPY /entry.sh / 28 | ENTRYPOINT /entry.sh 29 | -------------------------------------------------------------------------------- /docker/Dockerfile.jammy: -------------------------------------------------------------------------------- 1 | FROM ubuntu:jammy 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | curl \ 6 | diffutils \ 7 | elfutils \ 8 | gcc \ 9 | gnupg \ 10 | kmod \ 11 | make \ 12 | patch \ 13 | perl \ 14 | python3-setuptools \ 15 | && \ 16 | apt-get clean && \ 17 | cd /tmp && \ 18 | curl -fsSL https://github.com/LINBIT/python-lbdist/archive/master.tar.gz | tar vxz && \ 19 | ( cd python-lbdist-master && python3 setup.py install ) && \ 20 | rm -rf python-lbdist-master 21 | 22 | COPY /drbd.tar.gz / 23 | 24 | COPY /pkgs /pkgs 25 | 26 | COPY /entry.sh / 27 | ENTRYPOINT /entry.sh 28 | -------------------------------------------------------------------------------- /docker/Dockerfile.noble: -------------------------------------------------------------------------------- 1 | FROM ubuntu:noble 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y \ 5 | curl \ 6 | diffutils \ 7 | elfutils \ 8 | gcc \ 9 | gnupg \ 10 | kmod \ 11 | make \ 12 | patch \ 13 | perl \ 14 | python3-setuptools \ 15 | && \ 16 | apt-get clean && \ 17 | cd /tmp && \ 18 | curl -fsSL https://github.com/LINBIT/python-lbdist/archive/master.tar.gz | tar vxz && \ 19 | ( cd python-lbdist-master && python3 setup.py install ) && \ 20 | rm -rf python-lbdist-master 21 | 22 | COPY /entry.sh / 23 | COPY /drbd.tar.gz / 24 | COPY /pkgs /pkgs 25 | 26 | ENTRYPOINT /entry.sh 27 | -------------------------------------------------------------------------------- /docker/Dockerfile.rhel10: -------------------------------------------------------------------------------- 1 | ARG EXTRAPKGS=almalinux:10 2 | FROM $EXTRAPKGS as extrapkgs 3 | # by checking for /pkgs we can cache that step 4 | # and prepare images that already contain the packages. 5 | RUN mkdir /pkgs 6 | RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild 7 | 8 | FROM registry.access.redhat.com/ubi10/ubi 9 | MAINTAINER Roland Kammerer 10 | 11 | ENV DRBD_VERSION 9.3.0-rc.1 12 | 13 | ARG release=1 14 | LABEL name="DRBD Kernel module load container" \ 15 | vendor="LINBIT" \ 16 | version="$DRBD_VERSION" \ 17 | release="$release" \ 18 | summary="DRBD's kernel component" \ 19 | description="DRBD's kernel component" 20 | RUN mkdir /licenses && cp /usr/share/licenses/shadow-utils/gpl-2.0.txt /licenses/ 21 | 22 | RUN dnf -y update-minimal --security --sec-severity=Important --sec-severity=Critical && \ 23 | dnf install -y \ 24 | cpio \ 25 | diffutils \ 26 | gcc \ 27 | kmod \ 28 | make \ 29 | patch \ 30 | perl \ 31 | python3 \ 32 | python3-pip \ 33 | xz \ 34 | && \ 35 | dnf clean all -y && \ 36 | pip-3 install https://github.com/LINBIT/python-lbdist/archive/master.tar.gz 37 | 38 | COPY --from=extrapkgs /pkgs /pkgs 39 | RUN dnf install -y /pkgs/*.rpm # !lbbuild 40 | # or 41 | # =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel 42 | 43 | RUN rm -rf /pkgs 44 | 45 | # one can not comment copy 46 | RUN curl -fsSL https://pkg.linbit.com/downloads/drbd/9/drbd-${DRBD_VERSION}.tar.gz -o /drbd.tar.gz # !lbbuild 47 | # =lbbuild COPY /drbd.tar.gz / 48 | 49 | # these are now the kmod pkgs: 50 | COPY /pkgs /pkgs 51 | 52 | COPY /entry.sh / 53 | ENTRYPOINT /entry.sh 54 | -------------------------------------------------------------------------------- /docker/Dockerfile.rhel8: -------------------------------------------------------------------------------- 1 | ARG EXTRAPKGS=almalinux:8 2 | FROM $EXTRAPKGS as extrapkgs 3 | # by checking for /pkgs we can cache that step 4 | # and prepare images that already contain the packages. 5 | RUN mkdir /pkgs 6 | RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild 7 | 8 | FROM registry.access.redhat.com/ubi8/ubi 9 | MAINTAINER Roland Kammerer 10 | 11 | ENV DRBD_VERSION 9.3.0-rc.1 12 | 13 | ARG release=1 14 | LABEL name="DRBD Kernel module load container" \ 15 | vendor="LINBIT" \ 16 | version="$DRBD_VERSION" \ 17 | release="$release" \ 18 | summary="DRBD's kernel component" \ 19 | description="DRBD's kernel component" 20 | RUN mkdir /licenses && cp /usr/share/licenses/shadow-utils/gpl-2.0.txt /licenses/ 21 | 22 | RUN yum -y update-minimal --security --sec-severity=Important --sec-severity=Critical && \ 23 | yum install -y \ 24 | cpio \ 25 | curl \ 26 | diffutils \ 27 | gcc \ 28 | kmod \ 29 | make \ 30 | patch \ 31 | perl \ 32 | python3 \ 33 | python3-pip \ 34 | && \ 35 | yum clean all -y && \ 36 | alternatives --set python /usr/bin/python3 && \ 37 | pip-3 install https://github.com/LINBIT/python-lbdist/archive/master.tar.gz 38 | 39 | COPY --from=extrapkgs /pkgs /pkgs 40 | RUN yum install -y /pkgs/*.rpm # !lbbuild 41 | # or 42 | # =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel 43 | 44 | RUN rm -rf /pkgs 45 | 46 | # one can not comment copy 47 | RUN curl -fsSL https://pkg.linbit.com/downloads/drbd/9/drbd-${DRBD_VERSION}.tar.gz -o /drbd.tar.gz # !lbbuild 48 | # =lbbuild COPY /drbd.tar.gz / 49 | 50 | # these are now the kmod pkgs: 51 | COPY /pkgs /pkgs 52 | 53 | COPY /entry.sh / 54 | ENTRYPOINT /entry.sh 55 | -------------------------------------------------------------------------------- /docker/Dockerfile.rhel9: -------------------------------------------------------------------------------- 1 | ARG EXTRAPKGS=almalinux:9 2 | FROM $EXTRAPKGS as extrapkgs 3 | # by checking for /pkgs we can cache that step 4 | # and prepare images that already contain the packages. 5 | RUN mkdir /pkgs 6 | RUN dnf install -y 'dnf-command(download)' && cd /pkgs && dnf download elfutils-libelf-devel && rm -f *.i686.rpm # !lbbuild 7 | 8 | FROM registry.access.redhat.com/ubi9/ubi 9 | MAINTAINER Roland Kammerer 10 | 11 | ENV DRBD_VERSION 9.3.0-rc.1 12 | 13 | ARG release=1 14 | LABEL name="DRBD Kernel module load container" \ 15 | vendor="LINBIT" \ 16 | version="$DRBD_VERSION" \ 17 | release="$release" \ 18 | summary="DRBD's kernel component" \ 19 | description="DRBD's kernel component" 20 | RUN mkdir /licenses && cp /usr/share/licenses/shadow-utils/gpl-2.0.txt /licenses/ 21 | 22 | RUN dnf -y update-minimal --security --sec-severity=Important --sec-severity=Critical && \ 23 | dnf install -y \ 24 | cpio \ 25 | diffutils \ 26 | gcc \ 27 | kmod \ 28 | make \ 29 | patch \ 30 | perl \ 31 | python3 \ 32 | python3-pip \ 33 | && \ 34 | dnf clean all -y && \ 35 | pip-3 install https://github.com/LINBIT/python-lbdist/archive/master.tar.gz 36 | 37 | COPY --from=extrapkgs /pkgs /pkgs 38 | RUN dnf install -y /pkgs/*.rpm # !lbbuild 39 | # or 40 | # =lbbuild RUN curl -fsSL https://nexus.at.linbit.com/repository/lbbuild/from_rhel_repos.sh | bash -s -- elfutils-libelf-devel 41 | 42 | RUN rm -rf /pkgs 43 | 44 | # one can not comment copy 45 | RUN curl -fsSL https://pkg.linbit.com/downloads/drbd/9/drbd-${DRBD_VERSION}.tar.gz -o /drbd.tar.gz # !lbbuild 46 | # =lbbuild COPY /drbd.tar.gz / 47 | 48 | # these are now the kmod pkgs: 49 | COPY /pkgs /pkgs 50 | 51 | COPY /entry.sh / 52 | ENTRYPOINT /entry.sh 53 | -------------------------------------------------------------------------------- /docker/Dockerfile.sles15: -------------------------------------------------------------------------------- 1 | ARG BASE=docker.io/opensuse/leap:15 # !lbbuild 2 | # =lbbuild ARG BASE=registry.suse.com/suse/sle15 3 | FROM $BASE 4 | 5 | LABEL org.opencontainers.image.authors="Moritz Wanzenböck " 6 | 7 | ENV DRBD_VERSION 9.2.13-rc.1 8 | 9 | ARG release=1 10 | LABEL name="DRBD Kernel module load container" \ 11 | vendor="LINBIT" \ 12 | version="$DRBD_VERSION" \ 13 | release="$release" \ 14 | summary="DRBD's kernel component" \ 15 | description="DRBD's kernel component" 16 | 17 | # =lbbuild ARG TARGETARCH 18 | RUN \ 19 | --mount=type=cache,target=/var/cache/zypp,sharing=private \ 20 | # =lbbuild --mount=type=tmpfs,target=/run/secrets/credentials.d \ 21 | # =lbbuild curl -fsSL "https://nexus.at.linbit.com/repository/lbbuild/suse-secrets/15/SCCcredentials.$TARGETARCH" -o /run/secrets/credentials.d/SCCcredentials && \ 22 | zypper install -y \ 23 | awk \ 24 | cpio \ 25 | diffutils \ 26 | gcc \ 27 | kmod \ 28 | make \ 29 | patch \ 30 | perl \ 31 | python3 \ 32 | python3-pip \ 33 | tar \ 34 | && pip3 install --no-cache-dir https://github.com/LINBIT/python-lbdist/archive/master.tar.gz 35 | 36 | RUN curl -fsSL https://pkg.linbit.com/downloads/drbd/9/drbd-${DRBD_VERSION}.tar.gz -o /drbd.tar.gz # !lbbuild 37 | # =lbbuild COPY /drbd.tar.gz / 38 | 39 | COPY /pkgs /pkgs 40 | 41 | COPY --chmod=0755 /entry.sh / 42 | ENTRYPOINT ["/entry.sh"] 43 | -------------------------------------------------------------------------------- /docker/pkgs/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LINBIT/drbd/011f770e15a81aef8219141ca85f0bc1765ad1ec/docker/pkgs/.empty -------------------------------------------------------------------------------- /drbd/Kconfig: -------------------------------------------------------------------------------- 1 | # 2 | # DRBD device driver configuration 3 | # 4 | 5 | comment "DRBD disabled because PROC_FS or INET not selected" 6 | depends on PROC_FS='n' || INET='n' 7 | 8 | config BLK_DEV_DRBD 9 | tristate "DRBD Distributed Replicated Block Device support" 10 | depends on PROC_FS && INET 11 | select LRU_CACHE 12 | select CRC32 13 | default n 14 | help 15 | 16 | NOTE: In order to authenticate connections you have to select 17 | CRYPTO_HMAC and a hash function as well. 18 | 19 | DRBD is a shared-nothing, synchronously replicated block device. It 20 | is designed to serve as a building block for high availability 21 | clusters and in this context, is a "drop-in" replacement for shared 22 | storage. Simplistically, you could see it as a network RAID 1. 23 | 24 | Each minor device has a role, which can be 'primary' or 'secondary'. 25 | On the node with the primary device the application is supposed to 26 | run and to access the device (/dev/drbdX). Every write is sent to 27 | the local 'lower level block device' and, across the network, to the 28 | node with the device in 'secondary' state. The secondary device 29 | simply writes the data to its lower level block device. 30 | 31 | DRBD can also be used in dual-Primary mode (device writable on both 32 | nodes), which means it can exhibit shared disk semantics in a 33 | shared-nothing cluster. Needless to say, on top of dual-Primary 34 | DRBD utilizing a cluster file system is necessary to maintain for 35 | cache coherency. 36 | 37 | For automatic failover you need a cluster manager (e.g. heartbeat). 38 | See also: https://www.drbd.org/, http://www.linux-ha.org 39 | 40 | If unsure, say N. 41 | 42 | config DRBD_FAULT_INJECTION 43 | bool "DRBD fault injection" 44 | depends on BLK_DEV_DRBD 45 | help 46 | 47 | Say Y here if you want to simulate IO errors, in order to test DRBD's 48 | behavior. 49 | 50 | The actual simulation of IO errors is done by writing 3 values to 51 | /sys/module/drbd/parameters/ 52 | 53 | enable_faults: bitmask of... 54 | 1 meta data write 55 | 2 read 56 | 4 resync data write 57 | 8 read 58 | 16 data write 59 | 32 data read 60 | 64 read ahead 61 | 128 kmalloc of bitmap 62 | 256 allocation of peer_requests 63 | 512 insert data corruption on receiving side 64 | 65 | fault_devs: bitmask of minor numbers 66 | fault_rate: frequency in percent 67 | 68 | Example: Simulate data write errors on /dev/drbd0 with a probability of 5%. 69 | echo 16 > /sys/module/drbd/parameters/enable_faults 70 | echo 1 > /sys/module/drbd/parameters/fault_devs 71 | echo 5 > /sys/module/drbd/parameters/fault_rate 72 | 73 | If unsure, say N. 74 | 75 | config DRBD_TIMING_STATS 76 | bool "Enable additional timing collection" 77 | depends on BLK_DEV_DRBD 78 | help 79 | 80 | this option enables a virtual file in debug-fs 81 | /sys/kernel/debug/drbd/resources//volumes//req_timing 82 | 83 | that unveiles the culmative time consumed by requests in various 84 | stages of the request processing 85 | -------------------------------------------------------------------------------- /drbd/README: -------------------------------------------------------------------------------- 1 | Basic Data Structure 2 | ==================== 3 | 4 | A node has a number of DRBD resources. Each such resource has a number of 5 | devices (aka volumes) and connections to other nodes ("peer nodes"). Each 6 | device has a unique minor device number. 7 | 8 | This relationship is represented by the global variable drbd_resources, the 9 | drbd_resource, drbd_connection, drbd_device, and drbd_peer_device objects, and 10 | their interconnections. 11 | 12 | The objects form a matrix; a drbd_peer_device object sits at each intersection 13 | between a drbd_device and a drbd_connection: 14 | 15 | /--------------+---------------+.....+---------------\ 16 | | resource | device | | device | 17 | +--------------+---------------+.....+---------------+ 18 | | connection | peer_device | | peer_device | 19 | +--------------+---------------+.....+---------------+ 20 | : : : : : 21 | : : : : : 22 | +--------------+---------------+.....+---------------+ 23 | | connection | peer_device | | peer_device | 24 | \--------------+---------------+.....+---------------/ 25 | 26 | 27 | In the table above, horizontally, devices can be accessed from resources by 28 | their volume number. Likewise, peer_devices can be accessed from connections 29 | by their volume number. There is no useful order between connections, and so 30 | objects in the vertical direction are in double linked lists. There are back 31 | pointers from peer_devices to their connections a devices, and from connections 32 | and devices to their resource. 33 | 34 | In addition, devices can be accessed by major / minor number from the global 35 | variable drbd_devices. 36 | 37 | The drbd_resource, drbd_connection, and drbd_device objects are reference 38 | counted. The peer_device objects only serve to establish the links between 39 | devices and connections; their lifetime is determined by the lifetime of the 40 | device and connection which they reference. 41 | 42 | The objects below a resource (devices, connections, peer devices) are modified 43 | in a lru-safe way. They are modified under the resource->conf_update mutex. 44 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/.gitignore: -------------------------------------------------------------------------------- 1 | .idr.o.cmd 2 | idr.o 3 | 4 | .blkdev_issue_zeroout.o.cmd 5 | blkdev_issue_zeroout.o 6 | 7 | .nsecs_to_jiffies.o.cmd 8 | nsecs_to_jiffies.o 9 | 10 | .drbd_wrappers.o.cmd 11 | drbd_wrappers.o 12 | 13 | .gen_patch_names.cmd 14 | gen_patch_names 15 | 16 | cocci_cache/* 17 | compat.patch 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/README.md: -------------------------------------------------------------------------------- 1 | # drbd-kernel-compat 2 | 3 | This repository contains the kernel backwards compatibility tests and wrappers for DRBD. 4 | 5 | DRBD, developed by [LINBIT](https://www.linbit.com), is a software that allows RAID 1 functionality over 6 | TCP/IP and RDMA for GNU/Linux. DRBD is a block device which is designed to build high availability clusters and 7 | software defined storage by providing a virtual shared device which keeps disks in nodes synchronised using 8 | TCP/IP or RDMA. This simulates RAID 1 but avoids the use of uncommon hardware (shared SCSI buses or Fibre Channel). 9 | 10 | # Using DRBD 11 | Please read the user-guide provided at [docs.linbit.com](https://docs.linbit.com). 12 | 13 | # Support 14 | For further products and professional support, please 15 | [contact](http://links.linbit.com/support) us. 16 | 17 | # Contributing 18 | Development is coordinated via [mailing lists](http://lists.linbit.com). Currently, we do not intend to use 19 | github issue tracking. 20 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/asm/barrier.h: -------------------------------------------------------------------------------- 1 | /* used to be part of asm/system.h, before that was "Disintegrated" */ 2 | #include 3 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/build_cocci_cache.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LC_ALL=C LANG=C LANGUAGE=C 4 | 5 | FILES=$@ 6 | 7 | mkdir -p cocci_cache 8 | mkdir -p cocci_cache.previous 9 | for F in cocci_cache/*; do 10 | test -d $F && mv $F cocci_cache.previous/ 11 | done 12 | 13 | for F in $FILES; do 14 | N_CONFIGS=$((N_CONFIGS + 1)) 15 | MD5SUM_OUTPUT=$(md5sum $F) 16 | MD5SUM=${MD5SUM_OUTPUT%% *} 17 | 18 | if test -e cocci_cache.previous/$MD5SUM; then 19 | mv cocci_cache.previous/$MD5SUM cocci_cache/ 20 | # Maybe we can preserves a compat.patch 21 | N_PRESERVED=$((N_PRESERVED + 1)) 22 | N_UNIQUE=$((N_UNIQUE + 1)) 23 | fi 24 | 25 | if test ! -e cocci_cache/$MD5SUM; then 26 | mkdir cocci_cache/$MD5SUM 27 | mv $F cocci_cache/$MD5SUM/compat.h 28 | N_UNIQUE=$((N_UNIQUE + 1)) 29 | else 30 | rm $F 31 | fi 32 | 33 | # clean up directory if already empty 34 | D=$(dirname "$F") 35 | while [ -n "$D" -a "$D" != "." ]; do 36 | rmdir --ignore-fail-on-non-empty $D 37 | D="${D%/*}" 38 | done 39 | 40 | KERNELRELEASE=${F#*compat.h.} 41 | kernelrelease_txt=cocci_cache/$MD5SUM/kernelrelease.txt 42 | grep -sqxFe "$KERNELRELEASE" "$kernelrelease_txt" || 43 | echo "$KERNELRELEASE" >> "$kernelrelease_txt" 44 | 45 | ln -f -s -T ../cocci_cache/$MD5SUM l/$KERNELRELEASE 46 | 47 | # Progress 48 | printf "%3d %3d %-60s\r" $N_CONFIGS $N_UNIQUE $F 49 | done 50 | 51 | # sort/unique kernelrelease.txt 52 | for F in cocci_cache/*/kernelrelease.txt; do 53 | printf "%s\n" $(cat $F) | sort -u > $F.new 54 | mv $F.new $F 55 | done 56 | 57 | shopt -s nullglob 58 | REMOVED_A=(cocci_cache.previous/*) 59 | N_REMOVED=${#REMOVED_A[@]} 60 | rm -rf cocci_cache.previous 61 | 62 | printf "%3d config.h processed, %d unique found, (%d preserved, %d removed) \n" \ 63 | $N_CONFIGS $N_UNIQUE $N_PRESERVED $N_REMOVED 64 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/check_patch_names.cocci: -------------------------------------------------------------------------------- 1 | virtual report 2 | 3 | @find_compat@ 4 | expression compat; 5 | expression suffix; 6 | position p; 7 | @@ 8 | * patch(..., compat@p, suffix); 9 | 10 | @script:python depends on report@ 11 | c << find_compat.compat; 12 | p << find_compat.p; 13 | @@ 14 | import sys 15 | from os import listdir 16 | 17 | def exists(c): 18 | for f in listdir('drbd/drbd-kernel-compat/tests/'): 19 | if c == 'COMPAT_' + f.upper()[:-len('.c')]: 20 | return True 21 | return False 22 | 23 | if c in ['YES', 'NO']: 24 | sys.exit(0) 25 | 26 | if not c.startswith('COMPAT_'): 27 | msg = 'ERROR: compat define {} does not start with COMPAT_'.format(c) 28 | coccilib.report.print_report(p[0], msg) 29 | sys.exit(1) 30 | 31 | if not exists(c): 32 | msg = 'ERROR: compat define {} does not correspond to a compat test'.format(c) 33 | coccilib.report.print_report(p[0], msg) 34 | sys.exit(1) 35 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/__bio_add_page__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier __bio_add_page = __bio_add_page; 3 | @@ 4 | - __bio_add_page 5 | + bio_add_page 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/__vmalloc__no_has_2_params.cocci: -------------------------------------------------------------------------------- 1 | @@ expression S, G; @@ 2 | - __vmalloc(S, G) 3 | + __vmalloc(S, G, PAGE_KERNEL) 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/add_disk__no_returns_int.cocci: -------------------------------------------------------------------------------- 1 | @ remove_add_disk_return @ 2 | identifier e; 3 | identifier d; 4 | identifier label; 5 | @@ 6 | enum drbd_ret_code e = ...; 7 | ... 8 | - e = 9 | add_disk(d); 10 | - if (e) 11 | - goto label; 12 | 13 | @@ 14 | identifier remove_add_disk_return.label; 15 | identifier label_after; 16 | @@ 17 | -label: 18 | -... 19 | label_after: 20 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/allow_kernel_signal__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression sig; 3 | @@ 4 | -allow_kernel_signal(sig) 5 | +allow_signal(sig) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdev_discard_granularity__no_present.cocci: -------------------------------------------------------------------------------- 1 | // compat: 2 | // old kernel has 0 granularity means "unknown" means one sector. 3 | // current kernel has 0 granularity means "discard not supported". 4 | // Not supported is checked above already with !bdev_max_discard_sectors(bdev). 5 | @@ 6 | expression ebdev; 7 | @@ 8 | - bdev_discard_granularity(ebdev) 9 | + (ebdev->bd_disk->queue->limits.discard_granularity ?: 512) 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdev_file_open_by_path__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | struct drbd_backing_dev { 4 | ... 5 | - struct file *backing_bdev_file; 6 | + struct bdev_handle *backing_bdev_handle; 7 | ... 8 | - struct file *f_md_bdev; 9 | + struct bdev_handle *md_bdev_handle; 10 | ... 11 | } 12 | 13 | @@ 14 | identifier bdev_file; 15 | @@ 16 | static void close_backing_dev(..., 17 | - struct file *bdev_file 18 | + struct bdev_handle *handle 19 | , ... 20 | ) 21 | { 22 | <... 23 | ( 24 | - file_bdev(bdev_file) 25 | + handle->bdev 26 | | 27 | - fput(bdev_file) 28 | + bdev_release(handle) 29 | | 30 | - !bdev_file 31 | + !handle 32 | ) 33 | ...> 34 | } 35 | 36 | @@ 37 | identifier ldev; 38 | struct file *file; 39 | identifier device; 40 | @@ 41 | // generic close_backing_dev usage 42 | close_backing_dev(device, 43 | ( 44 | - ldev->backing_bdev_file 45 | + ldev->backing_bdev_handle 46 | | 47 | - ldev->f_md_bdev 48 | + ldev->md_bdev_handle 49 | | 50 | - file 51 | + handle 52 | ) 53 | , ...); 54 | 55 | @@ 56 | identifier file; 57 | @@ 58 | - struct file * 59 | + struct bdev_handle * 60 | open_backing_dev(...) 61 | { 62 | ... 63 | - struct file *file = bdev_file_open_by_path( 64 | + struct bdev_handle *handle = bdev_open_by_path( 65 | ...); 66 | <... 67 | ( 68 | IS_ERR 69 | | 70 | PTR_ERR 71 | ) 72 | ( 73 | - file 74 | + handle 75 | ) 76 | ...> 77 | return 78 | - file 79 | + handle 80 | ; 81 | } 82 | 83 | @@ 84 | identifier file; 85 | identifier err; 86 | @@ 87 | static int link_backing_dev(..., 88 | - struct file *file 89 | + struct bdev_handle *handle 90 | ) 91 | { 92 | ... 93 | int err = bd_link_disk_holder( 94 | - file_bdev(file) 95 | + handle->bdev 96 | , ...); 97 | if (err) { 98 | - fput(file); 99 | + bdev_release(handle); 100 | ... 101 | } 102 | ... 103 | } 104 | 105 | @@ 106 | identifier device; 107 | expression bd; 108 | identifier file; 109 | @@ 110 | // generic link_backing_dev usage 111 | link_backing_dev(device, bd, 112 | - file 113 | + handle 114 | ) 115 | 116 | @@ 117 | identifier file; 118 | @@ 119 | // generic open_backing_dev usage 120 | { 121 | ... 122 | - struct file *file; 123 | + struct bdev_handle *handle; 124 | <+... 125 | ( 126 | - file 127 | + handle 128 | = open_backing_dev(...); 129 | | 130 | IS_ERR( 131 | - file 132 | + handle 133 | ) 134 | ) 135 | ...+> 136 | } 137 | 138 | @@ 139 | struct drbd_backing_dev *nbc; 140 | identifier file; 141 | @@ 142 | ( 143 | - nbc->backing_bdev = file_bdev(file); 144 | - nbc->backing_bdev_file = file; 145 | + nbc->backing_bdev = handle->bdev; 146 | + nbc->backing_bdev_handle = handle; 147 | | 148 | - nbc->md_bdev = file_bdev(file); 149 | - nbc->f_md_bdev = file; 150 | + nbc->md_bdev = handle->bdev; 151 | + nbc->md_bdev_handle = handle; 152 | ) 153 | 154 | @@ 155 | identifier file; 156 | identifier nbc; 157 | @@ 158 | // only this one comparison exists in the code, just special-case it instead of implementing the generic case 159 | - file_bdev(file) != nbc->backing_bdev 160 | + handle->bdev != nbc->backing_bdev 161 | 162 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdev_max_discard_sectors__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression bd; 3 | @@ 4 | - bdev_max_discard_sectors(bd) 5 | + bdev_get_queue(bd)->limits.max_discard_sectors 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdev_nr_sectors__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct block_device *bd; 3 | @@ 4 | - bdev_nr_sectors(bd) 5 | + i_size_read(bd->bd_inode) >> 9 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdevname__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @initialize:python@ 2 | @@ 3 | 4 | @@ 5 | identifier dev, fn; 6 | constant old_format; 7 | fresh identifier new_format = script:python(old_format) { old_format.replace("%pg", "%s") }; 8 | @@ 9 | { 10 | + char b[BDEVNAME_SIZE]; 11 | ... 12 | fn(..., 13 | - old_format 14 | + new_format 15 | , ..., 16 | - dev->ldev->backing_bdev 17 | + bdevname(dev->ldev->backing_bdev, b) 18 | ); 19 | ... 20 | } 21 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdgrab__yes_present.cocci: -------------------------------------------------------------------------------- 1 | // If bdgrab is still around on this kernel, that implies that it still uses 2 | // the "old" way of refcounting for partitions -- see 9d3b8813895d 3 | // ("block: change the refcounting for partitions"). 4 | // As a consequence, we need to explicitly grab the partition before fsyncing it. 5 | @@ 6 | expression part; 7 | @@ 8 | - sync_blockdev(part); 9 | + struct block_device *bdev = bdgrab(part); 10 | + if (bdev) 11 | + sync_blockdev(bdev); 12 | + bdput(bdev); 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bdi_congested__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @ add_bdi_read_congested_congested_remote @ 2 | symbol false; 3 | @@ 4 | switch (...) 5 | { 6 | case ...: 7 | case RB_CONGESTED_REMOTE: 8 | - return false; 9 | + return bdi_read_congested(device->ldev->backing_bdev->bd_disk->bdi); 10 | ... 11 | } 12 | 13 | @ add_bdi_read_congested_device_to_statistics @ 14 | struct device_statistics *s; 15 | @@ 16 | - s->dev_lower_blocked = false; 17 | + s->dev_lower_blocked = bdi_congested(device->ldev->backing_bdev->bd_disk->bdi, 18 | + (1 << WB_async_congested) | 19 | + (1 << WB_sync_congested)); 20 | 21 | @ script:python depends on !(add_bdi_read_congested_congested_remote && add_bdi_read_congested_device_to_statistics) @ 22 | @@ 23 | import sys 24 | print('ERROR: A rule making an essential change was not executed! (bdi_read_congested)', file=sys.stderr) 25 | print('ERROR: This would not show up as a compiler error, but would still break DRBD.', file=sys.stderr) 26 | print('ERROR: Check bdi_congested__yes_present.cocci', file=sys.stderr) 27 | print('ERROR: As a precaution, the build will be aborted here.', file=sys.stderr) 28 | sys.exit(1) 29 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_advance_iter_single__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression bio; 3 | expression iter; 4 | expression bytes; 5 | @@ 6 | - bio_advance_iter_single(bio, iter, bytes) 7 | + bio_advance_iter(bio, iter, bytes) 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_alloc__no_has_4_params.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | local idexpression struct bio *b; 3 | expression ebdev, _opf, gfp_mask, nr_vecs, bioset; 4 | @@ 5 | b = 6 | ( 7 | bio_alloc( 8 | - ebdev, nr_vecs, _opf, gfp_mask 9 | + gfp_mask, nr_vecs 10 | ) 11 | | 12 | bio_alloc_bioset( 13 | - ebdev, nr_vecs, _opf, gfp_mask, bioset 14 | + gfp_mask, nr_vecs, bioset 15 | ) 16 | ); 17 | + bio_set_dev(b, ebdev); 18 | ... 19 | b->bi_end_io = ...; 20 | + b->bi_opf = _opf; 21 | 22 | // special case for the bio_alloc in submit_one_flush 23 | // 1) because it is "struct bio *b = ...", not just "b = ...", and 24 | // 2) because it has the "bio_set_dev" and "b->bi_opf" assignments in different 25 | // places 26 | @@ 27 | identifier b; 28 | expression ebdev, _opf, gfp_mask, nr_vecs; 29 | @@ 30 | struct bio *b = bio_alloc( 31 | - ebdev, nr_vecs, _opf, gfp_mask 32 | + gfp_mask, nr_vecs 33 | ); 34 | ... 35 | + bio_set_dev(b, ebdev); 36 | b->bi_private = ...; 37 | ... 38 | + b->bi_opf = _opf; 39 | submit_bio(b); 40 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_alloc_clone__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression ebdev, bi, gfp, set; 3 | @@ 4 | - bio_alloc_clone(ebdev, bi, gfp, set) 5 | + bio_clone_fast(bi, gfp, set) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_bi_bdev__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct bio *b; 3 | @@ 4 | // The only case where we really use bio->bi_bdev is when accessing its bd_disk. 5 | // We can trivially change that to use the old bi_disk instead. 6 | b-> 7 | - bi_bdev->bd_disk 8 | + bi_disk 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_max_segs__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | unsigned int nr_segs; 3 | @@ 4 | - bio_max_segs(nr_segs) 5 | + min(nr_segs, (unsigned int) BIO_MAX_VECS) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_max_vecs__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - BIO_MAX_VECS 4 | + BIO_MAX_PAGES 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_split_to_limits__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct bio *b; 3 | @@ 4 | - b = bio_split_to_limits(b); 5 | - if (!b) 6 | - return; 7 | + blk_queue_split(&b); 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bio_start_io_acct__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier r; 3 | @@ 4 | - r->start_jif = bio_start_io_acct(r->master_bio); 5 | + r->start_jif = start_jif; 6 | + generic_start_io_acct(r->device->rq_queue, bio_data_dir(r->master_bio), 7 | + r->i.size >> 9, &r->device->vdisk->part0); 8 | 9 | @@ 10 | identifier r; 11 | @@ 12 | - bio_end_io_acct(r->master_bio, r->start_jif); 13 | + generic_end_io_acct(r->device->rq_queue, bio_data_dir(r->master_bio), 14 | + &r->device->vdisk->part0, r->start_jif); 15 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bioset_init__no_present.cocci: -------------------------------------------------------------------------------- 1 | @find_mempool_t@ 2 | typedef mempool_t; 3 | identifier mp; 4 | @@ 5 | - mempool_t 6 | + mempool_t * 7 | mp; 8 | 9 | @find_struct_bio_set@ 10 | identifier bs; 11 | @@ 12 | - struct bio_set 13 | + struct bio_set * 14 | bs; 15 | 16 | @@ 17 | identifier find_struct_bio_set.bs; 18 | expression GFP, n; 19 | @@ 20 | ( 21 | bio_alloc_bioset(GFP, n, 22 | - &bs 23 | + bs 24 | ) 25 | | 26 | - bioset_initialized(&bs) 27 | + (bs != NULL) 28 | ) 29 | 30 | @@ 31 | identifier find_struct_bio_set.bs; 32 | @@ 33 | - bioset_exit(&bs); 34 | + if (bs) { bioset_free(bs); bs = NULL; } 35 | 36 | @@ 37 | identifier find_mempool_t.mp; 38 | expression min_nr, order, mem_cache, V, F; 39 | @@ 40 | ( 41 | - mempool_exit(&mp); 42 | + if (mp) { mempool_destroy(mp); mp = NULL; } 43 | | 44 | - mempool_init_page_pool(&mp, min_nr, order) 45 | + ((mp = mempool_create_page_pool(min_nr, order)) == NULL ? -ENOMEM : 0) 46 | | 47 | - mempool_init_slab_pool(&mp, min_nr, mem_cache) 48 | + ((mp = mempool_create_slab_pool(min_nr, mem_cache)) == NULL ? -ENOMEM : 0) 49 | | 50 | mempool_free(V, 51 | - &mp 52 | + mp 53 | ) 54 | | 55 | mempool_alloc( 56 | - &mp 57 | + mp 58 | , F) 59 | | 60 | mempool_is_saturated( 61 | - &mp 62 | + mp 63 | ) 64 | ) 65 | 66 | @@ 67 | identifier find_struct_bio_set.bs; 68 | expression bio, gfp; 69 | @@ 70 | bio_clone_fast(bio, gfp, 71 | - &bs 72 | + bs 73 | ) 74 | 75 | @@ 76 | identifier find_struct_bio_set.bs; 77 | expression re, size, front_pad, flags; 78 | statement S; 79 | @@ 80 | - re = bioset_init(&bs, size, front_pad, flags); 81 | + bs = bioset_create(size, front_pad, flags); 82 | ... 83 | - if (re) 84 | + if (bs == NULL) 85 | S 86 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_alloc_disk__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression node; 3 | fresh identifier q = "" ## "q"; 4 | identifier f, disk, device; 5 | symbol out_no_io_page, out_no_disk; 6 | @@ 7 | f(...) { 8 | ... 9 | struct drbd_device *device; 10 | + struct request_queue *q; 11 | ... 12 | - disk = blk_alloc_disk(node); 13 | + q = blk_alloc_queue(node); 14 | + if (!q) { 15 | + goto out_no_q; 16 | + } 17 | + device->rq_queue = q; 18 | + disk = alloc_disk(1); 19 | ... 20 | device->vdisk = disk; 21 | - device->rq_queue = disk->queue; 22 | ... 23 | - disk->minors = 1; 24 | + disk->queue = q; 25 | ... when exists 26 | out_no_io_page: 27 | ( 28 | - blk_cleanup_disk(disk); 29 | + put_disk(disk); 30 | | 31 | ... 32 | ) 33 | out_no_disk: 34 | + blk_cleanup_queue(q); 35 | + out_no_q: 36 | ... 37 | } 38 | 39 | @@ 40 | identifier f, device; 41 | @@ 42 | f(...) { 43 | ... 44 | struct drbd_device *device; 45 | ... 46 | - blk_cleanup_disk(device->vdisk); 47 | + put_disk(device->vdisk); 48 | + blk_cleanup_queue(device->rq_queue); 49 | ... 50 | } 51 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_alloc_disk__no_takes_queue_limits.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier d; 3 | expression ql; 4 | expression node; 5 | identifier err; 6 | @@ 7 | d = blk_alloc_disk( 8 | - ql, 9 | node); 10 | if ( 11 | - IS_ERR(d) 12 | + !d 13 | ) { 14 | - err = PTR_ERR(d); 15 | ... 16 | } 17 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_alloc_queue_rh__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @ blk_alloc_queue @ 2 | identifier make_request_fn; 3 | @@ 4 | - blk_alloc_queue(make_request_fn, NUMA_NO_NODE) 5 | + blk_alloc_queue_rh(make_request_fn, NUMA_NO_NODE) 6 | 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_cleanup_disk__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression d; 3 | @@ 4 | - put_disk 5 | + blk_cleanup_disk 6 | (d) 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_mode_t__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier fn; 3 | identifier mode; 4 | @@ 5 | fn ( 6 | ..., 7 | - blk_mode_t mode 8 | + fmode_t mode 9 | ) { 10 | <... 11 | ( 12 | - BLK_OPEN_WRITE 13 | + FMODE_WRITE 14 | | 15 | - BLK_OPEN_NDELAY 16 | + FMODE_NDELAY 17 | ) 18 | ...> 19 | } 20 | 21 | @@ 22 | @@ 23 | // special case: bdev_open_by_path takes a blk_mode_t, so convert that too. I can't seem to get 24 | // coccinelle to match the "READ | WRITE" condition generically, so just hard code it. 25 | bdev_file_open_by_path 26 | (..., 27 | - BLK_OPEN_READ | BLK_OPEN_WRITE 28 | + FMODE_READ | FMODE_WRITE 29 | , ...) 30 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_opf_t__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | typedef blk_opf_t; 3 | @@ 4 | - blk_opf_t 5 | + unsigned int 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_queue_flag_set__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression F, qu; 3 | fresh identifier flags = "____flags"; 4 | @@ 5 | - blk_queue_flag_set(F, qu); 6 | + { 7 | + unsigned long flags; 8 | + spin_lock_irqsave(qu->queue_lock, flags); 9 | + queue_flag_set(F, qu); 10 | + spin_unlock_irqrestore(qu->queue_lock, flags); 11 | + } 12 | 13 | @@ 14 | expression F, qu; 15 | fresh identifier flags = "____flags"; 16 | @@ 17 | - blk_queue_flag_clear(F, qu); 18 | + { 19 | + unsigned long flags; 20 | + spin_lock_irqsave(qu->queue_lock, flags); 21 | + queue_flag_clear(F, qu); 22 | + spin_unlock_irqrestore(qu->queue_lock, flags); 23 | + } 24 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_queue_make_request__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @ rm_blk_alloc_queue @ 2 | identifier make_request_fn; 3 | @@ 4 | - blk_alloc_queue(make_request_fn, NUMA_NO_NODE) 5 | + blk_alloc_queue(GFP_KERNEL) 6 | 7 | @@ 8 | struct gendisk *disk; 9 | identifier rm_blk_alloc_queue.make_request_fn; 10 | @@ 11 | drbd_create_device(...) 12 | { 13 | ... 14 | disk->private_data = ...; 15 | + blk_queue_make_request(q, make_request_fn); 16 | ... 17 | } 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_queue_max_write_same_sectors__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @ add_blk_queue_max_write_same_sectors @ 2 | identifier q; 3 | @@ 4 | blk_queue_max_hw_sectors(q, ...); 5 | + blk_queue_max_write_same_sectors(q, 0); 6 | 7 | @ script:python depends on !add_blk_queue_max_write_same_sectors @ 8 | @@ 9 | import sys 10 | print('ERROR: A rule making an essential change was not executed! (blk_queue_max_write_same_sectors)', file=sys.stderr) 11 | print('ERROR: This would not show up as a compiler error, but would still break DRBD.', file=sys.stderr) 12 | print('ERROR: Check blk_queue_max_write_same_sectors_yes_present.cocci', file=sys.stderr) 13 | print('ERROR: As a precaution, the build will be aborted here.', file=sys.stderr) 14 | sys.exit(1) 15 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_queue_split__yes_has_two_parameters.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression b; 3 | @@ 4 | - blk_queue_split(&b) 5 | + blk_queue_split(b->bi_bdev->bd_disk->queue, &b) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_queue_update_readahead__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier q, b; 3 | @@ 4 | struct request_queue *q; 5 | ... 6 | struct request_queue *b; 7 | <... 8 | - blk_queue_update_readahead(q); 9 | + if (q->backing_dev_info->ra_pages != 10 | + b->backing_dev_info->ra_pages) { 11 | + drbd_info(device, "Adjusting my ra_pages to backing device's (%lu -> %lu)\n", 12 | + q->backing_dev_info->ra_pages, 13 | + b->backing_dev_info->ra_pages); 14 | + q->backing_dev_info->ra_pages = 15 | + b->backing_dev_info->ra_pages; 16 | + } 17 | ...> -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blk_queue_write_cache__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression q; 3 | identifier enabled, fua; 4 | symbol true, false; 5 | @@ 6 | // enumerate all possible combinations of the "enabled" and "fua" parameters, 7 | // so that the resulting code looks neater, 8 | // but fall back to a generic version just in case. 9 | ( 10 | - blk_queue_write_cache(q, false, false) 11 | + blk_queue_flush(q, 0) 12 | | 13 | - blk_queue_write_cache(q, false, true) 14 | + blk_queue_flush(q, REQ_FUA) 15 | | 16 | - blk_queue_write_cache(q, true, false) 17 | + blk_queue_flush(q, REQ_FLUSH) 18 | | 19 | - blk_queue_write_cache(q, true, true) 20 | + blk_queue_flush(q, REQ_FLUSH | REQ_FUA) 21 | | 22 | - blk_queue_write_cache(q, enabled, fua) 23 | + blk_queue_flush(q, (enabled ? REQ_FLUSH : 0) | (fua ? REQ_FUA : 0)) 24 | ); 25 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blkdev_get_by_path__no_has_holder_ops.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression path, mode, holder, ops; 3 | @@ 4 | blkdev_get_by_path(path, mode, holder 5 | - , ops 6 | ) 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blkdev_issue_discard__yes_takes_flags.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | blkdev_issue_discard(... 4 | + , 0 5 | ) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/blkdev_put__no_has_holder.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression path, mode; 3 | @@ 4 | blkdev_get_by_path( 5 | path, 6 | - mode, 7 | + mode | FMODE_EXCL, 8 | ... 9 | ) 10 | 11 | @@ 12 | expression ebdev, holder; 13 | @@ 14 | blkdev_put( 15 | ebdev, 16 | - holder 17 | + FMODE_READ | FMODE_WRITE | FMODE_EXCL 18 | ) 19 | 20 | @@ 21 | identifier device, bdev, holder, do_bd_unlink; 22 | @@ 23 | void close_backing_dev( 24 | struct drbd_device *device, 25 | struct block_device *bdev, 26 | - void *holder, 27 | bool do_bd_unlink 28 | ) { ... } 29 | 30 | @@ 31 | expression device, ebdev, holder, do_bd_unlink; 32 | @@ 33 | close_backing_dev( 34 | device, 35 | ebdev, 36 | - holder, 37 | do_bd_unlink 38 | ); 39 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/block_device_operations_open__no_takes_gendisk.cocci: -------------------------------------------------------------------------------- 1 | @ drbd_open_arg @ 2 | identifier gd; 3 | fresh identifier bdev = "" ## "bdev"; 4 | @@ 5 | drbd_open( 6 | - struct gendisk *gd, 7 | + struct block_device *bdev, 8 | ... ) { 9 | <... 10 | ( 11 | - gd->part0 12 | + bdev 13 | | 14 | - gd 15 | + bdev->bd_disk 16 | ) 17 | ...> 18 | } 19 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/block_device_operations_release__no_takes_single_argument.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier gd; 3 | fresh identifier mode = "" ## "mode"; 4 | @@ 5 | drbd_release( 6 | struct gendisk *gd 7 | + , fmode_t mode 8 | ) { ... } 9 | 10 | @@ 11 | symbol drbd_release; 12 | expression gd; 13 | @@ 14 | drbd_release( 15 | gd 16 | + , 0 17 | ) 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/bvec_kmap_local__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier ptr, bvec; 3 | @@ 4 | recv_dless_read(...) 5 | { 6 | <... 7 | ptr = 8 | - bvec_kmap_local(&bvec) 9 | + kmap(bvec.bv_page) + bvec.bv_offset 10 | ... 11 | - kunmap_local(ptr); 12 | + kunmap(bvec.bv_page); 13 | ...> 14 | } 15 | 16 | // As of this writing (Linux 5.19), I am actually pretty sure that this special 17 | // case is not required on "modern" kernel, i.e. the kmap_atomic is not 18 | // necessary here. It was introduced with 3d0e63754fa4 ("drbd: Convert from 19 | // ahash to shash"), but we don't seem to be in a context where the _atomic is 20 | // required. More likely, this was just copied from the scatter-gather code that 21 | // was there before, to make the aforementioned commit not change any behavior. 22 | // 23 | // However, I cannot guarantee that this is always the case on all the kernels 24 | // we support. So just introduce a special case instead of having to debug an 25 | // obscure bug on an ancient kernel later. 26 | @@ 27 | identifier ptr, bvec; 28 | @@ 29 | drbd_csum_bio(...) 30 | { 31 | <... 32 | ptr = 33 | - bvec_kmap_local(&bvec) 34 | + kmap_atomic(bvec.bv_page) + bvec.bv_offset 35 | ... 36 | - kunmap_local(ptr); 37 | + kunmap_atomic(ptr); 38 | ...> 39 | } 40 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/congested_fn__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | iterator name for_each_peer_device_rcu; 3 | @@ 4 | drbd_cleanup(...) 5 | { ... } 6 | 7 | + /** 8 | + * drbd_congested() - Callback for the flusher thread 9 | + * @congested_data: User data 10 | + * @bdi_bits: Bits the BDI flusher thread is currently interested in 11 | + * 12 | + * Returns 1<resource->flags)) { 27 | + r |= (1 << WB_async_congested); 28 | + /* Without good local data, we would need to read from remote, 29 | + * and that would need the worker thread as well, which is 30 | + * currently blocked waiting for that usermode helper to 31 | + * finish. 32 | + */ 33 | + if (!get_ldev_if_state(device, D_UP_TO_DATE)) 34 | + r |= (1 << WB_sync_congested); 35 | + else 36 | + put_ldev(device); 37 | + r &= bdi_bits; 38 | + goto out; 39 | + } 40 | + 41 | + if (get_ldev(device)) { 42 | + q = bdev_get_queue(device->ldev->backing_bdev); 43 | + r = bdi_congested(q->backing_dev_info, bdi_bits); 44 | + put_ldev(device); 45 | + } 46 | + 47 | + if (bdi_bits & (1 << WB_async_congested)) { 48 | + struct drbd_peer_device *peer_device; 49 | + 50 | + rcu_read_lock(); 51 | + for_each_peer_device_rcu(peer_device, device) { 52 | + if (test_bit(NET_CONGESTED, &peer_device->connection->transport.flags)) { 53 | + r |= (1 << WB_async_congested); 54 | + break; 55 | + } 56 | + } 57 | + rcu_read_unlock(); 58 | + } 59 | + 60 | + out: 61 | + return r; 62 | + } 63 | 64 | @@ 65 | identifier dev; 66 | struct gendisk *disk; 67 | @@ 68 | drbd_create_device(...) 69 | { 70 | ... 71 | struct drbd_device *dev; 72 | ... 73 | disk->private_data = ...; 74 | + q->backing_dev_info->congested_fn = drbd_congested; 75 | + q->backing_dev_info->congested_data = dev; 76 | ... 77 | } 78 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/counted_by__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | type T; 3 | identifier s, x; 4 | attribute name __counted_by; 5 | @@ 6 | struct s { 7 | ... 8 | T x 9 | - __counted_by(...) 10 | ; 11 | ... 12 | }; 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/dax_direct_access__no_takes_mode.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | dax_direct_access(..., 4 | - DAX_ACCESS, 5 | ...) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/debugfs_change_name__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier err, resource, new_name; 3 | @@ 4 | void drbd_debugfs_resource_rename(struct drbd_resource *resource, const char *new_name) 5 | { 6 | - int err; 7 | + struct dentry *new_d; 8 | 9 | - err = debugfs_change_name(resource->debugfs_res, "%s", new_name); 10 | - if (err) 11 | + new_d = debugfs_rename(drbd_debugfs_resources, resource->debugfs_res, 12 | + drbd_debugfs_resources, new_name); 13 | + if (IS_ERR(new_d)) { 14 | drbd_err(resource, ... ); 15 | + } else { 16 | + resource->debugfs_res = new_d; 17 | + } 18 | } 19 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/debugfs_compat_template.cocci.in: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier m, ignored; 3 | @@ 4 | static int drbd_compat_show(struct seq_file *m, void *ignored) 5 | { 6 | ... 7 | + seq_puts(m, "@COMPAT_PATCH_NAME@\n"); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/disk_update_readahead__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier q; 3 | identifier dev; 4 | type T; 5 | @@ 6 | T q = dev->rq_queue; 7 | <... 8 | - disk_update_readahead(dev->vdisk); 9 | + blk_queue_update_readahead(q); 10 | ...> 11 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/drbd_wrappers__yes_need.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | + #include "drbd_wrappers.h" 4 | #include ... 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/enum_req_op__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - enum req_op 4 | + unsigned int 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/fallthrough__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | symbol fallthrough; 3 | @@ 4 | - fallthrough; 5 | + ;/* fallthrough */ 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/fs_dax_get_by_bdev__no_takes_start_off.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression b; 3 | identifier off; 4 | @@ 5 | - u64 off; 6 | ... 7 | fs_dax_get_by_bdev(b 8 | - , &off 9 | ) 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/fs_dax_get_by_bdev__no_takes_start_off_and_holder.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression b, off, holder, ops; 3 | @@ 4 | ... 5 | fs_dax_get_by_bdev(b, off, 6 | - holder, 7 | - ops 8 | ) 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/gendisk_part0__no_is_block_device.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression vdisk; 3 | @@ 4 | - bdgrab(vdisk->part0) 5 | + bdget_disk(vdisk, 0) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/genhd_fl_no_part__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - GENHD_FL_NO_PART 4 | + GENHD_FL_NO_PART_SCAN 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/genl_info_userhdr__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression info; 3 | @@ 4 | - genl_info_userhdr(info) 5 | + info->userhdr 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/get_random_u32__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - get_random_u32() 4 | + prandom_u32() 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/get_random_u32_below__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression i; 3 | @@ 4 | - get_random_u32_below(i) 5 | + (prandom_u32() % i) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/ib_device__no_has_ops.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct ib_device dev; 3 | expression D, A, U; 4 | @@ 5 | - dev.ops.query_device(D, A, U) 6 | + dev.query_device(D, A, U) 7 | 8 | @@ 9 | struct ib_device *dev; 10 | expression D, A, U; 11 | @@ 12 | - dev->ops.query_device(D, A, U) 13 | + dev->query_device(D, A, U) 14 | 15 | 16 | @@ 17 | struct ib_device dev; 18 | expression D, P, F, G; 19 | @@ 20 | - dev.ops.query_gid(D, P, F, G) 21 | + dev.query_gid(D, P, F, G) 22 | 23 | @@ 24 | struct ib_device *dev; 25 | expression D, P, F, G; 26 | @@ 27 | - dev->ops.query_gid(D, P, F, G) 28 | + dev->query_gid(D, P, F, G) 29 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/ib_post__no_const.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression Q, S; 3 | identifier fn, swr; 4 | @@ 5 | fn(...) 6 | { 7 | ... 8 | - const struct ib_send_wr *swr; 9 | + struct ib_send_wr *swr; 10 | ... 11 | ib_post_send(Q, S, &swr) 12 | ... 13 | } 14 | 15 | 16 | @@ 17 | expression Q, S; 18 | identifier fn, rwr; 19 | @@ 20 | fn(...) 21 | { 22 | ... 23 | - const struct ib_recv_wr *rwr; 24 | + struct ib_recv_wr *rwr; 25 | ... 26 | ib_post_recv(Q, S, &rwr) 27 | ... 28 | } 29 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/kernel_read__yes_before_4_13.cocci: -------------------------------------------------------------------------------- 1 | @@ expression F, B, C, P; @@ 2 | - kernel_read(F, B, C, P) 3 | + kernel_read(F, *(P), B, C) 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/kmap_local_page__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression page; 3 | @@ 4 | - kmap_local_page(page) 5 | + kmap(page) 6 | 7 | @@ 8 | identifier address; 9 | @@ 10 | - kunmap_local(address) 11 | + kunmap(address) 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/kvfree_rcu__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression ptr; 3 | @@ 4 | - kvfree_rcu(ptr); 5 | + synchronize_rcu(); 6 | + kfree(ptr); 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/kvfree_rcu_mightsleep__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier kvfree_rcu_mightsleep = kvfree_rcu_mightsleep; 3 | @@ 4 | - kvfree_rcu_mightsleep 5 | + kvfree_rcu 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/linux_unaligned_h__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ @@ 2 | - #include 3 | + #include 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/list_is_first__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression l, h; 3 | @@ 4 | -list_is_first(l, h) 5 | +((l)->prev == (h)) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/lookup_user_key__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression id, flags, perms; 3 | @@ 4 | - lookup_user_key(id, flags, perms) 5 | + ERR_PTR(-ENOKEY) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/mempool_is_saturated__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | typedef mempool_t; 3 | typedef bool; 4 | @@ 5 | enum rcv_timeou_kind { ... }; 6 | + #include 7 | + static inline bool mempool_is_saturated(mempool_t *pool) 8 | + { 9 | + return READ_ONCE(pool->curr_nr) >= pool->min_nr; 10 | + } 11 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/need_recalc_sigpending__yes_need.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct drbd_device *device; 3 | @@ 4 | int drbd_open(...) 5 | { 6 | ... 7 | + /* 8 | + * Older kernels sometimes fail to clear TIF_SIGPENDING when returning 9 | + * from drbd_open() with -ERESTARTSYS. The kernel calls into drbd_open() 10 | + * with TIF_SIGPENDING still set. recalc_sigpending() clears 11 | + * TIF_SIGPENDING if it is no longer accurate. 12 | + */ 13 | + if (signal_pending(current)) { 14 | + spin_lock_irq(¤t->sighand->siglock); 15 | + recalc_sigpending(); 16 | + spin_unlock_irq(¤t->sighand->siglock); 17 | + } 18 | + 19 | kref_get(&device->kref); 20 | ... 21 | } 22 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/nla_nest_start_noflag__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ expression E1, E2; @@ 2 | -nla_nest_start_noflag(E1, E2) 3 | +nla_nest_start(E1, E2) 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/nla_parse_deprecated__no_present.cocci: -------------------------------------------------------------------------------- 1 | // Note: this is basically the spatch from the original upstream commit, 2 | // but reversed. 3 | 4 | @@ 5 | expression TB, MAX, HEAD, LEN, POL, EXT; 6 | @@ 7 | -nla_parse_deprecated(TB, MAX, HEAD, LEN, POL, EXT) 8 | +nla_parse(TB, MAX, HEAD, LEN, POL, EXT) 9 | 10 | @@ 11 | expression NLH, HDRLEN, TB, MAX, POL, EXT; 12 | @@ 13 | -nlmsg_parse_deprecated(NLH, HDRLEN, TB, MAX, POL, EXT) 14 | +nlmsg_parse(NLH, HDRLEN, TB, MAX, POL, EXT) 15 | 16 | @@ 17 | expression NLH, HDRLEN, TB, MAX, POL, EXT; 18 | @@ 19 | -nlmsg_parse_deprecated_strict(NLH, HDRLEN, TB, MAX, POL, EXT) 20 | +nlmsg_parse_strict(NLH, HDRLEN, TB, MAX, POL, EXT) 21 | 22 | @@ 23 | expression TB, MAX, NLA, POL, EXT; 24 | @@ 25 | -nla_parse_nested_deprecated(TB, MAX, NLA, POL, EXT) 26 | +nla_parse_nested(TB, MAX, NLA, POL, EXT) 27 | 28 | @@ 29 | expression START, MAX, POL, EXT; 30 | @@ 31 | -nla_validate_nested_deprecated(START, MAX, POL, EXT) 32 | +nla_validate_nested(START, MAX, POL, EXT) 33 | 34 | @@ 35 | expression NLH, HDRLEN, MAX, POL, EXT; 36 | @@ 37 | -nlmsg_validate_deprecated(NLH, HDRLEN, MAX, POL, EXT) 38 | +nlmsg_validate(NLH, HDRLEN, MAX, POL, EXT) 39 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/part_stat_h__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - #include 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/part_stat_read__no_takes_block_device.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression part; 3 | @@ 4 | // part_stat_read{,_accum} changed from taking a "struct hd_struct *" to a 5 | // "struct block_device". Since this is a macro, and the "part" member on 6 | // struct gendisk was not renamed but only changed its type, we miraculously 7 | // only have to add a "&". 8 | part_stat_read_accum( 9 | - part 10 | + &part 11 | , ... 12 | ) 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/part_stat_read_accum__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression part; 3 | identifier sectors; 4 | @@ 5 | - (int)part_stat_read_accum(part, sectors) 6 | + (int)part_stat_read(part, sectors[0]) + (int)part_stat_read(part, sectors[1]) 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_flag_discard__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct queue_limits lim; 3 | identifier q; 4 | @@ 5 | struct request_queue *q = device->rq_queue; 6 | ... 7 | ( 8 | lim.max_hw_discard_sectors = 0; 9 | + blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q); 10 | | 11 | lim.max_hw_discard_sectors = ...; 12 | + blk_queue_flag_set(QUEUE_FLAG_DISCARD, q); 13 | ) 14 | 15 | @@ 16 | identifier q, device; 17 | @@ 18 | +static void fixup_discard_if_not_supported(struct request_queue *q) 19 | +{ 20 | + /* To avoid confusion, if this queue does not support discard, clear 21 | + * max_discard_sectors, which is what lsblk -D reports to the user. 22 | + * Older kernels got this wrong in "stack limits". 23 | + * */ 24 | + if (!blk_queue_discard(q)) { 25 | + blk_queue_max_discard_sectors(q, 0); 26 | + q->limits.discard_granularity = 0; 27 | + } 28 | +} 29 | 30 | void drbd_reconsider_queue_parameters(struct drbd_device *device, ...) 31 | { 32 | ... 33 | struct request_queue *q = device->rq_queue; 34 | ... 35 | + fixup_discard_if_not_supported(q); 36 | } 37 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_flag_stable_writes__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression q; 3 | @@ 4 | - blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q); 5 | + q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_limits__no_has_max_hw_discard_sectors.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct queue_limits lim; 3 | @@ 4 | - lim.max_hw_discard_sectors 5 | + lim.max_discard_sectors 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_limits_features__no_present.cocci: -------------------------------------------------------------------------------- 1 | // NOTE this actually encompasses three patches: 2 | // 1122c0c1 block: move cache control settings out of queue->flags 3 | // bd4a633b block: move the nonrot flag to queue_limits 4 | // 1a02f3a7 block: move the stable_writes flag to queue_limits 5 | // 6 | // They add "BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA", "BLK_FEAT_ROTATIONAL", and 7 | // "BLK_FEAT_STABLE_WRITES", respectively. 8 | // Since these commits are all from the same series, just patch them together. 9 | @@ 10 | expression e; 11 | struct gendisk *disk; 12 | identifier lim; 13 | @@ 14 | -struct queue_limits lim = { 15 | - .features = e, 16 | -}; 17 | ... 18 | blk_alloc_disk( 19 | - &lim 20 | + NULL 21 | , ...) 22 | ... 23 | disk->private_data = ...; 24 | + blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue); 25 | + blk_queue_write_cache(disk->queue, true, true); 26 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_limits_max_hw_zone_append_sectors__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct queue_limits *lim; 3 | @@ 4 | - lim->max_hw_zone_append_sectors 5 | + lim->max_zone_append_sectors 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_limits_max_zone_append_sectors__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct queue_limits *lim; 3 | @@ 4 | - lim->max_zone_append_sectors = ...; 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/queue_limits_start_update__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier lim; 3 | identifier q; 4 | identifier device; 5 | identifier bdev; 6 | @@ 7 | void drbd_reconsider_queue_parameters(struct drbd_device *device, struct drbd_backing_dev *bdev) 8 | { 9 | ... 10 | lim = 11 | - queue_limits_start_update(q); 12 | + q->limits; 13 | ... 14 | - if (queue_limits_commit_update(q, &lim)) { ... } 15 | + q->limits = lim; 16 | + blk_queue_max_hw_sectors(q, lim.max_hw_sectors); 17 | + blk_queue_max_discard_sectors(q, lim.max_hw_discard_sectors); 18 | + if (bdev) 19 | + disk_update_readahead(device->vdisk); 20 | ... 21 | } 22 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/rb_declare_callbacks_max__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | typedef sector_t; 3 | @@ 4 | -#define NODE_END(...) (...) 5 | +/** 6 | + * compute_subtree_last - compute end of @node 7 | + * 8 | + * The end of an interval is the highest (start + (size >> 9)) value of this 9 | + * node and of its children. Called for @node and its parents whenever the end 10 | + * may have changed. 11 | + */ 12 | +static inline sector_t 13 | +compute_subtree_last(struct drbd_interval *node) 14 | +{ 15 | + sector_t max = node->sector + (node->size >> 9); 16 | + 17 | + if (node->rb.rb_left) { 18 | + sector_t left = interval_end(node->rb.rb_left); 19 | + if (left > max) 20 | + max = left; 21 | + } 22 | + if (node->rb.rb_right) { 23 | + sector_t right = interval_end(node->rb.rb_right); 24 | + if (right > max) 25 | + max = right; 26 | + } 27 | + return max; 28 | +} 29 | 30 | @@ 31 | declarer name RB_DECLARE_CALLBACKS_MAX; 32 | declarer name RB_DECLARE_CALLBACKS; 33 | @@ 34 | -RB_DECLARE_CALLBACKS_MAX 35 | +RB_DECLARE_CALLBACKS 36 | (..., 37 | - NODE_END 38 | + compute_subtree_last 39 | ); 40 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/rdma_reject__no_4-arguments.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression cm_id, pd, pdl, reason; 3 | @@ 4 | -rdma_reject(cm_id, pd, pdl, reason) 5 | +rdma_reject(cm_id, pd, pdl) 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/revalidate_disk_size__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier x; 3 | @@ 4 | - revalidate_disk_size 5 | + revalidate_disk 6 | (..., 7 | - x 8 | ) 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sched_set_fifo__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression p; 3 | fresh identifier r = "____rv"; 4 | @@ 5 | // this is very specific to drbd's use of this function, 6 | // it is *not* a general purpose solution. 7 | - sched_set_fifo_low(p); 8 | + struct sched_param param = { .sched_priority = 2 }; 9 | + int r; 10 | + r = sched_setscheduler(p, SCHED_RR, ¶m); 11 | + if (r < 0) 12 | + drbd_err(connection, "drbd_ack_receiver: ERROR set priority, ret=%d\n", r); 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sendpage__yes_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression flags; 3 | @@ 4 | flags 5 | - | MSG_SPLICE_PAGES 6 | 7 | @@ 8 | identifier bvec, page, len, offset, msg, socket; 9 | identifier sent = sent; 10 | @@ 11 | - struct bio_vec bvec; 12 | ... 13 | int sent; 14 | - bvec_set_page(&bvec, page, len, offset); 15 | - iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, len); 16 | - sent = sock_sendmsg(socket, &msg); 17 | + sent = socket->ops->sendpage(socket, page, offset, len, msg.msg_flags); 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sendpage_ok__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct page *p; 3 | @@ 4 | ( 5 | - !sendpage_ok(p) 6 | + (PageSlab(page) || page_count(page) < 1) 7 | | 8 | - sendpage_ok(p) 9 | + (!PageSlab(page) && page_count(page) >= 1) 10 | ) 11 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/set_capacity_and_notify__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression disk, size; 3 | @@ 4 | - set_capacity_and_notify(disk, size); 5 | + set_capacity(disk, size); 6 | + revalidate_disk_size(disk, false); 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sge_max_send_and_recv__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct ib_device_attr dev_attr; 3 | @@ 4 | -min(dev_attr.max_send_sge, dev_attr.max_recv_sge) 5 | +dev_attr.max_sge 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sk_use_task_frag__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | expression s; 3 | @@ 4 | - s->sk_use_task_frag = ...; 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sock_ops__no_returns_addr_len.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct socket *sock; 3 | struct sockaddr *uaddr; 4 | int peer; 5 | identifier addr_len; 6 | @@ 7 | { 8 | ... 9 | int addr_len; 10 | ... 11 | - addr_len = sock->ops->getname(sock, uaddr, peer); 12 | + sock->ops->getname(sock, uaddr, &addr_len, peer); 13 | ... 14 | } 15 | 16 | 17 | @@ 18 | struct socket *sock; 19 | struct sockaddr *uaddr; 20 | int peer; 21 | @@ 22 | { 23 | +int ___addr_len; 24 | ... 25 | - sock->ops->getname(sock, uaddr, peer); 26 | + sock->ops->getname(sock, uaddr, &___addr_len, peer); 27 | ... 28 | } 29 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/sock_set_keepalive__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct socket *so; 3 | @@ 4 | - sock_set_keepalive(so->sk); 5 | +{ 6 | + int one = 1; 7 | + kernel_setsockopt(so, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, sizeof(one)); 8 | +} 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/struct_gendisk__no_has_backing_dev_info.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct drbd_device *d; 3 | @@ 4 | d->ldev->backing_bdev-> 5 | - bd_disk->bdi 6 | + bd_disk->queue->backing_dev_info 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/struct_size__no_present.cocci: -------------------------------------------------------------------------------- 1 | @ replace_struct_size @ 2 | identifier p; // pointer to the structure 3 | identifier m; // name of the array member 4 | expression n; // number of elements in the array 5 | @@ 6 | - struct_size(p, m, n) 7 | + sizeof(*p) + sizeof(*p->m) * n 8 | 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/submit_bio__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier NUMA; 3 | @@ 4 | blk_alloc_queue( 5 | + drbd_make_request, 6 | NUMA) 7 | 8 | @@ 9 | identifier x; 10 | symbol drbd_ops; 11 | @@ 12 | struct block_device_operations drbd_ops = { 13 | - .submit_bio = x, 14 | }; 15 | 16 | @@ 17 | type T; 18 | identifier b; 19 | identifier bio = bio; 20 | @@ 21 | T 22 | - drbd_submit_bio( 23 | + drbd_make_request(struct request_queue *q, 24 | struct bio *b) { ... } 25 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/submit_bio__no_returns_void.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | typedef blk_qc_t; 3 | @@ 4 | - void 5 | + blk_qc_t 6 | drbd_submit_bio(...) 7 | { 8 | ... 9 | - return; 10 | + return BLK_QC_T_NONE; 11 | } 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/submit_bio_noacct__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct bio *b; 3 | @@ 4 | - submit_bio_noacct 5 | + generic_make_request 6 | (b) 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tasklet_setup__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier object, member, callback; 3 | @@ 4 | - tasklet_setup(&object->member, callback) 5 | + tasklet_init(&object->member, callback, (unsigned long)object) 6 | 7 | @@ 8 | identifier tasklet_fn, t, object_struct, object, tasklet; 9 | @@ 10 | void 11 | -tasklet_fn(struct tasklet_struct *t) 12 | +tasklet_fn(unsigned long data) 13 | { 14 | - struct object_struct *object = from_tasklet(object, t, tasklet); 15 | + struct object_struct *object = (struct object_struct *) data; 16 | ... 17 | } 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tcp_sock_set_cork__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier socket; 3 | symbol true, false; 4 | @@ 5 | ( 6 | - tcp_sock_set_cork(socket->sk, true); 7 | + { int val = 1; (void) kernel_setsockopt(socket, SOL_TCP, TCP_CORK, (char *)&val, sizeof(val)); } 8 | | 9 | - tcp_sock_set_cork(socket->sk, false); 10 | + { int val = 0; (void) kernel_setsockopt(socket, SOL_TCP, TCP_CORK, (char *)&val, sizeof(val)); } 11 | ) 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tcp_sock_set_keepcnt__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct socket *so; 3 | unsigned int v; 4 | @@ 5 | - tcp_sock_set_keepcnt(so->sk, v); 6 | + kernel_setsockopt(so, SOL_TCP, TCP_KEEPCNT, (char *)&v, sizeof(v)); 7 | 8 | 9 | @@ 10 | struct socket *so; 11 | unsigned int v; 12 | @@ 13 | - tcp_sock_set_keepintvl(so->sk, v); 14 | + kernel_setsockopt(so, SOL_TCP, TCP_KEEPINTVL, (char *)&v, sizeof(v)); 15 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tcp_sock_set_keepidle__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | struct socket *so; 3 | unsigned int v; 4 | @@ 5 | - tcp_sock_set_keepidle(so->sk, v); 6 | + kernel_setsockopt(so, SOL_TCP, TCP_KEEPIDLE, (char *)&v, sizeof(v)); 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tcp_sock_set_nodelay__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier socket; 3 | @@ 4 | - tcp_sock_set_nodelay(socket->sk); 5 | + { int val = 1; (void) kernel_setsockopt(socket, SOL_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); } 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tcp_sock_set_quickack__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | identifier socket; 3 | @@ 4 | - tcp_sock_set_quickack(socket->sk, 2); 5 | + { int val = 2; (void) kernel_setsockopt(socket, SOL_TCP, TCP_QUICKACK, (char *)&val, sizeof(val)); } 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/timer_delete__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | ( 4 | - timer_delete 5 | + del_timer 6 | (...) 7 | | 8 | - timer_delete_sync 9 | + del_timer_sync 10 | (...) 11 | ) 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/timer_shutdown__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | ( 4 | - timer_shutdown 5 | + del_timer 6 | (...) 7 | | 8 | - timer_shutdown_sync 9 | + del_timer_sync 10 | (...) 11 | ) 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tls_get_record_type__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - #include 4 | 5 | @@ 6 | typedef u8; 7 | @@ 8 | + #define TLS_RECORD_TYPE_ALERT 0x15 9 | + #define TLS_RECORD_TYPE_DATA 0x17 10 | + #define TLS_ALERT_LEVEL_FATAL 2 11 | + #define TLS_GET_RECORD_TYPE 2 12 | + 13 | + /** 14 | + * tls_get_record_type - Look for TLS RECORD_TYPE information 15 | + * @sk: socket (for IP address information) 16 | + * @cmsg: incoming message to be parsed 17 | + * 18 | + * Returns zero or a TLS_RECORD_TYPE value. 19 | + */ 20 | + u8 tls_get_record_type(const struct sock *sk, const struct cmsghdr *cmsg) 21 | + { 22 | + if (cmsg->cmsg_level != SOL_TLS) 23 | + return 0; 24 | + if (cmsg->cmsg_type != TLS_GET_RECORD_TYPE) 25 | + return 0; 26 | + 27 | + return *((u8 *)CMSG_DATA(cmsg)); 28 | + } 29 | + 30 | + /** 31 | + * tls_alert_recv - Parse TLS Alert messages 32 | + * @sk: socket (for IP address information) 33 | + * @msg: incoming message to be parsed 34 | + * @level: OUT - TLS AlertLevel value 35 | + * @description: OUT - TLS AlertDescription value 36 | + * 37 | + */ 38 | + void tls_alert_recv(const struct sock *sk, const struct msghdr *msg, u8 *level, u8 *description) 39 | + { 40 | + const struct kvec *iov = msg->msg_iter.kvec; 41 | + u8 *data = iov->iov_base; 42 | + 43 | + *level = data[0]; 44 | + *description = data[1]; 45 | + } 46 | + 47 | dtt_recv_short(...) 48 | { ... } 49 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/tls_tx_rx__no_present.cocci: -------------------------------------------------------------------------------- 1 | @@ 2 | @@ 3 | - #include 4 | 5 | @@ 6 | @@ 7 | - #include 8 | 9 | @@ 10 | @@ 11 | - #include 12 | 13 | @@ 14 | @@ 15 | - #include 16 | 17 | @@ 18 | identifier msg; 19 | @@ 20 | - if (msg.msg_controllen != ...) { ... } 21 | 22 | @@ 23 | typedef gfp_t; 24 | @@ 25 | - typedef int (*tls_hello_func)(const struct tls_handshake_args *, gfp_t); 26 | 27 | @@ 28 | @@ 29 | - struct tls_handshake_wait { ... }; 30 | 31 | @@ 32 | @@ 33 | - static void tls_handshake_done(...) { ... } 34 | 35 | @@ 36 | @@ 37 | - static int tls_init_hello(...) { ... } 38 | 39 | @@ 40 | @@ 41 | - static int tls_wait_hello(...) { ... } 42 | 43 | @@ 44 | @@ 45 | - static void dtt_control_data_ready_work(...) { ... } 46 | 47 | @@ 48 | expression s; 49 | @@ 50 | - tls_handshake_cancel(s); 51 | 52 | @@ 53 | symbol tls; 54 | @@ 55 | if (tls) { 56 | - ... 57 | + err = -ENOTSUPP; 58 | + goto out; 59 | } 60 | 61 | @@ 62 | identifier transport, new_net_conf, ret; 63 | @@ 64 | dtt_net_conf_change(struct drbd_transport *transport, struct net_conf *new_net_conf) { 65 | ... 66 | int ret; 67 | ... 68 | rcu_read_unlock(); 69 | 70 | + if (new_net_conf->tls) { 71 | + tr_warn(transport, "kernel does not support kTLS\n"); 72 | + ret = -EINVAL; 73 | + goto end; 74 | + } 75 | ... 76 | } 77 | 78 | @@ 79 | declarer MODULE_SOFTDEP; 80 | @@ 81 | - MODULE_SOFTDEP("post: handshake"); 82 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci/vermagic_h__yes_can_include.cocci: -------------------------------------------------------------------------------- 1 | @ add_double_check @ 2 | @@ 3 | +static int __init double_check_for_kabi_breakage(void) 4 | +{ 5 | +#if defined(RHEL_RELEASE_CODE) && ((RHEL_RELEASE_CODE & 0xff00) == 0x700) 6 | + /* RHEL 7.5 chose to change sizeof(struct nla_policy), and to 7 | + * lie about that, which makes the module version magic believe 8 | + * it was compatible, while it is not. To avoid "surprises" in 9 | + * nla_parse() later, we ask the running kernel about its 10 | + * opinion about the nla_policy_len() of this dummy nla_policy, 11 | + * and if it does not agree, we fail on module load already. */ 12 | + static struct nla_policy dummy[] = { 13 | + [0] = { .type = NLA_UNSPEC, .len = 8, }, 14 | + [1] = { .type = NLA_UNSPEC, .len = 80, }, 15 | + [2] = { .type = NLA_UNSPEC, .len = 800, }, 16 | + [9] = { .type = NLA_UNSPEC, }, 17 | + }; 18 | + int len = nla_policy_len(dummy, 3); 19 | + if (len != 900) { 20 | + pr_notice("kernel disagrees about the layout of struct nla_policy (%d)\n", len); 21 | + pr_err("kABI breakage detected! module compiled for: %s\n", UTS_RELEASE); 22 | + return -EINVAL; 23 | + } 24 | +#endif 25 | + return 0; 26 | +} 27 | + 28 | drbd_init(...) 29 | { 30 | ... 31 | } 32 | 33 | @ call_double_check depends on ever add_double_check @ 34 | identifier err = err; 35 | @@ 36 | // it would be much more logical to do something like: 37 | // 38 | // drbd_init(...) 39 | // { 40 | // ... 41 | // T x; 42 | // + if(double_check...) 43 | // ... 44 | // } 45 | // 46 | // but for whatever reason, spatch does not want to match inside the drbd_init 47 | // function here. apparently it has something to do with the #ifdef MODULE 48 | // a few lines below. 49 | // so just chuck our call inbetween two known statements in that function and 50 | // hope that it matches the right thing. 51 | int err; 52 | + if (double_check_for_kabi_breakage()) 53 | + return -EINVAL; 54 | initialize_kref_debugging(); 55 | 56 | @ add_vermagic_h depends on ever add_double_check && file in "drbd_main.c" @ 57 | @@ 58 | #include <...> 59 | + #include 60 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/cocci_macros.h: -------------------------------------------------------------------------------- 1 | #define __must_hold(x) 2 | #define __printf(x, y) 3 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/collect_compat_h.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LC_ALL=C LANG=C LANGUAGE=C 4 | # 5 | # Do not try to use this unless you are on LINBIT's internal network 6 | # and have ssh access to lbbuild@thank.linbit 7 | # 8 | N_CONFIGS=0 9 | N_UNIQUE=0 10 | N_PRESERVED=0 11 | 12 | if [ -z "$LBBUILD_CI_BUILD" ]; then 13 | COMPAT_HEADERS_PATH=/home/lbbuild/lbbuild/localpkgs/drbd-9.3-compat-latest 14 | else 15 | COMPAT_HEADERS_PATH=/home/lbbuild/lbbuild/localpkgs/ci/drbd 16 | fi 17 | 18 | if [ "$(uname -n)" = "thank" ]; then 19 | FILES=$((cd $COMPAT_HEADERS_PATH; find . -name "compat.h*" \ 20 | | tar -T - -czf -) | tar xzvf -) 21 | elif ping -c1 thank.linbit > /dev/null 2>&1; then 22 | FILES=$(ssh lbbuild@thank.linbit \ 23 | "cd $COMPAT_HEADERS_PATH; find . -name "compat.h*" | tar -T - -czf -" \ 24 | | tar xzvf -) 25 | else 26 | echo "ERROR: you don't seem to have access to LINBIT's internal network." 27 | echo "Your tarball will not contain any pre-computed kernel backwards" 28 | echo "compatibility patches." 29 | exit 1 30 | fi 31 | 32 | ./build_cocci_cache.sh $FILES 33 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/drbd_wrappers.c: -------------------------------------------------------------------------------- 1 | #include "drbd_wrappers.h" 2 | 3 | #ifndef COMPAT_HAVE_PROC_CREATE_SINGLE 4 | #include 5 | #include 6 | /* This compat wrapper is not generic, only good enough for DRBD */ 7 | extern int drbd_seq_show(struct seq_file *seq, void *v); 8 | 9 | static int drbd_proc_single_open(struct inode *inode, struct file *file) 10 | { 11 | return single_open(file, drbd_seq_show, NULL); 12 | } 13 | 14 | struct proc_dir_entry *proc_create_single(const char *name, umode_t mode, 15 | struct proc_dir_entry *parent, 16 | int (*show)(struct seq_file *, void *)) 17 | { 18 | static const struct file_operations drbd_proc_single_fops = { 19 | .open = drbd_proc_single_open, 20 | .read = seq_read, 21 | .llseek = seq_lseek, 22 | .release = single_release, 23 | }; 24 | 25 | return proc_create_data(name, mode, parent, &drbd_proc_single_fops, NULL); 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/handshake/.gitignore: -------------------------------------------------------------------------------- 1 | *.cmd 2 | *.ko 3 | *.mod 4 | *.mod.c 5 | modules.order 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/handshake/Kbuild: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: GPL-2.0-only 2 | # 3 | # Makefile for the Generic HANDSHAKE service 4 | # 5 | # Author: Chuck Lever 6 | # 7 | # Copyright (c) 2023, Oracle and/or its affiliates. 8 | # 9 | 10 | override EXTRA_CFLAGS += -I$(src) -I$(src)/.. 11 | 12 | obj-m += handshake.o 13 | handshake-y := genl.o netlink.o request.o tlshd.o 14 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/handshake/genl.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 2 | /* Do not edit directly, auto-generated from: */ 3 | /* Documentation/netlink/specs/handshake.yaml */ 4 | /* YNL-GEN kernel source */ 5 | 6 | #include 7 | #include 8 | 9 | #include "genl.h" 10 | 11 | #include 12 | 13 | 14 | /* HANDSHAKE_CMD_ACCEPT - do */ 15 | static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_DONE_REMOTE_AUTH + 1] = { 16 | [HANDSHAKE_A_DONE_STATUS] = { .type = NLA_UNSPEC, }, 17 | [HANDSHAKE_A_ACCEPT_HANDLER_CLASS] = { .type = NLA_U32, }, 18 | [HANDSHAKE_A_DONE_REMOTE_AUTH] = { .type = NLA_UNSPEC, }, 19 | }; 20 | 21 | /* HANDSHAKE_CMD_DONE - do */ 22 | static const struct nla_policy handshake_done_nl_policy[HANDSHAKE_A_DONE_REMOTE_AUTH + 1] = { 23 | [HANDSHAKE_A_DONE_STATUS] = { .type = NLA_U32, }, 24 | [HANDSHAKE_A_DONE_SOCKFD] = { .type = NLA_S32, }, 25 | [HANDSHAKE_A_DONE_REMOTE_AUTH] = { .type = NLA_U32, }, 26 | }; 27 | 28 | /* Ops table for handshake */ 29 | static const struct genl_ops handshake_nl_ops[] = { 30 | { 31 | .cmd = HANDSHAKE_CMD_ACCEPT, 32 | .doit = handshake_nl_accept_doit, 33 | .policy = handshake_accept_nl_policy, 34 | .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 35 | }, 36 | { 37 | .cmd = HANDSHAKE_CMD_DONE, 38 | .doit = handshake_nl_done_doit, 39 | .policy = handshake_done_nl_policy, 40 | .flags = GENL_CMD_CAP_DO, 41 | }, 42 | }; 43 | 44 | static const struct genl_multicast_group handshake_nl_mcgrps[] = { 45 | [HANDSHAKE_NLGRP_NONE] = { "none", }, 46 | [HANDSHAKE_NLGRP_TLSHD] = { "tlshd", }, 47 | }; 48 | 49 | struct genl_family handshake_nl_family __ro_after_init = { 50 | .name = HANDSHAKE_FAMILY_NAME, 51 | .version = HANDSHAKE_FAMILY_VERSION, 52 | .netnsok = true, 53 | .parallel_ops = true, 54 | .module = THIS_MODULE, 55 | .ops = handshake_nl_ops, 56 | .n_ops = ARRAY_SIZE(handshake_nl_ops), 57 | .mcgrps = handshake_nl_mcgrps, 58 | .maxattr = HANDSHAKE_A_DONE_REMOTE_AUTH, 59 | .n_mcgrps = ARRAY_SIZE(handshake_nl_mcgrps), 60 | }; 61 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/handshake/genl.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 | /* Do not edit directly, auto-generated from: */ 3 | /* Documentation/netlink/specs/handshake.yaml */ 4 | /* YNL-GEN kernel header */ 5 | 6 | #ifndef _LINUX_HANDSHAKE_GEN_H 7 | #define _LINUX_HANDSHAKE_GEN_H 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | int handshake_nl_accept_doit(struct sk_buff *skb, struct genl_info *info); 15 | int handshake_nl_done_doit(struct sk_buff *skb, struct genl_info *info); 16 | 17 | enum { 18 | HANDSHAKE_NLGRP_NONE, 19 | HANDSHAKE_NLGRP_TLSHD, 20 | }; 21 | 22 | extern struct genl_family handshake_nl_family; 23 | 24 | #endif /* _LINUX_HANDSHAKE_GEN_H */ 25 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/handshake/handshake.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Generic netlink handshake service 4 | * 5 | * Author: Chuck Lever 6 | * 7 | * Copyright (c) 2023, Oracle and/or its affiliates. 8 | */ 9 | 10 | #ifndef _INTERNAL_HANDSHAKE_H 11 | #define _INTERNAL_HANDSHAKE_H 12 | 13 | /* Per-net namespace context */ 14 | struct handshake_net { 15 | spinlock_t hn_lock; /* protects next 3 fields */ 16 | int hn_pending; 17 | int hn_pending_max; 18 | struct list_head hn_requests; 19 | 20 | unsigned long hn_flags; 21 | }; 22 | 23 | enum hn_flags_bits { 24 | HANDSHAKE_F_NET_DRAINING, 25 | }; 26 | 27 | struct handshake_proto; 28 | 29 | /* One handshake request */ 30 | struct handshake_req { 31 | struct list_head hr_list; 32 | struct rhash_head hr_rhash; 33 | unsigned long hr_flags; 34 | const struct handshake_proto *hr_proto; 35 | struct sock *hr_sk; 36 | void (*hr_odestruct)(struct sock *sk); 37 | 38 | /* Always the last field */ 39 | char hr_priv[]; 40 | }; 41 | 42 | enum hr_flags_bits { 43 | HANDSHAKE_F_REQ_COMPLETED, 44 | }; 45 | 46 | /* Invariants for all handshake requests for one transport layer 47 | * security protocol 48 | */ 49 | struct handshake_proto { 50 | int hp_handler_class; 51 | size_t hp_privsize; 52 | unsigned long hp_flags; 53 | 54 | int (*hp_accept)(struct handshake_req *req, 55 | struct genl_info *info, int fd); 56 | void (*hp_done)(struct handshake_req *req, 57 | unsigned int status, 58 | struct genl_info *info); 59 | void (*hp_destroy)(struct handshake_req *req); 60 | }; 61 | 62 | enum hp_flags_bits { 63 | HANDSHAKE_F_PROTO_NOTIFY, 64 | }; 65 | 66 | /* netlink.c */ 67 | int handshake_genl_notify(struct net *net, const struct handshake_proto *proto, 68 | gfp_t flags); 69 | struct nlmsghdr *handshake_genl_put(struct sk_buff *msg, 70 | struct genl_info *info); 71 | struct handshake_net *handshake_pernet(struct net *net); 72 | 73 | /* request.c */ 74 | struct handshake_req *handshake_req_alloc(const struct handshake_proto *proto, 75 | gfp_t flags); 76 | int handshake_req_hash_init(void); 77 | void handshake_req_hash_destroy(void); 78 | void *handshake_req_private(struct handshake_req *req); 79 | struct handshake_req *handshake_req_hash_lookup(struct sock *sk); 80 | struct handshake_req *handshake_req_next(struct handshake_net *hn, int class); 81 | int handshake_req_submit(struct socket *sock, struct handshake_req *req, 82 | gfp_t flags); 83 | void handshake_complete(struct handshake_req *req, unsigned int status, 84 | struct genl_info *info); 85 | bool handshake_req_cancel(struct sock *sk); 86 | 87 | #endif /* _INTERNAL_HANDSHAKE_H */ 88 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/l/.empty_dir: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LINBIT/drbd/011f770e15a81aef8219141ca85f0bc1765ad1ec/drbd/drbd-kernel-compat/l/.empty_dir -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/l/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | !.empty_dir 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/linux/libnvdimm.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBNVDIMM_H 2 | #define LIBNVDIMM_H 3 | 4 | #define arch_wb_cache_pmem(A, S) do { } while (0) 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/linux/overflow.h: -------------------------------------------------------------------------------- 1 | #ifndef OVERFLOW_H 2 | #define OVERFLOW_H 3 | 4 | /* RHEL7 has a gcc-4.x which lacks __builtin_add_overflow() */ 5 | #if __GNUC__ < 5 6 | #define check_add_overflow(a, b, d) ({ *(d) = (a) + (b); *(d) < (a); }) 7 | #else 8 | #ifndef check_add_overflow 9 | #define check_add_overflow(a, b, d) __builtin_add_overflow(a, b, d) 10 | #endif 11 | #endif 12 | 13 | #endif /* OVERFLOW_H */ 14 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/net/handshake.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | * Generic netlink HANDSHAKE service. 4 | * 5 | * Author: Chuck Lever 6 | * 7 | * Copyright (c) 2023, Oracle and/or its affiliates. 8 | */ 9 | 10 | #ifndef _NET_HANDSHAKE_H 11 | #define _NET_HANDSHAKE_H 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | enum { 18 | TLS_NO_KEYRING = 0, 19 | TLS_NO_PEERID = 0, 20 | TLS_NO_CERT = 0, 21 | TLS_NO_PRIVKEY = 0, 22 | }; 23 | 24 | typedef void (*tls_done_func_t)(void *data, int status, 25 | key_serial_t peerid); 26 | 27 | struct tls_handshake_args { 28 | struct socket *ta_sock; 29 | tls_done_func_t ta_done; 30 | void *ta_data; 31 | const char *ta_peername; 32 | unsigned int ta_timeout_ms; 33 | key_serial_t ta_keyring; 34 | key_serial_t ta_my_cert; 35 | key_serial_t ta_my_privkey; 36 | unsigned int ta_num_peerids; 37 | key_serial_t ta_my_peerids[5]; 38 | }; 39 | 40 | int tls_client_hello_anon(const struct tls_handshake_args *args, gfp_t flags); 41 | int tls_client_hello_x509(const struct tls_handshake_args *args, gfp_t flags); 42 | int tls_client_hello_psk(const struct tls_handshake_args *args, gfp_t flags); 43 | int tls_server_hello_x509(const struct tls_handshake_args *args, gfp_t flags); 44 | int tls_server_hello_psk(const struct tls_handshake_args *args, gfp_t flags); 45 | 46 | bool tls_handshake_cancel(struct sock *sk); 47 | 48 | #endif /* _NET_HANDSHAKE_H */ 49 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/nsecs_to_jiffies.c: -------------------------------------------------------------------------------- 1 | #include /* for HZ */ 2 | #include /* for NSECS_PER_SEC */ 3 | 4 | /* If it is not exported yet, use our own copy. */ 5 | static u64 nsecs_to_jiffies64(u64 n) 6 | { 7 | #if (NSEC_PER_SEC % HZ) == 0 8 | /* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */ 9 | return div_u64(n, NSEC_PER_SEC / HZ); 10 | #elif (HZ % 512) == 0 11 | /* overflow after 292 years if HZ = 1024 */ 12 | return div_u64(n * HZ / 512, NSEC_PER_SEC / 512); 13 | #else 14 | /* 15 | * Generic case - optimized for cases where HZ is a multiple of 3. 16 | * overflow after 64.99 years, exact for HZ = 60, 72, 90, 120 etc. 17 | */ 18 | return div_u64(n * 9, (9ull * NSEC_PER_SEC + HZ / 2) / HZ); 19 | #endif 20 | } 21 | 22 | /* Ged rid of "missing prototype" warning. 23 | * The real prototype is in linux/jiffies.h, 24 | * which we do not include here, for reasons I do not recall. */ 25 | unsigned long nsecs_to_jiffies(u64 n); 26 | 27 | unsigned long nsecs_to_jiffies(u64 n) 28 | { 29 | return (unsigned long)nsecs_to_jiffies64(n); 30 | } 31 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/patches/genl_policy__no_in_ops.patch: -------------------------------------------------------------------------------- 1 | --- drbd-headers/linux/genl_magic_func.h 2 | +++ drbd-headers/linux/genl_magic_func.h 3 | @@ -253,7 +253,6 @@ static const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd) 4 | { \ 5 | handler \ 6 | .cmd = op_name, \ 7 | - .policy = CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy), \ 8 | }, 9 | 10 | #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops) 11 | @@ -311,6 +310,7 @@ static struct genl_family ZZZ_genl_family __read_mostly = { 12 | #endif 13 | .netnsok = false, 14 | .parallel_ops = true, 15 | + .policy = CONCAT_(GENL_MAGIC_FAMILY, _tla_nl_policy), 16 | }; 17 | 18 | /* 19 | 20 | --- drbd-kernel-compat/handshake/genl.c 21 | +++ drbd-kernel-compat/handshake/genl.c 22 | @@ -10,14 +10,6 @@ 23 | 24 | #include 25 | 26 | - 27 | -/* HANDSHAKE_CMD_ACCEPT - do */ 28 | -static const struct nla_policy handshake_accept_nl_policy[HANDSHAKE_A_DONE_REMOTE_AUTH + 1] = { 29 | - [HANDSHAKE_A_DONE_STATUS] = { .type = NLA_UNSPEC, }, 30 | - [HANDSHAKE_A_ACCEPT_HANDLER_CLASS] = { .type = NLA_U32, }, 31 | - [HANDSHAKE_A_DONE_REMOTE_AUTH] = { .type = NLA_UNSPEC, }, 32 | -}; 33 | - 34 | /* HANDSHAKE_CMD_DONE - do */ 35 | static const struct nla_policy handshake_done_nl_policy[HANDSHAKE_A_DONE_REMOTE_AUTH + 1] = { 36 | [HANDSHAKE_A_DONE_STATUS] = { .type = NLA_U32, }, 37 | @@ -30,13 +22,11 @@ static const struct genl_ops handshake_nl_ops[] = { 38 | { 39 | .cmd = HANDSHAKE_CMD_ACCEPT, 40 | .doit = handshake_nl_accept_doit, 41 | - .policy = handshake_accept_nl_policy, 42 | .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, 43 | }, 44 | { 45 | .cmd = HANDSHAKE_CMD_DONE, 46 | .doit = handshake_nl_done_doit, 47 | - .policy = handshake_done_nl_policy, 48 | .flags = GENL_CMD_CAP_DO, 49 | }, 50 | }; 51 | @@ -55,6 +45,7 @@ struct genl_family handshake_nl_family __ro_after_init = { 52 | .ops = handshake_nl_ops, 53 | .n_ops = ARRAY_SIZE(handshake_nl_ops), 54 | .mcgrps = handshake_nl_mcgrps, 55 | + .policy = handshake_done_nl_policy, 56 | .maxattr = HANDSHAKE_A_DONE_REMOTE_AUTH, 57 | .n_mcgrps = ARRAY_SIZE(handshake_nl_mcgrps), 58 | }; 59 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/patches/genlmsg_multicast_allns__no_has_4_params.patch: -------------------------------------------------------------------------------- 1 | --- drbd-headers/linux/genl_magic_func-genl_register_family_with_ops_groups.h 2 | +++ drbd-headers/linux/genl_magic_func-genl_register_family_with_ops_groups.h 3 | @@ -18,8 +18,12 @@ static int CONCAT_(GENL_MAGIC_FAMILY, _genl_multicast_ ## group)( \ 4 | { \ 5 | unsigned int group_id = \ 6 | CONCAT_(GENL_MAGIC_FAMILY, _group_ ## group); \ 7 | - return genlmsg_multicast_allns(&ZZZ_genl_family, skb, 0, \ 8 | - group_id); \ 9 | + int ret; \ 10 | + rcu_read_lock(); \ 11 | + ret = genlmsg_multicast_allns(&ZZZ_genl_family, skb, 0, \ 12 | + group_id, GFP_ATOMIC); \ 13 | + rcu_read_unlock(); \ 14 | + return ret; \ 15 | } 16 | 17 | #include GENL_MAGIC_INCLUDE_FILE 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/patches/nla_strscpy__no_present.patch: -------------------------------------------------------------------------------- 1 | --- drbd-headers/linux/genl_magic_struct.h 2 | +++ drbd-headers/linux/genl_magic_struct.h 3 | @@ -98,7 +98,7 @@ static inline int nla_put_u64_0pad(struc 4 | nla_get_u64, nla_put_u64_0pad, false) 5 | #define __str_field(attr_nr, attr_flag, name, maxlen) \ 6 | __array(attr_nr, attr_flag, name, NLA_NUL_STRING, char, maxlen, \ 7 | - nla_strscpy, nla_put, false) 8 | + nla_strlcpy, nla_put, false) 9 | #define __bin_field(attr_nr, attr_flag, name, maxlen) \ 10 | __array(attr_nr, attr_flag, name, NLA_BINARY, char, maxlen, \ 11 | nla_memcpy, nla_put, false) 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/scripts/constant-tests.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | [ ! -d drbd/drbd-kernel-compat ] && echo "Must be called from repository root" && exit 1 4 | 5 | pushd drbd/drbd-kernel-compat > /dev/null 6 | 7 | for f in tests/*.c; do 8 | define="COMPAT_$(basename -s .c $f | tr a-z A-Z)" 9 | str="" 10 | while read line; do 11 | if [[ $line = \#define* ]]; then 12 | str+="1 " 13 | else 14 | str+="0 " 15 | fi 16 | done <<<$(grep --no-filename -P " $define( |$)" cocci_cache/*/compat.h) 17 | 18 | [[ $str != *0* ]] && echo "$define is always set" 19 | [[ $str != *1* ]] && echo "$define is always unset" 20 | done 21 | 22 | popd > /dev/null 23 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/scripts/findunused.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import json 5 | 6 | UNKNOWN, TOGGLED = range(2) 7 | UNDEFINED, DEFINED = 'undefined', 'defined' 8 | 9 | defines = {} 10 | for dirpath, _, fnames in os.walk('../cocci_cache'): 11 | for compat in fnames: 12 | if not compat.startswith("compat.h"): 13 | continue 14 | with open(os.path.join(dirpath, compat)) as f: 15 | lines = f.readlines() 16 | for l in lines: 17 | sp = l.strip().split() 18 | 19 | what, result = '', '' 20 | if sp[0] == '/*' and sp[1] == '#undef': 21 | what, result = sp[2], UNDEFINED 22 | elif sp[0] == '#define': 23 | what, result = sp[1], DEFINED 24 | else: 25 | continue 26 | 27 | if what == 'COMPAT_HAVE_SANE_TEST_ENVIRONMENT' or what == 'COMPAT_HAVE_SANE_TEST_ENVIRONMENT_ALWAYS_FAIL': 28 | # these are obviously "always (un)defined", but we don't want to flag them for removal 29 | continue 30 | 31 | current = defines.get(what, UNKNOWN) 32 | if current == UNKNOWN: 33 | defines[what] = result 34 | elif current != result: 35 | defines[what] = TOGGLED 36 | 37 | prefix = 'compat_' 38 | for k, v in defines.items(): 39 | if v != TOGGLED: 40 | vers, commit = UNDEFINED, UNDEFINED 41 | fname = k.lower() 42 | if fname.startswith(prefix): 43 | fname = fname[len(prefix):] 44 | fname += '.c' 45 | fname = os.path.join('..', 'tests', fname) 46 | try: 47 | with open(fname) as fp: 48 | line = fp.readline().strip() 49 | if line.startswith('/*') or line.startswith('//'): 50 | line = line[2:] 51 | if line.endswith('*/'): 52 | line = line[:-2] 53 | try: 54 | info = json.loads(line) 55 | vers = info.get('version', UNDEFINED) 56 | commit = info.get('commit', UNDEFINED) 57 | except: 58 | pass 59 | except IOError: 60 | print('Could not open file {}'.format(fname)) 61 | 62 | print('{} is always {} (v:{}, c:{})'.format(k, v, vers, commit)) 63 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/scripts/unused-patches.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Prints all cocci patches that are never used in the current cocci_cache. 4 | # Implies that `make compat` has previously been run to generate the applied_cocci_files.txt files 5 | 6 | for f in cocci/*; do 7 | patch="$(basename -s .cocci $f)" 8 | grep -qFx $patch cocci_cache/*/applied_cocci_files.txt || echo "$f" 9 | done 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/scripts/unused-tests.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | [ ! -d drbd/drbd-kernel-compat ] && echo "Must be called from repository root" && exit 1 4 | 5 | for f in drbd/drbd-kernel-compat/tests/*.c; do 6 | define="COMPAT_$(basename -s .c $f | tr a-z A-Z)" 7 | used=$(git grep --recurse-submodules "$define" | wc -l) 8 | [ "$used" -eq "0" ] && echo "$f" 9 | done 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/spatch_works.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | for PATCH in "$@"; do 4 | spatch --very-quiet --parse-cocci "$PATCH" >/dev/null && echo " COCCISYNTAX OK $(basename "$PATCH")" || { echo " COCCISYNTAX FAIL $(basename "$PATCH")" ; exit 1 ; } 5 | done 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/splitdiff.pl: -------------------------------------------------------------------------------- 1 | %seen = (); 2 | while (defined($_=)) { 3 | /^--- (?:.\/)?(\S+)/ and do { 4 | ($out = $1) =~ s,/,_,g; 5 | $mode = '>'; 6 | if (exists $seen{$out}) { 7 | warn qq{$.: $out patched multiple times, APPENDING to previous version: @{[join ", ", @{$seen{$out}}]}\n}; 8 | $mode = '>>'; 9 | } 10 | push @{$seen{$out}}, $.; 11 | $out .= ".patch"; 12 | open STDOUT,$mode,$out or die "$out: $!"; 13 | print STDERR "$mode$out\n" if $ENV{V}; 14 | }; 15 | 16 | /^[+-]{3} / and next if $mode eq '>>'; 17 | 18 | print; 19 | } 20 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/__vmalloc_has_2_params.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8-rc1", "commit": "88dca4ca5a93d2c09e5bbc6a62fbfc3af83c4fca", "comment": "pgprot argument to __vmalloc was removed", "author": "Christoph Hellwig ", "date": "Mon Jun 1 21:51:40 2020 -0700" } */ 2 | 3 | #include 4 | 5 | void foo(void) 6 | { 7 | __vmalloc(0, 0); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/add_disk_returns_int.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.14-rc5", "commit": "83cbce9574462c6b4eed6797bdaf18fae6859ab3", "comment": "add_disk gained error handling, changing its return type to int", "author": "Luis Chamberlain ", "date": "Wed Aug 18 16:45:40 2021 +0200" } */ 2 | 3 | #include 4 | 5 | int foo(struct gendisk *d) 6 | { 7 | return add_disk(d); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/before_4_13_kernel_read.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef __same_type 4 | # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 5 | #endif 6 | 7 | ssize_t kernel_read_since_4_13(struct file *file, void *buf, size_t count, loff_t *pos); 8 | int kernel_read_before_4_13(struct file *file, loff_t offset, char *addr, unsigned long count); 9 | 10 | 11 | int foo(void) 12 | { 13 | struct file *file = NULL; 14 | loff_t offset = 0; 15 | char *addr = NULL; 16 | unsigned long count = 0; 17 | 18 | BUILD_BUG_ON(!(__same_type(kernel_read_before_4_13, kernel_read))); 19 | return kernel_read(file, offset, addr, count); 20 | } 21 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/bio_alloc_has_4_params.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.17-rc3", "commit": "07888c665b405b1cd3577ddebfeb74f4717a84c4", "comment": "bio_alloc got two new arguments", "author": "Christoph Hellwig ", "date": "Mon Jan 24 10:11:05 2022 +0100" } */ 2 | 3 | /* note: this result is also valid for bio_alloc_bioset, since the same 4 | signature change was made there in the same patch series. */ 5 | 6 | #include 7 | 8 | struct bio *foo(struct block_device *bdev, unsigned short nr_vecs, 9 | unsigned int opf, gfp_t gfp_mask) 10 | { 11 | return bio_alloc(bdev, nr_vecs, opf, gfp_mask); 12 | } 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/blk_alloc_disk_takes_queue_limits.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.9-rc1", "commit": "74fa8f9c553f7b5ccab7d103acae63cc2e080465", "comment": "block: pass a queue_limits argument to blk_alloc_disk", "author": "Christoph Hellwig ", "date": "Thu Feb 15 08:10:47 2024 +0100" } */ 2 | 3 | #include 4 | 5 | struct gendisk *foo(struct queue_limits *lim, int node) 6 | { 7 | return blk_alloc_disk(lim, node); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/blkdev_get_by_path_has_holder_ops.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.5-rc1", "commit": "0718afd47f70cf46877c39c25d06b786e1a3f36c", "comment": "block: introduce holder ops", "author": "Christoph Hellwig ", "date": "Thu Jun 1 11:44:52 2023 +0200" } */ 2 | #include 3 | 4 | struct block_device *foo(const char *bdev_path, struct blk_holder_ops *ops) 5 | { 6 | return blkdev_get_by_path(bdev_path, 0, NULL, ops); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/blkdev_issue_discard_takes_flags.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.19-rc1", "commit": "44abff2c0b970ae3d310b97617525dc01f248d7c", "comment": "blkdev_issue_discard had its last parameter (flags) removed", "author": "Christoph Hellwig ", "date": "Fri Apr 15 06:52:57 2022 +0200" } */ 2 | 3 | #include 4 | 5 | int foo(struct block_device *bdev, sector_t sector, sector_t nr_sects, 6 | gfp_t gfp_mask, unsigned long flags) 7 | { 8 | return blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, flags); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/blkdev_issue_zeroout_discard.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef __same_type 4 | # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 5 | #endif 6 | 7 | extern int biz_fn(struct block_device *bdev, sector_t start, sector_t len, gfp_t gfp_mask, bool discard); 8 | 9 | int foo(void) 10 | { 11 | struct block_device *bdev = NULL; 12 | sector_t start = 0; 13 | sector_t len = 0; 14 | BUILD_BUG_ON(!(__same_type(biz_fn, blkdev_issue_zeroout))); 15 | return blkdev_issue_zeroout(bdev, start, len, GFP_KERNEL, false); 16 | } 17 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/blkdev_put_has_holder.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.5-rc1", "commit": "ae220766d87cd6799dbf918fea10613ae14c0654", "comment": "block: remove the unused mode argument to ->release", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:37 2023 +0200" } */ 2 | #include 3 | 4 | #ifndef __same_type 5 | # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 6 | #endif 7 | 8 | void foo_blkdev_put(struct block_device *bdev, void *holder) 9 | { 10 | } 11 | 12 | 13 | void foo(void) 14 | { 15 | BUILD_BUG_ON(!(__same_type(&blkdev_put, &foo_blkdev_put))); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/block_device_operations_open_takes_gendisk.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.5-rc1", "commit": "d32e2bf83791727a84ad5d3e3d713e82f9adbe30", "comment": "block: pass a gendisk to ->open", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:36 2023 +0200" } */ 2 | #include 3 | 4 | #ifndef __same_type 5 | # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 6 | #endif 7 | 8 | int foo_open(struct gendisk *disk, unsigned int mode) 9 | { 10 | return 0; 11 | } 12 | 13 | void foo(void) 14 | { 15 | struct block_device_operations ops; 16 | BUILD_BUG_ON(!(__same_type(ops.open, &foo_open))); 17 | } 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/block_device_operations_release_takes_single_argument.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.5-rc1", "commit": "ae220766d87cd6799dbf918fea10613ae14c0654", "comment": "block: remove the unused mode argument to ->release", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:37 2023 +0200" } */ 2 | #include 3 | 4 | void foo(struct block_device_operations *ops, struct gendisk *gd) 5 | { 6 | ops->release(gd); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/can_include_vermagic_h.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.7-rc2", "commit": "51161bfc66a68d21f13d15a689b3ea7980457790", "comment": "An include guard was added to vermagic.h, forbidding modules from including it", "author": "Leon Romanovsky ", "date": "Sun Apr 19 18:55:06 2020 +0300" } */ 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/dax_direct_access_takes_mode.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.18-rc5", "commit": "e511c4a3d2a1f64aafc1f5df37a2ffcf7ef91b55", "comment": "A new parameter, mode, was added to dax_direct_access", "author": "Jane Chu ", "date": "Fri May 13 15:10:58 2022 -0700" } */ 2 | 3 | #include 4 | 5 | long foo(struct dax_device *dax_dev, pgoff_t pgoff, long nr_pages, 6 | enum dax_access_mode mode, void **kaddr, pfn_t *pfn) 7 | { 8 | return dax_direct_access(dax_dev, pgoff, nr_pages, mode, kaddr, pfn); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/fs_dax_get_by_bdev_takes_start_off.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.16-rc2", "commit": "cd913c76f489def1a388e3a5b10df94948ede3f5", "comment": "fs_dax_get_by_bdev was changed to return the partition offset via a second parameter", "author": "Christoph Hellwig ", "date": "Mon Nov 29 11:21:59 2021 +0100" } */ 2 | 3 | #include 4 | #include 5 | 6 | struct dax_device *foo(struct block_device *bdev, u64 *start_off) 7 | { 8 | return fs_dax_get_by_bdev(bdev, start_off); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/fs_dax_get_by_bdev_takes_start_off_and_holder.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.0-rc1", "commit": "8012b866085523758780850087102421dbcce522", "comment": "fs_dax_get_by_bdev was changed to take optional holder parameters", "author": "Shiyang Ruan ", "date": "Fri Jun 3 13:37:25 2022 +0800" } */ 2 | 3 | #include 4 | #include 5 | 6 | struct dax_device *foo(struct block_device *bdev, u64 *start_off, void *holder, const struct dax_holder_operations *ops) 7 | { 8 | return fs_dax_get_by_bdev(bdev, start_off, holder, ops); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/genl_policy_in_ops.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct genl_ops ops = { .policy = NULL, }; 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/genlmsg_multicast_allns_has_4_params.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.12-rc2", "commit": "56440d7ec28d60f8da3bfa09062b3368ff9b16db", "comment": "gfp_t flags argument was removed", "author": "Eric Dumazet ", "date": "Fri Oct 11 17:12:17 2024 +0000" } */ 2 | 3 | #include 4 | 5 | void foo(void) 6 | { 7 | struct genl_family *family = NULL; 8 | struct sk_buff *skb = NULL; 9 | u32 portid = 0; 10 | unsigned int group = 0; 11 | int r; 12 | 13 | r = genlmsg_multicast_allns(family, skb, portid, group); 14 | } 15 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_BIO_MAX_VECS.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.12-rc2", "commit": "a8affc03a9b375e19bc81573de0c9108317d78c7", "comment": "rename BIO_MAX_PAGES to BIO_MAX_VECS", "author": "Christoph Hellwig ", "date": "Thu Mar 11 12:01:37 2021 +0100" } */ 2 | 3 | #include 4 | 5 | int foo(void) 6 | { 7 | return BIO_MAX_VECS; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_GENHD_FL_NO_PART.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.16-rc4", "commit": "46e7eac647b34ed4106a8262f8bedbb90801fadd", "comment": "GENHD_FL_NO_PART_SCAN was renamed to GENHD_FL_NO_PART", "author": "Christoph Hellwig ", "date": "Mon Nov 22 14:06:17 2021 +0100" } */ 2 | 3 | #include 4 | 5 | int foo(void) 6 | { 7 | return GENHD_FL_NO_PART; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have___bio_add_page.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.18-rc1", "commit": "0aa69fd32a5f766e997ca8ab4723c5a1146efa8b", "comment": "__bio_add_page was introduced", "author": "Christoph Hellwig ", "date": "Fri Jun 1 09:03:05 2018 -0700" } */ 2 | 3 | #include 4 | 5 | void foo(struct bio *bio, struct page *page, 6 | unsigned int len, unsigned int off) 7 | { 8 | __bio_add_page(bio, page, len, off); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_allow_kernel_signal.c: -------------------------------------------------------------------------------- 1 | /* {"version": "5.3-rc5", "commit": "33da8e7c814f77310250bb54a9db36a44c5de784", "comment": "allow_kernel_signal was added to only allow signals from other kernel threads, not from userspace", "author": "Eric W. Biederman ", "date": "Fri Aug 16 12:33:54 2019 -0500"} */ 2 | #include 3 | 4 | void dummy(int sig) 5 | { 6 | allow_kernel_signal(sig); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdev_discard_granularity.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.18-rc4", "commit": "7b47ef52d0a2025fd1408a8a0990933b8e1e510f", "comment": "A new helper, bdev_discard_granularity, was added", "author": "Christoph Hellwig ", "date": "Fri Apr 15 06:52:56 2022 +0200" } */ 2 | 3 | #include 4 | 5 | unsigned int foo(struct block_device *bdev) 6 | { 7 | return bdev_discard_granularity(bdev); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdev_file_open_by_path.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.9-rc1", "commit": "f3a608827d1f8de0dd12813e8d9c6803fe64e119", "comment": "bdev: open block devices as files", "author": "Christian Brauner ", "date": "Thu Feb 8 18:47:35 2024 +0100" } */ 2 | 3 | #include 4 | 5 | struct file *foo(const char *path, blk_mode_t mode, void *holder, 6 | const struct blk_holder_ops *hops) 7 | { 8 | return bdev_file_open_by_path(path, mode, holder, hops); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdev_max_discard_sectors.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.19-rc1", "commit": "cf0fbf894bb543f472f682c486be48298eccf199", "comment": "The bdev_max_discard_sectors was added", "author": "Christoph Hellwig ", "date": "Fri Apr 15 06:52:54 2022 +0200" } */ 2 | 3 | #include 4 | 5 | unsigned int foo(struct block_device *bdev) 6 | { 7 | return bdev_max_discard_sectors(bdev); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdev_nr_sectors.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.10-rc5", "commit": "a782483cc1f875355690625d8253a232f2581418", "comment": "the bdev_nr_sectors helper was introduced", "author": "Christoph Hellwig ", "date": "Thu Nov 26 18:43:37 2020 +0100" } */ 2 | 3 | #include 4 | 5 | sector_t foo(struct block_device *bdev) 6 | { 7 | return bdev_nr_sectors(bdev); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdev_open_by_path.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.7", "commit": "e719b4d156749f02eafed31a3c515f2aa9dcc72a", "comment": "introduce bdev_open_by_* functions", "author": "Jan Kara ", "date": "Wed Sep 27 11:34:07 2023 +0200" } */ 2 | 3 | #include 4 | 5 | struct bdev_handle *foo(const char *path, blk_mode_t mode, void *holder, 6 | const struct blk_holder_ops *hops) { 7 | return bdev_open_by_path(path, mode, holder, hops); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdevname.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.19-rc5", "commit": "900d156bac2bc474cf7c7bee4efbc6c83ec5ae58", "comment": "the bdevname helper was removed", "author": "Christoph Hellwig ", "date": "Wed Jul 13 07:53:17 2022 +0200" } */ 2 | 3 | #include 4 | 5 | const char *foo(struct block_device *bdev, char *buf) 6 | { 7 | return bdevname(bdev, b); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdgrab.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.14-rc5", "commit": "14cf1dbb55bb07427babee425fd2a8a9300737cc", "comment": "bdgrab was removed", "author": "Christoph Hellwig ", "date": "Thu Jul 22 09:54:01 2021 +0200" } */ 2 | 3 | #include 4 | 5 | struct block_device *foo(struct block_device *b) { 6 | return bdgrab(b); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdi_congested.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.18-rc1", "commit": "b9b1335e640308acc1b8f26c739b804c80a6c147", "comment": "In 5.18, inode_congested() and all its related functions were removed because 'No bdi reports congestion any more'", "author": "NeilBrown ", "date": "Tue Mar 22 14:39:10 2022 -0700" } */ 2 | 3 | #include 4 | 5 | int foo(struct backing_dev_info *bdi, int cong_bits) 6 | { 7 | return bdi_congested(bdi, cong_bits); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bdi_congested_fn.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8-rc2", "commit": "21cf866145047f8bfecb38ec8d2fed64464c074f", "comment": "In 5.8 bdi->congested_fn was removed", "author": "Christoph Hellwig ", "date": "Wed Jul 1 11:06:22 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct backing_dev_info bdi) 6 | { 7 | bdi.congested_fn = NULL; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_advance_iter_single.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void dummy(struct bio *bio) 4 | { 5 | struct bvec_iter iter = bio->bi_iter; 6 | 7 | bio_advance_iter_single(bio, &iter, 17); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_alloc_clone.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.18-rc1", "commit": "abfc426d1b2fb2176df59851a64223b58ddae7e7", "comment": "bio_clone_fast was renamed to bio_alloc_clone and had its signature changed", "author": "Christoph Hellwig ", "date": "Wed Feb 2 17:01:09 2022 +0100" } */ 2 | 3 | #include 4 | 5 | struct bio *dummy(struct block_device *bdev, struct bio *bio_src, gfp_t gfp, 6 | struct bio_set *bs) 7 | { 8 | return bio_alloc_clone(bdev, bio_src, gfp, bs); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_bi_bdev.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void dummy(struct bio *bio) 4 | { 5 | bio->bi_bdev = NULL; 6 | } 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_bi_error.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void dummy(struct bio *bio) 4 | { 5 | bio->bi_error = -EIO; 6 | bio_endio(bio); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_max_segs.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.11", "commit": "5f7136db82996089cdfb2939c7664b29e9da141d", "comment": "block: Add bio_max_segs", "author": "Matthew Wilcox (Oracle) ", "date": "Fri Jan 29 04:38:57 2021 +0000" } */ 2 | 3 | #include 4 | 5 | unsigned int foo(unsigned int nr_segs) 6 | { 7 | return bio_max_segs(nr_segs); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_split_to_limits.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.0-rc1", "commit": "5a97806f7dc069d9561d9930a2ae108700e222ab", "comment": "blk_queue_split was renamed to bio_split_to_limits", "author": "Christoph Hellwig ", "date": "Wed Jul 27 12:22:55 2022 -0400" } */ 2 | 3 | #include 4 | 5 | struct bio *foo(struct bio *b) 6 | { 7 | return bio_split_to_limits(b); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bio_start_io_acct.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.7-rc3", "commit": "24d69293d9a561645e0b4d78c2fb179827e35f53", "comment": "some new helpers, bio_{start,end}_io_acct were introduced. they are supposed to replace generic_{start,end}_io_acct for bio-based drivers", "author": "Christoph Hellwig ", "date": "Wed May 27 07:24:05 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(void) 6 | { 7 | unsigned long jif; 8 | jif = bio_start_io_acct(NULL); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bioset_init.c: -------------------------------------------------------------------------------- 1 | /* {"version":"4.18", "commit":"917a38c71af82185c39e31589587591fa764fb85", "comment":"With linux v4.18 biosets get embedded", "author":"Kent Overstreet ", "date":"Tue May 8 21:33:51 2018 -0400"} */ 2 | #include 3 | 4 | static struct bio_set foo(void) 5 | { 6 | struct bio_set bio_set; 7 | int err; 8 | 9 | err = bioset_init(&bio_set, 10, 0, 0); 10 | 11 | return bio_set; 12 | } 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.13-rc4", "commit": "b647ad024841d02d67e78716f51f355d8d3e9656", "comment": "5.13 introduces a blk_alloc_disk helper", "author": "Christoph Hellwig ", "date": "Fri May 21 07:50:57 2021 +0200" } */ 2 | 3 | #include 4 | 5 | struct gendisk *foo(int node) 6 | { 7 | return blk_alloc_disk(node); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_alloc_queue_rh.c: -------------------------------------------------------------------------------- 1 | /* { "version": "4.18.0-277.el8" } */ 2 | 3 | #include 4 | 5 | struct request_queue *foo(make_request_fn *fn) 6 | { 7 | return blk_alloc_queue_rh(fn, NUMA_NO_NODE); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_cleanup_disk.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.1-rc3", "commit": "8b9ab62662048a3274361c7e5f64037c2c133e2c", "comment": "blk_cleanup_disk was removed", "author": "Christoph Hellwig ", "date": "Sun Jun 19 08:05:52 2022 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct gendisk *disk) 6 | { 7 | blk_cleanup_disk(disk); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_mode_t.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.5-rc1", "commit": "05bdb9965305bbfdae79b31d22df03d1e2cfcb22", "comment": "block: replace fmode_t with a block-specific type for block open flags", "author": "Christoph Hellwig ", "date": "Thu Jun 8 13:02:55 2023 +0200" } */ 2 | #include 3 | 4 | void foo(blk_mode_t mode) {} 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_opf_t.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.0-rc1", "commit": "342a72a334073f163da924b69c3d3fb4685eb33a", "comment": "blk_opf_t was introduced", "author": "Bart Van Assche ", "date": "Thu Jul 14 11:06:31 2022 -0700" } */ 2 | 3 | #include 4 | 5 | blk_opf_t foo = REQ_OP_WRITE; 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_qc_t_submit_bio.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "c62b37d96b6eb3ec5ae4cbe00db107bf15aebc93", "comment": "Since 5.8 make_request_fn has been replaced by a block_device_operations method called submit_bio", "author": "Christoph Hellwig ", "date": "Wed Jul 1 10:59:43 2020 +0200" } */ 2 | 3 | #include 4 | 5 | blk_qc_t submit(struct bio *bio); 6 | 7 | void foo(struct block_device_operations *ops) 8 | { 9 | ops->submit_bio = submit; 10 | } 11 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_flag_set.c: -------------------------------------------------------------------------------- 1 | /* {"version":"4.17"} */ 2 | #include 3 | 4 | void dummy(struct request_queue *q) 5 | { 6 | blk_queue_flag_set(0, q); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_make_request.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.6-rc7", "commit": "3d745ea5b095a3985129e162900b7e6c22518a9d", "comment": "blk_queue_make_request was removed, users should now pass the make_request function to blk_alloc_queue", "author": "Christoph Hellwig ", "date": "Fri Mar 27 09:30:11 2020 +0100" } */ 2 | 3 | #include 4 | 5 | void foo(void) 6 | { 7 | blk_queue_make_request(NULL, NULL); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_max_write_same_sectors.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.18-rc1", "commit": "73bd66d9c834220579c881a3eb020fd8917075d8", "comment": "REQ_OP_WRITE_SAME was removed, and with it this helper", "author": "Christoph Hellwig ", "date": "Wed Feb 9 09:28:28 2022 +0100" } */ 2 | 3 | #include 4 | 5 | void foo(struct request_queue *q, unsigned int s) 6 | { 7 | blk_queue_max_write_same_sectors(q, s); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_split_bio.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9", "commit": "f695ca3886ce72b027af7aa6040cd420cae2088c", "comment": "In 5.9, blk_queue_split lost its first parameter, since the bio can be derived from the queue", "author": "Christoph Hellwig ", "date": "Wed Jul 1 10:59:39 2020 +0200" } */ 2 | 3 | 4 | #include 5 | 6 | void dummy(struct bio *bio) 7 | { 8 | blk_queue_split(&bio); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_split_q_bio.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void dummy(struct request_queue *q, struct bio *bio) 4 | { 5 | blk_queue_split(q, &bio); 6 | } 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_update_readahead.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9-rc4", "commit": "c2e4cd57cfa1f627b786c764d185fff85fd12be9", "comment": "In v5.9-rc4 blk_queue_update_readahead was introduced", "author": "Christoph Hellwig ", "date": "Thu Sep 24 08:51:34 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct request_queue *q) 6 | { 7 | blk_queue_update_readahead(q); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_blk_queue_write_cache.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void dummy(struct request_queue *q, bool enabled, bool fua) 4 | { 5 | blk_queue_write_cache(q, enabled, fua); 6 | } 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_bvec_kmap_local.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.15-rc1", "commit": "e6e7471706dc42cbe0e01278540c0730138d43e5", "comment": "The bvec_kmap_local helper was added", "author": "Christoph Hellwig ", "date": "Tue Jul 27 07:56:34 2021 +0200" } */ 2 | 3 | #include 4 | 5 | void *foo(struct bio_vec *bvec) 6 | { 7 | return bvec_kmap_local(bvec); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_counted_by.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.4", "commit": "dd06e72e68bcb4070ef211be100d2896e236c8fb", "comment": "add __counted_by macro", "author": "Kees Cook ", "date": "Wed May 17 12:08:44 2023 -0700" } */ 2 | 3 | #include 4 | 5 | struct foo { 6 | int a; 7 | int b[] __counted_by(a); 8 | }; 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_debugfs_change_name.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.13-rc7", "commit": "f7862dfef6612b87b2ad8352c4d73886f09456d6", "comment": "debugfs_chnage_name() replaces debugfs_rename()", "author": "Al Viro ", "date": "Sun Jan 12 08:07:05 2025 +0000" } */ 2 | 3 | #include 4 | 5 | int foo(const char *s); 6 | int foo(const char *s) 7 | { 8 | return debugfs_change_name(NULL, "%s", s); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.17-rc1", "commit": "471aa704db4904f7af5a50019ca3b5b018c0cf62", "comment": "In v5.17-rc1 blk_queue_update_readahead was renamed to disk_update_readahead", "author": "Christoph Hellwig ", "date": "Mon Aug 9 16:17:41 2021 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct gendisk *d) 6 | { 7 | disk_update_readahead(d); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_enum_req_op.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.7-rc3", "commit": "f21508211d2b16e65821abd171378fa6ece126fe", "comment": "enum req_op was added", "author": "Mike Christie ", "date": "Sun Jun 5 14:31:42 2016 -0500" } */ 2 | 3 | /* 4 | * NOTE: this tests for the same commit as have_req_op_write.c, but it still needs a separate test. 5 | * 6 | * 2016-06-05 f2150821: "enum req_op" was introduced 7 | * 2016-10-28 ef295ecf: renamed to "enum req_opf" 8 | * 2022-07-14 ff07a02e: renamed back to "enum req_op" 9 | * 10 | * So: some old kernels have "enum req_op", most have "enum req_opf", and the (current) newest have 11 | * "enum req_op" again; while all of them have the REQ_OP_* flags. 12 | */ 13 | 14 | #include 15 | 16 | enum req_op dummy = REQ_OP_WRITE; 17 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_fallthrough.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.4-rc3", "commit": "294f69e662d1570703e9b56e95be37a9fd3afba5", "comment": "The fallthrough pseudo-statement was added in v5.4-rc3", "author": "Joe Perches ", "date": "Sat Oct 5 09:46:42 2019 -0700" } */ 2 | 3 | #include 4 | 5 | int foo(int i); /* Avoid warning about missing function prototype */ 6 | int foo(int i) 7 | { 8 | int y = 0; 9 | 10 | switch(i) { 11 | case 0: 12 | fallthrough; 13 | case 1: 14 | y = i; 15 | } 16 | 17 | return y; 18 | } 19 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_fs_dax_get_by_bdev.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.13-rc7", "commit": "78f35473508118df5ea04b9515ac3f1aaec0a980", "comment": "fs_dax_get_by_bdev was introduced", "author": "Dan Williams ", "date": "Wed Aug 30 09:16:38 2017 -0700" } */ 2 | 3 | #include 4 | #include 5 | 6 | void *x = fs_dax_get_by_bdev; 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_generic_start_io_acct_q_rw_sect_part.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Introduced by mainline commit d62e26b3ffd2, available since v4.14 */ 4 | void foo(struct request_queue *q) 5 | { 6 | generic_start_io_acct(q, WRITE, 0, (struct hd_struct *) NULL); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_generic_start_io_acct_rw_sect_part.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Introduced by mainline commit 394ffa503b, available since v3.19 */ 4 | 5 | void foo(void) 6 | { 7 | generic_start_io_acct(WRITE, 0, (struct hd_struct *) NULL); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_genl_info_userhdr.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.6-rc1", "commit": "bffcc6882a1bb2be8c9420184966f4c2c822078e", "comment": "genetlink: remove userhdr from struct genl_info", "author": "Jakub Kicinski ", "date": "Mon Aug 14 14:47:16 2023 -0700" } */ 2 | #include 3 | 4 | void *foo(struct genl_info *info) 5 | { 6 | return genl_info_userhdr(info); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_get_random_u32.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.11-rc2", "commit": "c440408cf6901eeb2c09563397e24a9097907078", "comment": "get_random_int was renamed to get_random_u32", "author": "Jason A. Donenfeld ", "date": "Sun Jan 22 16:34:08 2017 +0100" } */ 2 | 3 | #include 4 | 5 | u32 foo(void) 6 | { 7 | return get_random_u32(); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_get_random_u32_below.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.1-rc6", "commit": "7f576b2593a978451416424e75f69ad1e3ae4efe", "comment": "get_random_u32_below was added", "author": "Jason A. Donenfeld ", "date": "Wed Oct 19 23:19:35 2022 -0600" } */ 2 | 3 | #include 4 | 5 | u32 foo(u32 i) 6 | { 7 | return get_random_u32_below(i); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_hd_struct.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.10-rc5", "commit": "0d02129e76edf91cf04fabf1efbc3a9a1f1d729a", "comment": "struct hd_struct was merged into struct block_device", "author": "Christoph Hellwig ", "date": "Fri Nov 27 16:43:51 2020 +0100" } */ 2 | 3 | #include 4 | 5 | struct hd_struct hd; 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_kmap_local_page.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void dummy(struct page *page) 4 | { 5 | void *addr = kmap_local_page(page); 6 | 7 | kunmap_local(addr); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_kvfree_rcu.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9-rc1", "commit": "1835f475e3518ade61e25a57572c78b953778656", "comment": "The single-argument version of kvfree_rcu was added", "author": "Uladzislau Rezki (Sony) ", "date": "Mon May 25 23:47:59 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(void *ptr) 6 | { 7 | kvfree_rcu(ptr); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_kvfree_rcu_mightsleep.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.3-rc1", "commit": "608723c41cd951fb32ade2f8371e61c270816175", "comment": "kvfree_rcu_mightsleep was added", "author": "Uladzislau Rezki (Sony) ", "date": "Wed Feb 1 16:08:07 2023 +0100" } */ 2 | 3 | #include 4 | 5 | void foo(void *ptr) 6 | { 7 | kvfree_rcu_mightsleep(ptr); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_linux_unaligned_h.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.12-rc2", "commit": "5f60d5f6bbc12e782fac78110b0ee62698f3b576", "comment": "move asm/unaligned.h to linux/unaligned.h", "author": "Al Viro ", "date": "Tue Oct 1 15:35:57 2024 -0400" } */ 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_list_is_first.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.1-rc1", "commit": "70b44595eafe9c7c235f076d653a268ca1ab9fdb", "comment": "list_is_first() was moved to list.h", "author": "Mel Gorman ", "date": "Tue Mar 5 15:44:54 2019 -0800" } */ 2 | #include 3 | 4 | bool dummy(const struct list_head *list, const struct list_head *head) 5 | { 6 | return list_is_first(list, head); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_lookup_user_key.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.0-rc1", "commit": "76ef5e17252789da79db78341851922af0c16181", "comment": "keys: Export lookup_user_key to external users", "author": "Dave Jiang ", "date": "Tue Dec 4 10:31:27 2018 -0800" } */ 2 | #include 3 | 4 | key_ref_t foo(void) 5 | { 6 | return lookup_user_key(0, 0, 0); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_max_send_recv_sge.c: -------------------------------------------------------------------------------- 1 | /* {"version":"4.18", "commit":"33023fb85a42b53bf778bc025f9667b582282be4"} */ 2 | #include 3 | 4 | void foo(struct ib_device_attr *dev_attr) 5 | { 6 | dev_attr->max_send_sge = 1; 7 | dev_attr->max_recv_sge = 1; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_mempool_is_saturated.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.1-rc3", "commit": "6e4068a11413b96687a03c39814539e202de294b", "comment": "mempool: introduce mempool_is_saturated", "author": "Pavel Begunkov ", "date": "Wed Nov 2 15:18:19 2022 +0000" } */ 2 | 3 | #include 4 | 5 | bool foo(mempool_t *pool) 6 | { 7 | return mempool_is_saturated(pool); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_nla_nest_start_noflag.c: -------------------------------------------------------------------------------- 1 | /* {"version": "5.1-rc7", "commit": "ae0be8de9a53cda3505865c11826d8ff0640237c", "comment": "nla_nest_start was renamed to _noflag, and the original version became a wrapper adding a flag", "author": "Michal Kubecek ", "date": "Fri Apr 26 11:13:06 2019 +0200"} */ 2 | #include 3 | 4 | static struct nlattr *dummy(struct sk_buff *skb, int attrtype) 5 | { 6 | return nla_nest_start_noflag(skb, attrtype); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_nla_parse_deprecated.c: -------------------------------------------------------------------------------- 1 | /* {"version": "5.1-rc7", "commit": "8cb081746c031fb164089322e2336a0bf5b3070c", "comment": "In order to allow for stricter checking in the future, nla_parse_* as we use it is now deprecated", "author": "Johannes Berg ", "date": "Fri Apr 26 14:07:28 2019 +0200"} */ 2 | #include 3 | 4 | /* NOTE: this will have to be changed when _deprecated eventually goes away. 5 | * Hopefully by then we won't be using the deprecated version anymore... */ 6 | 7 | int dummy(struct nlattr **tb, int maxtype, const struct nlattr *head, int len, 8 | const struct nla_policy *policy, struct netlink_ext_ack *extack) 9 | { 10 | return nla_parse_deprecated(tb, maxtype, head, len, policy, extack); 11 | } 12 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_nla_strscpy.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.10-rc4", "commit": "872f690341948b502c93318f806d821c56772c42", "comment": "nla_strlcpy was renamed to nla_strscpy", "author": "Francis Laniel ", "date": "Sun Nov 15 18:08:06 2020 +0100" } */ 2 | 3 | #include 4 | 5 | ssize_t foo(char *dst, const struct nlattr *nla, size_t dstsize) 6 | { 7 | return nla_strscpy(dst, nla, dstsize); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_part_stat_h.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.6-rc6", "commit": "c6a564ffadc9105880329710164ee493f0de103c", "comment": "The part_stat* helpers were moved to a new header", "author": "Christoph Hellwig ", "date": "Wed Mar 25 16:48:42 2020 +0100" } */ 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_part_stat_read_accum.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.18-rc5", "commit": "59767fbd49d794b4499d30b314df6c0d4aca584b", "comment": "part_stat_read_accum was added to read all STAT_* field entries", "author": "Michael Callahan ", "date": "Wed Jul 18 04:47:37 2018 -0700" } */ 2 | 3 | #include 4 | 5 | #ifndef part_stat_read_accum 6 | # error "Not defined" 7 | #endif 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_proc_create_single.c: -------------------------------------------------------------------------------- 1 | /* {"version":"4.17", "commit":"3f3942aca6da351a12543aa776467791b63b3a78", "comment":"With linux v4.17 the timer proc interface got simplified", "author":"Christoph Hellwig ", "date":"Tue May 15 15:57:23 2018 +0200"} */ 2 | #include 3 | 4 | static int foo_seq_show(struct seq_file *seq, void *v) 5 | { 6 | return 0; 7 | } 8 | 9 | struct proc_dir_entry *foo(void) 10 | { 11 | struct proc_dir_entry *pde; 12 | 13 | pde = proc_create_single("foo", S_IFREG | S_IRUGO , NULL, 14 | foo_seq_show); 15 | 16 | return pde; 17 | } 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_queue_flag_discard.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.19-rc1", "commit": "70200574cc229f6ba038259e8142af2aa09e6976", "comment": "QUEUE_FLAG_DISCARD was removed", "author": "Christoph Hellwig ", "date": "Fri Apr 15 06:52:55 2022 +0200" } */ 2 | 3 | #include 4 | 5 | int foo = QUEUE_FLAG_DISCARD; 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_queue_flag_stable_writes.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9-rc4", "commit": "1cb039f3dc1619eb795c54aad0a98fdb379b4237", "comment": "BDI_CAP_STALBE_WRITES as a backing_dev_info flag is gone, it is now the queue flag QUEUE_FLAG_STABLE_WRITES", "author": "Christoph Hellwig ", "date": "Thu Sep 24 08:51:38 2020 +0200" } */ 2 | 3 | #include 4 | 5 | int foo(void) 6 | { 7 | return QUEUE_FLAG_STABLE_WRITES; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_queue_limits_start_update.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.9-rc1", "commit": "d690cb8ae14bd377d422b7905b6959c7e7a45b95", "comment": "block: add an API to atomically update queue limits", "author": "Christoph Hellwig ", "date": "Tue Feb 13 08:34:14 2024 +0100" } */ 2 | 3 | #include 4 | 5 | static struct queue_limits foo(struct request_queue *q) 6 | { 7 | return queue_limits_start_update(q); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_rb_declare_callbacks_max.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct s { 4 | struct rb_node rb; 5 | int x; 6 | }; 7 | 8 | int f(struct s*); 9 | 10 | RB_DECLARE_CALLBACKS_MAX(static, a, struct s, rb, int, x, f); 11 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_req_op_write.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.7-rc3", "commit": "f21508211d2b16e65821abd171378fa6ece126fe", "comment": "REQ_OPs were introduced", "author": "Mike Christie ", "date": "Sun Jun 5 14:31:42 2016 -0500" } */ 2 | #include 3 | 4 | int dummy = REQ_OP_WRITE; 5 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_revalidate_disk_size.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9-rc4", "commit": "659e56ba864d37b7ee0a49cd432205b2a5ca815e", "comment": "The revalidate_disk_size helper was added in v5.9-rc4", "author": "Christoph Hellwig ", "date": "Tue Sep 1 17:57:43 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct gendisk *disk) 6 | { 7 | revalidate_disk_size(disk, false); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sane_test_environment.c: -------------------------------------------------------------------------------- 1 | /* Check if our test cases are test-compiled against a sane environment. 2 | * For now, just include some header files we expect to be always present. 3 | */ 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sane_test_environment_always_fail.c: -------------------------------------------------------------------------------- 1 | /* Check if our test cases are test-compiled against a sane environment. 2 | * This checks that an expected test failure actually fails 3 | * by trying to includ some non-existant file. 4 | */ 5 | #include 6 | #error "INTENTIONAL BUILD FAILURE" 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sched_set_fifo.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8-rc2", "commit": "7318d4cc14c8c8a5dde2b0b72ea50fd2545f0b7a", "comment": "sched_set_fifo was introduced, replacing sched_setscheduler and friends", "author": "Peter Zijlstra ", "date": "Tue Apr 21 12:09:13 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct task_struct *p) 6 | { 7 | sched_set_fifo(p); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sendpage.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.5-rc1", "commit": "dc97391e661009eab46783030d2404c9b6e6f2e7", "comment": "sock: Remove ->sendpage*() in favour of sendmsg(MSG_SPLICE_PAGES)", "author": "David Howells ", "date": "Fri Jun 23 23:55:12 2023 +0100" } */ 2 | #include 3 | 4 | int foo(struct socket *socket, struct page *page) 5 | { 6 | return socket->ops->sendpage(socket, page, 0, 0, 0); 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sendpage_ok.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9-rc7", "commit": "c381b07941adc2274ce552daf86c94701c5e265a", "comment": "In v5.9-rc7 sendpage_ok() was introduced", "author": "Coly Li ", "date": "Fri Oct 2 16:27:28 2020 +0800" } */ 2 | 3 | #include 4 | 5 | void foo(struct page *page) 6 | { 7 | sendpage_ok(page); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_set_capacity_and_notify.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.10-rc5", "commit": "449f4ec9892ebc2f37a7eae6d97db2cf7c65e09a", "comment": "New (as far as DRBD is concerned) helper set_capacity_and_notify", "author": "Christoph Hellwig ", "date": "Mon Nov 16 15:56:56 2020 +0100" } */ 2 | 3 | #include 4 | 5 | bool foo(struct gendisk *disk, sector_t size) 6 | { 7 | return set_capacity_and_notify(disk, size); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sk_use_task_frag.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.2-rc1", "commit": "fb87bd47516d9a26b6d549231aa743b20fd4a569", "comment": "the sk_use_task_frag field was added", "author": "Guillaume Nault ", "date": "Fri Dec 16 07:45:26 2022 -0500" } */ 2 | 3 | #include 4 | 5 | bool foo(struct sock *s) 6 | { 7 | return s->sk_use_task_frag; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_sock_set_keepalive.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "ce3d9544cecacd40389c399d2b7ca31acc533b70", "comment": "kernel_setsockopt with SO_KEEPALIVE was replaced by sock_set_keepalive", "author": "Christoph Hellwig ", "date": "Thu May 28 07:12:15 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct socket *sock) 6 | { 7 | sock_set_keepalive(sock->sk); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_struct_size.c: -------------------------------------------------------------------------------- 1 | /* {"version":"4.17", "commit": "610b15c50e86eb1e4b77274fabcaea29ac72d6a8", "comment": "Since Linux 4.17, struct_size should be used to get the size of a struct with a trailing array", "author": "Kees Cook ", "date": "Mon May 7 16:47:02 2018 -0700" } */ 2 | #include 3 | #include 4 | 5 | struct x { 6 | int some; 7 | int values[]; 8 | }; 9 | 10 | void foo(void) 11 | { 12 | struct x *p; 13 | struct_size(p, values, 1); 14 | } 15 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_submit_bio_noacct.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8-rc2", "commit": "ed00aabd5eb9fb44d6aff1173234a2e911b9fead", "comment": "Since 5.8 generic_make_request has been renamed to submit_bio_noacct", "author": "Christoph Hellwig ", "date": "Wed Jul 1 10:59:44 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct bio *bio) 6 | { 7 | submit_bio_noacct(bio); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tasklet_setup.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.9-rc1", "commit": "12cc923f1ccc1df467e046b02a72c2b3b321b6a2", "comment": "tasklet: Introduce new initialization API", "author": "Romain Perier ", "date": "Sun Sep 29 18:30:13 2019 +0200" } */ 2 | #include 3 | 4 | void callback(struct tasklet_struct *t) 5 | { 6 | } 7 | 8 | void foo(void) 9 | { 10 | struct tasklet_struct t; 11 | 12 | tasklet_setup(&t, callback); 13 | } 14 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tcp_sock_set_cork.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "db10538a4b997a77a1fd561adaaa58afc7dcfa2f", "comment": "In 5.8 kernel_setsockopt with TCP_CORK was replaced by tcp_sock_set_cork", "author": "Christoph Hellwig ", "date": "Thu May 28 07:12:18 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct socket *sock) 6 | { 7 | tcp_sock_set_cork(sock->sk, true); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tcp_sock_set_keepcnt.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "480aeb9639d6a077c611b303a22f9b1e5937d081", "comment": "tcp: add tcp_sock_set_keepcnt", "author": "Christoph Hellwig ", "date": "Thu May 28 07:12:25 2020 +0200" } */ 2 | 3 | /* ...and there were the commits: 4 | d41ecaac903c9f4658a71d4e7a708673cfb5abba tcp: add tcp_sock_set_keepintvl 5 | ...seconds later. 6 | */ 7 | 8 | #include 9 | 10 | void foo(struct socket *sock) 11 | { 12 | tcp_sock_set_keepcnt(sock->sk, 0); 13 | } 14 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tcp_sock_set_keepidle.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "71c48eb81c9ecb6fed49dc33e7c9b621fdcb7bf8", "comment": "tcp: add tcp_sock_set_keepidle", "author": "Christoph Hellwig ", "date": "Thu May 28 07:12:23 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct socket *sock) 6 | { 7 | tcp_sock_set_keepidle(sock->sk, 0); 8 | } 9 | 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tcp_sock_set_nodelay.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "12abc5ee7873a085cc280240822b8ac53c86fecd", "comment": "In 5.8 kernel_setsockopt with TCP_NODELAY was replaced by tcp_sock_set_nodelay", "author": "Christoph Hellwig ", "date": "Thu May 28 07:12:19 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct socket *sock) 6 | { 7 | tcp_sock_set_nodelay(sock->sk); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tcp_sock_set_quickack.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.8", "commit": "ddd061b8daed3ce0c01109a69c9a2a9f9669f01a", "comment": "In 5.8 kernel_setsockopt with TCP_QUICKACK was replaced by tcp_sock_set_quickack", "author": "Christoph Hellwig ", "date": "Thu May 28 07:12:20 2020 +0200" } */ 2 | 3 | #include 4 | 5 | void foo(struct socket *sock) 6 | { 7 | tcp_sock_set_quickack(sock->sk, 2); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_timer_delete.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.15", "commit": "8fa7292fee5c5240402371ea89ab285ec856c916", "comment": "timer_delete introduced", "author": "Thomas Gleixner ", "date": "Sat Apr 5 10:17:26 2025 +0200" } */ 2 | 3 | #include 4 | 5 | int foo(struct timer_list *t) 6 | { 7 | return timer_delete(t); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_timer_shutdown.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.2-rc1", "commit": "f571faf6e443b6011ccb585d57866177af1f643c", "comment": "timer_shutdown was added", "author": "Thomas Gleixner ", "date": "Wed Nov 23 21:18:53 2022 +0100" } */ 2 | 3 | #include 4 | 5 | int foo(struct timer_list *t) 6 | { 7 | return timer_shutdown(t); 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tls_get_record_type.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.6-rc1", "commit": "39d0e38dcced8d4da92cd11f3ff618bacc42d8a9", "comment": "net/handshake: Add helpers for parsing incoming TLS Alerts", "author": "Chuck Lever ", "date": "Thu Jul 27 13:37:10 2023 -0400" } */ 2 | #include 3 | #include 4 | 5 | #if !IS_ENABLED(CONFIG_NET_HANDSHAKE) 6 | # error "TLS Handshake module not enabled" 7 | #endif 8 | 9 | u8 foo(struct sock *sk, struct cmsghdr *cmsg) 10 | { 11 | return tls_get_record_type(sk, cmsg); 12 | } 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_tls_tx_rx.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v4.17-rc1", "commit": "c46234ebb4d1eee5e09819f49169e51cfc6eb909", "comment": "tls: RX path for ktls", "author": "Dave Watson ", "date": "Thu Mar 22 10:10:35 2018 -0700" } */ 2 | #include 3 | #include 4 | 5 | #if !IS_ENABLED(CONFIG_TLS) 6 | # error "TLS module not enabled" 7 | #endif 8 | 9 | int foo(void) 10 | { 11 | return TLS_TX; 12 | } 13 | 14 | int bar(void) 15 | { 16 | return TLS_RX; 17 | } 18 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/have_void_submit_bio.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.15-rc7", "commit": "3e08773c3841e9db7a520908cc2b136a77d275ff", "comment": "submit_bio changed from a blk_qc_t return value to void", "author": "Christoph Hellwig ", "date": "Tue Oct 12 13:12:24 2021 +0200" } */ 2 | 3 | #include 4 | 5 | void submit(struct bio *bio); 6 | 7 | void foo(struct block_device_operations *ops) 8 | { 9 | ops->submit_bio = submit; 10 | } 11 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/ib_device_has_ops.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.0", "commit": "3023a1e93656c02b8d6a3a46e712b815843fa514", "comment": "ib_device ops were moved to a separate struct", "author": "Kamal Heib ", "date": "Mon Dec 10 21:09:48 2018 +0200" } */ 2 | #include 3 | 4 | void *dummy(struct ib_device *device) 5 | { 6 | return (void *) &device->ops; 7 | } 8 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/ib_post_send_const_params.c: -------------------------------------------------------------------------------- 1 | /* {"version": "4.19", "commit": "d34ac5cd3a73aacd11009c4fc3ba15d7ea62c411", "comment": "RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const", "author": "Bart Van Assche ", "date": "Wed Jul 18 09:25:32 2018 -0700" } */ 2 | #include 3 | 4 | #ifndef __same_type 5 | # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 6 | #endif 7 | 8 | int ib_post_send_before_4_19(struct ib_qp *qp, 9 | struct ib_send_wr *send_wr, 10 | struct ib_send_wr **bad_send_wr); 11 | 12 | int ib_post_send_after_4_19(struct ib_qp *qp, 13 | const struct ib_send_wr *send_wr, 14 | const struct ib_send_wr **bad_send_wr); 15 | 16 | int foo(void) 17 | { 18 | struct ib_qp *qp; 19 | const struct ib_send_wr *send_wr; 20 | const struct ib_send_wr **bad_send_wr; 21 | 22 | BUILD_BUG_ON(!(__same_type(ib_post_send_after_4_19, ib_post_send))); 23 | return ib_post_send(qp, send_wr, bad_send_wr); 24 | } 25 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/need_drbd_wrappers.c: -------------------------------------------------------------------------------- 1 | /* Cheap heuristic: just assume every kernel below 5.0 needs drbd_wrappers.h. 2 | * This is obviously not really right, but it doesn't hurt if we include it on 3 | * a kernel that does not need it. 4 | * The only thing we care about: we don't want (and don't need) drbd_wrappers.h 5 | * on "modern" kernels. 6 | */ 7 | 8 | #include 9 | 10 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0) 11 | #error drbd_wrappers.h not required 12 | #endif 13 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/need_make_request_recursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) 4 | # error Don't need recursion 5 | #endif 6 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/need_recalc_sigpending.c: -------------------------------------------------------------------------------- 1 | /* Tests show older kernels sometimes fails to clear TIF_SIGPENDING 2 | * when repeatedly calling drbd_open() when the first invocation 3 | * returned -ERESTARTSYS because of a pending signal. */ 4 | 5 | #include 6 | 7 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0) 8 | #error No need to call recalc sigpending in drbd_open() 9 | #endif 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/part_stat_read_takes_block_device.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.10-rc5", "commit": "8446fe9255be821cb38ffd306d7e8edc4b9ea662", "comment": "partition lookup was changed to expect a struct block_device", "author": "Christoph Hellwig ", "date": "Tue Nov 24 09:36:54 2020 +0100" } */ 2 | 3 | #include 4 | #include 5 | 6 | int foo(struct block_device *d) 7 | { 8 | return (int)part_stat_read(d, sectors[0]); 9 | } 10 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/queue_limits_has_features.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.10", "commit": "1122c0c1cc71f740fa4d5f14f239194e06a1d5e7", "comment": "features field was introduced", "author": "Christoph Hellwig ", "date": "Mon Jun 17 08:04:40 2024 +0200" } */ 2 | 3 | #include 4 | 5 | unsigned int foo(struct queue_limits lim) 6 | { 7 | return lim.features; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/queue_limits_has_max_hw_discard_sectors.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.9-rc1", "commit": "4f563a64732dabb2677c7d1232a8f714a18b41b3", "comment": "lim.max_hw_discard_sectors was added", "author": "Christoph Hellwig ", "date": "Tue Feb 13 08:34:16 2024 +0100" } */ 2 | 3 | #include 4 | 5 | int foo(struct queue_limits *lim) 6 | { 7 | return lim->max_hw_discard_sectors; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/queue_limits_has_max_hw_zone_append_sectors.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v6.13-rc1", "commit": "559218d43ec9dde3d2847c7aa127e88d6ab1c9ed", "comment": "max_hw_zone_append_sectors introduced", "author": "Christoph Hellwig ", "date": "Fri Nov 8 16:46:51 2024 +0100" } */ 2 | 3 | #include 4 | 5 | int foo(struct queue_limits *lim) 6 | { 7 | return lim->max_hw_zone_append_sectors; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/queue_limits_has_max_zone_append_sectors.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.7-rc3", "commit": "0512a75b98f847c2e9a4b664013424e603e202f7", "comment": "max_zone_append_sectors introduced", "author": "Keith Busch ", "date": "Tue May 12 17:55:47 2020 +0900" } */ 2 | 3 | #include 4 | 5 | int foo(struct queue_limits *lim) 6 | { 7 | return lim->max_zone_append_sectors; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/rdma_reject_has_reason_arg.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void foo(void) 4 | { 5 | rdma_reject(NULL, NULL, 0, 0); 6 | } 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/sock_ops_returns_addr_len.c: -------------------------------------------------------------------------------- 1 | /* {"version":"4.17", "commit":"9b2c45d479d0"} */ 2 | #include 3 | int always_getpeername(struct socket *sock, struct sockaddr *addr) 4 | { 5 | return sock->ops->getname(sock, addr, 2); 6 | } 7 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/tests/struct_gendisk_has_backing_dev_info.c: -------------------------------------------------------------------------------- 1 | /* { "version": "v5.15-rc1", "commit": "21cf866145047f8bfecb38ec8d2fed64464c074f", "comment": "The backing_dev_info was moved from request_queue to backing_dev_info", "author": "Christoph Hellwig ", "date": "Wed Jul 1 11:06:22 2020 +0200" } */ 2 | 3 | #include 4 | 5 | struct backing_dev_info *foo(struct gendisk *d) 6 | { 7 | return d->bdi; 8 | } 9 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/uapi/linux/handshake.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ 2 | /* Do not edit directly, auto-generated from: */ 3 | /* Documentation/netlink/specs/handshake.yaml */ 4 | /* YNL-GEN uapi header */ 5 | 6 | #ifndef _UAPI_LINUX_HANDSHAKE_H 7 | #define _UAPI_LINUX_HANDSHAKE_H 8 | 9 | #define HANDSHAKE_FAMILY_NAME "handshake" 10 | #define HANDSHAKE_FAMILY_VERSION 1 11 | 12 | enum handshake_handler_class { 13 | HANDSHAKE_HANDLER_CLASS_NONE, 14 | HANDSHAKE_HANDLER_CLASS_TLSHD, 15 | HANDSHAKE_HANDLER_CLASS_MAX, 16 | }; 17 | 18 | enum handshake_msg_type { 19 | HANDSHAKE_MSG_TYPE_UNSPEC, 20 | HANDSHAKE_MSG_TYPE_CLIENTHELLO, 21 | HANDSHAKE_MSG_TYPE_SERVERHELLO, 22 | }; 23 | 24 | enum handshake_auth { 25 | HANDSHAKE_AUTH_UNSPEC, 26 | HANDSHAKE_AUTH_UNAUTH, 27 | HANDSHAKE_AUTH_PSK, 28 | HANDSHAKE_AUTH_X509, 29 | }; 30 | 31 | enum { 32 | HANDSHAKE_A_X509_CERT = 1, 33 | HANDSHAKE_A_X509_PRIVKEY, 34 | 35 | __HANDSHAKE_A_X509_MAX, 36 | HANDSHAKE_A_X509_MAX = (__HANDSHAKE_A_X509_MAX - 1) 37 | }; 38 | 39 | enum { 40 | HANDSHAKE_A_ACCEPT_SOCKFD = 1, 41 | HANDSHAKE_A_ACCEPT_HANDLER_CLASS, 42 | HANDSHAKE_A_ACCEPT_MESSAGE_TYPE, 43 | HANDSHAKE_A_ACCEPT_TIMEOUT, 44 | HANDSHAKE_A_ACCEPT_AUTH_MODE, 45 | HANDSHAKE_A_ACCEPT_PEER_IDENTITY, 46 | HANDSHAKE_A_ACCEPT_CERTIFICATE, 47 | HANDSHAKE_A_ACCEPT_PEERNAME, 48 | 49 | __HANDSHAKE_A_ACCEPT_MAX, 50 | HANDSHAKE_A_ACCEPT_MAX = (__HANDSHAKE_A_ACCEPT_MAX - 1) 51 | }; 52 | 53 | enum { 54 | HANDSHAKE_A_DONE_STATUS = 1, 55 | HANDSHAKE_A_DONE_SOCKFD, 56 | HANDSHAKE_A_DONE_REMOTE_AUTH, 57 | 58 | __HANDSHAKE_A_DONE_MAX, 59 | HANDSHAKE_A_DONE_MAX = (__HANDSHAKE_A_DONE_MAX - 1) 60 | }; 61 | 62 | enum { 63 | HANDSHAKE_CMD_READY = 1, 64 | HANDSHAKE_CMD_ACCEPT, 65 | HANDSHAKE_CMD_DONE, 66 | 67 | __HANDSHAKE_CMD_MAX, 68 | HANDSHAKE_CMD_MAX = (__HANDSHAKE_CMD_MAX - 1) 69 | }; 70 | 71 | #define HANDSHAKE_MCGRP_NONE "none" 72 | #define HANDSHAKE_MCGRP_TLSHD "tlshd" 73 | 74 | #endif /* _UAPI_LINUX_HANDSHAKE_H */ 75 | -------------------------------------------------------------------------------- /drbd/drbd-kernel-compat/uapi/linux/sched/types.h: -------------------------------------------------------------------------------- 1 | /* Just an empty file. */ 2 | -------------------------------------------------------------------------------- /drbd/drbd_dax_pmem.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #ifndef DRBD_DAX_H 3 | #define DRBD_DAX_H 4 | 5 | #include 6 | 7 | #if IS_ENABLED(CONFIG_DEV_DAX_PMEM) && !defined(DAX_PMEM_IS_INCOMPLETE) 8 | 9 | int drbd_dax_open(struct drbd_backing_dev *bdev); 10 | void drbd_dax_close(struct drbd_backing_dev *bdev); 11 | int drbd_dax_map(struct drbd_backing_dev *bdev); 12 | void drbd_dax_al_update(struct drbd_device *device, struct lc_element *al_ext); 13 | void drbd_dax_al_begin_io_commit(struct drbd_device *device); 14 | int drbd_dax_al_initialize(struct drbd_device *device); 15 | void *drbd_dax_bitmap(struct drbd_device *device, unsigned long want); 16 | 17 | static inline bool drbd_md_dax_active(struct drbd_backing_dev *bdev) 18 | { 19 | return bdev->dax_dev != NULL; 20 | } 21 | static inline struct meta_data_on_disk_9 *drbd_dax_md_addr(struct drbd_backing_dev *bdev) 22 | { 23 | return bdev->md_on_pmem; 24 | } 25 | #else 26 | 27 | #define drbd_dax_open(B) do { } while (0) 28 | #define drbd_dax_close(B) do { } while (0) 29 | #define drbd_dax_map(B) (-ENOTSUPP) 30 | #define drbd_dax_al_begin_io_commit(D) do { } while (0) 31 | #define drbd_dax_al_initialize(D) (-EIO) 32 | #define drbd_dax_bitmap(D, L) (NULL) 33 | #define drbd_md_dax_active(B) (false) 34 | #define drbd_dax_md_addr(B) (NULL) 35 | 36 | #define arch_wb_cache_pmem(A, L) do { } while (0) 37 | 38 | #endif /* IS_ENABLED(CONFIG_DEV_DAX_PMEM) */ 39 | 40 | #endif /* DRBD_DAX_H */ 41 | -------------------------------------------------------------------------------- /drbd/drbd_debugfs.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #include 3 | #include 4 | #include 5 | 6 | #include "drbd_int.h" 7 | 8 | #ifdef CONFIG_DEBUG_FS 9 | void __init drbd_debugfs_init(void); 10 | void drbd_debugfs_cleanup(void); 11 | 12 | void drbd_debugfs_resource_add(struct drbd_resource *resource); 13 | void drbd_debugfs_resource_cleanup(struct drbd_resource *resource); 14 | void drbd_debugfs_resource_rename(struct drbd_resource *resource, const char *new_name); 15 | 16 | void drbd_debugfs_connection_add(struct drbd_connection *connection); 17 | void drbd_debugfs_connection_cleanup(struct drbd_connection *connection); 18 | 19 | void drbd_debugfs_device_add(struct drbd_device *device); 20 | void drbd_debugfs_device_cleanup(struct drbd_device *device); 21 | 22 | void drbd_debugfs_peer_device_add(struct drbd_peer_device *peer_device); 23 | void drbd_debugfs_peer_device_cleanup(struct drbd_peer_device *peer_device); 24 | #else 25 | 26 | static inline void __init drbd_debugfs_init(void) { } 27 | static inline void drbd_debugfs_cleanup(void) { } 28 | 29 | static inline void drbd_debugfs_resource_add(struct drbd_resource *resource) { } 30 | static inline void drbd_debugfs_resource_cleanup(struct drbd_resource *resource) { } 31 | static inline void drbd_debugfs_resource_rename(struct drbd_resource *resource, const char *new_name) { } 32 | 33 | static inline void drbd_debugfs_connection_add(struct drbd_connection *connection) { } 34 | static inline void drbd_debugfs_connection_cleanup(struct drbd_connection *connection) { } 35 | 36 | static inline void drbd_debugfs_device_add(struct drbd_device *device) { } 37 | static inline void drbd_debugfs_device_cleanup(struct drbd_device *device) { } 38 | 39 | static inline void drbd_debugfs_peer_device_add(struct drbd_peer_device *peer_device) { } 40 | static inline void drbd_debugfs_peer_device_cleanup(struct drbd_peer_device *peer_device) { } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /drbd/drbd_kref_debug.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #ifndef DRBD_KREF_DEBUG_H 3 | #define DRBD_KREF_DEBUG_H 4 | 5 | #include 6 | 7 | #ifdef CONFIG_KREF_DEBUG 8 | extern struct kref_debug_class kref_class_resource; 9 | extern struct kref_debug_class kref_class_connection; 10 | extern struct kref_debug_class kref_class_device; 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /drbd/drbd_nla.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | #include 3 | #include 4 | #include 5 | #include "drbd_nla.h" 6 | 7 | static int drbd_nla_check_mandatory(int maxtype, struct nlattr *nla) 8 | { 9 | struct nlattr *head = nla_data(nla); 10 | int len = nla_len(nla); 11 | int rem; 12 | 13 | /* 14 | * validate_nla (called from nla_parse_nested) ignores attributes 15 | * beyond maxtype, and does not understand the DRBD_GENLA_F_MANDATORY flag. 16 | * In order to have it validate attributes with the DRBD_GENLA_F_MANDATORY 17 | * flag set also, check and remove that flag before calling 18 | * nla_parse_nested. 19 | */ 20 | 21 | nla_for_each_attr(nla, head, len, rem) { 22 | if (nla->nla_type & DRBD_GENLA_F_MANDATORY) { 23 | nla->nla_type &= ~DRBD_GENLA_F_MANDATORY; 24 | if (nla_type(nla) > maxtype) 25 | return -EOPNOTSUPP; 26 | } 27 | } 28 | return 0; 29 | } 30 | 31 | int drbd_nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, 32 | const struct nla_policy *policy) 33 | { 34 | int err; 35 | 36 | err = drbd_nla_check_mandatory(maxtype, nla); 37 | if (!err) 38 | err = nla_parse_nested_deprecated(tb, maxtype, nla, policy, 39 | NULL); 40 | 41 | return err; 42 | } 43 | 44 | struct nlattr *drbd_nla_find_nested(int maxtype, struct nlattr *nla, int attrtype) 45 | { 46 | int err; 47 | /* 48 | * If any nested attribute has the DRBD_GENLA_F_MANDATORY flag set and 49 | * we don't know about that attribute, reject all the nested 50 | * attributes. 51 | */ 52 | err = drbd_nla_check_mandatory(maxtype, nla); 53 | if (err) 54 | return ERR_PTR(err); 55 | return nla_find_nested(nla, attrtype); 56 | } 57 | -------------------------------------------------------------------------------- /drbd/drbd_nla.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #ifndef __DRBD_NLA_H 3 | #define __DRBD_NLA_H 4 | 5 | int drbd_nla_parse_nested(struct nlattr *tb[], int maxtype, 6 | struct nlattr *nla, const struct nla_policy *policy); 7 | struct nlattr *drbd_nla_find_nested(int maxtype, struct nlattr *nla, 8 | int attrtype); 9 | 10 | #endif /* __DRBD_NLA_H */ 11 | -------------------------------------------------------------------------------- /drbd/drbd_proc.c: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-2.0-only 2 | /* 3 | drbd_proc.c 4 | 5 | This file is part of DRBD by Philipp Reisner and Lars Ellenberg. 6 | 7 | Copyright (C) 2001-2008, LINBIT Information Technologies GmbH. 8 | Copyright (C) 1999-2008, Philipp Reisner . 9 | Copyright (C) 2002-2008, Lars Ellenberg . 10 | 11 | 12 | */ 13 | 14 | #include 15 | #include 16 | #include "drbd_int.h" 17 | #include "drbd_transport.h" 18 | 19 | struct proc_dir_entry *drbd_proc; 20 | 21 | int drbd_seq_show(struct seq_file *seq, void *v) 22 | { 23 | seq_printf(seq, "version: " REL_VERSION " (api:%d/proto:%d-%d)\n%s\n", 24 | GENL_MAGIC_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX, drbd_buildtag()); 25 | 26 | drbd_print_transports_loaded(seq); 27 | 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /drbd/drbd_state_change.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #ifndef DRBD_STATE_CHANGE_H 3 | #define DRBD_STATE_CHANGE_H 4 | 5 | struct drbd_resource_state_change { 6 | struct drbd_resource *resource; 7 | enum drbd_role role[2]; 8 | bool susp[2]; 9 | bool susp_nod[2]; 10 | bool susp_uuid[2]; 11 | bool fail_io[2]; 12 | }; 13 | 14 | struct drbd_device_state_change { 15 | struct drbd_device *device; 16 | enum drbd_disk_state disk_state[2]; 17 | bool have_quorum[2]; 18 | }; 19 | 20 | struct drbd_connection_state_change { 21 | struct drbd_connection *connection; 22 | enum drbd_conn_state cstate[2]; 23 | enum drbd_role peer_role[2]; 24 | bool susp_fen[2]; 25 | }; 26 | 27 | /* exception: stores state, not change. 28 | * for get_initial_state. */ 29 | struct drbd_path_state { 30 | struct drbd_connection *connection; 31 | struct drbd_path *path; 32 | /* not an array, 33 | * because it's not an array in struct drbd_path either */ 34 | bool path_established; 35 | }; 36 | 37 | struct drbd_peer_device_state_change { 38 | struct drbd_peer_device *peer_device; 39 | enum drbd_disk_state disk_state[2]; 40 | enum drbd_repl_state repl_state[2]; 41 | bool resync_susp_user[2]; 42 | bool resync_susp_peer[2]; 43 | bool resync_susp_dependency[2]; 44 | bool resync_susp_other_c[2]; 45 | bool resync_active[2]; 46 | bool replication[2]; 47 | bool peer_replication[2]; 48 | }; 49 | 50 | struct drbd_state_change_object_count { 51 | unsigned int n_devices; 52 | unsigned int n_connections; 53 | unsigned int n_paths; 54 | }; 55 | 56 | struct drbd_state_change { 57 | struct list_head list; 58 | unsigned int n_devices; 59 | unsigned int n_connections; 60 | unsigned int n_paths; 61 | struct drbd_resource_state_change resource[1]; 62 | struct drbd_device_state_change *devices; 63 | struct drbd_connection_state_change *connections; 64 | struct drbd_peer_device_state_change *peer_devices; 65 | struct drbd_path_state *paths; 66 | }; 67 | 68 | struct drbd_state_change *remember_state_change(struct drbd_resource *resource, 69 | gfp_t gfp); 70 | void copy_old_to_new_state_change(struct drbd_state_change *state_change); 71 | void forget_state_change(struct drbd_state_change *state_change); 72 | 73 | int notify_resource_state_change(struct sk_buff *skb, unsigned int seq, 74 | void *state_change, 75 | enum drbd_notification_type type); 76 | int notify_connection_state_change(struct sk_buff *skb, unsigned int seq, 77 | void *state_change, 78 | enum drbd_notification_type type); 79 | int notify_device_state_change(struct sk_buff *skb, unsigned int seq, 80 | void *state_change, 81 | enum drbd_notification_type type); 82 | int notify_peer_device_state_change(struct sk_buff *skb, unsigned int seq, 83 | void *state_change, 84 | enum drbd_notification_type type); 85 | 86 | #endif /* DRBD_STATE_CHANGE_H */ 87 | -------------------------------------------------------------------------------- /drbd/kref_debug.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | #ifndef KREF_DEBUG_H 3 | #define KREF_DEBUG_H 4 | 5 | #include 6 | 7 | #ifdef CONFIG_KREF_DEBUG 8 | 9 | #define KREF_DEBUG_HOLDER_MAX 20 10 | 11 | struct kref_debug_info; 12 | 13 | struct kref_debug_class { 14 | const char *name; 15 | void (*get_object_name)(const struct kref_debug_info *, char *); 16 | const char *holder_name[KREF_DEBUG_HOLDER_MAX]; 17 | }; 18 | 19 | struct kref_debug_info { 20 | const struct kref_debug_class *class; 21 | struct kref *kref; 22 | int holders[KREF_DEBUG_HOLDER_MAX]; 23 | struct list_head objects; 24 | }; 25 | 26 | void initialize_kref_debugging(void); 27 | void kref_debug_init(struct kref_debug_info *debug_info, 28 | struct kref *kref, 29 | const struct kref_debug_class *class); 30 | void kref_debug_destroy(struct kref_debug_info *debug_info); 31 | void kref_debug_get(struct kref_debug_info *debug_info, int holder_nr); 32 | void kref_debug_sub(struct kref_debug_info *debug_info, int refs, int holder_nr); 33 | void print_kref_debug_info(struct seq_file *seq); 34 | static inline void kref_debug_put(struct kref_debug_info *debug_info, int holder_nr) 35 | { 36 | kref_debug_sub(debug_info, 1, holder_nr); 37 | } 38 | #else 39 | struct kref_debug_class {}; 40 | struct kref_debug_info {}; 41 | static inline void initialize_kref_debugging(void) 42 | {} 43 | #define kref_debug_init(D, K, C) __kref_debug_init(D, K) 44 | static inline void __kref_debug_init(struct kref_debug_info *debug_info, struct kref *kref) 45 | {} 46 | static inline void kref_debug_destroy(struct kref_debug_info *debug_info) 47 | {} 48 | static inline void kref_debug_get(struct kref_debug_info *debug_info, int holder_nr) 49 | {} 50 | static inline void kref_debug_sub(struct kref_debug_info *debug_info, int refs, int holder_nr) 51 | {} 52 | static inline void kref_debug_put(struct kref_debug_info *debug_info, int holder_nr) 53 | {} 54 | static inline void print_kref_debug_info(struct seq_file *seq) 55 | {} 56 | #endif 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /drbd/linux/drbd_config.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0-only */ 2 | /* 3 | drbd_config.h 4 | DRBD's compile time configuration. 5 | */ 6 | 7 | #ifndef DRBD_CONFIG_H 8 | #define DRBD_CONFIG_H 9 | 10 | const char *drbd_buildtag(void); 11 | 12 | #define REL_VERSION "9.3.0-rc.1" 13 | #define PRO_VERSION_MIN 118 /* 9.0.26 */ 14 | #define PRO_VERSION_MAX 123 15 | 16 | #define PRO_VERSION_8_MIN 86 17 | #define PRO_VERSION_8_MAX 101 18 | 19 | /* We support two ranges of DRBD protocol version: 20 | * 86-101: accepted DRBD 8 protocol versions as "rolling upgrade" path 21 | * 102-109: never defined 22 | * 110-117: _rejected_ because of bugs in the backward compat path 23 | * in more recent DRBD versions. That is 9.0.0 to 9.0.25 inclusive. 24 | * "Rolling" upgrade path for those versions: 25 | * first upgrade to 9.0.latest, then connect to 9.1/9.2 or later. 26 | * 118-PRO_VERSION_MAX: accepted DRBD 9 protocol versions. 27 | */ 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /filelist-redhat: -------------------------------------------------------------------------------- 1 | %defattr(644,root,root,755) 2 | %doc COPYING 3 | %doc ChangeLog 4 | /lib/modules/%verrel%dotvariant 5 | %doc obj/k-config-%verrel%dotvariant.gz 6 | %config /etc/depmod.d/drbd.conf 7 | %config /etc/pki/linbit/SECURE-BOOT-KEY-linbit.com.der 8 | -------------------------------------------------------------------------------- /filelist-suse: -------------------------------------------------------------------------------- 1 | %defattr(-,root,root) 2 | %doc COPYING 3 | %doc ChangeLog 4 | /lib/modules/%2-%1 5 | %doc obj/k-config-%2-%1.gz 6 | -------------------------------------------------------------------------------- /misc/SECURE-BOOT-KEY-linbit.com.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LINBIT/drbd/011f770e15a81aef8219141ca85f0bc1765ad1ec/misc/SECURE-BOOT-KEY-linbit.com.der -------------------------------------------------------------------------------- /misc/copy-to-mainline.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # SPDX-License-Identifier: GPL-2.0-only 3 | # 4 | # Copy all source files from the out-of-tree DRBD repository to the 5 | # appropriate places in an upstream Linux kernel source tree. 6 | 7 | if [ "$#" -ne 1 ]; then 8 | echo "Usage: $0 " 9 | exit 1 10 | fi 11 | 12 | KDIR=$(readlink -f "$1") 13 | if [ ! -d "$KDIR" ]; then 14 | echo "Kernel directory $KDIR not found" 15 | exit 1 16 | fi 17 | 18 | if [ ! -f "drbd/drbd_main.c" ]; then 19 | echo "Must be called from the base directory of the drbd repository" 20 | exit 1 21 | fi 22 | 23 | pushd drbd > /dev/null 24 | 25 | cp drbd_actlog.c drbd_bitmap.c drbd_dax_pmem.[ch] drbd_debugfs.[ch] \ 26 | drbd_interval.[ch] drbd_int.h drbd_kref_debug.[ch] \ 27 | drbd_main.c drbd_nla.[ch] drbd_nl.c \ 28 | drbd_polymorph_printk.h drbd_proc.c drbd_receiver.c drbd_req.[ch] \ 29 | drbd_sender.c drbd_state.[ch] drbd_state_change.h drbd_transport.c \ 30 | drbd_transport_tcp.c drbd_transport_rdma.c drbd_transport_lb-tcp.c \ 31 | drbd_transport_template.c drbd_vli.h \ 32 | drbd-headers/drbd_transport.h drbd-headers/drbd_strings.[ch] \ 33 | drbd-headers/drbd_protocol.h drbd-headers/drbd_meta_data.h \ 34 | $KDIR/drivers/block/drbd/ 35 | 36 | sed -i 's/drbd_worker.o/drbd_sender.o/' $KDIR/drivers/block/drbd/Makefile 37 | 38 | hl=drbd-headers/linux 39 | cp $hl/drbd_genl_api.h $hl/drbd_genl.h $hl/drbd_limits.h $hl/drbd.h \ 40 | $hl/genl_magic_func.h $hl/genl_magic_struct.h \ 41 | $hl/genl_magic_func-genl_register_family_with_ops_groups.h \ 42 | $hl/genl_magic_func-genl_register_mc_group.h \ 43 | linux/drbd_config.h \ 44 | $KDIR/include/linux/ 45 | 46 | cp kref_debug.[ch] \ 47 | $KDIR/include/ 48 | 49 | popd > /dev/null 50 | 51 | git -C $KDIR --no-pager diff --stat 52 | -------------------------------------------------------------------------------- /misc/dkms.conf: -------------------------------------------------------------------------------- 1 | PACKAGE_VERSION="#MODULE_VERSION#" 2 | PACKAGE_NAME="drbd" 3 | MAKE="make -C src/drbd KDIR=$kernel_source_dir" 4 | CLEAN="make -C src/drbd clean KDIR=$kernel_source_dir" 5 | AUTOINSTALL="yes" 6 | 7 | BUILT_MODULE_NAME[0]="drbd" 8 | BUILT_MODULE_NAME[1]="drbd_transport_tcp" 9 | BUILT_MODULE_NAME[2]="drbd_transport_lb-tcp" 10 | BUILT_MODULE_LOCATION[0]="./src/drbd/build-current/" 11 | BUILT_MODULE_LOCATION[1]="./src/drbd/build-current/" 12 | BUILT_MODULE_LOCATION[2]="./src/drbd/build-current/" 13 | DEST_MODULE_LOCATION[0]="/kernel/drivers/block/drbd" 14 | DEST_MODULE_LOCATION[1]="/kernel/drivers/block/drbd" 15 | DEST_MODULE_LOCATION[2]="/kernel/drivers/block/drbd" 16 | 17 | IDX=3 18 | 19 | if grep -q ^CONFIG_INFINIBAND= "$kernel_source_dir/.config"; then 20 | BUILT_MODULE_NAME[$IDX]="drbd_transport_rdma" 21 | BUILT_MODULE_LOCATION[$IDX]="./src/drbd/build-current/" 22 | DEST_MODULE_LOCATION[$IDX]="/kernel/drivers/block/drbd" 23 | IDX=$(($IDX + 1)) 24 | fi 25 | 26 | test -z $BUILD_OFED && 27 | test -e /usr/src/ofa_kernel/default/Module.symvers && 28 | modinfo mlx_compat &>/dev/null && 29 | MAKE+=" BUILD_OFED=1" 30 | 31 | # See drbd/Kbuild: this is that check for the kernel version, but worse: check for kernel >= 4.17 32 | IFS=".-" read -ra KVER <<< "$kernelver" 33 | if [ "${KVER[0]}" -ge 4 ] && ( [ "${KVER[0]}" -gt 4 ] || [ "${KVER[1]}" -ge 17 ] ) ; then 34 | if grep -q ^CONFIG_TLS= "$kernel_source_dir/.config" && ! grep -q ^CONFIG_NET_HANDSHAKE= "$kernel_source_dir/.config" ; then 35 | BUILT_MODULE_NAME[$IDX]="handshake" 36 | BUILT_MODULE_LOCATION[$IDX]="./src/drbd/build-current/drbd-kernel-compat/handshake" 37 | DEST_MODULE_LOCATION[$IDX]="/kernel/net/handshake" 38 | fi 39 | fi 40 | 41 | # On some distros (OL8 for example), the default cc is not the one used to build the kernel. 42 | # In this case, the gcc is installed as a "Software Collection" which can be enabled. 43 | # So we try to find a compiler that matches the version used to build the original kernel. 44 | get_cc_version() { 45 | if [ -n "$1" ]; then 46 | scl run "$1" -- "$kernel_source_dir/scripts/cc-version.sh" cc | cut -d' ' -f2 47 | else 48 | "$kernel_source_dir/scripts/cc-version.sh" cc | cut -d' ' -f2 49 | fi 50 | } 51 | 52 | if [ -e "$kernel_source_dir/scripts/cc-version.sh" ]; then 53 | KERNEL_GCC_VERSION="$(grep ^CONFIG_GCC_VERSION= "$kernel_source_dir/.config" | cut -d= -f2)" 54 | 55 | if [ "$KERNEL_GCC_VERSION" -gt "$(get_cc_version)" ] && command -v scl >/dev/null; then 56 | for COLLECTION in $(scl list-collections); do 57 | if [ "$KERNEL_GCC_VERSION" -le "$(get_cc_version "$COLLECTION")" ]; then 58 | MAKE="scl run $COLLECTION -- $MAKE" 59 | break 60 | fi 61 | done 62 | fi 63 | fi 64 | -------------------------------------------------------------------------------- /misc/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Script based on https://github.com/ofi-cray/fab-utils/blob/master/git/hooks/pre-commit-linux-coding-style 4 | 5 | # Pre-commit hook for running the Linux coding style checker 6 | # Available at: 7 | # https://github.com/torvalds/linux/blob/master/scripts/checkpatch.pl 8 | # https://github.com/torvalds/linux/blob/master/scripts/spelling.txt 9 | 10 | if [ "$CHECKPATCH" == "" ]; then 11 | CHECKPATCH=`command -v checkpatch.pl` 12 | if [ $? == 1 ]; then 13 | echo "checkpatch.pl not found" 14 | exit -1 15 | fi 16 | fi 17 | 18 | git diff --cached HEAD -- drbd/{drbd-headers/{linux/,},linux/,}*\.[ch] | \ 19 | $CHECKPATCH --no-tree --ignore FILE_PATH_CHANGES - 20 | 21 | if [ $? -ne 0 ]; then 22 | echo "Coding style check failed. Please fix warnings or commit with \"--no-verify\"." >&2 23 | exit -1 24 | fi 25 | 26 | exit 0 27 | -------------------------------------------------------------------------------- /rpm-macro-fixes/README: -------------------------------------------------------------------------------- 1 | macros.kernel-source.sles11-sp1.diff: 2 | 3 | Patch needed on SUSE products in order to allow building kernel module 4 | packages for a specific kernel version. 5 | See the patch for more detailed documentation. 6 | 7 | macros.kernel-source.sles11.diff: 8 | 9 | Same thing for sles11 (no sp1) 10 | 11 | suse_macros.sles10.diff: 12 | 13 | Similar thing for sles10 14 | 15 | kmodtool.rhel5.diff 16 | 17 | Add filelist tag substitution capabilities to rhel5 kmodtool, 18 | and drop the dependency on a ...-kmod-common package, 19 | similar to what rhel6 does. 20 | 21 | -------------------------------------------------------------------------------- /rpm-macro-fixes/kmodtool.rhel5.diff: -------------------------------------------------------------------------------- 1 | --- /usr/lib/rpm/redhat/kmodtool 2 | +++ /usr/lib/rpm/redhat/kmodtool 3 | @@ -65,12 +65,19 @@ 4 | { 5 | local variant="${1}" 6 | local dashvariant="${variant:+-${variant}}" 7 | + local dotvariant="${variant:+.${variant}}" 8 | + 9 | case "$verrel" in 10 | *.el*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;; 11 | *.EL*) kdep="kernel${dashvariant}-%{_target_cpu} = ${verrel}" ;; 12 | *) kdep="kernel-%{_target_cpu} = ${verrel}${variant}" ;; 13 | esac 14 | 15 | + echo "%global verrel $verrel" 16 | + echo "%global variant ${variant:-%nil}" 17 | + echo "%global dashvariant ${dashvariant:-%nil}" 18 | + echo "%global dotvariant ${dotvariant:-%nil}" 19 | + 20 | echo "%package -n kmod-${kmod_name}${dashvariant}" 21 | 22 | if [ -z "$kmp_provides_summary" ]; then 23 | @@ -100,7 +107,6 @@ 24 | fi 25 | 26 | cat <= %{?epoch:%{epoch}:}%{version} 28 | Requires(post): /sbin/depmod 29 | Requires(postun): /sbin/depmod 30 | EOF 31 | -------------------------------------------------------------------------------- /rpm-macro-fixes/macros.kernel-source.sles11-sp1.diff: -------------------------------------------------------------------------------- 1 | By default, the %kernel_module_package will build packages for all kernel 2 | flavors it finds in /usr/src/linux-obj: this directory contains symlinks to the 3 | latest kernel-$flavor-devel packages installed. 4 | 5 | This default can be overridden by defining the %kernel_version macro on the 6 | rpmbuild command line. For example, you can build against version 7 | 2.6.32.19-0.2 with: 8 | 9 | rpmbuild --define 'kernel_version 2.6.32.19-0.2' 10 | 11 | When doing that, rpmbuild will iterate over the kernels defined in 12 | /usr/src/linux-%kernel_version-obj, instead. 13 | 14 | It is not possible to iterate over all installed kernel-$flavor-devel packages 15 | in one rpmbuild command: rpm only allows to build a single sub-package with a 16 | given name (for example, drbd-kmp-default), and cannot build two separate 17 | drbd-kmp-default sub-packages with different versions. 18 | 19 | Andreas Gruenbacher 20 | 21 | --- /etc/rpm/macros.kernel-source.orig 22 | +++ /etc/rpm/macros.kernel-source 23 | @@ -9,14 +9,14 @@ 24 | echo "%%define _suse_kernel_module_subpackage(n:v:r:f:p:) %%{expand:%%(cd %_sourcedir; cat $subpkg; echo %%%%nil)}" \ 25 | flavors_to_build= \ 26 | flavors="%*" \ 27 | - for flavor in $(ls /usr/src/linux-obj/%_target_cpu 2>/dev/null); do \ 28 | + for flavor in $(ls /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu 2>/dev/null); do \ 29 | case " $flavors " in \ 30 | (*" $flavor "*) \ 31 | [ -n "%{-X}" ] && continue ;; \ 32 | (*) \ 33 | [ -z "%{-X}" -a -n "$flavors" ] && continue ;; \ 34 | esac \ 35 | - krel=$(make -s -C /usr/src/linux-obj/%_target_cpu/$flavor kernelrelease) \ 36 | + krel=$(make -s -C /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu/$flavor kernelrelease) \ 37 | kver=${krel%%-*} \ 38 | [ -e /boot/symsets-$kver-$flavor.tar.gz ] || continue \ 39 | flavors_to_build="$flavors_to_build $flavor" \ 40 | @@ -24,7 +24,7 @@ 41 | done \ 42 | echo "%%global flavors_to_build${flavors_to_build:-%%nil}" \ 43 | echo "%%{expand:%%(test -z '%flavors_to_build' && echo %%%%internal_kmp_error)}" \ 44 | - echo "%%global kernel_source() /usr/src/linux-obj/%_target_cpu/%%%%{1}" \ 45 | + echo "%%global kernel_source() /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu/%%%%{1}" \ 46 | echo "%%global kernel_module_package_moddir() updates" \ 47 | \ 48 | echo "%package -n %{-n*}%{!-n:%name}-kmp-_dummy_" \ 49 | -------------------------------------------------------------------------------- /rpm-macro-fixes/macros.kernel-source.sles11.diff: -------------------------------------------------------------------------------- 1 | See comment in macros.kernel-source.sles11-sp1.diff 2 | 3 | --- /etc/rpm/macros.kernel-source.orig 4 | +++ /etc/rpm/macros.kernel-source 5 | @@ -9,14 +9,14 @@ 6 | echo "%%define _suse_kernel_module_subpackage(n:v:r:f:p:) %%{expand:%%(cd %_sourcedir; cat $subpkg; echo %%%%nil)}" \ 7 | flavors_to_build= \ 8 | flavors="%*" \ 9 | - for flavor in $(ls /usr/src/linux-obj/%_target_cpu 2>/dev/null); do \ 10 | + for flavor in $(ls /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu 2>/dev/null); do \ 11 | case " $flavors " in \ 12 | (*" $flavor "*) \ 13 | [ -n "%{-X}" ] && continue ;; \ 14 | (*) \ 15 | [ -z "%{-X}" -a -n "$flavors" ] && continue ;; \ 16 | esac \ 17 | - krel=$(make -s -C /usr/src/linux-obj/%_target_cpu/$flavor kernelrelease) \ 18 | + krel=$(make -s -C /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu/$flavor kernelrelease) \ 19 | kver=${krel%%-*} \ 20 | [ -e /boot/symsets-$kver-$flavor.tar.gz ] || continue \ 21 | flavors_to_build="$flavors_to_build $flavor" \ 22 | @@ -24,7 +24,7 @@ 23 | done \ 24 | echo "%%global flavors_to_build${flavors_to_build:-%%nil}" \ 25 | echo "%%{expand:%%(test -z '%flavors_to_build' && echo %%%%internal_kmp_error)}" \ 26 | - echo "%%global kernel_source() /usr/src/linux-obj/%_target_cpu/%%%%{1}" \ 27 | + echo "%%global kernel_source() /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu/%%%%{1}" \ 28 | \ 29 | echo "%package -n %{-n*}%{!-n:%name}-kmp-_dummy_" \ 30 | echo "Version: %version" \ 31 | -------------------------------------------------------------------------------- /rpm-macro-fixes/macros.rhel5.diff: -------------------------------------------------------------------------------- 1 | --- /usr/lib/rpm/redhat/macros.orig 2 | +++ /usr/lib/rpm/redhat/macros 3 | @@ -170,8 +170,8 @@ 4 | 5 | %kernel_module_package(n:v:r:s:f:xp:) %{expand:%( \ 6 | %define kmodtool %{-s*}%{!-s:/usr/lib/rpm/redhat/kmodtool} \ 7 | - %define kmp_version %{-v*}%{!-v:%{version}} \ 8 | - %define kmp_release %{-r*}%{!-r:%{release}} \ 9 | + %global kmp_version %{-v*}%{!-v:%{version}} \ 10 | + %global kmp_release %{-r*}%{!-r:%{release}} \ 11 | %define latest_kernel %(rpm -q --qf '%{VERSION}-%{RELEASE}\\\\n' `rpm -q kernel-devel | /usr/lib/rpm/redhat/rpmsort -r | head -n 1` | head -n 1) \ 12 | %{!?kernel_version:%{expand:%%global kernel_version %{latest_kernel}}} \ 13 | %global kverrel %(%{kmodtool} verrel %{?kernel_version} 2>/dev/null) \ 14 | -------------------------------------------------------------------------------- /rpm-macro-fixes/suse_macros.sles10.diff: -------------------------------------------------------------------------------- 1 | See comment in macros.kernel-source.sles11-sp1.diff 2 | 3 | --- /usr/lib/rpm/suse_macros.orig 4 | +++ /usr/lib/rpm/suse_macros 5 | @@ -473,12 +473,12 @@ 6 | 7 | # Defines %flavors_to_build as a side effect. 8 | %suse_kernel_module_package(n:v:r:s:f:xp:) \ 9 | -%{expand:%( \ 10 | +%{expand:%{expand:%( \ 11 | + ( \ 12 | subpkg=%{-s*}%{!-s:/usr/lib/rpm/rpm-suse-kernel-module-subpackage} \ 13 | echo "%%define _suse_kernel_module_subpackage(n:v:r:f:p:) %%{expand:%%(cd %_sourcedir; cat $subpkg; echo %%%%nil)}" \ 14 | - flavors="%{-x:%*}%{!-x:$(ls /usr/src/linux-obj/%_target_cpu 2>/dev/null)}" \ 15 | + flavors="%{-x:%*}%{!-x:$(ls /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu 2>/dev/null)}" \ 16 | flavors_to_build= \ 17 | - kver=$(rpm -q --qf '%{VERSION}-%{RELEASE}' kernel-source) \ 18 | for flavor in $flavors; do \ 19 | if [ -z "%{-x}" ]; then \ 20 | case " %* " in \ 21 | @@ -486,19 +486,23 @@ 22 | continue ;; \ 23 | esac \ 24 | fi \ 25 | - krel=$(make -s -C /usr/src/linux-obj/%_target_cpu/$flavor kernelrelease) \ 26 | + krel=$(make -s -C /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu/$flavor kernelrelease) \ 27 | + kver=${krel%%-*} \ 28 | [ -e /boot/symsets-$krel.tar.gz ] || continue \ 29 | flavors_to_build="$flavors_to_build $flavor" \ 30 | echo "%%_suse_kernel_module_subpackage -n %{-n*}%{!-n:%name}-kmp -v %{-v*}%{!-v:%version} -r %{-r*}%{!-r:%release} %{-p} $flavor $krel $kver" \ 31 | done \ 32 | echo "%%global flavors_to_build${flavors_to_build:-%%nil}" \ 33 | + echo "%%global kernel_source() /usr/src/linux-%{?kernel_version:%kernel_version-}obj/%_target_cpu/%%%%{1}" \ 34 | + echo "%%global kernel_module_package_moddir() updates" \ 35 | \ 36 | echo "%package -n %{-n*}%{!-n:%name}-kmp-_dummy_" \ 37 | echo "Version: %version" \ 38 | echo "Summary: %summary" \ 39 | echo "Group: %group" \ 40 | echo "%description -n %{-n*}%{!-n:%name}-kmp-_dummy_" \ 41 | - )} 42 | + ) | sed -e 's/%%/%%%%/g' \ 43 | + )}} 44 | 45 | %suse_version 1010 46 | %sles_version 10 47 | -------------------------------------------------------------------------------- /rpm-macro-fixes/symset-table.diff: -------------------------------------------------------------------------------- 1 | symsets-xyz-tar.gz contain only the current symsets, 2 | and potentially compatible symsets. 3 | 4 | To be compatible by definition means to be a subset of the current symset. 5 | 6 | If we scan through the symsets in ascending order of their size in bytes, 7 | the first symset to match a particular symbol will be the "oldest", 8 | "most compatible". 9 | 10 | This way, even if the most recent kernel version provides some new 11 | symset containing new symbols, a kernel module package built 12 | against it will still only require the weakest symset(s) necessary, 13 | so will stay compatible on the rpm dependency level with all older 14 | kernels that provide the actually used symbols. 15 | 16 | Without the sorting and filtering, the resulting kmp would require 17 | all symsets the respective symbols are defined in, including the 18 | latest symset, even if only a subset of the contained symbols is 19 | actually used. Thus the kmp may become "incompatible" on the rpm 20 | level with older kernel versions, even though it works just fine 21 | with "weak-modules" on the actual symbol version level. 22 | 23 | --- /usr/lib/rpm/symset-table 24 | +++ /usr/lib/rpm/symset-table 25 | @@ -21,15 +21,26 @@ 26 | 27 | for symsets in *; do 28 | krel=${symsets#symsets-} 29 | - for symset in $symsets/*; do 30 | + for symset in $(ls -Sr $symsets/* ); do 31 | class=${symset##*/} ; class=${class%.*} 32 | hash=${symset##*.} 33 | awk ' 34 | BEGIN { FS = "\t" ; OFS = "\t" } 35 | { sub(/0x0*/, "", $1) 36 | - print krel "/" $1 "/" $2, class, hash } 37 | + print krel "/" $1, $2, class, hash } 38 | ' krel="$krel" class="$class" hash="$hash" $symset 39 | - done 40 | + done \ 41 | + | awk ' 42 | + # Filter out duplicate symbols. Since we went through the symset 43 | + # files in increasing size order, each symbol will remain in the 44 | + # table with the oldest symset it is defined in. 45 | + BEGIN { FS = "\t" ; OFS = "\t" } 46 | + { if ($2 in seen) 47 | + next 48 | + seen[$2]=1 49 | + print $1 "/" $2, $3, $4 } 50 | + ' \ 51 | + | sort -t $'\t' -k 1,1 52 | done 53 | 54 | # vim:shiftwidth=4 softtabstop=4 55 | -------------------------------------------------------------------------------- /sbom/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # we inherit some variables from our "parent" Makefile 3 | THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) 4 | $(foreach v,REL_VERSION FDIST_VERSION,$(if $($(v)),,$(error "Do not use this Makefile ($(THIS_MAKEFILE)) directly! ($(v) missing)))) 5 | 6 | all: drbd-kmod.cdx.json drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json 7 | 8 | export SPDX_VERSION SPDX_DATE SPDX_YEAR SPDX_UUID SPDX_PKG_NAME 9 | SPDX_VERSION:=$(REL_VERSION) 10 | SPDX_DATE:=$(shell date --utc +%FT%TZ) 11 | SPDX_YEAR:=$(firstword $(subst -, ,$(SPDX_DATE))) 12 | drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json: SPDX_UUID:=$(shell cat /proc/sys/kernel/random/uuid) 13 | drbd-kmod_rhel.spdx.json: SPDX_PKG_NAME:=kmod-drbd 14 | drbd-kmod_sles.spdx.json: SPDX_PKG_NAME:=drbd-kmp-default 15 | drbd-kmod_rhel.spdx.json drbd-kmod_sles.spdx.json: FORCE 16 | @rm -f $@; jq -n -f drbd-kmod.spdx.json.in > $@.tmp && mv $@.tmp $@ 17 | 18 | # uses: 19 | # SPDX_DATE from above and FDIST_VERSION from parent Makefile 20 | drbd-kmod.cdx.json: FORCE 21 | @rm -f $@; jq -n -f drbd-kmod.cdx.json.in > $@.tmp && mv $@.tmp $@ 22 | 23 | .PHONY: FORCE 24 | FORCE: 25 | -------------------------------------------------------------------------------- /sbom/drbd-kmod.cdx.json.in: -------------------------------------------------------------------------------- 1 | { 2 | "bomFormat": "CycloneDX", 3 | "specVersion": "1.5", 4 | "metadata": { 5 | "timestamp": "\(env.SPDX_DATE)", 6 | "authors": [ 7 | { 8 | "name": "Philipp Reisner", 9 | "email": "philipp.reisner@linbit.com" 10 | }, 11 | { 12 | "name": "Lars Ellenberg", 13 | "email": "lars.ellenberg@linbit.com" 14 | } 15 | ], 16 | "component": { 17 | "type": "application", 18 | "name": "kmod-drbd", 19 | "version": "\(env.FDIST_VERSION)", 20 | "bom-ref": "pkg:github/LINBIT/drbd@drbd-\(env.FDIST_VERSION)", 21 | "purl": "pkg:github/LINBIT/drbd@drbd-\(env.FDIST_VERSION)", 22 | "licenses": [ 23 | { 24 | "licenses": { 25 | "id": "GPL-2.0-only" 26 | } 27 | } 28 | ], 29 | "externalReferences": [ 30 | { 31 | "url": "https://github.com/LINBIT/drbd", 32 | "type": "website" 33 | } 34 | ] 35 | }, 36 | "manufacturer": { 37 | "name": "LINBIT HA-Solutions GmbH", 38 | "url": [ 39 | "https://www.linbit.com" 40 | ], 41 | "contact": [ 42 | { 43 | "name": "LINBIT HA-Solutions GmbH", 44 | "email": "office@linbit.com" 45 | } 46 | ] 47 | }, 48 | "supplier": { 49 | "name": "LINBIT HA-Solutions GmbH", 50 | "url": [ 51 | "https://www.linbit.com" 52 | ], 53 | "contact": [ 54 | { 55 | "name": "LINBIT HA-Solutions GmbH", 56 | "email": "office@linbit.com" 57 | } 58 | ] 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /sbom/drbd-kmod.spdx.json.in: -------------------------------------------------------------------------------- 1 | { 2 | "SPDXID": "SPDXRef-DOCUMENT", 3 | "spdxVersion": "SPDX-2.3", 4 | "creationInfo": { 5 | "created": "\(env.SPDX_DATE)", 6 | "creators": [ 7 | "Person: Philipp Reisner (philipp.reisner@linbit.com)" 8 | ] 9 | }, 10 | "name": "drbd kernel module SBOM (software bill of materials)", 11 | "dataLicense": "CC0-1.0", 12 | "documentNamespace": "https://linbit.org/spdx-docs/drbd-kmod-\(env.SPDX_VERSION)-\(env.SPDX_UUID)", 13 | "packages": [ 14 | { 15 | "SPDXID": "SPDXRef-Package-\(env.SPDX_PKG_NAME)", 16 | "copyrightText": "2001-2008, LINBIT Information Technologies GmbH\n2008-\(env.SPDX_YEAR), LINBIT HA-Solutions GmbH", 17 | "downloadLocation": "https://github.com/LINBIT/drbd", 18 | "filesAnalyzed": false, 19 | "licenseDeclared": "GPL-2.0-only", 20 | "name": "\(env.SPDX_PKG_NAME)", 21 | "supplier": "Organization: LINBIT HA-Solutions GmbH", 22 | "versionInfo": "\(env.SPDX_VERSION)" 23 | } 24 | ], 25 | "relationships": [ 26 | { 27 | "spdxElementId": "SPDXRef-DOCUMENT", 28 | "relationshipType": "DESCRIBES", 29 | "relatedSpdxElement": "SPDXRef-Package-\(env.SPDX_PKG_NAME)" 30 | } 31 | ] 32 | } 33 | --------------------------------------------------------------------------------