.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Block Translation Table |
---|
3 | 4 | * Copyright (c) 2014-2015, 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 | #include <linux/highmem.h> |
---|
15 | 7 | #include <linux/debugfs.h> |
---|
.. | .. |
---|
1447 | 1439 | return ret; |
---|
1448 | 1440 | } |
---|
1449 | 1441 | |
---|
1450 | | -static blk_qc_t btt_make_request(struct request_queue *q, struct bio *bio) |
---|
| 1442 | +static blk_qc_t btt_submit_bio(struct bio *bio) |
---|
1451 | 1443 | { |
---|
1452 | 1444 | struct bio_integrity_payload *bip = bio_integrity(bio); |
---|
1453 | | - struct btt *btt = q->queuedata; |
---|
| 1445 | + struct btt *btt = bio->bi_disk->private_data; |
---|
1454 | 1446 | struct bvec_iter iter; |
---|
1455 | 1447 | unsigned long start; |
---|
1456 | 1448 | struct bio_vec bvec; |
---|
.. | .. |
---|
1460 | 1452 | if (!bio_integrity_prep(bio)) |
---|
1461 | 1453 | return BLK_QC_T_NONE; |
---|
1462 | 1454 | |
---|
1463 | | - do_acct = nd_iostat_start(bio, &start); |
---|
| 1455 | + do_acct = blk_queue_io_stat(bio->bi_disk->queue); |
---|
| 1456 | + if (do_acct) |
---|
| 1457 | + start = bio_start_io_acct(bio); |
---|
1464 | 1458 | bio_for_each_segment(bvec, bio, iter) { |
---|
1465 | 1459 | unsigned int len = bvec.bv_len; |
---|
1466 | 1460 | |
---|
.. | .. |
---|
1485 | 1479 | } |
---|
1486 | 1480 | } |
---|
1487 | 1481 | if (do_acct) |
---|
1488 | | - nd_iostat_end(bio, start); |
---|
| 1482 | + bio_end_io_acct(bio, start); |
---|
1489 | 1483 | |
---|
1490 | 1484 | bio_endio(bio); |
---|
1491 | 1485 | return BLK_QC_T_NONE; |
---|
.. | .. |
---|
1496 | 1490 | { |
---|
1497 | 1491 | struct btt *btt = bdev->bd_disk->private_data; |
---|
1498 | 1492 | int rc; |
---|
1499 | | - unsigned int len; |
---|
1500 | 1493 | |
---|
1501 | | - len = hpage_nr_pages(page) * PAGE_SIZE; |
---|
1502 | | - rc = btt_do_bvec(btt, NULL, page, len, 0, op, sector); |
---|
| 1494 | + rc = btt_do_bvec(btt, NULL, page, thp_size(page), 0, op, sector); |
---|
1503 | 1495 | if (rc == 0) |
---|
1504 | 1496 | page_endio(page, op_is_write(op), 0); |
---|
1505 | 1497 | |
---|
.. | .. |
---|
1518 | 1510 | |
---|
1519 | 1511 | static const struct block_device_operations btt_fops = { |
---|
1520 | 1512 | .owner = THIS_MODULE, |
---|
| 1513 | + .submit_bio = btt_submit_bio, |
---|
1521 | 1514 | .rw_page = btt_rw_page, |
---|
1522 | 1515 | .getgeo = btt_getgeo, |
---|
1523 | | - .revalidate_disk = nvdimm_revalidate_disk, |
---|
1524 | 1516 | }; |
---|
1525 | 1517 | |
---|
1526 | 1518 | static int btt_blk_init(struct btt *btt) |
---|
.. | .. |
---|
1529 | 1521 | struct nd_namespace_common *ndns = nd_btt->ndns; |
---|
1530 | 1522 | |
---|
1531 | 1523 | /* create a new disk and request queue for btt */ |
---|
1532 | | - btt->btt_queue = blk_alloc_queue(GFP_KERNEL); |
---|
| 1524 | + btt->btt_queue = blk_alloc_queue(NUMA_NO_NODE); |
---|
1533 | 1525 | if (!btt->btt_queue) |
---|
1534 | 1526 | return -ENOMEM; |
---|
1535 | 1527 | |
---|
.. | .. |
---|
1545 | 1537 | btt->btt_disk->private_data = btt; |
---|
1546 | 1538 | btt->btt_disk->queue = btt->btt_queue; |
---|
1547 | 1539 | btt->btt_disk->flags = GENHD_FL_EXT_DEVT; |
---|
1548 | | - btt->btt_disk->queue->backing_dev_info->capabilities |= |
---|
1549 | | - BDI_CAP_SYNCHRONOUS_IO; |
---|
1550 | 1540 | |
---|
1551 | | - blk_queue_make_request(btt->btt_queue, btt_make_request); |
---|
1552 | 1541 | blk_queue_logical_block_size(btt->btt_queue, btt->sector_size); |
---|
1553 | 1542 | blk_queue_max_hw_sectors(btt->btt_queue, UINT_MAX); |
---|
1554 | 1543 | blk_queue_flag_set(QUEUE_FLAG_NONROT, btt->btt_queue); |
---|
1555 | | - btt->btt_queue->queuedata = btt; |
---|
1556 | 1544 | |
---|
1557 | 1545 | if (btt_meta_size(btt)) { |
---|
1558 | 1546 | int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); |
---|
.. | .. |
---|
1565 | 1553 | } |
---|
1566 | 1554 | } |
---|
1567 | 1555 | set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9); |
---|
1568 | | - device_add_disk(&btt->nd_btt->dev, btt->btt_disk); |
---|
| 1556 | + device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL); |
---|
1569 | 1557 | btt->nd_btt->size = btt->nlba * (u64)btt->sector_size; |
---|
1570 | | - revalidate_disk(btt->btt_disk); |
---|
| 1558 | + nvdimm_check_and_set_ro(btt->btt_disk); |
---|
1571 | 1559 | |
---|
1572 | 1560 | return 0; |
---|
1573 | 1561 | } |
---|
.. | .. |
---|
1682 | 1670 | struct nd_region *nd_region; |
---|
1683 | 1671 | struct btt_sb *btt_sb; |
---|
1684 | 1672 | struct btt *btt; |
---|
1685 | | - size_t rawsize; |
---|
| 1673 | + size_t size, rawsize; |
---|
| 1674 | + int rc; |
---|
1686 | 1675 | |
---|
1687 | 1676 | if (!nd_btt->uuid || !nd_btt->ndns || !nd_btt->lbasize) { |
---|
1688 | 1677 | dev_dbg(&nd_btt->dev, "incomplete btt configuration\n"); |
---|
.. | .. |
---|
1693 | 1682 | if (!btt_sb) |
---|
1694 | 1683 | return -ENOMEM; |
---|
1695 | 1684 | |
---|
| 1685 | + size = nvdimm_namespace_capacity(ndns); |
---|
| 1686 | + rc = devm_namespace_enable(&nd_btt->dev, ndns, size); |
---|
| 1687 | + if (rc) |
---|
| 1688 | + return rc; |
---|
| 1689 | + |
---|
1696 | 1690 | /* |
---|
1697 | 1691 | * If this returns < 0, that is ok as it just means there wasn't |
---|
1698 | 1692 | * an existing BTT, and we're creating a new one. We still need to |
---|
.. | .. |
---|
1701 | 1695 | */ |
---|
1702 | 1696 | nd_btt_version(nd_btt, ndns, btt_sb); |
---|
1703 | 1697 | |
---|
1704 | | - rawsize = nvdimm_namespace_capacity(ndns) - nd_btt->initial_offset; |
---|
| 1698 | + rawsize = size - nd_btt->initial_offset; |
---|
1705 | 1699 | if (rawsize < ARENA_MIN_SIZE) { |
---|
1706 | 1700 | dev_dbg(&nd_btt->dev, "%s must be at least %ld bytes\n", |
---|
1707 | 1701 | dev_name(&ndns->dev), |
---|