summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-writecache.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-writecache.c')
-rw-r--r--drivers/md/dm-writecache.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index 1cb137f0ef9d..d06b8aa41e26 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -190,7 +190,6 @@ struct writeback_struct {
190 struct dm_writecache *wc; 190 struct dm_writecache *wc;
191 struct wc_entry **wc_list; 191 struct wc_entry **wc_list;
192 unsigned wc_list_n; 192 unsigned wc_list_n;
193 struct page *page;
194 struct wc_entry *wc_list_inline[WB_LIST_INLINE]; 193 struct wc_entry *wc_list_inline[WB_LIST_INLINE];
195 struct bio bio; 194 struct bio bio;
196}; 195};
@@ -727,7 +726,8 @@ static void writecache_flush(struct dm_writecache *wc)
727 } 726 }
728 writecache_commit_flushed(wc); 727 writecache_commit_flushed(wc);
729 728
730 writecache_wait_for_ios(wc, WRITE); 729 if (!WC_MODE_PMEM(wc))
730 writecache_wait_for_ios(wc, WRITE);
731 731
732 wc->seq_count++; 732 wc->seq_count++;
733 pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count)); 733 pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count));
@@ -1561,7 +1561,7 @@ static void writecache_writeback(struct work_struct *work)
1561{ 1561{
1562 struct dm_writecache *wc = container_of(work, struct dm_writecache, writeback_work); 1562 struct dm_writecache *wc = container_of(work, struct dm_writecache, writeback_work);
1563 struct blk_plug plug; 1563 struct blk_plug plug;
1564 struct wc_entry *e, *f, *g; 1564 struct wc_entry *f, *g, *e = NULL;
1565 struct rb_node *node, *next_node; 1565 struct rb_node *node, *next_node;
1566 struct list_head skipped; 1566 struct list_head skipped;
1567 struct writeback_list wbl; 1567 struct writeback_list wbl;
@@ -1598,7 +1598,14 @@ restart:
1598 break; 1598 break;
1599 } 1599 }
1600 1600
1601 e = container_of(wc->lru.prev, struct wc_entry, lru); 1601 if (unlikely(wc->writeback_all)) {
1602 if (unlikely(!e)) {
1603 writecache_flush(wc);
1604 e = container_of(rb_first(&wc->tree), struct wc_entry, rb_node);
1605 } else
1606 e = g;
1607 } else
1608 e = container_of(wc->lru.prev, struct wc_entry, lru);
1602 BUG_ON(e->write_in_progress); 1609 BUG_ON(e->write_in_progress);
1603 if (unlikely(!writecache_entry_is_committed(wc, e))) { 1610 if (unlikely(!writecache_entry_is_committed(wc, e))) {
1604 writecache_flush(wc); 1611 writecache_flush(wc);
@@ -1629,8 +1636,8 @@ restart:
1629 if (unlikely(!next_node)) 1636 if (unlikely(!next_node))
1630 break; 1637 break;
1631 g = container_of(next_node, struct wc_entry, rb_node); 1638 g = container_of(next_node, struct wc_entry, rb_node);
1632 if (read_original_sector(wc, g) == 1639 if (unlikely(read_original_sector(wc, g) ==
1633 read_original_sector(wc, f)) { 1640 read_original_sector(wc, f))) {
1634 f = g; 1641 f = g;
1635 continue; 1642 continue;
1636 } 1643 }
@@ -1659,8 +1666,14 @@ restart:
1659 g->wc_list_contiguous = BIO_MAX_PAGES; 1666 g->wc_list_contiguous = BIO_MAX_PAGES;
1660 f = g; 1667 f = g;
1661 e->wc_list_contiguous++; 1668 e->wc_list_contiguous++;
1662 if (unlikely(e->wc_list_contiguous == BIO_MAX_PAGES)) 1669 if (unlikely(e->wc_list_contiguous == BIO_MAX_PAGES)) {
1670 if (unlikely(wc->writeback_all)) {
1671 next_node = rb_next(&f->rb_node);
1672 if (likely(next_node))
1673 g = container_of(next_node, struct wc_entry, rb_node);
1674 }
1663 break; 1675 break;
1676 }
1664 } 1677 }
1665 cond_resched(); 1678 cond_resched();
1666 } 1679 }