forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/md/md-linear.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 linear.c : Multiple Devices driver for Linux
34 Copyright (C) 1994-96 Marc ZYNGIER
....@@ -6,14 +7,6 @@
67
78 Linear mode management functions.
89
9
- This program is free software; you can redistribute it and/or modify
10
- it under the terms of the GNU General Public License as published by
11
- the Free Software Foundation; either version 2, or (at your option)
12
- any later version.
13
-
14
- You should have received a copy of the GNU General Public License
15
- (for example /usr/src/linux/COPYING); if not, write to the Free
16
- Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1710 */
1811
1912 #include <linux/blkdev.h>
....@@ -53,29 +46,6 @@
5346 return conf->disks + lo;
5447 }
5548
56
-/*
57
- * In linear_congested() conf->raid_disks is used as a copy of
58
- * mddev->raid_disks to iterate conf->disks[], because conf->raid_disks
59
- * and conf->disks[] are created in linear_conf(), they are always
60
- * consitent with each other, but mddev->raid_disks does not.
61
- */
62
-static int linear_congested(struct mddev *mddev, int bits)
63
-{
64
- struct linear_conf *conf;
65
- int i, ret = 0;
66
-
67
- rcu_read_lock();
68
- conf = rcu_dereference(mddev->private);
69
-
70
- for (i = 0; i < conf->raid_disks && !ret ; i++) {
71
- struct request_queue *q = bdev_get_queue(conf->disks[i].rdev->bdev);
72
- ret |= bdi_congested(q->backing_dev_info, bits);
73
- }
74
-
75
- rcu_read_unlock();
76
- return ret;
77
-}
78
-
7949 static sector_t linear_size(struct mddev *mddev, sector_t sectors, int raid_disks)
8050 {
8151 struct linear_conf *conf;
....@@ -96,8 +66,7 @@
9666 int i, cnt;
9767 bool discard_supported = false;
9868
99
- conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info),
100
- GFP_KERNEL);
69
+ conf = kzalloc(struct_size(conf, disks, raid_disks), GFP_KERNEL);
10170 if (!conf)
10271 return NULL;
10372
....@@ -233,7 +202,7 @@
233202 md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
234203 set_capacity(mddev->gendisk, mddev->array_sectors);
235204 mddev_resume(mddev);
236
- revalidate_disk(mddev->gendisk);
205
+ revalidate_disk_size(mddev->gendisk, true);
237206 kfree_rcu(oldconf, rcu);
238207 return 0;
239208 }
....@@ -265,12 +234,17 @@
265234 bio_sector < start_sector))
266235 goto out_of_bounds;
267236
237
+ if (unlikely(is_mddev_broken(tmp_dev->rdev, "linear"))) {
238
+ bio_io_error(bio);
239
+ return true;
240
+ }
241
+
268242 if (unlikely(bio_end_sector(bio) > end_sector)) {
269243 /* This bio crosses a device boundary, so we have to split it */
270244 struct bio *split = bio_split(bio, end_sector - bio_sector,
271245 GFP_NOIO, &mddev->bio_set);
272246 bio_chain(split, bio);
273
- generic_make_request(bio);
247
+ submit_bio_noacct(bio);
274248 bio = split;
275249 }
276250
....@@ -289,7 +263,7 @@
289263 bio_sector);
290264 mddev_check_writesame(mddev, bio);
291265 mddev_check_write_zeroes(mddev, bio);
292
- generic_make_request(bio);
266
+ submit_bio_noacct(bio);
293267 }
294268 return true;
295269
....@@ -325,7 +299,6 @@
325299 .hot_add_disk = linear_add,
326300 .size = linear_size,
327301 .quiesce = linear_quiesce,
328
- .congested = linear_congested,
329302 };
330303
331304 static int __init linear_init (void)