]> git.proxmox.com Git - zfsonlinux.git/blame - debian/patches/0017-vdev_disk-reorganise-vdev_disk_io_start.patch
backport 2.2.4 staging for better 6.8 support
[zfsonlinux.git] / debian / patches / 0017-vdev_disk-reorganise-vdev_disk_io_start.patch
CommitLineData
68be554e
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Rob Norris <rob.norris@klarasystems.com>
3Date: Tue, 9 Jan 2024 12:23:30 +1100
4Subject: [PATCH] vdev_disk: reorganise vdev_disk_io_start
5
6Light reshuffle to make it a bit more linear to read and get rid of a
7bunch of args that aren't needed in all cases.
8
9Reviewed-by: Alexander Motin <mav@FreeBSD.org>
10Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
11Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
12Sponsored-by: Klara, Inc.
13Sponsored-by: Wasabi Technology, Inc.
14Closes #15533
15Closes #15588
16(cherry picked from commit 867178ae1db28e73051c8a7ce662f2f2f81cd8e6)
17---
18 module/os/linux/zfs/vdev_disk.c | 51 ++++++++++++++++++++-------------
19 1 file changed, 31 insertions(+), 20 deletions(-)
20
21diff --git a/module/os/linux/zfs/vdev_disk.c b/module/os/linux/zfs/vdev_disk.c
22index 957619b87..51e7cef2f 100644
23--- a/module/os/linux/zfs/vdev_disk.c
24+++ b/module/os/linux/zfs/vdev_disk.c
25@@ -720,9 +720,16 @@ vdev_classic_bio_max_segs(zio_t *zio, int bio_size, uint64_t abd_offset)
26 }
27
28 static int
29-vdev_classic_physio(struct block_device *bdev, zio_t *zio,
30- size_t io_size, uint64_t io_offset, int rw, int flags)
31+vdev_classic_physio(zio_t *zio)
32 {
33+ vdev_t *v = zio->io_vd;
34+ vdev_disk_t *vd = v->vdev_tsd;
35+ struct block_device *bdev = BDH_BDEV(vd->vd_bdh);
36+ size_t io_size = zio->io_size;
37+ uint64_t io_offset = zio->io_offset;
38+ int rw = zio->io_type == ZIO_TYPE_READ ? READ : WRITE;
39+ int flags = 0;
40+
41 dio_request_t *dr;
42 uint64_t abd_offset;
43 uint64_t bio_offset;
44@@ -944,7 +951,7 @@ vdev_disk_io_start(zio_t *zio)
45 {
46 vdev_t *v = zio->io_vd;
47 vdev_disk_t *vd = v->vdev_tsd;
48- int rw, error;
49+ int error;
50
51 /*
52 * If the vdev is closed, it's likely in the REMOVED or FAULTED state.
53@@ -1007,13 +1014,6 @@ vdev_disk_io_start(zio_t *zio)
54 rw_exit(&vd->vd_lock);
55 zio_execute(zio);
56 return;
57- case ZIO_TYPE_WRITE:
58- rw = WRITE;
59- break;
60-
61- case ZIO_TYPE_READ:
62- rw = READ;
63- break;
64
65 case ZIO_TYPE_TRIM:
66 zio->io_error = vdev_disk_io_trim(zio);
67@@ -1026,23 +1026,34 @@ vdev_disk_io_start(zio_t *zio)
68 #endif
69 return;
70
71- default:
72+ case ZIO_TYPE_READ:
73+ case ZIO_TYPE_WRITE:
74+ zio->io_target_timestamp = zio_handle_io_delay(zio);
75+ error = vdev_classic_physio(zio);
76 rw_exit(&vd->vd_lock);
77- zio->io_error = SET_ERROR(ENOTSUP);
78- zio_interrupt(zio);
79+ if (error) {
80+ zio->io_error = error;
81+ zio_interrupt(zio);
82+ }
83 return;
84- }
85
86- zio->io_target_timestamp = zio_handle_io_delay(zio);
87- error = vdev_classic_physio(BDH_BDEV(vd->vd_bdh), zio,
88- zio->io_size, zio->io_offset, rw, 0);
89- rw_exit(&vd->vd_lock);
90+ default:
91+ /*
92+ * Getting here means our parent vdev has made a very strange
93+ * request of us, and shouldn't happen. Assert here to force a
94+ * crash in dev builds, but in production return the IO
95+ * unhandled. The pool will likely suspend anyway but that's
96+ * nicer than crashing the kernel.
97+ */
98+ ASSERT3S(zio->io_type, ==, -1);
99
100- if (error) {
101- zio->io_error = error;
102+ rw_exit(&vd->vd_lock);
103+ zio->io_error = SET_ERROR(ENOTSUP);
104 zio_interrupt(zio);
105 return;
106 }
107+
108+ __builtin_unreachable();
109 }
110
111 static void