mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Update bcachefs sources to 496cbe9474 bcachefs: export bch2_alloc_write()
This commit is contained in:
parent
99adc23cf6
commit
1ef243e3ad
@ -1 +1 @@
|
||||
0e765bc37c971c4b0c91ddd281e5ea82e2d682dc
|
||||
496cbe9474173ec41bf221dc8ab1f5d70a128c3b
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
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);
|
||||
|
||||
if (ret) {
|
||||
percpu_ref_put(&ca->io_ref);
|
||||
break;
|
||||
|
||||
clear_bit(bucket, ca->buckets_dirty);
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
@ -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 *);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 &&
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user