summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-02-07 06:16:50 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2018-02-07 06:16:50 -0500
commit1ef243e3ad33dcc31fbdc44a940a0de56ee02037 (patch)
tree0c8ae96775a81edfe4f50768d231aad30132c67f
parent99adc23cf6260a8e5b237f498119ee163d8f71f6 (diff)
Update bcachefs sources to 496cbe9474 bcachefs: export bch2_alloc_write()
-rw-r--r--.bcachefs_revision2
-rw-r--r--libbcachefs/acl.c18
-rw-r--r--libbcachefs/alloc.c46
-rw-r--r--libbcachefs/alloc.h1
-rw-r--r--libbcachefs/fs.c39
-rw-r--r--libbcachefs/str_hash.h3
-rw-r--r--libbcachefs/super-io.c6
7 files changed, 89 insertions, 26 deletions
diff --git a/.bcachefs_revision b/.bcachefs_revision
index 4ffc0c5..f35d38b 100644
--- a/.bcachefs_revision
+++ b/.bcachefs_revision
@@ -1 +1 @@
-0e765bc37c971c4b0c91ddd281e5ea82e2d682dc
+496cbe9474173ec41bf221dc8ab1f5d70a128c3b
diff --git a/libbcachefs/acl.c b/libbcachefs/acl.c
index 480941d..4016ab9 100644
--- a/libbcachefs/acl.c
+++ b/libbcachefs/acl.c
@@ -185,6 +185,24 @@ int bch2_set_acl(struct inode *vinode, struct posix_acl *acl, int type)
size_t size = 0;
int ret;
+ if (type == ACL_TYPE_ACCESS && acl) {
+ umode_t mode = inode->v.i_mode;
+
+ ret = posix_acl_update_mode(&inode->v, &mode, &acl);
+ if (ret)
+ return ret;
+
+ mutex_lock(&inode->ei_update_lock);
+ inode->v.i_mode = mode;
+ inode->v.i_ctime = current_time(&inode->v);
+
+ ret = bch2_write_inode(c, inode);
+ mutex_unlock(&inode->ei_update_lock);
+
+ if (ret)
+ return ret;
+ }
+
switch (type) {
case ACL_TYPE_ACCESS:
name_index = BCH_XATTR_INDEX_POSIX_ACL_ACCESS;
diff --git a/libbcachefs/alloc.c b/libbcachefs/alloc.c
index f6592de..c195ffb 100644
--- a/libbcachefs/alloc.c
+++ b/libbcachefs/alloc.c
@@ -400,26 +400,36 @@ int bch2_alloc_replay_key(struct bch_fs *c, struct bpos pos)
return ret;
}
-static int bch2_alloc_write(struct bch_fs *c, struct bch_dev *ca)
+int bch2_alloc_write(struct bch_fs *c)
{
- struct btree_iter iter;
- unsigned long bucket;
+ struct bch_dev *ca;
+ unsigned i;
int ret = 0;
- bch2_btree_iter_init(&iter, c, BTREE_ID_ALLOC, POS_MIN,
- BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
+ for_each_rw_member(ca, c, i) {
+ struct btree_iter iter;
+ unsigned long bucket;
- down_read(&ca->bucket_lock);
- for_each_set_bit(bucket, ca->buckets_dirty, ca->mi.nbuckets) {
- ret = __bch2_alloc_write_key(c, ca, bucket, &iter, NULL);
- if (ret)
- break;
+ bch2_btree_iter_init(&iter, c, BTREE_ID_ALLOC, POS_MIN,
+ BTREE_ITER_SLOTS|BTREE_ITER_INTENT);
+
+ down_read(&ca->bucket_lock);
+ for_each_set_bit(bucket, ca->buckets_dirty, ca->mi.nbuckets) {
+ ret = __bch2_alloc_write_key(c, ca, bucket, &iter, NULL);
+ if (ret)
+ break;
+
+ clear_bit(bucket, ca->buckets_dirty);
+ }
+ up_read(&ca->bucket_lock);
+ bch2_btree_iter_unlock(&iter);
- clear_bit(bucket, ca->buckets_dirty);
+ if (ret) {
+ percpu_ref_put(&ca->io_ref);
+ break;
+ }
}
- up_read(&ca->bucket_lock);
- bch2_btree_iter_unlock(&iter);
return ret;
}
@@ -2037,15 +2047,7 @@ int bch2_fs_allocator_start(struct bch_fs *c)
}
}
- for_each_rw_member(ca, c, i) {
- ret = bch2_alloc_write(c, ca);
- if (ret) {
- percpu_ref_put(&ca->io_ref);
- return ret;
- }
- }
-
- return 0;
+ return bch2_alloc_write(c);
}
void bch2_fs_allocator_init(struct bch_fs *c)
diff --git a/libbcachefs/alloc.h b/libbcachefs/alloc.h
index 3bd765b..3bdc294 100644
--- a/libbcachefs/alloc.h
+++ b/libbcachefs/alloc.h
@@ -118,6 +118,7 @@ static inline void writepoint_init(struct write_point *wp,
wp->type = type;
}
+int bch2_alloc_write(struct bch_fs *);
int bch2_fs_allocator_start(struct bch_fs *);
void bch2_fs_allocator_init(struct bch_fs *);
diff --git a/libbcachefs/fs.c b/libbcachefs/fs.c
index 98f282b..80962b5 100644
--- a/libbcachefs/fs.c
+++ b/libbcachefs/fs.c
@@ -658,6 +658,41 @@ out_unlock:
return ret;
}
+static int bch2_getattr(const struct path *path, struct kstat *stat,
+ u32 request_mask, unsigned query_flags)
+{
+ struct bch_inode_info *inode = to_bch_ei(d_inode(path->dentry));
+ struct bch_fs *c = inode->v.i_sb->s_fs_info;
+
+ stat->dev = inode->v.i_sb->s_dev;
+ stat->ino = inode->v.i_ino;
+ stat->mode = inode->v.i_mode;
+ stat->nlink = inode->v.i_nlink;
+ stat->uid = inode->v.i_uid;
+ stat->gid = inode->v.i_gid;
+ stat->rdev = inode->v.i_rdev;
+ stat->size = i_size_read(&inode->v);
+ stat->atime = inode->v.i_atime;
+ stat->mtime = inode->v.i_mtime;
+ stat->ctime = inode->v.i_ctime;
+ stat->blksize = block_bytes(c);
+ stat->blocks = inode->v.i_blocks;
+
+ if (request_mask & STATX_BTIME) {
+ stat->result_mask |= STATX_BTIME;
+ stat->btime = bch2_time_to_timespec(c, inode->ei_inode.bi_otime);
+ }
+
+ if (inode->ei_inode.bi_flags & BCH_INODE_IMMUTABLE)
+ stat->attributes |= STATX_ATTR_IMMUTABLE;
+ if (inode->ei_inode.bi_flags & BCH_INODE_APPEND)
+ stat->attributes |= STATX_ATTR_APPEND;
+ if (inode->ei_inode.bi_flags & BCH_INODE_NODUMP)
+ stat->attributes |= STATX_ATTR_NODUMP;
+
+ return 0;
+}
+
static int bch2_setattr(struct dentry *dentry, struct iattr *iattr)
{
struct bch_inode_info *inode = to_bch_ei(dentry->d_inode);
@@ -817,6 +852,7 @@ static const struct file_operations bch_file_operations = {
};
static const struct inode_operations bch_file_inode_operations = {
+ .getattr = bch2_getattr,
.setattr = bch2_setattr,
.fiemap = bch2_fiemap,
.listxattr = bch2_xattr_list,
@@ -836,6 +872,7 @@ static const struct inode_operations bch_dir_inode_operations = {
.rmdir = bch2_rmdir,
.mknod = bch2_mknod,
.rename = bch2_rename2,
+ .getattr = bch2_getattr,
.setattr = bch2_setattr,
.tmpfile = bch2_tmpfile,
.listxattr = bch2_xattr_list,
@@ -858,6 +895,7 @@ static const struct file_operations bch_dir_file_operations = {
static const struct inode_operations bch_symlink_inode_operations = {
.get_link = page_get_link,
+ .getattr = bch2_getattr,
.setattr = bch2_setattr,
.listxattr = bch2_xattr_list,
#ifdef CONFIG_BCACHEFS_POSIX_ACL
@@ -867,6 +905,7 @@ static const struct inode_operations bch_symlink_inode_operations = {
};
static const struct inode_operations bch_special_inode_operations = {
+ .getattr = bch2_getattr,
.setattr = bch2_setattr,
.listxattr = bch2_xattr_list,
#ifdef CONFIG_BCACHEFS_POSIX_ACL
diff --git a/libbcachefs/str_hash.h b/libbcachefs/str_hash.h
index 0adb9a1..f7dd014 100644
--- a/libbcachefs/str_hash.h
+++ b/libbcachefs/str_hash.h
@@ -237,8 +237,7 @@ static inline int bch2_hash_needs_whiteout(const struct bch_hash_desc desc,
{
struct bkey_s_c k;
- bch2_btree_iter_set_pos(iter,
- btree_type_successor(start->btree_id, start->pos));
+ bch2_btree_iter_next_slot(iter);
for_each_btree_key_continue(iter, BTREE_ITER_SLOTS, k) {
if (k.k->type != desc.key_type &&
diff --git a/libbcachefs/super-io.c b/libbcachefs/super-io.c
index e3c319f..1f266ba 100644
--- a/libbcachefs/super-io.c
+++ b/libbcachefs/super-io.c
@@ -1077,6 +1077,11 @@ static int bch2_check_mark_super_slowpath(struct bch_fs *c,
/* allocations done, now commit: */
+ if (new_r)
+ bch2_write_super(c);
+
+ /* don't update in memory replicas until changes are persistent */
+
if (new_gc) {
rcu_assign_pointer(c->replicas_gc, new_gc);
kfree_rcu(old_gc, rcu);
@@ -1085,7 +1090,6 @@ static int bch2_check_mark_super_slowpath(struct bch_fs *c,
if (new_r) {
rcu_assign_pointer(c->replicas, new_r);
kfree_rcu(old_r, rcu);
- bch2_write_super(c);
}
mutex_unlock(&c->sb_lock);