.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * NVDIMM Block Window Driver |
---|
3 | 4 | * 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. |
---|
13 | 5 | */ |
---|
14 | 6 | |
---|
15 | 7 | #include <linux/blkdev.h> |
---|
.. | .. |
---|
170 | 162 | return err; |
---|
171 | 163 | } |
---|
172 | 164 | |
---|
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) |
---|
174 | 166 | { |
---|
175 | 167 | struct bio_integrity_payload *bip; |
---|
176 | | - struct nd_namespace_blk *nsblk; |
---|
| 168 | + struct nd_namespace_blk *nsblk = bio->bi_disk->private_data; |
---|
177 | 169 | struct bvec_iter iter; |
---|
178 | 170 | unsigned long start; |
---|
179 | 171 | struct bio_vec bvec; |
---|
.. | .. |
---|
184 | 176 | return BLK_QC_T_NONE; |
---|
185 | 177 | |
---|
186 | 178 | bip = bio_integrity(bio); |
---|
187 | | - nsblk = q->queuedata; |
---|
188 | 179 | 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); |
---|
190 | 183 | bio_for_each_segment(bvec, bio, iter) { |
---|
191 | 184 | unsigned int len = bvec.bv_len; |
---|
192 | 185 | |
---|
.. | .. |
---|
203 | 196 | } |
---|
204 | 197 | } |
---|
205 | 198 | if (do_acct) |
---|
206 | | - nd_iostat_end(bio, start); |
---|
| 199 | + bio_end_io_acct(bio, start); |
---|
207 | 200 | |
---|
208 | 201 | bio_endio(bio); |
---|
209 | 202 | return BLK_QC_T_NONE; |
---|
.. | .. |
---|
232 | 225 | |
---|
233 | 226 | static const struct block_device_operations nd_blk_fops = { |
---|
234 | 227 | .owner = THIS_MODULE, |
---|
235 | | - .revalidate_disk = nvdimm_revalidate_disk, |
---|
| 228 | + .submit_bio = nd_blk_submit_bio, |
---|
236 | 229 | }; |
---|
237 | 230 | |
---|
238 | 231 | static void nd_blk_release_queue(void *q) |
---|
.. | .. |
---|
257 | 250 | internal_nlba = div_u64(nsblk->size, nsblk_internal_lbasize(nsblk)); |
---|
258 | 251 | available_disk_size = internal_nlba * nsblk_sector_size(nsblk); |
---|
259 | 252 | |
---|
260 | | - q = blk_alloc_queue(GFP_KERNEL); |
---|
| 253 | + q = blk_alloc_queue(NUMA_NO_NODE); |
---|
261 | 254 | if (!q) |
---|
262 | 255 | return -ENOMEM; |
---|
263 | 256 | if (devm_add_action_or_reset(dev, nd_blk_release_queue, q)) |
---|
264 | 257 | return -ENOMEM; |
---|
265 | 258 | |
---|
266 | | - blk_queue_make_request(q, nd_blk_make_request); |
---|
267 | 259 | blk_queue_max_hw_sectors(q, UINT_MAX); |
---|
268 | 260 | blk_queue_logical_block_size(q, nsblk_sector_size(nsblk)); |
---|
269 | 261 | blk_queue_flag_set(QUEUE_FLAG_NONROT, q); |
---|
270 | | - q->queuedata = nsblk; |
---|
271 | 262 | |
---|
272 | 263 | disk = alloc_disk(0); |
---|
273 | 264 | if (!disk) |
---|
.. | .. |
---|
277 | 268 | disk->fops = &nd_blk_fops; |
---|
278 | 269 | disk->queue = q; |
---|
279 | 270 | disk->flags = GENHD_FL_EXT_DEVT; |
---|
| 271 | + disk->private_data = nsblk; |
---|
280 | 272 | nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name); |
---|
281 | 273 | |
---|
282 | 274 | if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) |
---|
.. | .. |
---|
290 | 282 | } |
---|
291 | 283 | |
---|
292 | 284 | 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); |
---|
295 | 287 | return 0; |
---|
296 | 288 | } |
---|
297 | 289 | |
---|