aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/btree.c
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-06-05 09:21:07 -0400
committerKent Overstreet <koverstreet@google.com>2013-06-27 00:57:23 -0400
commit279afbad4e54acbd61bf88a54a73af3bbfdeb5dd (patch)
treeaefebaa3a7f54049904a275ca3035301603a9be1 /drivers/md/bcache/btree.c
parent444fc0b6b167ed164e7436621a9d095e042644dd (diff)
bcache: Track dirty data by stripe
To make background writeback aware of raid5/6 stripes, we first need to track the amount of dirty data within each stripe - we do this by breaking up the existing sectors_dirty into per stripe atomic_ts Signed-off-by: Kent Overstreet <koverstreet@google.com>
Diffstat (limited to 'drivers/md/bcache/btree.c')
-rw-r--r--drivers/md/bcache/btree.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 230c3a6d9be2..b93cf56260a4 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -24,6 +24,7 @@
24#include "btree.h" 24#include "btree.h"
25#include "debug.h" 25#include "debug.h"
26#include "request.h" 26#include "request.h"
27#include "writeback.h"
27 28
28#include <linux/slab.h> 29#include <linux/slab.h>
29#include <linux/bitops.h> 30#include <linux/bitops.h>
@@ -1599,14 +1600,14 @@ static bool fix_overlapping_extents(struct btree *b,
1599 struct btree_iter *iter, 1600 struct btree_iter *iter,
1600 struct btree_op *op) 1601 struct btree_op *op)
1601{ 1602{
1602 void subtract_dirty(struct bkey *k, int sectors) 1603 void subtract_dirty(struct bkey *k, uint64_t offset, int sectors)
1603 { 1604 {
1604 struct bcache_device *d = b->c->devices[KEY_INODE(k)]; 1605 if (KEY_DIRTY(k))
1605 1606 bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
1606 if (KEY_DIRTY(k) && d) 1607 offset, -sectors);
1607 atomic_long_sub(sectors, &d->sectors_dirty);
1608 } 1608 }
1609 1609
1610 uint64_t old_offset;
1610 unsigned old_size, sectors_found = 0; 1611 unsigned old_size, sectors_found = 0;
1611 1612
1612 while (1) { 1613 while (1) {
@@ -1618,6 +1619,7 @@ static bool fix_overlapping_extents(struct btree *b,
1618 if (bkey_cmp(k, &START_KEY(insert)) <= 0) 1619 if (bkey_cmp(k, &START_KEY(insert)) <= 0)
1619 continue; 1620 continue;
1620 1621
1622 old_offset = KEY_START(k);
1621 old_size = KEY_SIZE(k); 1623 old_size = KEY_SIZE(k);
1622 1624
1623 /* 1625 /*
@@ -1673,7 +1675,7 @@ static bool fix_overlapping_extents(struct btree *b,
1673 1675
1674 struct bkey *top; 1676 struct bkey *top;
1675 1677
1676 subtract_dirty(k, KEY_SIZE(insert)); 1678 subtract_dirty(k, KEY_START(insert), KEY_SIZE(insert));
1677 1679
1678 if (bkey_written(b, k)) { 1680 if (bkey_written(b, k)) {
1679 /* 1681 /*
@@ -1720,7 +1722,7 @@ static bool fix_overlapping_extents(struct btree *b,
1720 } 1722 }
1721 } 1723 }
1722 1724
1723 subtract_dirty(k, old_size - KEY_SIZE(k)); 1725 subtract_dirty(k, old_offset, old_size - KEY_SIZE(k));
1724 } 1726 }
1725 1727
1726check_failed: 1728check_failed:
@@ -1796,6 +1798,10 @@ static bool btree_insert_key(struct btree *b, struct btree_op *op,
1796insert: shift_keys(b, m, k); 1798insert: shift_keys(b, m, k);
1797copy: bkey_copy(m, k); 1799copy: bkey_copy(m, k);
1798merged: 1800merged:
1801 if (KEY_DIRTY(k))
1802 bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
1803 KEY_START(k), KEY_SIZE(k));
1804
1799 bch_check_keys(b, "%u for %s", status, op_type(op)); 1805 bch_check_keys(b, "%u for %s", status, op_type(op));
1800 1806
1801 if (b->level && !KEY_OFFSET(k)) 1807 if (b->level && !KEY_OFFSET(k))