Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1440023
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 10/17] libnvdimm, pmem: use REQ_FUA, REQ_FLUSH for nvdimm_flush() |
| Date | 2016-07-10 05:40 +0200 |
| Message-ID | <rTdL3-3Dk-5@gated-at.bofh.it> (permalink) |
| References | <rTdBn-3ye-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Given that nvdimm_flush() has higher overhead than wmb_pmem() (pointer
chasing through nd_region), and that we otherwise assume a platform has
ADR capability when flush hints are not present, move nvdimm_flush() to
REQ_FLUSH context.
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/pmem.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index e303655f243e..18cd95719da0 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -113,6 +113,11 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
return rc;
}
+/* account for REQ_FLUSH rename, replace with REQ_PREFLUSH after v4.8-rc1 */
+#ifndef REQ_FLUSH
+#define REQ_FLUSH REQ_PREFLUSH
+#endif
+
static blk_qc_t pmem_make_request(struct request_queue *q, struct bio *bio)
{
int rc = 0;
@@ -121,6 +126,10 @@ static blk_qc_t pmem_make_request(struct request_queue *q, struct bio *bio)
struct bio_vec bvec;
struct bvec_iter iter;
struct pmem_device *pmem = q->queuedata;
+ struct nd_region *nd_region = to_region(pmem);
+
+ if (bio->bi_rw & REQ_FLUSH)
+ nvdimm_flush(nd_region);
do_acct = nd_iostat_start(bio, &start);
bio_for_each_segment(bvec, bio, iter) {
@@ -135,8 +144,8 @@ static blk_qc_t pmem_make_request(struct request_queue *q, struct bio *bio)
if (do_acct)
nd_iostat_end(bio, start);
- if (bio_data_dir(bio))
- nvdimm_flush(to_region(pmem));
+ if (bio->bi_rw & REQ_FUA)
+ nvdimm_flush(nd_region);
bio_endio(bio);
return BLK_QC_T_NONE;
@@ -149,8 +158,6 @@ static int pmem_rw_page(struct block_device *bdev, sector_t sector,
int rc;
rc = pmem_do_bvec(pmem, page, PAGE_SIZE, 0, rw, sector);
- if (rw & WRITE)
- nvdimm_flush(to_region(pmem));
/*
* The ->rw_page interface is subtle and tricky. The core
@@ -209,9 +216,9 @@ static int pmem_attach_disk(struct device *dev,
struct nd_namespace_io *nsio = to_nd_namespace_io(&ndns->dev);
struct nd_region *nd_region = to_nd_region(dev->parent);
struct vmem_altmap __altmap, *altmap = NULL;
+ int nid = dev_to_node(dev), has_flush;
struct resource *res = &nsio->res;
struct nd_pfn *nd_pfn = NULL;
- int nid = dev_to_node(dev);
struct nd_pfn_sb *pfn_sb;
struct pmem_device *pmem;
struct resource pfn_res;
@@ -237,8 +244,6 @@ static int pmem_attach_disk(struct device *dev,
dev_set_drvdata(dev, pmem);
pmem->phys_addr = res->start;
pmem->size = resource_size(res);
- if (nvdimm_has_flush(nd_region) < 0)
- dev_warn(dev, "unable to guarantee persistence of writes\n");
if (!devm_request_mem_region(dev, res->start, resource_size(res),
dev_name(dev))) {
@@ -279,6 +284,11 @@ static int pmem_attach_disk(struct device *dev,
return PTR_ERR(addr);
pmem->virt_addr = (void __pmem *) addr;
+ has_flush = nvdimm_has_flush(nd_region);
+ if (has_flush < 0)
+ dev_warn(dev, "unable to guarantee persistence of writes\n");
+ else if (has_flush > 0)
+ blk_queue_write_cache(q, true, true);
blk_queue_make_request(q, pmem_make_request);
blk_queue_physical_block_size(q, PAGE_SIZE);
blk_queue_max_hw_sectors(q, UINT_MAX);
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 00/17] replace pcommit with ADR or directed flushing Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 17/17] pmem: kill __pmem address space Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 13/17] libnvdimm, pmem: use nvdimm_flush() for namespace I/O writes Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 14/17] pmem: kill wmb_pmem() Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 12/17] fs/dax: remove wmb_pmem() Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 05/17] libnvdimm, nfit: move flush hint mapping to region-device driver-data Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 11/17] libnvdimm, pmem: flush posted-write queues on shutdown Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 15/17] Revert "KVM: x86: add pcommit support" Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 09/17] libnvdimm: cycle flush hints Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:30 +0200
[PATCH v2 01/17] nfit: always associate flush hints Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:40 +0200
[PATCH v2 04/17] libnvdimm, nfit: remove nfit_spa_map() infrastructure Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:40 +0200
[PATCH v2 06/17] tools/testing/nvdimm: simulate multiple flush hints per-dimm Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:40 +0200
[PATCH v2 10/17] libnvdimm, pmem: use REQ_FUA, REQ_FLUSH for nvdimm_flush() Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:40 +0200
[PATCH v3] libnvdimm, pmem: use REQ_FUA, REQ_FLUSH for nvdimm_flush() Dan Williams <dan.j.williams@intel.com> - 2016-07-13 00:40 +0200
Re: [PATCH v3] libnvdimm, pmem: use REQ_FUA, REQ_FLUSH for nvdimm_flush() "Kani, Toshimitsu" <toshi.kani@hpe.com> - 2016-07-13 21:50 +0200
[PATCH v2 03/17] libnvdimm: introduce devm_nvdimm_memremap(), convert nfit_spa_map() users Dan Williams <dan.j.williams@intel.com> - 2016-07-10 05:40 +0200
Re: [PATCH v2 03/17] libnvdimm: introduce devm_nvdimm_memremap(), convert nfit_spa_map() users kbuild test robot <lkp@intel.com> - 2016-07-10 07:40 +0200
[PATCH v3] libnvdimm: introduce devm_nvdimm_memremap(), convert nfit_spa_map() users Dan Williams <dan.j.williams@intel.com> - 2016-07-13 00:30 +0200
csiph-web