Accepting request 1109379 from network:ha-clustering:Factory

OBS-URL: https://build.opensuse.org/request/show/1109379
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/drbd?expand=0&rev=104
This commit is contained in:
Ana Guerrero 2023-09-07 19:13:08 +00:00 committed by Git OBS Bridge
commit cadc9519cc
36 changed files with 265 additions and 2100 deletions

View File

@ -1,31 +0,0 @@
/* {"version":"v5.15-rc1~161", "commit": "c66fd019713e9cf7d6f1243c378cd177d01fe18a", "comment": "block: make the block holder code optional"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_bd_claim_by_disk.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_bd_claim_by_disk.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_bd_claim_by_disk.c 2021-11-18 11:27:38.503118180 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_bd_claim_by_disk.c 2021-11-18 11:28:30.370889421 +0800
@@ -1,6 +1,6 @@
#include <linux/fs.h>
-#ifdef CONFIG_SYSFS
+#if defined(CONFIG_SYSFS) || defined(CONFIG_BLOCK_HOLDER_DEPRECATED)
void dummy(struct block_device *bdev, void *holder, struct gendisk *disk)
{
bd_claim_by_disk(bdev, holder, disk);
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c 2021-11-18 11:27:38.503118180 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c 2021-11-18 13:15:26.943553840 +0800
@@ -2,12 +2,12 @@
#include <linux/fs.h>
#include <linux/blkdev.h>
-#ifdef CONFIG_SYSFS
+#if defined(CONFIG_SYSFS) || defined(CONFIG_BLOCK_HOLDER_DEPRECATED)
void dummy(struct block_device *bdev, struct gendisk *disk)
{
/* also check that we are not between 49731ba and e09b457,
* where there was a singular bd_holder_disk for a short time */
- if (!list_empty(&bdev->bd_holder_disks))
+ /* if (!list_empty(&bdev->bd_holder_disks)) */
bd_unlink_disk_holder(bdev, disk);
}
#endif

View File

@ -1,11 +0,0 @@
/* {"version":"v5.16-rc1~106", "commit": "8587ca6f34152ea650bad4b2db68456601159024", "comment": "mm: move kvmalloc-related functions to slab.h"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_kvfree.c drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_kvfree.c
--- drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_kvfree.c 2021-11-09 22:43:17.000000000 +0800
+++ drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_kvfree.c 2021-11-18 13:32:39.783138887 +0800
@@ -1,4 +1,5 @@
#include <linux/mm.h>
+#include <linux/slab.h>
void foo(void) {
kvfree(NULL);

View File

@ -1,14 +0,0 @@
/* {"version":"v5.16-rc1~75", "commit": "3e08773c3841e9db7a520908cc2b136a77d275ff", "comment": "block: switch polling to be bio based"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_submit_bio_noacct.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_submit_bio_noacct.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_submit_bio_noacct.c 2021-11-18 13:33:44.434862535 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_submit_bio_noacct.c 2021-11-18 16:47:31.764019596 +0800
@@ -4,7 +4,5 @@
void foo(struct bio *bio)
{
- blk_qc_t result;
-
- result = submit_bio_noacct(bio);
+ submit_bio_noacct(bio);
}

View File

@ -1,44 +0,0 @@
/* {"version":"v5.15-rc1~161", "commit": ""471aa704db4904f7af5a50019ca3b5b018c0cf62, "comment": "block: pass a gendisk to blk_queue_update_readahead"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/gen_patch_names.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/gen_patch_names.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/gen_patch_names.c 2021-11-19 12:56:56.962529304 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/gen_patch_names.c 2021-11-19 12:58:45.370112678 +0800
@@ -391,8 +391,10 @@
patch(1, "wb_congested_enum", true, false,
COMPAT_HAVE_WB_CONGESTED_ENUM, "present");
+#ifndef COMPAT_HAVE_DISK_UPDATE_READAHEAD
patch(1, "blk_queue_update_readahead", true, false,
COMPAT_HAVE_BLK_QUEUE_UPDATE_READAHEAD, "present");
+#endif
patch(1, "backing_dev_info", true, false,
COMPAT_HAVE_POINTER_BACKING_DEV_INFO, "is_pointer");
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c 1970-01-01 08:00:00.000000000 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c 2021-11-19 12:59:10.194017276 +0800
@@ -0,0 +1,9 @@
+/* { "version": "v5.16", "commit": "471aa704db4904f7af5a50019ca3b5b018c0cf62", "comment": "block: pass a gendisk to blk_queue_update_readahead", "author": "Christoph Hellwig <hch@lst.de>", "date": "Mon Aug 9 16:17:41 2021 +0200" } */
+
+#include <linux/genhd.h>
+#include <linux/blkdev.h>
+
+void foo(struct gendisk *d)
+{
+ disk_update_readahead(d);
+}
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_nl.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd_nl.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_nl.c 2021-11-19 12:56:56.966529288 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd_nl.c 2021-11-19 13:00:37.777680684 +0800
@@ -2124,7 +2124,11 @@
if (b) {
blk_stack_limits(&q->limits, &b->limits, 0);
+#ifdef COMPAT_HAVE_DISK_UPDATE_READAHEAD
+ disk_update_readahead(device->vdisk);
+#else
blk_queue_update_readahead(q);
+#endif
}
fixup_discard_if_not_supported(q);
fixup_write_zeroes(device, q);

View File

@ -1,26 +0,0 @@
/* {"version":"v5.16-rc1~73", "commit": "e92ab4eda516a5bfd96c087282ebe9521deba4f4", "comment": "drbd: add error handling support for add_disk()"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_main.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd_main.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_main.c 2021-11-19 15:36:33.405592808 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd_main.c 2021-11-19 15:43:32.799929686 +0800
@@ -3794,7 +3794,10 @@
goto out_remove_peer_device;
}
- add_disk(disk);
+ err = add_disk(disk);
+ if (err)
+ goto out_cleanup_disk;
+
device->have_quorum[OLD] =
device->have_quorum[NEW] =
(resource->res_opts.quorum == QOU_OFF);
@@ -3811,6 +3814,8 @@
*p_device = device;
return NO_ERROR;
+out_cleanup_disk:
+ blk_cleanup_disk(disk);
out_remove_peer_device:
list_add_rcu(&tmp, &device->peer_devices);
list_del_init(&device->peer_devices);

View File

@ -1,84 +0,0 @@
/* {"version":"v5.16-rc1~75", "commit": "3e08773c3841e9db7a520908cc2b136a77d275ff", "comment": "block: switch polling to be bio based"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_void_drbd_submit_bio.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_void_drbd_submit_bio.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd-kernel-compat/tests/have_void_drbd_submit_bio.c 1970-01-01 08:00:00.000000000 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_void_drbd_submit_bio.c 2021-11-19 16:52:39.349253992 +0800
@@ -0,0 +1,8 @@
+/* { "version": "v5.16-rc1", "commit": "3e08773c3841e9db7a520908cc2b136a77d275ff", "comment": "block: switch polling to be bio based", "author": "Christoph Hellwig <hch@lst.de>", "date": "Tue Oct 12 13:12:24 2021 +0200" } */
+
+#include <linux/bio.h>
+
+void foo(struct bio *b)
+{
+ b->bi_cookie = 0;
+}
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_int.h drbd-9.0.30~1+git.8e9c0812/drbd/drbd_int.h
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_int.h 2021-11-19 16:43:47.011257061 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd_int.h 2021-11-19 16:57:32.204153502 +0800
@@ -1848,7 +1848,11 @@
#define __drbd_make_request(d,b,k,j) __drbd_make_request(d,b,j)
#endif
extern void __drbd_make_request(struct drbd_device *, struct bio *, ktime_t, unsigned long);
+#ifdef COMPAT_HAVE_VOID_DRBD_SUBMIT_BIO
+extern void drbd_submit_bio(struct bio *bio);
+#else
extern blk_qc_t drbd_submit_bio(struct bio *bio);
+#endif
/* drbd_nl.c */
enum suspend_scope {
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_req.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd_req.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_req.c 2021-11-19 16:43:47.011257061 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd_req.c 2021-11-19 16:54:34.460820836 +0800
@@ -2186,7 +2186,11 @@
return false;
}
+#ifdef COMPAT_HAVE_VOID_DRBD_SUBMIT_BIO
+void drbd_submit_bio(struct bio *bio)
+#else
blk_qc_t drbd_submit_bio(struct bio *bio)
+#endif
{
struct drbd_device *device = bio->bi_bdev->bd_disk->private_data;
#ifdef CONFIG_DRBD_TIMING_STATS
@@ -2197,7 +2201,9 @@
if (drbd_fail_request_early(device, bio)) {
bio->bi_status = BLK_STS_IOERR;
bio_endio(bio);
+#ifndef COMPAT_HAVE_VOID_DRBD_SUBMIT_BIO
return BLK_QC_T_NONE;
+#endif
}
blk_queue_split(&bio);
@@ -2205,7 +2211,9 @@
if (device->cached_err_io) {
bio->bi_status = BLK_STS_IOERR;
bio_endio(bio);
+#ifndef COMPAT_HAVE_VOID_DRBD_SUBMIT_BIO
return BLK_QC_T_NONE;
+#endif
}
/* This is both an optimization: READ of size 0, nothing to do
@@ -2217,7 +2225,9 @@
if (bio_op(bio) == REQ_OP_READ && bio->bi_iter.bi_size == 0) {
WARN_ONCE(1, "size zero read from upper layers");
bio_endio(bio);
+#ifndef COMPAT_HAVE_VOID_DRBD_SUBMIT_BIO
return BLK_QC_T_NONE;
+#endif
}
ktime_get_accounting(start_kt);
@@ -2225,7 +2235,9 @@
__drbd_make_request(device, bio, start_kt, start_jif);
+#ifndef COMPAT_HAVE_VOID_DRBD_SUBMIT_BIO
return BLK_QC_T_NONE;
+#endif
}
static unsigned long time_min_in_future(unsigned long now,

View File

@ -1,17 +0,0 @@
/* {"version":"v5.15-rc1~161", "commit": "14cf1dbb55bb07427babee425fd2a8a9300737cc", "comment": "block: remove bdgrab"} */
diff -Naur drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_nl.c drbd-9.0.30~1+git.8e9c0812/drbd/drbd_nl.c
--- drbd-9.0.30~1+git.8e9c0812.orig/drbd/drbd_nl.c 2021-11-22 12:32:17.202848720 +0800
+++ drbd-9.0.30~1+git.8e9c0812/drbd/drbd_nl.c 2021-11-22 12:32:57.719098447 +0800
@@ -1038,10 +1038,7 @@
} else /* (role == R_SECONDARY) */ {
down(&resource->state_sem);
idr_for_each_entry(&resource->devices, device, vnr) {
- bdev = bdgrab(device->vdisk->part0);
- if (bdev)
- fsync_bdev(bdev);
- bdput(bdev);
+ fsync_bdev(bdev);
flush_workqueue(device->submit.wq);
}

View File

@ -1,55 +0,0 @@
From 25592a4a902415cf1a353a1e26ba11b4ccc0eca7 Mon Sep 17 00:00:00 2001
From: <christoph.boehmwalder@linbit.com>
Date: Wed, 6 Apr 2022 12:27:36 +0200
Subject: [PATCH] compat: test and cocci patch for bdi in gendisk
---
.../cocci/struct_gendisk__no_has_backing_dev_info.cocci | 6 ++++++
drbd/drbd-kernel-compat/gen_patch_names.c | 3 +++
.../tests/struct_gendisk_has_backing_dev_info.c | 8 ++++++++
3 files changed, 17 insertions(+)
create mode 100644 drbd/drbd-kernel-compat/cocci/struct_gendisk__no_has_backing_dev_info.cocci
create mode 100644 drbd/drbd-kernel-compat/tests/struct_gendisk_has_backing_dev_info.c
diff --git a/drbd/drbd-kernel-compat/cocci/struct_gendisk__no_has_backing_dev_info.cocci b/drbd/drbd-kernel-compat/cocci/struct_gendisk__no_has_backing_dev_info.cocci
new file mode 100644
index 000000000000..b3d290710ee8
--- /dev/null
+++ b/drbd/drbd-kernel-compat/cocci/struct_gendisk__no_has_backing_dev_info.cocci
@@ -0,0 +1,6 @@
+@@
+struct drbd_device *d;
+@@
+d->ldev->backing_bdev->
+- bd_disk->bdi
++ bd_disk->queue->backing_dev_info
diff -Nupr a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
--- a/drbd/drbd-kernel-compat/gen_patch_names.c 2022-07-08 19:43:37.106735503 +0800
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c 2022-07-08 19:45:17.570310319 +0800
@@ -396,6 +396,9 @@ int main(int argc, char **argv)
COMPAT_HAVE_BLK_QUEUE_UPDATE_READAHEAD, "present");
#endif
+ patch(1, "struct_gendisk", true, false,
+ COMPAT_STRUCT_GENDISK_HAS_BACKING_DEV_INFO, "has_backing_dev_info");
+
patch(1, "backing_dev_info", true, false,
COMPAT_HAVE_POINTER_BACKING_DEV_INFO, "is_pointer");
diff --git a/drbd/drbd-kernel-compat/tests/struct_gendisk_has_backing_dev_info.c b/drbd/drbd-kernel-compat/tests/struct_gendisk_has_backing_dev_info.c
new file mode 100644
index 000000000000..cd40214a564c
--- /dev/null
+++ b/drbd/drbd-kernel-compat/tests/struct_gendisk_has_backing_dev_info.c
@@ -0,0 +1,8 @@
+/* { "version": "v5.15-rc1", "commit": "21cf866145047f8bfecb38ec8d2fed64464c074f", "comment": "The backing_dev_info was moved from request_queue to backing_dev_info", "author": "Christoph Hellwig <hch@lst.de>", "date": "Wed Jul 1 11:06:22 2020 +0200" } */
+
+#include <linux/blkdev.h>
+
+struct backing_dev_info *foo(struct gendisk *d)
+{
+ return d->bdi;
+}
--
2.34.1

View File

@ -1,37 +0,0 @@
From eacd74206a8f48c3861de2096215790426331237 Mon Sep 17 00:00:00 2001
From: <christoph.boehmwalder@linbit.com>
Date: Wed, 6 Apr 2022 13:36:08 +0200
Subject: [PATCH] compat: only apply bdi pointer patch if bdi is in
request_queue
The history is as follows:
1. In the beginning, request_queue.backing_dev_info was a regular member
2. Then, backing_dev_info became a pointer
3. Now the backing_dev_info pointer has moved to gendisk.bdi
So there is never a case where gendisk has a non-pointer
backing_dev_info. Thus, we only want to apply the pointer patch for old
kernels where backing_dev_info was still in request_queue.
---
drbd/drbd-kernel-compat/gen_patch_names.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
index 9210d2c2eeb9..763652a8908b 100644
--- a/drbd/drbd-kernel-compat/gen_patch_names.c
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c
@@ -400,8 +400,10 @@ int main(int argc, char **argv)
patch(1, "struct_gendisk", true, false,
COMPAT_STRUCT_GENDISK_HAS_BACKING_DEV_INFO, "has_backing_dev_info");
+#if !defined(COMPAT_STRUCT_GENDISK_HAS_BACKING_DEV_INFO)
patch(1, "backing_dev_info", true, false,
COMPAT_HAVE_POINTER_BACKING_DEV_INFO, "is_pointer");
+#endif
patch(1, "sendpage_ok", true, false,
COMPAT_HAVE_SENDPAGE_OK, "present");
--
2.34.1

View File

@ -1,102 +0,0 @@
/* this patch is related with following upstream kernel commit */
commit 322cbb50de711814c42fb088f6d31901502c711a
Author: Christoph Hellwig <hch@lst.de>
Date: Mon Jan 24 10:39:13 2022 +0100
block: remove genhd.h
There is no good reason to keep genhd.h separate from the main blkdev.h
header that includes it. So fold the contents of genhd.h into blkdev.h
and remove genhd.h entirely.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20220124093913.742411-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_atomic_in_flight.c b/drbd/drbd-kernel-compat/tests/have_atomic_in_flight.c
--- a/drbd/drbd-kernel-compat/tests/have_atomic_in_flight.c 2022-07-07 16:50:27.736823224 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_atomic_in_flight.c 2022-07-08 18:27:01.362626866 +0800
@@ -1,6 +1,6 @@
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
-#include <linux/genhd.h>
+#include <linux/blkdev.h>
#ifndef __same_type
# define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b))
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c b/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c
--- a/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c 2022-07-07 16:50:35.476788526 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_bd_unlink_disk_holder.c 2022-07-07 16:52:09.432367225 +0800
@@ -1,4 +1,3 @@
-#include <linux/genhd.h>
#include <linux/fs.h>
#include <linux/blkdev.h>
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c b/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c
--- a/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c 2022-07-07 16:50:42.400757477 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_blk_alloc_disk.c 2022-07-08 18:27:51.914415515 +0800
@@ -1,6 +1,6 @@
/* { "version": "v5.13-rc4", "commit": "b647ad024841d02d67e78716f51f355d8d3e9656", "comment": "5.13 introduces a blk_alloc_disk helper", "author": "Christoph Hellwig <hch@lst.de>", "date": "Fri May 21 07:50:57 2021 +0200" } */
-#include <linux/genhd.h>
+#include <linux/blkdev.h>
struct gendisk *foo(int node)
{
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c b/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c
--- a/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c 2022-07-08 20:00:47.590378757 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_disk_update_readahead.c 2022-07-08 20:01:47.462126256 +0800
@@ -1,6 +1,5 @@
/* { "version": "v5.16", "commit": "471aa704db4904f7af5a50019ca3b5b018c0cf62", "comment": "block: pass a gendisk to blk_queue_update_readahead", "author": "Christoph Hellwig <hch@lst.de>", "date": "Mon Aug 9 16:17:41 2021 +0200" } */
-#include <linux/genhd.h>
#include <linux/blkdev.h>
void foo(struct gendisk *d)
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_hd_struct.c b/drbd/drbd-kernel-compat/tests/have_hd_struct.c
--- a/drbd/drbd-kernel-compat/tests/have_hd_struct.c 2022-07-07 16:51:01.344672526 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_hd_struct.c 2022-07-08 18:31:19.633543494 +0800
@@ -1,5 +1,6 @@
/* { "version": "v5.10-rc5", "commit": "0d02129e76edf91cf04fabf1efbc3a9a1f1d729a", "comment": "struct hd_struct was merged into struct block_device", "author": "Christoph Hellwig <hch@lst.de>", "date": "Fri Nov 27 16:43:51 2020 +0100" } */
#include <linux/genhd.h>
+#include <linux/blkdev.h>
struct hd_struct hd;
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_revalidate_disk_size.c b/drbd/drbd-kernel-compat/tests/have_revalidate_disk_size.c
--- a/drbd/drbd-kernel-compat/tests/have_revalidate_disk_size.c 2022-07-07 16:51:06.892647651 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_revalidate_disk_size.c 2022-07-08 18:28:55.114151284 +0800
@@ -1,6 +1,6 @@
/* { "version": "v5.9-rc4", "commit": "659e56ba864d37b7ee0a49cd432205b2a5ca815e", "comment": "The revalidate_disk_size helper was added in v5.9-rc4", "author": "Christoph Hellwig <hch@lst.de>", "date": "Tue Sep 1 17:57:43 2020 +0200" } */
-#include <linux/genhd.h>
+#include <linux/blkdev.h>
void foo(struct gendisk *disk)
{
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_set_capacity_and_notify.c b/drbd/drbd-kernel-compat/tests/have_set_capacity_and_notify.c
--- a/drbd/drbd-kernel-compat/tests/have_set_capacity_and_notify.c 2022-07-07 16:51:12.376623066 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_set_capacity_and_notify.c 2022-07-08 18:29:26.082021496 +0800
@@ -1,6 +1,6 @@
/* { "version": "v5.10-rc5", "commit": "449f4ec9892ebc2f37a7eae6d97db2cf7c65e09a", "comment": "New (as far as DRBD is concerned) helper set_capacity_and_notify", "author": "Christoph Hellwig <hch@lst.de>", "date": "Mon Nov 16 15:56:56 2020 +0100" } */
-#include <linux/genhd.h>
+#include <linux/blkdev.h>
bool foo(struct gendisk *disk, sector_t size)
{
diff -Nupr a/drbd/drbd_int.h b/drbd/drbd_int.h
--- a/drbd/drbd_int.h 2022-07-07 16:50:13.032889154 +0800
+++ b/drbd/drbd_int.h 2022-07-07 16:51:38.292506862 +0800
@@ -28,7 +28,6 @@
#include <linux/major.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
-#include <linux/genhd.h>
#include <linux/idr.h>
#include <linux/lru_cache.h>
#include <linux/prefetch.h>

View File

@ -1,79 +0,0 @@
/* This patch is related with following upstream kernel commit */
commit 609be1066731fea86436f5f91022f82e592ab456
Author: Christoph Hellwig <hch@lst.de>
Date: Mon Jan 24 10:11:03 2022 +0100
block: pass a block_device and opf to bio_alloc_bioset
Pass the block_device and operation that we plan to use this bio for to
bio_alloc_bioset to optimize the assigment. NULL/0 can be passed, both
for the passthrough case on a raw request_queue and to temporarily avoid
refactoring some nasty code.
Also move the gfp_mask argument after the nr_vecs argument for a much
more logical calling convention matching what most of the kernel does.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220124091107.642561-16-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_actlog.c b/drbd/drbd_actlog.c
--- a/drbd/drbd_actlog.c 2022-07-07 18:23:47.643895879 +0800
+++ b/drbd/drbd_actlog.c 2022-07-08 06:46:56.597471149 +0800
@@ -94,8 +94,8 @@ static int _drbd_md_sync_page_io(struct
device->md_io.done = 0;
device->md_io.error = -ENODEV;
- bio = bio_alloc_bioset(GFP_NOIO, 1, &drbd_md_io_bio_set);
- bio_set_dev(bio, bdev->md_bdev);
+ bio = bio_alloc_bioset(bdev->md_bdev, 1, op | op_flags, GFP_NOIO,
+ &drbd_md_io_bio_set);
bio->bi_iter.bi_sector = sector;
err = -EIO;
if (bio_add_page(bio, device->md_io.page, size, 0) != size)
@@ -103,8 +103,6 @@ static int _drbd_md_sync_page_io(struct
bio->bi_private = device;
bio->bi_end_io = drbd_md_endio;
- bio->bi_opf = op | op_flags;
-
if (op != REQ_OP_WRITE && device->disk_state[NOW] == D_DISKLESS && device->ldev == NULL)
/* special case, drbd_md_read() during drbd_adm_attach(): no get_ldev */
;
diff -Nupr a/drbd/drbd_bitmap.c b/drbd/drbd_bitmap.c
--- a/drbd/drbd_bitmap.c 2022-07-07 18:24:13.671780513 +0800
+++ b/drbd/drbd_bitmap.c 2022-07-08 06:49:05.232970673 +0800
@@ -1123,12 +1123,13 @@ static void drbd_bm_endio(struct bio *bi
static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_hold(local)
{
- struct bio *bio = bio_alloc_bioset(GFP_NOIO, 1, &drbd_md_io_bio_set);
struct drbd_device *device = ctx->device;
+ unsigned int op = (ctx->flags & BM_AIO_READ) ? REQ_OP_READ : REQ_OP_WRITE;
+ struct bio *bio = bio_alloc_bioset(device->ldev->md_bdev, 1, op,
+ GFP_NOIO, &drbd_md_io_bio_set);
struct drbd_bitmap *b = device->bitmap;
struct page *page;
unsigned int len;
- unsigned int op = (ctx->flags & BM_AIO_READ) ? REQ_OP_READ : REQ_OP_WRITE;
sector_t on_disk_sector =
device->ldev->md.md_offset + device->ldev->md.bm_offset;
@@ -1153,14 +1154,12 @@ static void bm_page_io_async(struct drbd
bm_store_page_idx(page, page_nr);
} else
page = b->bm_pages[page_nr];
- bio_set_dev(bio, device->ldev->md_bdev);
bio->bi_iter.bi_sector = on_disk_sector;
/* bio_add_page of a single page to an empty bio will always succeed,
* according to api. Do we want to assert that? */
bio_add_page(bio, page, len, 0);
bio->bi_private = ctx;
bio->bi_end_io = drbd_bm_endio;
- bio->bi_opf = op;
if (drbd_insert_fault(device, (op == REQ_OP_WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) {
bio->bi_status = BLK_STS_IOERR;

View File

@ -1,70 +0,0 @@
/* this patch is related with following upstream kernel commit */
commit 07888c665b405b1cd3577ddebfeb74f4717a84c4
Author: Christoph Hellwig <hch@lst.de>
Date: Mon Jan 24 10:11:05 2022 +0100
block: pass a block_device and opf to bio_alloc
Pass the block_device and operation that we plan to use this bio for to
bio_alloc to optimize the assignment. NULL/0 can be passed, both for the
passthrough case on a raw request_queue and to temporarily avoid
refactoring some nasty code.
Also move the gfp_mask argument after the nr_vecs argument for a much
more logical calling convention matching what most of the kernel does.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220124091107.642561-18-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
--- a/drbd/drbd_receiver.c 2022-07-08 06:55:17.451589834 +0800
+++ b/drbd/drbd_receiver.c 2022-07-08 06:59:24.486571488 +0800
@@ -1263,7 +1263,8 @@ static void one_flush_endio(struct bio *
static void submit_one_flush(struct drbd_device *device, struct issue_flush_context *ctx)
{
- struct bio *bio = bio_alloc(GFP_NOIO, 0);
+ struct bio *bio = bio_alloc(device->ldev->backing_bdev, 0,
+ REQ_OP_FLUSH | REQ_PREFLUSH, GFP_NOIO);
struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO);
if (!bio || !octx) {
drbd_warn(device, "Could not allocate a bio, CANNOT ISSUE FLUSH\n");
@@ -1283,14 +1284,12 @@ static void submit_one_flush(struct drbd
octx->device = device;
octx->ctx = ctx;
- bio_set_dev(bio, device->ldev->backing_bdev);
bio->bi_private = octx;
bio->bi_end_io = one_flush_endio;
device->flush_jif = jiffies;
set_bit(FLUSH_PENDING, &device->flags);
atomic_inc(&ctx->pending);
- bio->bi_opf = REQ_OP_FLUSH | REQ_PREFLUSH;
submit_bio(bio);
}
@@ -1832,17 +1831,14 @@ next_bio:
goto fail;
}
- bio = bio_alloc(GFP_NOIO, nr_pages);
+ bio = bio_alloc(device->ldev->backing_bdev, nr_pages, peer_req->opf,
+ GFP_NOIO);
if (!bio) {
drbd_err(device, "submit_ee: Allocation of a bio failed (nr_pages=%u)\n", nr_pages);
goto fail;
}
/* > peer_req->i.sector, unless this is the first bio */
bio->bi_iter.bi_sector = sector;
- bio_set_dev(bio, device->ldev->backing_bdev);
- /* we special case some flags in the multi-bio case, see below
- * (REQ_PREFLUSH, or BIO_RW_BARRIER in older kernels) */
- bio->bi_opf = peer_req->opf;
bio->bi_private = peer_req;
bio->bi_end_io = drbd_peer_request_endio;

View File

@ -1,133 +0,0 @@
/* this patch is related with following 4 upstream kernel commits */
commit 8fd6533ef3f7729e4aa29ead83844c042688615a
Author: Haowen Bai <baihaowen@meizu.com>
Date: Wed Apr 6 21:07:15 2022 +0200
drbd: Return true/false (not 1/0) from bool functions
Return boolean values ("true" or "false") instead of 1 or 0 from bool
functions. This fixes the following warnings from coccicheck:
./drivers/block/drbd/drbd_req.c:912:9-10: WARNING: return of 0/1 in
function 'remote_due_to_read_balancing' with return type bool
Signed-off-by: Haowen Bai <baihaowen@meizu.com>
Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20220406190715.1938174-8-christoph.boehmwalder@linbit.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
commit b9b1335e640308acc1b8f26c739b804c80a6c147
Author: NeilBrown <neilb@suse.de>
Date: Tue Mar 22 14:39:10 2022 -0700
remove bdi_congested() and wb_congested() and related functions
These functions are no longer useful as no BDIs report congestions any
more.
Removing the test on bdi_write_contested() in current_may_throttle()
could cause a small change in behaviour, but only when PF_LOCAL_THROTTLE
is set.
So replace the calls by 'false' and simplify the code - and remove the
functions.
[akpm@linux-foundation.org: fix build]
Link: https://lkml.kernel.org/r/164549983742.9187.2570198746005819592.stgit@noble.brown
Signed-off-by: NeilBrown <neilb@suse.de>
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com> [nilfs]
Cc: Anna Schumaker <Anna.Schumaker@Netapp.com>
Cc: Chao Yu <chao@kernel.org>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Lars Ellenberg <lars.ellenberg@linbit.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Paolo Valente <paolo.valente@linaro.org>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
commit edb0872f44ec9976ea6d052cb4b93cd2d23ac2ba
Author: Christoph Hellwig <hch@lst.de>
Date: Mon Aug 9 16:17:43 2021 +0200
block: move the bdi from the request_queue to the gendisk
The backing device information only makes sense for file system I/O,
and thus belongs into the gendisk and not the lower level request_queue
structure. Move it there.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20210809141744.1203023-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
commit b807a2c5e0e2e81c96160682977c6f497cfcee96
Author: Christoph Hellwig <hch@lst.de>
Date: Thu Sep 24 08:51:29 2020 +0200
drbd: remove dead code in device_to_statistics
Ever since the switch to blk-mq, a lower device not used for VM
writeback will not be marked congested, so the check will never
trigger.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_req.c b/drbd/drbd_req.c
--- a/drbd/drbd_req.c 2022-07-08 18:08:35.075249173 +0800
+++ b/drbd/drbd_req.c 2022-07-08 07:50:00.750419154 +0800
@@ -1148,13 +1148,11 @@ static bool remote_due_to_read_balancing
struct drbd_peer_device *peer_device, sector_t sector,
enum drbd_read_balancing rbm)
{
- struct backing_dev_info *bdi;
int stripe_shift;
switch (rbm) {
case RB_CONGESTED_REMOTE:
- bdi = device->ldev->backing_bdev->bd_disk->queue->backing_dev_info;
- return bdi_read_congested(bdi);
+ return false;
case RB_LEAST_PENDING:
return atomic_read(&device->local_cnt) >
atomic_read(&peer_device->ap_pending_cnt) + atomic_read(&peer_device->rs_pending_cnt);
diff -Nupr a/drbd/drbd_nl.c b/drbd/drbd_nl.c
--- a/drbd/drbd_nl.c 2022-07-08 08:50:52.751580529 +0800
+++ b/drbd/drbd_nl.c 2022-07-08 08:51:20.971464720 +0800
@@ -5593,7 +5593,6 @@ static void device_to_statistics(struct
if (get_ldev(device)) {
struct drbd_md *md = &device->ldev->md;
u64 *history_uuids = (u64 *)s->history_uuids;
- struct request_queue *q;
int n;
spin_lock_irq(&md->uuid_lock);
@@ -5605,11 +5604,6 @@ static void device_to_statistics(struct
spin_unlock_irq(&md->uuid_lock);
s->dev_disk_flags = md->flags;
- q = bdev_get_queue(device->ldev->backing_bdev);
- s->dev_lower_blocked =
- bdi_congested(q->backing_dev_info,
- (1 << WB_async_congested) |
- (1 << WB_sync_congested));
put_ldev(device);
}
s->dev_size = get_capacity(device->vdisk);

View File

@ -1,28 +0,0 @@
/* this patch is related with following upstream kernel commit */
commit a34592ff6b78e84e11b19183b60cd240737f76f9
Author: Christoph Hellwig <hch@lst.de>
Date: Wed Feb 9 09:28:23 2022 +0100
scsi: drbd: Remove WRITE_SAME support
REQ_OP_WRITE_SAME was only ever submitted by the legacy Linux zeroing code,
which has switched to use REQ_OP_WRITE_ZEROES long ago.
Link: https://lore.kernel.org/r/20220209082828.2629273-3-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
---
diff -Nupr a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
--- a/drbd/drbd_receiver.c 2022-07-08 07:14:26.331017361 +0800
+++ b/drbd/drbd_receiver.c 2022-07-08 07:14:57.750893198 +0800
@@ -2737,8 +2737,6 @@ static unsigned long wire_flags_to_bio_o
return REQ_OP_WRITE_ZEROES;
if (dpf & DP_DISCARD)
return REQ_OP_DISCARD;
- if (dpf & DP_WSAME)
- return REQ_OP_WRITE_SAME;
else
return REQ_OP_WRITE;
}

View File

@ -1,30 +0,0 @@
/* this patch is related with following upstream kernel commit */
commit abfc426d1b2fb2176df59851a64223b58ddae7e7
Author: Christoph Hellwig <hch@lst.de>
Date: Wed Feb 2 17:01:09 2022 +0100
block: pass a block_device to bio_clone_fast
Pass a block_device to bio_clone_fast and __bio_clone_fast and give
the functions more suitable names.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Link: https://lore.kernel.org/r/20220202160109.108149-14-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_req.c b/drbd/drbd_req.c
--- a/drbd/drbd_req.c 2022-07-08 08:00:58.007783979 +0800
+++ b/drbd/drbd_req.c 2022-07-08 08:09:29.157733345 +0800
@@ -1543,7 +1543,8 @@ drbd_request_prepare(struct drbd_device
req->start_jif = bio_start_io_acct(req->master_bio);
if (get_ldev(device)) {
- req->private_bio = bio_clone_fast(bio, GFP_NOIO, &drbd_io_bio_set);
+ req->private_bio = bio_alloc_clone(device->ldev->backing_bdev, bio,
+ GFP_NOIO, &drbd_io_bio_set);
req->private_bio->bi_private = req;
req->private_bio->bi_end_io = drbd_request_endio;
}

View File

@ -1,156 +0,0 @@
/*
This patch is related with following upstream kernel commit.
This patch uses QUEUE_FLAG_STABLE_WRITES to replace QUEUE_FLAG_DISCARD.
*/
commit 70200574cc229f6ba038259e8142af2aa09e6976
Author: Christoph Hellwig <hch@lst.de>
Date: Fri Apr 15 06:52:55 2022 +0200
block: remove QUEUE_FLAG_DISCARD
Just use a non-zero max_discard_sectors as an indicator for discard
support, similar to what is done for write zeroes.
The only places where needs special attention is the RAID5 driver,
which must clear discard support for security reasons by default,
even if the default stacking rules would allow for it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> [drbd]
Acked-by: Jan Höppner <hoeppner@linux.ibm.com> [s390]
Acked-by: Coly Li <colyli@suse.de> [bcache]
Acked-by: David Sterba <dsterba@suse.com> [btrfs]
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220415045258.199825-25-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_blk_queue_flag_set.c b/drbd/drbd-kernel-compat/tests/have_blk_queue_flag_set.c
--- a/drbd/drbd-kernel-compat/tests/have_blk_queue_flag_set.c 2022-08-22 18:14:20.639382230 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_blk_queue_flag_set.c 2022-08-22 18:14:43.819285373 +0800
@@ -3,5 +3,5 @@
void dummy(struct request_queue *q)
{
- blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
+ blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q);
}
diff -Nupr a/drbd/drbd_main.c b/drbd/drbd_main.c
--- a/drbd/drbd_main.c 2022-08-23 08:04:26.097721587 +0800
+++ b/drbd/drbd_main.c 2022-08-23 08:04:41.449655955 +0800
@@ -1574,7 +1574,7 @@ static void assign_p_sizes_qlim(struct d
p->qlim->alignment_offset = cpu_to_be32(queue_alignment_offset(q));
p->qlim->io_min = cpu_to_be32(queue_io_min(q));
p->qlim->io_opt = cpu_to_be32(queue_io_opt(q));
- p->qlim->discard_enabled = blk_queue_discard(q);
+ p->qlim->discard_enabled = !!bdev_max_discard_sectors(device->ldev->backing_bdev);
p->qlim->discard_zeroes_data = queue_discard_zeroes_data(q);
p->qlim->write_same_capable = !!q->limits.max_write_same_sectors;
} else {
diff -Nupr a/drbd/drbd_nl.c b/drbd/drbd_nl.c
--- a/drbd/drbd_nl.c 2022-08-23 08:04:26.101721570 +0800
+++ b/drbd/drbd_nl.c 2022-08-23 08:04:41.453655938 +0800
@@ -1967,13 +1967,14 @@ static unsigned int drbd_max_discard_sec
static void decide_on_discard_support(struct drbd_device *device,
struct request_queue *q,
struct request_queue *b,
- bool discard_zeroes_if_aligned)
+ bool discard_zeroes_if_aligned,
+ struct drbd_backing_dev *bdev)
{
/* q = drbd device queue (device->rq_queue)
* b = backing device queue (device->ldev->backing_bdev->bd_disk->queue),
* or NULL if diskless
*/
- bool can_do = b ? blk_queue_discard(b) : true;
+ bool can_do = b ? bdev_max_discard_sectors(bdev->backing_bdev) : true;
if (can_do && b && !queue_discard_zeroes_data(b) && !discard_zeroes_if_aligned) {
can_do = false;
@@ -1992,23 +1993,12 @@ static void decide_on_discard_support(st
* topology on all peers. */
blk_queue_discard_granularity(q, 512);
q->limits.max_discard_sectors = drbd_max_discard_sectors(device->resource);
- blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
+ q->limits.max_write_zeroes_sectors =
+ drbd_max_discard_sectors(device->resource);
} else {
- blk_queue_flag_clear(QUEUE_FLAG_DISCARD, q);
blk_queue_discard_granularity(q, 0);
q->limits.max_discard_sectors = 0;
- }
-}
-
-static void fixup_discard_if_not_supported(struct request_queue *q)
-{
- /* To avoid confusion, if this queue does not support discard, clear
- * max_discard_sectors, which is what lsblk -D reports to the user.
- * Older kernels got this wrong in "stack limits".
- * */
- if (!blk_queue_discard(q)) {
- blk_queue_max_discard_sectors(q, 0);
- blk_queue_discard_granularity(q, 0);
+ q->limits.max_write_zeroes_sectors = 0;
}
}
@@ -2116,7 +2106,7 @@ static void drbd_setup_queue_param(struc
blk_queue_max_hw_sectors(q, max_hw_sectors);
/* This is the workaround for "bio would need to, but cannot, be split" */
blk_queue_segment_boundary(q, PAGE_SIZE-1);
- decide_on_discard_support(device, q, b, discard_zeroes_if_aligned);
+ decide_on_discard_support(device, q, b, discard_zeroes_if_aligned, bdev);
decide_on_write_same_support(device, q, b, o, disable_write_same);
if (b) {
@@ -2127,7 +2117,6 @@ static void drbd_setup_queue_param(struc
blk_queue_update_readahead(q);
#endif
}
- fixup_discard_if_not_supported(q);
fixup_write_zeroes(device, q);
}
@@ -2233,13 +2222,14 @@ static void sanitize_disk_conf(struct dr
struct drbd_backing_dev *nbc)
{
struct request_queue * const q = nbc->backing_bdev->bd_disk->queue;
+ struct block_device *bdev = nbc->backing_bdev;
if (disk_conf->al_extents < DRBD_AL_EXTENTS_MIN)
disk_conf->al_extents = DRBD_AL_EXTENTS_MIN;
if (disk_conf->al_extents > drbd_al_extents_max(nbc))
disk_conf->al_extents = drbd_al_extents_max(nbc);
- if (!blk_queue_discard(q) ||
+ if (!bdev_max_discard_sectors(bdev) ||
(!queue_discard_zeroes_data(q) && !disk_conf->discard_zeroes_if_aligned)) {
if (disk_conf->rs_discard_granularity) {
disk_conf->rs_discard_granularity = 0; /* disable feature */
@@ -2261,7 +2251,7 @@ static void sanitize_disk_conf(struct dr
/* compat:
* old kernel has 0 granularity means "unknown" means one sector.
* current kernel has 0 granularity means "discard not supported".
- * Not supported is checked above already with !blk_queue_discard(q).
+ * Not supported is checked above already with !blk_max_discard_sectors().
*/
unsigned int ql_dg = q->limits.discard_granularity ?: 512;
diff -Nupr a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
--- a/drbd/drbd_receiver.c 2022-08-23 08:04:26.105721553 +0800
+++ b/drbd/drbd_receiver.c 2022-08-23 08:25:31.188262629 +0800
@@ -1686,11 +1686,10 @@ int drbd_issue_discard_or_zero_out(struc
static bool can_do_reliable_discards(struct drbd_device *device)
{
- struct request_queue *q = bdev_get_queue(device->ldev->backing_bdev);
struct disk_conf *dc;
bool can_do;
- if (!blk_queue_discard(q))
+ if (!bdev_max_discard_sectors(device->ldev->backing_bdev))
return false;
if (queue_discard_zeroes_data(q))

View File

@ -1,47 +0,0 @@
/* This patch is related with following upstream kernel commit. */
From e511c4a3d2a1f64aafc1f5df37a2ffcf7ef91b55 Mon Sep 17 00:00:00 2001
From: Jane Chu <jane.chu@oracle.com>
Date: Fri, 13 May 2022 15:10:58 -0700
Subject: [PATCH] dax: introduce DAX_RECOVERY_WRITE dax access mode
Up till now, dax_direct_access() is used implicitly for normal
access, but for the purpose of recovery write, dax range with
poison is requested. To make the interface clear, introduce
enum dax_access_mode {
DAX_ACCESS,
DAX_RECOVERY_WRITE,
}
where DAX_ACCESS is used for normal dax access, and
DAX_RECOVERY_WRITE is used for dax recovery write.
Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jane Chu <jane.chu@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Mike Snitzer <snitzer@redhat.com>
Reviewed-by: Vivek Goyal <vgoyal@redhat.com>
Link: https://lore.kernel.org/r/165247982851.52965.11024212198889762949.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
diff -Nupr a/drbd/drbd_dax_pmem.c b/drbd/drbd_dax_pmem.c
--- a/drbd/drbd_dax_pmem.c 2022-08-22 16:26:24.786369807 +0800
+++ b/drbd/drbd_dax_pmem.c 2022-08-22 16:26:47.706276429 +0800
@@ -39,7 +39,7 @@ static int map_superblock_for_dax(struct
int id;
id = dax_read_lock();
- len = dax_direct_access(dax_dev, pgoff, want, &kaddr, &pfn_unused);
+ len = dax_direct_access(dax_dev, pgoff, want, DAX_ACCESS, &kaddr, &pfn_unused);
dax_read_unlock(id);
if (len < want)
@@ -100,7 +100,7 @@ int drbd_dax_map(struct drbd_backing_dev
int id;
id = dax_read_lock();
- len = dax_direct_access(dax_dev, pgoff, want, &kaddr, &pfn_unused);
+ len = dax_direct_access(dax_dev, pgoff, want, DAX_ACCESS, &kaddr, &pfn_unused);
dax_read_unlock(id);
if (len < want)

View File

@ -1,49 +0,0 @@
/* This patch is related with following upstream kernel commit. */
From 44abff2c0b970ae3d310b97617525dc01f248d7c Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Fri, 15 Apr 2022 06:52:57 +0200
Subject: [PATCH] block: decouple REQ_OP_SECURE_ERASE from REQ_OP_DISCARD
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Secure erase is a very different operation from discard in that it is
a data integrity operation vs hint. Fully split the limits and helper
infrastructure to make the separation more clear.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com> [drbd]
Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com> [nifs2]
Acked-by: Jaegeuk Kim <jaegeuk@kernel.org> [f2fs]
Acked-by: Coly Li <colyli@suse.de> [bcache]
Acked-by: David Sterba <dsterba@suse.com> [btrfs]
Acked-by: Chao Yu <chao@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220415045258.199825-27-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
--- a/drbd/drbd_receiver.c 2022-08-22 16:34:38.332333231 +0800
+++ b/drbd/drbd_receiver.c 2022-08-22 16:36:22.651901537 +0800
@@ -1658,7 +1658,8 @@ int drbd_issue_discard_or_zero_out(struc
start = tmp;
}
while (nr_sectors >= max_discard_sectors) {
- err |= blkdev_issue_discard(bdev, start, max_discard_sectors, GFP_NOIO, 0);
+ err |= blkdev_issue_discard(bdev, start, max_discard_sectors,
+ GFP_NOIO);
nr_sectors -= max_discard_sectors;
start += max_discard_sectors;
}
@@ -1670,7 +1671,7 @@ int drbd_issue_discard_or_zero_out(struc
nr = nr_sectors;
nr -= (unsigned int)nr % granularity;
if (nr) {
- err |= blkdev_issue_discard(bdev, start, nr, GFP_NOIO, 0);
+ err |= blkdev_issue_discard(bdev, start, nr, GFP_NOIO);
nr_sectors -= nr;
start += nr;
}

View File

@ -1,99 +0,0 @@
/* This patch is related with following upstream kernel commit. */
From 40349d0e16cedd0de561f59752c3249780fb749b Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Fri, 15 Apr 2022 06:52:35 +0200
Subject: [PATCH] drbd: remove assign_p_sizes_qlim
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fold each branch into its only caller.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
Link: https://lore.kernel.org/r/20220415045258.199825-5-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_main.c b/drbd/drbd_main.c
--- a/drbd/drbd_main.c 2022-08-22 23:16:08.082402396 +0800
+++ b/drbd/drbd_main.c 2022-08-22 23:22:31.292772570 +0800
@@ -1565,31 +1565,6 @@ int drbd_attach_peer_device(struct drbd_
return err;
}
-/* communicated if (agreed_features & DRBD_FF_WSAME) */
-static void assign_p_sizes_qlim(struct drbd_device *device, struct p_sizes *p, struct request_queue *q)
-{
- if (q) {
- p->qlim->physical_block_size = cpu_to_be32(queue_physical_block_size(q));
- p->qlim->logical_block_size = cpu_to_be32(queue_logical_block_size(q));
- p->qlim->alignment_offset = cpu_to_be32(queue_alignment_offset(q));
- p->qlim->io_min = cpu_to_be32(queue_io_min(q));
- p->qlim->io_opt = cpu_to_be32(queue_io_opt(q));
- p->qlim->discard_enabled = !!bdev_max_discard_sectors(device->ldev->backing_bdev);
- p->qlim->discard_zeroes_data = queue_discard_zeroes_data(q);
- p->qlim->write_same_capable = !!q->limits.max_write_same_sectors;
- } else {
- q = device->rq_queue;
- p->qlim->physical_block_size = cpu_to_be32(queue_physical_block_size(q));
- p->qlim->logical_block_size = cpu_to_be32(queue_logical_block_size(q));
- p->qlim->alignment_offset = 0;
- p->qlim->io_min = cpu_to_be32(queue_io_min(q));
- p->qlim->io_opt = cpu_to_be32(queue_io_opt(q));
- p->qlim->discard_enabled = 0;
- p->qlim->discard_zeroes_data = 0;
- p->qlim->write_same_capable = 0;
- }
-}
-
int drbd_send_sizes(struct drbd_peer_device *peer_device,
uint64_t u_size_diskless, enum dds_flags flags)
{
@@ -1610,7 +1585,9 @@ int drbd_send_sizes(struct drbd_peer_dev
memset(p, 0, packet_size);
if (get_ldev_if_state(device, D_NEGOTIATING)) {
- struct request_queue *q = bdev_get_queue(device->ldev->backing_bdev);
+ struct block_device *bdev = device->ldev->backing_bdev;
+ struct request_queue *q = bdev_get_queue(bdev);
+
d_size = drbd_get_max_capacity(device, device->ldev, false);
rcu_read_lock();
u_size = rcu_dereference(device->ldev->disk_conf)->disk_size;
@@ -1618,14 +1595,32 @@ int drbd_send_sizes(struct drbd_peer_dev
q_order_type = drbd_queue_order_type(device);
max_bio_size = queue_max_hw_sectors(q) << 9;
max_bio_size = min(max_bio_size, DRBD_MAX_BIO_SIZE);
- assign_p_sizes_qlim(device, p, q);
+ p->qlim->physical_block_size =
+ cpu_to_be32(bdev_physical_block_size(bdev));
+ p->qlim->logical_block_size =
+ cpu_to_be32(bdev_logical_block_size(bdev));
+ p->qlim->alignment_offset =
+ cpu_to_be32(bdev_alignment_offset(bdev));
+ p->qlim->io_min = cpu_to_be32(bdev_io_min(bdev));
+ p->qlim->io_opt = cpu_to_be32(bdev_io_opt(bdev));
+ p->qlim->discard_enabled = !!bdev_max_discard_sectors(bdev);
put_ldev(device);
} else {
+ struct request_queue *q = device->rq_queue;
+
+ p->qlim->physical_block_size =
+ cpu_to_be32(queue_physical_block_size(q));
+ p->qlim->logical_block_size =
+ cpu_to_be32(queue_logical_block_size(q));
+ p->qlim->alignment_offset = 0;
+ p->qlim->io_min = cpu_to_be32(queue_io_min(q));
+ p->qlim->io_opt = cpu_to_be32(queue_io_opt(q));
+ p->qlim->discard_enabled = 0;
+
d_size = 0;
u_size = u_size_diskless;
q_order_type = QUEUE_ORDERED_NONE;
max_bio_size = DRBD_MAX_BIO_SIZE; /* ... multiple BIOs per peer_request */
- assign_p_sizes_qlim(device, p, NULL);
}
if (peer_device->connection->agreed_pro_version <= 94)

View File

@ -1,49 +0,0 @@
/*
This patch is related with following upstream kernel commit.
blk_alloc_disk__no_present.cocci doesn't work for this patch.
*/
From 8b9ab62662048a3274361c7e5f64037c2c133e2c Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Sun, 19 Jun 2022 08:05:52 +0200
Subject: [PATCH] block: remove blk_cleanup_disk
blk_cleanup_disk is nothing but a trivial wrapper for put_disk now,
so remove it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20220619060552.1850436-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr a/drbd/drbd_main.c b/drbd/drbd_main.c
--- a/drbd/drbd_main.c 2022-10-22 19:16:29.466820303 +0800
+++ b/drbd/drbd_main.c 2022-10-22 19:17:08.098772762 +0800
@@ -2928,7 +2928,7 @@ static void drbd_device_finalize_work_fn
device->bitmap = NULL;
}
- blk_cleanup_disk(device->vdisk);
+ put_disk(device->vdisk);
kfree(device);
@@ -3810,7 +3810,7 @@ enum drbd_ret_code drbd_create_device(st
return NO_ERROR;
out_cleanup_disk:
- blk_cleanup_disk(disk);
+ put_disk(disk);
out_remove_peer_device:
list_add_rcu(&tmp, &device->peer_devices);
list_del_init(&device->peer_devices);
@@ -3848,7 +3848,7 @@ out_no_peer_device:
out_no_bitmap:
__free_page(device->md_io.page);
out_no_io_page:
- blk_cleanup_disk(disk);
+ put_disk(disk);
out_no_disk:
kref_put(&resource->kref, drbd_destroy_resource);
kref_debug_put(&resource->kref_debug, 4);

View File

@ -1,38 +0,0 @@
From d9a0a8d2c02f7a8da542230bebf0045f24f0fc74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Thu, 13 Oct 2022 15:00:46 +0200
Subject: [PATCH] drbd: remove usage of bdevname
See upstream commit 1b70ccecaed4 (drbd: stop using bdevname in
drbd_report_io_error)
---
drbd/drbd_req.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drbd/drbd_req.c b/drbd/drbd_req.c
index a6b9723fde42..1ee50f1c1720 100644
--- a/drbd/drbd_req.c
+++ b/drbd/drbd_req.c
@@ -868,16 +868,14 @@ static void mod_rq_state(struct drbd_request *req, struct bio_and_error *m,
static void drbd_report_io_error(struct drbd_device *device, struct drbd_request *req)
{
- char b[BDEVNAME_SIZE];
-
if (!drbd_ratelimit())
return;
- drbd_warn(device, "local %s IO error sector %llu+%u on %s\n",
+ drbd_warn(device, "local %s IO error sector %llu+%u on %pg\n",
(req->local_rq_state & RQ_WRITE) ? "WRITE" : "READ",
(unsigned long long)req->i.sector,
req->i.size >> 9,
- bdevname(device->ldev->backing_bdev, b));
+ device->ldev->backing_bdev);
}
/* Helper for HANDED_OVER_TO_NETWORK.
--
2.26.2

View File

@ -1,52 +0,0 @@
From c89bb88cde9349b11dbf255e762203c626e70d30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Mon, 3 Oct 2022 14:49:55 +0200
Subject: [PATCH] drbd: add comments explaining removal of bdi congestion
The bdi congestion tracking framework was removed, so this leaves a few
confusing places where we just blindly set a "congested" flag to false.
Add some comments, briefly explaining the history of why it is like
that.
---
by heming.zhao@suse.com:
bsc-1201335_06-bdi.patch followed upstream patch b807a2c5e0e2, which
removed s->dev_lower_blocked from device_to_statistics(). But drbd main
branch latest code still keep s->dev_lower_blocked, I used this patch
to restore s->dev_lower_blocked.
---
diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c
index 020372fdb258..6a2afd184ae6 100644
--- a/drbd/drbd_nl.c
+++ b/drbd/drbd_nl.c
@@ -5514,6 +5514,10 @@ static void device_to_statistics(struct device_statistics *s,
spin_unlock_irq(&md->uuid_lock);
s->dev_disk_flags = md->flags;
+ /* originally, this used the bdi congestion framework,
+ * but that was removed in linux 5.18.
+ * so just never report the lower device as congested. */
+ s->dev_lower_blocked = false;
put_ldev(device);
}
s->dev_size = get_capacity(device->vdisk);
diff --git a/drbd/drbd_req.c b/drbd/drbd_req.c
index e5098bf8b26c..02dbc61946ca 100644
--- a/drbd/drbd_req.c
+++ b/drbd/drbd_req.c
@@ -1275,6 +1275,9 @@ static bool remote_due_to_read_balancing(struct drbd_device *device,
switch (rbm) {
case RB_CONGESTED_REMOTE:
+ /* originally, this used the bdi congestion framework,
+ * but that was removed in linux 5.18.
+ * so just never report the lower device as congested. */
return false;
case RB_LEAST_PENDING:
return atomic_read(&device->local_cnt) >
--
2.26.2

View File

@ -1,88 +0,0 @@
From f465ef1a70c7b559fcf3924e450bc5e836e448de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Mon, 3 Oct 2022 15:56:44 +0200
Subject: [PATCH] drbd: fix static analysis warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC now does some pretty impressive static analysis, and it spits out
some warnings when compiling DRBD. Newer kernels "unfortunately" set
-Werror, which forces us to stop sweeping these under the rug.
This commits fixes two distinct classes of warning.
First, if a netlink field is declared with DRBD_GENLA_F_MANDATORY, it
can never be NULL. The compiler catches this and complains:
drbd_nl.c:3490:53: warning: the comparison will always evaluate
as true for the address of integrity_alg
will never be NULL [-Waddress]
3490 | if (!new_net_conf->integrity_alg != !old_net_conf->integrity_alg)
| ^
And similarly for net_conf->name. The fix is simple: just remove the
checks.
The other warning that is fixed is:
drbd_main.c:421:55: warning: unused variable ddm [-Wunused-variable]
421 | DEFINE_DYNAMIC_DEBUG_METADATA(ddm, "Bad barrier ack dump");
| ^~~
Which happens when dynamic debug is not enabled, erasing the
DYNAMIC_DEBUG_BRANCH(ddm) below.
This is easily fixed by "accessing" the declared variable by doing a
dummy cast to void.
Finally, the compiler complains that the DYNAMIC_DEBUG macros are
redefined in drbd_polymorph_printk.h, so #undef them before #defining
them.
---
drbd/drbd_nl.c | 5 +----
drbd/drbd_polymorph_printk.h | 5 ++++-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c
index 6a2afd184ae6..de064215b638 100644
--- a/drbd/drbd_nl.c
+++ b/drbd/drbd_nl.c
@@ -3553,9 +3553,6 @@ _check_net_options(struct drbd_connection *connection, struct net_conf *old_net_
if (new_net_conf->two_primaries != old_net_conf->two_primaries)
return ERR_NEED_APV_100;
- if (!new_net_conf->integrity_alg != !old_net_conf->integrity_alg)
- return ERR_NEED_APV_100;
-
if (strcmp(new_net_conf->integrity_alg, old_net_conf->integrity_alg))
return ERR_NEED_APV_100;
}
@@ -5398,7 +5395,7 @@ static int nla_put_drbd_cfg_context(struct sk_buff *skb,
if (connection) {
nla_put_u32(skb, T_ctx_peer_node_id, connection->peer_node_id);
rcu_read_lock();
- if (connection->transport.net_conf && connection->transport.net_conf->name)
+ if (connection->transport.net_conf)
nla_put_string(skb, T_ctx_conn_name, connection->transport.net_conf->name);
rcu_read_unlock();
}
diff --git a/drbd/drbd_polymorph_printk.h b/drbd/drbd_polymorph_printk.h
index 1ce6cc2e6f74..4e7f2f17014e 100644
--- a/drbd/drbd_polymorph_printk.h
+++ b/drbd/drbd_polymorph_printk.h
@@ -2,7 +2,10 @@
#define DRBD_POLYMORPH_PRINTK_H
#if !defined(CONFIG_DYNAMIC_DEBUG)
-#define DEFINE_DYNAMIC_DEBUG_METADATA(D, F) const char *D = F
+#undef DEFINE_DYNAMIC_DEBUG_METADATA
+#undef __dynamic_pr_debug
+#undef DYNAMIC_DEBUG_BRANCH
+#define DEFINE_DYNAMIC_DEBUG_METADATA(D, F) const char *D = F; ((void)D)
#define __dynamic_pr_debug(D, F, args...) do { (void)(D); if (0) printk(F, ## args); } while(0)
#define DYNAMIC_DEBUG_BRANCH(D) false
#endif
--
2.26.2

View File

@ -1,31 +0,0 @@
From 1b4b7a945d5191225965d8e79fc6705c1b394e1d Mon Sep 17 00:00:00 2001
From: Philipp Reisner <philipp.reisner@linbit.com>
Date: Mon, 10 Oct 2022 09:20:20 +0200
Subject: [PATCH] drbd: fix warning about initializing multiple struct members
with one memset()
It comes from 6cedeb568b, November 2008
"proto version 89: support checksum based resyn"
Modern compiler warns about this and warnings might be treated as errors.
---
drbd/drbd_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drbd/drbd_main.c b/drbd/drbd_main.c
index 84040ed4bfaf..fe8cf60a85fc 100644
--- a/drbd/drbd_main.c
+++ b/drbd/drbd_main.c
@@ -1150,7 +1150,8 @@ int drbd_send_sync_param(struct drbd_peer_device *peer_device)
return -EIO;
/* initialize verify_alg and csums_alg */
- memset(p->verify_alg, 0, 2 * SHARED_SECRET_MAX);
+ memset(p->verify_alg, 0, sizeof(p->verify_alg));
+ memset(p->csums_alg, 0, sizeof(p->csums_alg));
rcu_read_lock();
nc = rcu_dereference(peer_device->connection->transport.net_conf);
--
2.26.2

View File

@ -1,62 +0,0 @@
/* This patch related with below upstream kernel commit */
commit 5a97806f7dc069d9561d9930a2ae108700e222ab
Author: Christoph Hellwig <hch@lst.de>
Date: Wed Jul 27 12:22:55 2022 -0400
block: change the blk_queue_split calling convention
The double indirect bio leads to somewhat suboptimal code generation.
Instead return the (original or split) bio, and make sure the
request_queue arguments to the lower level helpers is passed after the
bio to avoid constant reshuffling of the argument passing registers.
Also give it and the helpers used to implement it more descriptive names.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220727162300.3089193-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
diff -Nupr drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/cocci/bio_split_to_limits__yes_present.cocci b/drbd/drbd-kernel-compat/cocci/bio_split_to_limits__yes_present.cocci
--- drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/cocci/bio_split_to_limits__yes_present.cocci 1970-01-01 08:00:00.000000000 +0800
+++ b/drbd/drbd-kernel-compat/cocci/bio_split_to_limits__yes_present.cocci 2023-01-05 09:58:43.742081303 +0800
@@ -0,0 +1,5 @@
+@@
+expression b;
+@@
+- blk_queue_split(&b)
++ bio_split_to_limits(b)
diff -Nupr drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
--- drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/gen_patch_names.c 2023-01-05 09:02:53.371032160 +0800
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c 2023-01-05 09:59:24.921772632 +0800
@@ -92,8 +92,13 @@ int main(int argc, char **argv)
patch(1, "timer_setup", true, false,
COMPAT_HAVE_TIMER_SETUP, "present");
-#if defined(COMPAT_HAVE_BLK_QUEUE_SPLIT_BIO)
- /* "modern" version (>=5.9) with only 1 argument. nothing to do */
+#if defined(COMPAT_HAVE_BIO_SPLIT_TO_LIMITS)
+ /* since 5a97806f7dc069d9561d9930a2ae108700e222ab, blk_queue_split_bio
+ * change to bio_split_to_limits */
+ patch(1, "bio_split_to_limits", false, true,
+ YES, "present");
+#elif defined(COMPAT_HAVE_BLK_QUEUE_SPLIT_BIO)
+ /* "modern" version (>=5.9 && < v6.0-rc1) with only 1 argument. nothing to do */
#elif defined(COMPAT_HAVE_BLK_QUEUE_SPLIT_Q_BIO)
/* older version with 2 arguments */
patch(1, "blk_queue_split", false, true,
diff -Nupr a/drbd/drbd-kernel-compat/tests/have_bio_split_to_limits.c b/drbd/drbd-kernel-compat/tests/have_bio_split_to_limits.c
--- a/drbd/drbd-kernel-compat/tests/have_bio_split_to_limits.c 1970-01-01 08:00:00.000000000 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_bio_split_to_limits.c 2023-01-05 10:08:37.081595899 +0800
@@ -0,0 +1,9 @@
+/* { "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 <hch@lst.de>", "date": "Wed Jul 1 10:59:39 2020 +0200" } */
+
+
+#include <linux/blkdev.h>
+
+void dummy(struct bio *bio)
+{
+ bio_split_to_limits(bio);
+}

View File

@ -1,128 +0,0 @@
by heming.zhao@suse.com on 20220105 (bsc#1206791)
This is SUSE special patch, and this patch cocci codes were partly
copied from upstream kernel commit 81895a65ec63ee1daec3255dc1a06675d2fbe915
("treewide: use prandom_u32_max() when possible, part 1").
Because I don't know cocci syntax, so in drbd_state.c this patch
directly modifies prandom_u32() to prandom_u32_max(U32_MAX). All
other cases use cocci to modify.
---
by heming.zhao@suse.com on 20230311 (bsc#1209168)
OpenSUSE kernel had been updated to v6.2.1, modification on 20220105
is not suitable. The upstream commit 8032bf1233a7 ("treewide:
use get_random_u32_below() instead of deprecated function") replaced
the prandom.h function prandom_u32_max with the random.h function
get_random_u32_below.
I changed this patch under latest kernel, using get_random_u32_below
to replace prandom_u32_max.
---
diff -Nupr a/drbd/drbd-kernel-compat/cocci/prandom_u32__no_present.cocci b/drbd/drbd-kernel-compat/cocci/prandom_u32__no_present.cocci
--- a/drbd/drbd-kernel-compat/cocci/prandom_u32__no_present.cocci 2023-01-04 23:15:30.435899748 +0800
+++ b/drbd/drbd-kernel-compat/cocci/prandom_u32__no_present.cocci 2023-01-05 08:58:23.177198823 +0800
@@ -1,3 +1,76 @@
-@@ @@
-- prandom_u32()
-+ random32()
+@basic@
+expression E;
+type T;
+identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32";
+typedef u64;
+@@
+(
+- ((T)get_random_u32() % (E))
++ get_random_u32_below(E)
+|
+- ((T)get_random_u32() & ((E) - 1))
++ get_random_u32_below(E * XXX_MAKE_SURE_E_IS_POW2)
+|
+- ((u64)(E) * get_random_u32() >> 32)
++ get_random_u32_below(E)
+|
+- ((T)get_random_u32() & ~PAGE_MASK)
++ get_random_u32_below(PAGE_SIZE)
+)
+
+@multi_line@
+identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32";
+identifier RAND;
+expression E;
+@@
+
+- RAND = get_random_u32();
+ ... when != RAND
+- RAND %= (E);
++ RAND = get_random_u32_below(E);
+
+// Find a potential literal
+@literal_mask@
+expression LITERAL;
+type T;
+identifier get_random_u32 =~ "get_random_int|prandom_u32|get_random_u32";
+position p;
+@@
+
+ ((T)get_random_u32()@p & (LITERAL))
+
+// Add one to the literal.
+@script:python add_one@
+literal << literal_mask.LITERAL;
+RESULT;
+@@
+
+value = None
+if literal.startswith('0x'):
+ value = int(literal, 16)
+elif literal[0] in '123456789':
+ value = int(literal, 10)
+if value is None:
+ print("I don't know how to handle %s" % (literal))
+ cocci.include_match(False)
+elif value == 2**32 - 1 or value == 2**31 - 1 or value == 2**24 - 1 or value == 2**16 - 1 or value == 2**8 - 1:
+ print("Skipping 0x%x for cleanup elsewhere" % (value))
+ cocci.include_match(False)
+elif value & (value + 1) != 0:
+ print("Skipping 0x%x because it's not a power of two minus one" % (value))
+ cocci.include_match(False)
+elif literal.startswith('0x'):
+ coccinelle.RESULT = cocci.make_expr("0x%x" % (value + 1))
+else:
+ coccinelle.RESULT = cocci.make_expr("%d" % (value + 1))
+
+// Replace the literal mask with the calculated result.
+@plus_one@
+expression literal_mask.LITERAL;
+position literal_mask.p;
+expression add_one.RESULT;
+identifier FUNC;
+@@
+
+- (FUNC()@p & (LITERAL))
++ get_random_u32_below(RESULT)
diff -Nupr a/drbd/drbd_state.c b/drbd/drbd_state.c
--- a/drbd/drbd_state.c 2023-01-05 09:00:01.252434773 +0800
+++ b/drbd/drbd_state.c 2023-01-05 09:02:47.519078927 +0800
@@ -4488,7 +4488,7 @@ change_cluster_wide_state(bool (*change)
}
do
- reply->tid = prandom_u32();
+ reply->tid = get_random_u32_below(U32_MAX);
while (!reply->tid);
request.tid = cpu_to_be32(reply->tid);
@@ -4716,7 +4716,7 @@ retry:
*reply = (struct twopc_reply) { 0 };
do
- reply->tid = prandom_u32();
+ reply->tid = get_random_u32_below(U32_MAX);
while (!reply->tid);
request.tid = cpu_to_be32(reply->tid);

View File

@ -1,8 +0,0 @@
diff -Nupr drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_req_op_write_zeroes.c b/drbd/drbd-kernel-compat/tests/have_req_op_write_zeroes.c
--- drbd-9.0.30~1+git.8e9c0812/drbd/drbd-kernel-compat/tests/have_req_op_write_zeroes.c 2021-11-09 22:43:17.000000000 +0800
+++ b/drbd/drbd-kernel-compat/tests/have_req_op_write_zeroes.c 2023-01-05 10:40:17.383202903 +0800
@@ -1,3 +1,3 @@
#include <linux/blk_types.h>
-enum req_opf dummy = REQ_OP_WRITE_ZEROES;
+enum req_op dummy = REQ_OP_WRITE_ZEROES;

View File

@ -1,391 +0,0 @@
From 2573d91be862ed65781c4a37dcaaa051a905a48a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Wed, 5 Oct 2022 13:36:18 +0200
Subject: [PATCH] drbd: fix use-after-free bugs in get_initial_state
See upstream commit aadb22ba2f65 ("drbd: Fix five use after free bugs
in get_initial_state").
Original message:
In get_initial_state, it calls notify_initial_state_done(skb,..) if
cb->args[5]==1. If genlmsg_put() failed in notify_initial_state_done(),
the skb will be freed by nlmsg_free(skb).
Then get_initial_state will goto out and the freed skb will be used by
return value skb->len, which is a uaf bug.
What's worse, the same problem goes even further: skb can also be
freed in the notify_*_state_change -> notify_*_state calls below.
Thus 4 additional uaf bugs happened.
My patch lets the problem callee functions: notify_initial_state_done
and notify_*_state_change return an error code if errors happen.
So that the error codes could be propagated and the uaf bugs can be avoid.
---
drbd/drbd_int.h | 10 ++++----
drbd/drbd_nl.c | 51 ++++++++++++++++++++++++----------------
drbd/drbd_state.c | 18 +++++++-------
drbd/drbd_state_change.h | 8 +++----
4 files changed, 49 insertions(+), 38 deletions(-)
diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h
index fcde3b96bd6a..4bf2c6dde93d 100644
--- a/drbd/drbd_int.h
+++ b/drbd/drbd_int.h
@@ -2154,30 +2154,30 @@ extern int drbd_al_initialize(struct drbd_device *, void *);
extern struct mutex notification_mutex;
extern atomic_t drbd_genl_seq;
-extern void notify_resource_state(struct sk_buff *,
+extern int notify_resource_state(struct sk_buff *,
unsigned int,
struct drbd_resource *,
struct resource_info *,
struct rename_resource_info *,
enum drbd_notification_type);
-extern void notify_device_state(struct sk_buff *,
+extern int notify_device_state(struct sk_buff *,
unsigned int,
struct drbd_device *,
struct device_info *,
enum drbd_notification_type);
-extern void notify_connection_state(struct sk_buff *,
+extern int notify_connection_state(struct sk_buff *,
unsigned int,
struct drbd_connection *,
struct connection_info *,
enum drbd_notification_type);
-extern void notify_peer_device_state(struct sk_buff *,
+extern int notify_peer_device_state(struct sk_buff *,
unsigned int,
struct drbd_peer_device *,
struct peer_device_info *,
enum drbd_notification_type);
extern void notify_helper(enum drbd_notification_type, struct drbd_device *,
struct drbd_connection *, const char *, int);
-extern void notify_path(struct drbd_connection *, struct drbd_path *,
+extern int notify_path(struct drbd_connection *, struct drbd_path *,
enum drbd_notification_type);
extern void drbd_broadcast_peer_device_state(struct drbd_peer_device *);
diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c
index 3dee5a1ab2eb..4418d143e09f 100644
--- a/drbd/drbd_nl.c
+++ b/drbd/drbd_nl.c
@@ -6492,7 +6492,7 @@ static int nla_put_notification_header(struct sk_buff *msg,
return drbd_notification_header_to_skb(msg, &nh, true);
}
-void notify_resource_state(struct sk_buff *skb,
+int notify_resource_state(struct sk_buff *skb,
unsigned int seq,
struct drbd_resource *resource,
struct resource_info *resource_info,
@@ -6546,16 +6546,17 @@ void notify_resource_state(struct sk_buff *skb,
if (err && err != -ESRCH)
goto failed;
}
- return;
+ return 0;
nla_put_failure:
nlmsg_free(skb);
failed:
drbd_err(resource, "Error %d while broadcasting event. Event seq:%u\n",
err, seq);
+ return err;
}
-void notify_device_state(struct sk_buff *skb,
+int notify_device_state(struct sk_buff *skb,
unsigned int seq,
struct drbd_device *device,
struct device_info *device_info,
@@ -6595,17 +6596,18 @@ void notify_device_state(struct sk_buff *skb,
if (err && err != -ESRCH)
goto failed;
}
- return;
+ return 0;
nla_put_failure:
nlmsg_free(skb);
failed:
drbd_err(device, "Error %d while broadcasting event. Event seq:%u\n",
err, seq);
+ return err;
}
/* open coded path_parms_to_skb() iterating of the list */
-void notify_connection_state(struct sk_buff *skb,
+int notify_connection_state(struct sk_buff *skb,
unsigned int seq,
struct drbd_connection *connection,
struct connection_info *connection_info,
@@ -6646,16 +6648,17 @@ void notify_connection_state(struct sk_buff *skb,
if (err && err != -ESRCH)
goto failed;
}
- return;
+ return 0;
nla_put_failure:
nlmsg_free(skb);
failed:
drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n",
err, seq);
+ return err;
}
-void notify_peer_device_state(struct sk_buff *skb,
+int notify_peer_device_state(struct sk_buff *skb,
unsigned int seq,
struct drbd_peer_device *peer_device,
struct peer_device_info *peer_device_info,
@@ -6696,13 +6699,14 @@ void notify_peer_device_state(struct sk_buff *skb,
if (err && err != -ESRCH)
goto failed;
}
- return;
+ return 0;
nla_put_failure:
nlmsg_free(skb);
failed:
drbd_err(peer_device, "Error %d while broadcasting event. Event seq:%u\n",
err, seq);
+ return err;
}
void drbd_broadcast_peer_device_state(struct drbd_peer_device *peer_device)
@@ -6714,7 +6718,7 @@ void drbd_broadcast_peer_device_state(struct drbd_peer_device *peer_device)
mutex_unlock(&notification_mutex);
}
-void notify_path_state(struct sk_buff *skb,
+int notify_path_state(struct sk_buff *skb,
unsigned int seq,
/* until we have a backpointer in drbd_path, we need an explicit connection: */
struct drbd_connection *connection,
@@ -6754,7 +6758,7 @@ void notify_path_state(struct sk_buff *skb,
if (err && err != -ESRCH)
goto failed;
}
- return;
+ return 0;
nla_put_failure:
nlmsg_free(skb);
@@ -6762,16 +6766,19 @@ failed:
/* FIXME add path specifics to our drbd_polymorph_printk.h */
drbd_err(connection, "path: Error %d while broadcasting event. Event seq:%u\n",
err, seq);
+ return err;
}
-void notify_path(struct drbd_connection *connection, struct drbd_path *path, enum drbd_notification_type type)
+int notify_path(struct drbd_connection *connection, struct drbd_path *path, enum drbd_notification_type type)
{
struct drbd_path_info path_info;
+ int err;
path_info.path_established = path->established;
mutex_lock(&notification_mutex);
- notify_path_state(NULL, 0, connection, path, &path_info, type);
+ err = notify_path_state(NULL, 0, connection, path, &path_info, type);
mutex_unlock(&notification_mutex);
+ return err;
}
@@ -6823,7 +6830,7 @@ fail:
err, seq);
}
-static void notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
+static int notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
{
struct drbd_genlmsghdr *dh;
int err;
@@ -6837,11 +6844,12 @@ static void notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
if (nla_put_notification_header(skb, NOTIFY_EXISTS))
goto nla_put_failure;
genlmsg_end(skb, dh);
- return;
+ return 0;
nla_put_failure:
nlmsg_free(skb);
pr_err("Error %d sending event. Event seq:%u\n", err, seq);
+ return err;
}
static void free_state_changes(struct list_head *list)
@@ -6869,6 +6877,7 @@ static int get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
unsigned int seq = cb->args[2];
unsigned int n;
enum drbd_notification_type flags = 0;
+ int err = 0;
/* There is no need for taking notification_mutex here: it doesn't
matter if the initial state events mix with later state change
@@ -6877,20 +6886,20 @@ static int get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
cb->args[5]--;
if (cb->args[5] == 1) {
- notify_initial_state_done(skb, seq);
+ err = notify_initial_state_done(skb, seq);
goto out;
}
n = cb->args[4]++;
if (cb->args[4] < cb->args[3])
flags |= NOTIFY_CONTINUES;
if (n < 1) {
- notify_resource_state_change(skb, seq, state_change,
+ err = notify_resource_state_change(skb, seq, state_change,
NOTIFY_EXISTS | flags);
goto next;
}
n--;
if (n < state_change->n_connections) {
- notify_connection_state_change(skb, seq, &state_change->connections[n],
+ err = notify_connection_state_change(skb, seq, &state_change->connections[n],
NOTIFY_EXISTS | flags);
goto next;
}
@@ -6900,7 +6909,7 @@ static int get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
struct drbd_path_info path_info;
path_info.path_established = path_state->path_established;
- notify_path_state(skb, seq,
+ err = notify_path_state(skb, seq,
path_state->connection,
path_state->path,
&path_info, NOTIFY_EXISTS | flags);
@@ -6908,13 +6917,13 @@ static int get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
}
n -= state_change->n_paths;
if (n < state_change->n_devices) {
- notify_device_state_change(skb, seq, &state_change->devices[n],
+ err = notify_device_state_change(skb, seq, &state_change->devices[n],
NOTIFY_EXISTS | flags);
goto next;
}
n -= state_change->n_devices;
if (n < state_change->n_devices * state_change->n_connections) {
- notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n],
+ err = notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n],
NOTIFY_EXISTS | flags);
goto next;
}
@@ -6930,6 +6939,8 @@ next:
cb->args[4] = 0;
}
out:
+ if (err)
+ return err;
return skb->len;
}
diff --git a/drbd/drbd_state.c b/drbd/drbd_state.c
index de53fa7a21f1..cec88b18852f 100644
--- a/drbd/drbd_state.c
+++ b/drbd/drbd_state.c
@@ -3062,7 +3062,7 @@ static union drbd_state state_change_word(struct drbd_state_change *state_change
return state;
}
-void notify_resource_state_change(struct sk_buff *skb,
+int notify_resource_state_change(struct sk_buff *skb,
unsigned int seq,
struct drbd_state_change *state_change,
enum drbd_notification_type type)
@@ -3079,10 +3079,10 @@ void notify_resource_state_change(struct sk_buff *skb,
.res_susp_quorum = state_change_is_susp_quorum(state_change, NEW),
};
- notify_resource_state(skb, seq, resource, &resource_info, NULL, type);
+ return notify_resource_state(skb, seq, resource, &resource_info, NULL, type);
}
-void notify_connection_state_change(struct sk_buff *skb,
+int notify_connection_state_change(struct sk_buff *skb,
unsigned int seq,
struct drbd_connection_state_change *connection_state_change,
enum drbd_notification_type type)
@@ -3093,10 +3093,10 @@ void notify_connection_state_change(struct sk_buff *skb,
.conn_role = connection_state_change->peer_role[NEW],
};
- notify_connection_state(skb, seq, connection, &connection_info, type);
+ return notify_connection_state(skb, seq, connection, &connection_info, type);
}
-void notify_device_state_change(struct sk_buff *skb,
+int notify_device_state_change(struct sk_buff *skb,
unsigned int seq,
struct drbd_device_state_change *device_state_change,
enum drbd_notification_type type)
@@ -3105,10 +3105,10 @@ void notify_device_state_change(struct sk_buff *skb,
struct device_info device_info;
device_state_change_to_info(&device_info, device_state_change);
- notify_device_state(skb, seq, device, &device_info, type);
+ return notify_device_state(skb, seq, device, &device_info, type);
}
-void notify_peer_device_state_change(struct sk_buff *skb,
+int notify_peer_device_state_change(struct sk_buff *skb,
unsigned int seq,
struct drbd_peer_device_state_change *state_change,
enum drbd_notification_type type)
@@ -3117,7 +3117,7 @@ void notify_peer_device_state_change(struct sk_buff *skb,
struct peer_device_info peer_device_info;
peer_device_state_change_to_info(&peer_device_info, state_change);
- notify_peer_device_state(skb, seq, peer_device, &peer_device_info, type);
+ return notify_peer_device_state(skb, seq, peer_device, &peer_device_info, type);
}
static void notify_state_change(struct drbd_state_change *state_change)
@@ -3125,7 +3125,7 @@ static void notify_state_change(struct drbd_state_change *state_change)
struct drbd_resource_state_change *resource_state_change = &state_change->resource[0];
bool resource_state_has_changed;
unsigned int n_device, n_connection, n_peer_device, n_peer_devices;
- void (*last_func)(struct sk_buff *, unsigned int, void *,
+ int (*last_func)(struct sk_buff *, unsigned int, void *,
enum drbd_notification_type) = NULL;
void *last_arg = NULL;
diff --git a/drbd/drbd_state_change.h b/drbd/drbd_state_change.h
index e60ec1b8ee6e..df23977462c1 100644
--- a/drbd/drbd_state_change.h
+++ b/drbd/drbd_state_change.h
@@ -66,19 +66,19 @@ extern struct drbd_state_change *remember_state_change(struct drbd_resource *, g
extern void copy_old_to_new_state_change(struct drbd_state_change *);
extern void forget_state_change(struct drbd_state_change *);
-extern void notify_resource_state_change(struct sk_buff *,
+extern int notify_resource_state_change(struct sk_buff *,
unsigned int,
struct drbd_state_change *,
enum drbd_notification_type type);
-extern void notify_connection_state_change(struct sk_buff *,
+extern int notify_connection_state_change(struct sk_buff *,
unsigned int,
struct drbd_connection_state_change *,
enum drbd_notification_type type);
-extern void notify_device_state_change(struct sk_buff *,
+extern int notify_device_state_change(struct sk_buff *,
unsigned int,
struct drbd_device_state_change *,
enum drbd_notification_type type);
-extern void notify_peer_device_state_change(struct sk_buff *,
+extern int notify_peer_device_state_change(struct sk_buff *,
unsigned int,
struct drbd_peer_device_state_change *,
enum drbd_notification_type type);
--
2.26.2

View File

@ -1,36 +0,0 @@
From c2a620949ed609d6e256d1ce4d671a6da6bfeac0 Mon Sep 17 00:00:00 2001
From: John Sanpe <sanpeqf@gmail.com>
Date: Sat, 23 Jul 2022 09:59:31 +0200
Subject: [PATCH] lib/lru_cache: Fixed array overflow caused by incorrect
boundary handling.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This problem occurs when malloc element failed on the first time.
At this time, the counter i is 0. When it's released, we subtract 1
in advance without checking, which will cause i to become UINT_MAX,
resulting in array overflow.
Signed-off-by: John Sanpe <sanpeqf@gmail.com>
Reviewed-by: Christoph Böhmwalder <christoph.boehmwalder@linbit.com>
---
drbd/lru_cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drbd/lru_cache.c b/drbd/lru_cache.c
index 7e604cdc87db..fc640490607a 100644
--- a/drbd/lru_cache.c
+++ b/drbd/lru_cache.c
@@ -127,7 +127,7 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache,
return lc;
/* else: could not allocate all elements, give up */
- for (i--; i; i--) {
+ while (i--) {
void *p = element[i];
kmem_cache_free(cache, (unsigned char *)p - e_off);
}
--
2.26.2

View File

@ -1,35 +0,0 @@
From 998a1faccbbb7e7b6d1042e7fe841734671ee365 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?=
<christoph.boehmwalder@linbit.com>
Date: Wed, 6 Apr 2022 13:39:44 +0200
Subject: [PATCH] pmem: use fs_dax_get_by_bdev instead of dax_get_by_host
The {fs,}dax_get_by_host helpers went away.
---
by heming.zhao on 20230105
This patch partly refer code from drbd-9.1 branch commit
a68200c121de9e17a73a53962697fa32239e99f6
---
--- drbd-9.0.30~1+git.8e9c0812/drbd/drbd_dax_pmem.c 2023-01-05 20:50:39.022187673 +0800
+++ b/drbd/drbd_dax_pmem.c 2023-01-05 20:40:10.878947325 +0800
@@ -56,14 +56,11 @@ static int map_superblock_for_dax(struct
*/
int drbd_dax_open(struct drbd_backing_dev *bdev)
{
- const char *disk_name = bdev->md_bdev->bd_disk->disk_name;
struct dax_device *dax_dev;
int err;
+ u64 part_off;
- if (!blk_queue_dax(bdev->md_bdev->bd_disk->queue))
- return -ENODEV;
-
- dax_dev = dax_get_by_host(disk_name);
+ dax_dev = fs_dax_get_by_bdev(bdev->md_bdev, &part_off, NULL, NULL);
if (!dax_dev)
return -ENODEV;

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:79d58db5907e8fe69a34ade98a174d3375d25998675eb61e555d6ff74d8cce5e
size 372369

BIN
drbd-9.1.16.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +1,257 @@
------------------------------------------------------------------
Mon Sep 04 11:35:00 UTC 2023 - Heming Zhao <heming.zhao@suse.com>
- Update DRBD version from 9.0.30+ to 9.1.16 (PED-6362)
* 9.1.16 (api:genl2/proto:86-121/transport:18)
* shorten times DRBD keeps IRQs on one CPU disabled. Could lead
to connection interruption under specific conditions
* fix a corner case where resync did not start after resync-pause
state flapped
* fix online adding of volumes/minors to an already connected resource
* fix a possible split-brain situation with quorum enabled with
ping-timeout set to (unusual) high value
* fix a locking problem that could lead to kernel OOPS
* ensure resync can continue (bitmap-based) after interruption
also when it started as a full-resync first
* correctly handle meta-data when forgetting diskless peers
* fix a possibility of getting a split-brain although quorum enabled
* correctly propagate UUIDs after resync following a resize operation.
Consequence could be a full resync instead of a bitmap-based one
* fix a rare race condition that can cause a drbd device to end up
with WFBitMapS/Established replication states
* 9.1.15 (api:genl2/proto:86-121/transport:18)
* fix how flush requests are marked when submitted to the Linux IO
stack on the secondary node
* when establishing a connection failed with a two-pc timeout, a
receiver thread deadlocked, causing drbdsetup calls to block on
that resource (difficult to trigger)
* fixed a NULL-ptr deref (a OOPS) caused by a rare race condition
while taking a resource down
* fix a possible hard kernel-lockup, can only be triggerd when a
CPU-mask is configured
* updated kernel compatibility to at least Linux head and also fixed
a bug in the compat checks/rules that caused OOPSes of the previous
drbd releases when compiled with Linux-6.2 (or on RHEL 9.2 kernel).
* fix an aspect of the data-generation (UUID) handling where DRBD
failed to do a resync when a diskless node in the remaining
partition promotes and demotes while a diskful node is isolated
* fix an aspect of the data-generation (UUID) handling where DRBD
considered a node to have unrelated data; this bug was triggered by
a sequence involving removing two nodes from a cluster and readding
one with the "day-0" UUIDs.
* do not block specific state changes (promote, demote, attach, and
detach) when only some nodes add a new minor
* 9.1.14 (api:genl2/proto:86-121/transport:18)
* fix a race with concurrent promotion and demotion, which can
lead to an unexpected "split-brain" later on
* fix a specific case where promotion was allowed where it should not
* fix a race condition between auto-promote and a second two-phase
commit that can lead to a DRBD thread locking up in an endless loop
* fix several bugs with "resync-after":
- missing resync-resume when minor numbers run in opposite
direction as the resync-after dependencies
- a race that might lead to an OOPS in add_timer()
* fix an OOPS when reading from in_flight_summary in debugfs
* fix a race that might lead to an endless loop of printing
"postponing start_resync" while starting a resync
* fix diskless node with a diskfull with a 4KiB backend
* simplify remembering two-pc parents, maybe fixing a one-time-seen bug
* derive abort_local_transaction timeout from ping-timeout
* 9.1.13 (api:genl2/proto:86-121/transport:18)
* when calculating if a partition has quorum, take into account if
the missing nodes might have quorum
* fix forget-peer for diskless peers
* clear the resync_again counter upon disconnect
* also call the unfence handler when no resync happens
* do not set bitmap bits when attaching to an up-to-date disk (late)
* work on bringing the out-of-tree DRBD9 closer to DRBD in the upstream
kernel; Use lru_cahche.ko from the installed kernel whenever possible
* 9.1.12 (api:genl2/proto:86-121/transport:18)
* fix a race that could result in connection attempts getting aborted
with the message "sock_recvmsg returned -11"
* rate limit messages in case the peer can not write the backing storage
and it does not finish the necessary state transitions
* reduced the receive timeout during connecting to the intended 5 seconds
(ten times ping-ack timeout)
* losing the connection at a specific point in time during establishing
a connection could cause a transition to StandAlone; fixed that, so
that it keeps trying to connect
* fix a race that could lead to a fence-peer handler being called
unexpectedly when the fencing policy is changed at the moment before
promoting
* 9.1.11 (api:genl2/proto:86-121/transport:18)
* The change introduced with 9.1.10 created another problem that might
lead to premature request completion (kernel crash); reverted that
change and fix it in another way
* 9.1.10 (api:genl2/proto:86-121/transport:18)
* fix a regression introduced with 9.1.9; using protocol A on SMP
with heavy IO can might cause kernel crash
* 9.1.9 (api:genl2/proto:86-121/transport:18)
* fix a mistake in the compat generation code; it broke DRBD on
partitions on kernel older than linux 5.10 (this was introduced
with drbd-9.1.8; not affected: logical volumes)
* fix for a bug (introduced with drbd-9.0.0), that caused possible
inconsistencies in the mirror when using the 'resync-after' option
* fix a bug that could cause a request to get stuck after an unlucky
timing with a loss of connection
* close a very small timing window between connect and promote that
could lead to the new-current-uuid not being transmitted to the
concurrently connecting peer, which might lead to denied connections
later on
* fix a recently introduced OOPS when adding new volumes to a
connected resource
* fix online attach when the connection to a 3rd node is down
* 9.1.8 (api:genl2/proto:86-121/transport:18)
* restore protocol compatibility with drbd-8.4
* detect peers that died silently when starting a two-phase-commit
* correctly abort two-phase-commits when a connection breaks between
phases 1 and 2
* allow re-connect to a node that was forced into secondary role and
where an opener is still present from the last time it was primary
* fix a race condition that allowed to configure two peers with the
same node id
* ensure that an open() call fails within the auto-promote timeout
if it can not succeed
* build fixes for RHEL9
* following upstream changes to DRBD up to Linux 5.17 and updated compat
* 9.1.7 (api:genl2/proto:110-121/transport:18)
* avoid deadlock upon trying to down an io-frozen DRBD device that
has a file system mounted
* fix DRBD to not send too large resync requests at multiples of 8TiB
* fix for a "forgotten" resync after IO was suspended due to lack of quorum
* refactored IO suspend/resume fixing several bugs; the worst one could
lead to premature request completion
* disable discards on diskless if diskful peers do not support it
* make demote to secondary a two-phase state transition; that guarantees that
after demotion, DRBD will not write to any meta-data in the cluster
* enable "--force primary" in for no-quorum situations
* allow graceful recovery of primary lacking quorum and therefore
have forzen IO requests; that includes "--force secondary"
* following upstream changes to DRBD up to Linux 5.15 and updated compat
* 9.1.6 (api:genl2/proto:110-121/transport:17)
* fix IO to internal meta-data for backing device larger than 128TB
* fix resending requests towards diskless peers, this is relevant when
fencing is enabled, but the connection is re-established before fencing
succeeds; when the bug triggered it lead to "stuck" requests
* remove lockless buffer pages handling; it still contained very hard to
trigger bugs
* make sure DRBD's resync does not cause unnecessary allocation in
a thinly provisioned backing device on a resync target node
* avoid unnecessary resync (or split-brain) due to a wrongly generated
new current UUID when an already IO frozen DBRD gets new writes
* small fix to autopromote, when an application tries a read-only open
before it does a read-write open immediately after the peer primary
vanished ungracefully
* split out the secure boot key into a package on its own, that is
necessary to allow installation of multiple drbd kernel module packages
* Support for building containers for flacar linux
* 9.1.5 (api:genl2/proto:110-121/transport:17)
* merged all changes from drbd-9.0.32
- fix a read-access-after-free, that could cause an OOPs; triggers with
an unusual configuration with a secondary having a smaller AL than
the primary or a diskless primary and heavy IO
- avoid a livelock that can cause long IO delays during resync on a
primary resync-target node
- following upstream changes to DRBD up to Linux 5.14 and updated compat
(including RHEL9-beta)
- fix module override for Oracle-Linux
* fixed a locking regression of the 9.1 branch, only relevant in
the moment a local backing device delivers an IO error to drbd
* removed compat support for kernel older than Linux-3.10 (RHEL7)
* code cleanups and refactoring
* 9.1.4 (api:genl2/proto:110-121/transport:17)
* merged all changes from drbd-9.0.31
* enabled dynamic debug on some additional log messages
* remove (broken) write conflict resolution, replace it with warning
about the fact
* debugfs entry for the interval tree
* 9.1.3 (api:genl2/proto:110-120/transport:17)
* merged all fixes from drbd-9.0.30-0rc1
* fix a corner-case NULL deref in the lockless buffer pages handling; the
regression was introduced with 9.1.0 (released Feb 2021); To my knowledge
it took 6 months until someone triggered it for the first time
* fix sending a P_PEERS_IN_SYNC packet into a fresh connection (before
handshake packets); this problem was introduced when the drbd-8.x
compatibility code was removed
* remove sending a DRBD-barrier packet when processing a REQ_PREFLUSH
request, that improves IO-depth and improves performance with that
* 9.1.2 (api:genl2/proto:110-120/transport:17)
* merged all fixes from drbd-9.0.29; other than that no changes in this branch
* 9.1.1 (api:genl2/proto:110-119/transport:17)
* fix a temporal deadlock you could trigger when you exercise promotion races
and mix some read-only openers into the test case
* fix for bitmap-copy operation in a very specific and unlikely case where
two nodes do a bitmap-based resync due to disk-states
* fix size negotiation when combining nodes of different CPU architectures
that have different page sizes
* fix a very rare race where DRBD reported wrong magic in a header
packet right after reconnecting
* fix a case where DRBD ends up reporting unrelated data; it affected
thinly allocated resources with a diskless node in a recreate from day0
event
* changes to socket buffer sizes get applied to established connections immediately;
before it was applied after a re-connect
* add exists events for path objects
* fix a merge-mistake that broke compatibility with 5.10 kernels
* 9.1.0 (api:genl2/proto:110-119/transport:16)
* was forked off from drbd 9.0.19
* has all changes up to 9.0.28-1
* locking in the IO-submit code path was considerably improved,
allowing multiple CPU to submit in parallel
* rename patch
- fix-resync-finished-with-syncs-have-bits-set.patch
+ bsc-1025089_fix-resync-finished-with-syncs-have-bits-set.patch
* remove patches which are already included in upstream code:
- bsc-1192929_01-make_block_holder_optional.patch
- bsc-1192929_02-move_kvmalloc_related_to_slab.patch
- bsc-1192929_03-polling_to_bio_base.patch
- bsc-1192929_04-pass_gend_to_blk_queue_update_readahead.patch
- bsc-1192929_07-add_disk_error_handle.patch
- bsc-1192929_08-have_void_drbd_submit_bio.patch
- bsc-1192929_09-remove_bdgrab.patch
- bsc-1201335_01-compat-test-and-cocci-patch-for-bdi-in-gendisk.patch
- bsc-1201335_02-compat-only-apply-bdi-pointer-patch-if-bdi-is-in-req.patch
- bsc-1201335_03-genhd.patch
- bsc-1201335_04-bio_alloc_bioset.patch
- bsc-1201335_05-bio_alloc.patch
- bsc-1201335_06-bdi.patch
- bsc-1201335_07-write-same.patch
- bsc-1201335_08-bio_clone_fast.patch
- bsc-1202600_01-remove-QUEUE_FLAG_DISCARD.patch
- bsc-1202600_02-dax-introduce-DAX_RECOVERY_WRITE-dax-access-mode.patch
- bsc-1202600_03-block-decouple-REQ_OP_SECURE_ERASE-from-REQ_OP_DISCA.patch
- bsc-1202600_04-remove-assign_p_sizes_qlim.patch
- bsc-1204596_01-block-remove-blk_cleanup_disk.patch
- bsc-1204596_02-drbd-remove-usage-of-bdevname.patch
- bsc-1206791-01-drbd-add-comments-explaining-removal-of-bdi-congesti.patch
- bsc-1206791-02-drbd-fix-static-analysis-warnings.patch
- bsc-1206791-03-drbd-fix-warning-about-initializing-multiple-struct-.patch
- bsc-1206791-04-blk_queue_split__no_present.patch
- bsc-1206791-05-prandom_u32_max.patch
- bsc-1206791-06-write_zeroes__no_capable.patch
- bsc-1206791-07-drbd-fix-use-after-free-bugs-in-get_initial_state.patch
- bsc-1206791-08-lib-lru_cache-Fixed-array-overflow-caused-by-incorre.patch
- bsc-1206791-09-pmem-use-fs_dax_get_by_bdev-instead-of-dax_get_by_ho.patch
------------------------------------------------------------------
Sat Mar 11 06:25:00 UTC 2023 - Heming Zhao <heming.zhao@suse.com>

View File

@ -24,48 +24,19 @@
%endif
%endif
Name: drbd
Version: 9.0.30~1+git.8e9c0812
Version: 9.1.16
Release: 0
Summary: Linux driver for the "Distributed Replicated Block Device"
License: GPL-2.0-or-later
URL: https://drbd.linbit.com/
Source: %{name}-%{version}.tar.bz2
Source: %{name}-%{version}.tar.gz
Source1: preamble
#In kernel is: kernel/drivers/block/drbd/drbd.ko
Source2: Module.supported
Source3: drbd_git_revision
Patch1: fix-resync-finished-with-syncs-have-bits-set.patch
Patch2: bsc-1192929_01-make_block_holder_optional.patch
Patch3: bsc-1192929_02-move_kvmalloc_related_to_slab.patch
Patch4: bsc-1192929_03-polling_to_bio_base.patch
Patch5: bsc-1192929_04-pass_gend_to_blk_queue_update_readahead.patch
Patch6: bsc-1192929_07-add_disk_error_handle.patch
Patch7: bsc-1192929_08-have_void_drbd_submit_bio.patch
Patch8: bsc-1192929_09-remove_bdgrab.patch
Patch9: bsc-1201335_01-compat-test-and-cocci-patch-for-bdi-in-gendisk.patch
Patch10: bsc-1201335_02-compat-only-apply-bdi-pointer-patch-if-bdi-is-in-req.patch
Patch11: bsc-1201335_03-genhd.patch
Patch12: bsc-1201335_04-bio_alloc_bioset.patch
Patch13: bsc-1201335_05-bio_alloc.patch
Patch14: bsc-1201335_06-bdi.patch
Patch15: bsc-1201335_07-write-same.patch
Patch16: bsc-1201335_08-bio_clone_fast.patch
Patch17: bsc-1202600_01-remove-QUEUE_FLAG_DISCARD.patch
Patch18: bsc-1202600_02-dax-introduce-DAX_RECOVERY_WRITE-dax-access-mode.patch
Patch19: bsc-1202600_03-block-decouple-REQ_OP_SECURE_ERASE-from-REQ_OP_DISCA.patch
Patch20: bsc-1202600_04-remove-assign_p_sizes_qlim.patch
Patch21: bsc-1204596_01-block-remove-blk_cleanup_disk.patch
Patch22: bsc-1204596_02-drbd-remove-usage-of-bdevname.patch
Patch23: bsc-1206791-01-drbd-add-comments-explaining-removal-of-bdi-congesti.patch
Patch24: bsc-1206791-02-drbd-fix-static-analysis-warnings.patch
Patch25: bsc-1206791-03-drbd-fix-warning-about-initializing-multiple-struct-.patch
Patch26: bsc-1206791-04-blk_queue_split__no_present.patch
Patch27: bsc-1206791-05-prandom_u32_max.patch
Patch28: bsc-1206791-06-write_zeroes__no_capable.patch
Patch29: bsc-1206791-07-drbd-fix-use-after-free-bugs-in-get_initial_state.patch
Patch30: bsc-1206791-08-lib-lru_cache-Fixed-array-overflow-caused-by-incorre.patch
Patch31: bsc-1206791-09-pmem-use-fs_dax_get_by_bdev-instead-of-dax_get_by_ho.patch
Patch1: bsc-1025089_fix-resync-finished-with-syncs-have-bits-set.patch
Patch99: suse-coccinelle.patch
#https://github.com/openSUSE/rpmlint-checks/blob/master/KMPPolicyCheck.py
BuildRequires: coccinelle >= 1.0.8
BuildRequires: kernel-source
@ -73,8 +44,8 @@ BuildRequires: kernel-syms
BuildRequires: libelf-devel
BuildRequires: modutils
BuildRequires: %kernel_module_package_buildreqs
Requires: drbd-utils >= 9.2.0
Supplements: drbd-utils >= 9.2.0
Requires: drbd-utils >= 9.3.0
Supplements: drbd-utils >= 9.3.0
Obsoletes: drbd-kmp < %{version}
ExcludeArch: i586 s390
%kernel_module_package -n drbd -p %{_sourcedir}/preamble
@ -100,36 +71,6 @@ installed kernel.
%prep
%setup -q -n drbd-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch28 -p1
%patch29 -p1
%patch30 -p1
%patch31 -p1
%patch99 -p1
mkdir source

View File

@ -1 +1 @@
GIT-hash: 8e9c08122ae738eec189abe402ba7358b57182cd
GIT-hash: 288abda1fb8c93e385960af01ab28729fefdaa38