summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2015-04-26 03:15:59 -0700
committerKent Overstreet <kent.overstreet@gmail.com>2016-10-07 12:33:49 -0800
commitd419c5e95a518a28fddfb82246a12d09a0e4da62 (patch)
tree4d0181be52541cfe6f368ed90cb8dd58c28be48a
parent4cc62959eda2e1deb09116eca21c1f881c11a185 (diff)
bcache: Plumb through journal_seq
will be used for bcachefs Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--drivers/md/bcache/blockdev.c11
-rw-r--r--drivers/md/bcache/inode.c5
-rw-r--r--drivers/md/bcache/inode.h3
-rw-r--r--drivers/md/bcache/super.c1
-rw-r--r--drivers/md/bcache/sysfs.c19
5 files changed, 27 insertions, 12 deletions
diff --git a/drivers/md/bcache/blockdev.c b/drivers/md/bcache/blockdev.c
index 5a28fe669163..710d078a1151 100644
--- a/drivers/md/bcache/blockdev.c
+++ b/drivers/md/bcache/blockdev.c
@@ -362,7 +362,9 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
char buf[BDEVNAME_SIZE];
bool found;
int ret;
+ struct closure cl;
+ closure_init_stack(&cl);
bdevname(dc->disk_sb.bdev, buf);
if (memcmp(&dc->sb.set_uuid, &c->sb.set_uuid, sizeof(c->sb.set_uuid)))
@@ -408,10 +410,6 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
*/
if (!found) {
- struct closure cl;
-
- closure_init_stack(&cl);
-
bkey_inode_blockdev_init(&dc->disk.inode.k_i);
dc->disk.inode.v.i_uuid = dc->sb.disk_uuid;
memcpy(dc->disk.inode.v.i_label, dc->sb.label, SB_LABEL_SIZE);
@@ -432,12 +430,13 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
SET_BDEV_STATE(&dc->sb, BDEV_STATE_CLEAN);
bch_write_bdev_super(dc, &cl);
- closure_sync(&cl);
} else {
dc->disk.inode.v.i_inode.i_mtime = rtime;
- bch_inode_update(c, &dc->disk.inode.k_i);
+ bch_inode_update(c, &dc->disk.inode.k_i, &cl, NULL);
}
+ closure_sync(&cl);
+
/* Count dirty sectors before attaching */
if (BDEV_STATE(&dc->sb) == BDEV_STATE_DIRTY)
bch_sectors_dirty_init(dc, c);
diff --git a/drivers/md/bcache/inode.c b/drivers/md/bcache/inode.c
index a579276e5ed5..e5a3b34b6166 100644
--- a/drivers/md/bcache/inode.c
+++ b/drivers/md/bcache/inode.c
@@ -155,11 +155,12 @@ again:
return -ENOSPC;
}
-int bch_inode_update(struct cache_set *c, struct bkey_i *inode)
+int bch_inode_update(struct cache_set *c, struct bkey_i *inode,
+ struct closure *cl, u64 *journal_seq)
{
return bch_btree_insert(c, BTREE_ID_INODES,
&keylist_single(inode),
- NULL, NULL, NULL);
+ NULL, cl, journal_seq);
}
int bch_inode_truncate(struct cache_set *c, u64 inode_nr, u64 new_size)
diff --git a/drivers/md/bcache/inode.h b/drivers/md/bcache/inode.h
index d8888423f900..0e566afc409f 100644
--- a/drivers/md/bcache/inode.h
+++ b/drivers/md/bcache/inode.h
@@ -7,7 +7,8 @@ extern const struct bkey_ops bch_bkey_inode_ops;
ssize_t bch_inode_status(char *, size_t, const struct bkey *);
int bch_inode_create(struct cache_set *, struct bkey_i *, u64, u64, u64 *);
-int bch_inode_update(struct cache_set *, struct bkey_i *);
+int bch_inode_update(struct cache_set *, struct bkey_i *,
+ struct closure *, u64 *);
int bch_inode_truncate(struct cache_set *, u64, u64);
int bch_inode_rm(struct cache_set *, u64);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 0c78aebe85cb..f6951cdeeb92 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1151,6 +1151,7 @@ static const char *run_cache_set(struct cache_set *c)
SET_CACHE_SYNC(&c->sb, true);
bch_journal_set_replay_done(&c->journal);
+ /* XXX: necessary? */
bch_journal_meta(c, &cl);
}
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index c9330fcbf67a..ccb48d0a2b09 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -249,6 +249,9 @@ STORE(__cached_dev)
unsigned v = size;
struct cache_set *c;
struct kobj_uevent_env *env;
+ struct closure cl;
+
+ closure_init_stack(&cl);
#define d_strtoul(var) sysfs_strtoul(var, dc->var)
#define d_strtoul_nonzero(var) sysfs_strtoul_clamp(var, dc->var, 1, INT_MAX)
@@ -302,10 +305,13 @@ STORE(__cached_dev)
bch_write_bdev_super(dc, NULL);
if (dc->disk.c)
- bch_inode_update(dc->disk.c, &dc->disk.inode.k_i);
+ bch_inode_update(dc->disk.c, &dc->disk.inode.k_i,
+ &cl, NULL);
mutex_unlock(&dc->disk.inode_lock);
+ closure_sync(&cl);
+
env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
if (!env)
return -ENOMEM;
@@ -411,6 +417,9 @@ STORE(__bch_flash_dev)
{
struct bcache_device *d = container_of(kobj, struct bcache_device,
kobj);
+ struct closure cl;
+
+ closure_init_stack(&cl);
sysfs_strtoul(data_csum, d->data_csum);
@@ -422,19 +431,23 @@ STORE(__bch_flash_dev)
if (v < d->inode.v.i_inode.i_size)
bch_inode_truncate(d->c, d->inode.k.p.inode, v >> 9);
d->inode.v.i_inode.i_size = v;
- bch_inode_update(d->c, &d->inode.k_i);
+ bch_inode_update(d->c, &d->inode.k_i, &cl, NULL);
set_capacity(d->disk, d->inode.v.i_inode.i_size >> 9);
mutex_unlock(&d->inode_lock);
+
+ closure_sync(&cl);
}
if (attr == &sysfs_label) {
mutex_lock(&d->inode_lock);
memcpy(d->inode.v.i_label, buf, SB_LABEL_SIZE);
- bch_inode_update(d->c, &d->inode.k_i);
+ bch_inode_update(d->c, &d->inode.k_i, &cl, NULL);
mutex_unlock(&d->inode_lock);
+
+ closure_sync(&cl);
}
if (attr == &sysfs_unregister) {