hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/nvdimm/blk.c
....@@ -1,15 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * NVDIMM Block Window Driver
34 * Copyright (c) 2014, Intel Corporation.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
135 */
146
157 #include <linux/blkdev.h>
....@@ -170,10 +162,10 @@
170162 return err;
171163 }
172164
173
-static blk_qc_t nd_blk_make_request(struct request_queue *q, struct bio *bio)
165
+static blk_qc_t nd_blk_submit_bio(struct bio *bio)
174166 {
175167 struct bio_integrity_payload *bip;
176
- struct nd_namespace_blk *nsblk;
168
+ struct nd_namespace_blk *nsblk = bio->bi_disk->private_data;
177169 struct bvec_iter iter;
178170 unsigned long start;
179171 struct bio_vec bvec;
....@@ -184,9 +176,10 @@
184176 return BLK_QC_T_NONE;
185177
186178 bip = bio_integrity(bio);
187
- nsblk = q->queuedata;
188179 rw = bio_data_dir(bio);
189
- do_acct = nd_iostat_start(bio, &start);
180
+ do_acct = blk_queue_io_stat(bio->bi_disk->queue);
181
+ if (do_acct)
182
+ start = bio_start_io_acct(bio);
190183 bio_for_each_segment(bvec, bio, iter) {
191184 unsigned int len = bvec.bv_len;
192185
....@@ -203,7 +196,7 @@
203196 }
204197 }
205198 if (do_acct)
206
- nd_iostat_end(bio, start);
199
+ bio_end_io_acct(bio, start);
207200
208201 bio_endio(bio);
209202 return BLK_QC_T_NONE;
....@@ -232,7 +225,7 @@
232225
233226 static const struct block_device_operations nd_blk_fops = {
234227 .owner = THIS_MODULE,
235
- .revalidate_disk = nvdimm_revalidate_disk,
228
+ .submit_bio = nd_blk_submit_bio,
236229 };
237230
238231 static void nd_blk_release_queue(void *q)
....@@ -257,17 +250,15 @@
257250 internal_nlba = div_u64(nsblk->size, nsblk_internal_lbasize(nsblk));
258251 available_disk_size = internal_nlba * nsblk_sector_size(nsblk);
259252
260
- q = blk_alloc_queue(GFP_KERNEL);
253
+ q = blk_alloc_queue(NUMA_NO_NODE);
261254 if (!q)
262255 return -ENOMEM;
263256 if (devm_add_action_or_reset(dev, nd_blk_release_queue, q))
264257 return -ENOMEM;
265258
266
- blk_queue_make_request(q, nd_blk_make_request);
267259 blk_queue_max_hw_sectors(q, UINT_MAX);
268260 blk_queue_logical_block_size(q, nsblk_sector_size(nsblk));
269261 blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
270
- q->queuedata = nsblk;
271262
272263 disk = alloc_disk(0);
273264 if (!disk)
....@@ -277,6 +268,7 @@
277268 disk->fops = &nd_blk_fops;
278269 disk->queue = q;
279270 disk->flags = GENHD_FL_EXT_DEVT;
271
+ disk->private_data = nsblk;
280272 nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name);
281273
282274 if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk))
....@@ -290,8 +282,8 @@
290282 }
291283
292284 set_capacity(disk, available_disk_size >> SECTOR_SHIFT);
293
- device_add_disk(dev, disk);
294
- revalidate_disk(disk);
285
+ device_add_disk(dev, disk, NULL);
286
+ nvdimm_check_and_set_ro(disk);
295287 return 0;
296288 }
297289