diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-11-04 19:48:06 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2018-05-22 00:44:18 -0400 |
commit | 74b9d89260f54a4a426538d7bf7e166d6d868061 (patch) | |
tree | 3fa01e9a86af78ee31c6b779862eb2cf2f0043b5 | |
parent | effb3581f27dc5348d0d2328d697ffc451739cee (diff) |
bcachefs: rename bch_inode_info fields
-rw-r--r-- | fs/bcachefs/dirent.c | 8 | ||||
-rw-r--r-- | fs/bcachefs/fs-io.c | 114 | ||||
-rw-r--r-- | fs/bcachefs/fs.c | 104 | ||||
-rw-r--r-- | fs/bcachefs/fs.h | 27 | ||||
-rw-r--r-- | fs/bcachefs/xattr.c | 12 |
5 files changed, 135 insertions, 130 deletions
diff --git a/fs/bcachefs/dirent.c b/fs/bcachefs/dirent.c index 056715bc3ebb..d63f05ad4089 100644 --- a/fs/bcachefs/dirent.c +++ b/fs/bcachefs/dirent.c @@ -195,7 +195,7 @@ static void dirent_copy_target(struct bkey_i_dirent *dst, static struct bpos bch2_dirent_pos(struct bch_inode_info *ei, const struct qstr *name) { - return POS(ei->vfs_inode.i_ino, bch2_dirent_hash(&ei->str_hash, name)); + return POS(ei->v.i_ino, bch2_dirent_hash(&ei->ei_str_hash, name)); } int bch2_dirent_rename(struct bch_fs *c, @@ -241,13 +241,13 @@ retry: * in bch_hash_set) - we never move existing dirents to different slot: */ old_src = bch2_hash_lookup_at(bch2_dirent_hash_desc, - &src_ei->str_hash, + &src_ei->ei_str_hash, &src_iter, src_name); if ((ret = btree_iter_err(old_src))) goto err; ret = bch2_hash_needs_whiteout(bch2_dirent_hash_desc, - &src_ei->str_hash, + &src_ei->ei_str_hash, &whiteout_iter, &src_iter); if (ret < 0) goto err; @@ -261,7 +261,7 @@ retry: old_dst = mode == BCH_RENAME ? bch2_hash_hole_at(bch2_dirent_hash_desc, &dst_iter) : bch2_hash_lookup_at(bch2_dirent_hash_desc, - &dst_ei->str_hash, + &dst_ei->ei_str_hash, &dst_iter, dst_name); if ((ret = btree_iter_err(old_dst))) goto err; diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index ee545bae0fea..a21f7a979670 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -68,11 +68,11 @@ static int inode_set_size(struct bch_inode_info *ei, { loff_t *new_i_size = p; - lockdep_assert_held(&ei->update_lock); + lockdep_assert_held(&ei->ei_update_lock); bi->bi_size = *new_i_size; - if (atomic_long_read(&ei->i_size_dirty_count)) + if (atomic_long_read(&ei->ei_size_dirty_count)) bi->bi_flags |= BCH_INODE_I_SIZE_DIRTY; else bi->bi_flags &= ~BCH_INODE_I_SIZE_DIRTY; @@ -89,14 +89,14 @@ static int __must_check bch2_write_inode_size(struct bch_fs *c, static inline void i_size_dirty_put(struct bch_inode_info *ei) { - atomic_long_dec_bug(&ei->i_size_dirty_count); + atomic_long_dec_bug(&ei->ei_size_dirty_count); } static inline void i_size_dirty_get(struct bch_inode_info *ei) { - lockdep_assert_held(&ei->vfs_inode.i_rwsem); + lockdep_assert_held(&ei->v.i_rwsem); - atomic_long_inc(&ei->i_size_dirty_count); + atomic_long_inc(&ei->ei_size_dirty_count); } /* i_sectors accounting: */ @@ -114,8 +114,8 @@ i_sectors_hook_fn(struct extent_insert_hook *hook, int sign = bkey_extent_is_allocation(&insert->k) - (k.k && bkey_extent_is_allocation(k.k)); - EBUG_ON(!(h->ei->i_flags & BCH_INODE_I_SECTORS_DIRTY)); - EBUG_ON(!atomic_long_read(&h->ei->i_sectors_dirty_count)); + EBUG_ON(!(h->ei->ei_flags & BCH_INODE_I_SECTORS_DIRTY)); + EBUG_ON(!atomic_long_read(&h->ei->ei_sectors_dirty_count)); h->sectors += sectors * sign; @@ -137,7 +137,7 @@ static int inode_clear_i_sectors_dirty(struct bch_inode_info *ei, { BUG_ON(!(bi->bi_flags & BCH_INODE_I_SECTORS_DIRTY)); - bi->bi_sectors = atomic64_read(&ei->i_sectors); + bi->bi_sectors = atomic64_read(&ei->ei_sectors); bi->bi_flags &= ~BCH_INODE_I_SECTORS_DIRTY; return 0; } @@ -145,29 +145,29 @@ static int inode_clear_i_sectors_dirty(struct bch_inode_info *ei, static void i_sectors_dirty_put(struct bch_inode_info *ei, struct i_sectors_hook *h) { - struct inode *inode = &ei->vfs_inode; + struct inode *inode = &ei->v; if (h->sectors) { spin_lock(&inode->i_lock); inode->i_blocks += h->sectors; spin_unlock(&inode->i_lock); - atomic64_add(h->sectors, &ei->i_sectors); - EBUG_ON(atomic64_read(&ei->i_sectors) < 0); + atomic64_add(h->sectors, &ei->ei_sectors); + EBUG_ON(atomic64_read(&ei->ei_sectors) < 0); } - EBUG_ON(atomic_long_read(&ei->i_sectors_dirty_count) <= 0); + EBUG_ON(atomic_long_read(&ei->ei_sectors_dirty_count) <= 0); - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); - if (atomic_long_dec_and_test(&ei->i_sectors_dirty_count)) { - struct bch_fs *c = ei->vfs_inode.i_sb->s_fs_info; + if (atomic_long_dec_and_test(&ei->ei_sectors_dirty_count)) { + struct bch_fs *c = ei->v.i_sb->s_fs_info; int ret = __bch2_write_inode(c, ei, inode_clear_i_sectors_dirty, NULL); ret = ret; } - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); } static int __must_check i_sectors_dirty_get(struct bch_inode_info *ei, @@ -181,21 +181,21 @@ static int __must_check i_sectors_dirty_get(struct bch_inode_info *ei, h->ei = ei; #endif - if (atomic_long_inc_not_zero(&ei->i_sectors_dirty_count)) + if (atomic_long_inc_not_zero(&ei->ei_sectors_dirty_count)) return 0; - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); - if (!(ei->i_flags & BCH_INODE_I_SECTORS_DIRTY)) { - struct bch_fs *c = ei->vfs_inode.i_sb->s_fs_info; + if (!(ei->ei_flags & BCH_INODE_I_SECTORS_DIRTY)) { + struct bch_fs *c = ei->v.i_sb->s_fs_info; ret = __bch2_write_inode(c, ei, inode_set_i_sectors_dirty, NULL); } if (!ret) - atomic_long_inc(&ei->i_sectors_dirty_count); + atomic_long_inc(&ei->ei_sectors_dirty_count); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); return ret; } @@ -220,7 +220,7 @@ bchfs_extent_update_hook(struct extent_insert_hook *hook, struct bchfs_extent_trans_hook *h = container_of(hook, struct bchfs_extent_trans_hook, hook); struct bch_inode_info *ei = h->op->ei; - struct inode *inode = &ei->vfs_inode; + struct inode *inode = &ei->v; int sign = bkey_extent_is_allocation(&insert->k) - (k.k && bkey_extent_is_allocation(k.k)); s64 sectors = (s64) (next_pos.offset - committed_pos.offset) * sign; @@ -230,8 +230,8 @@ bchfs_extent_update_hook(struct extent_insert_hook *hook, BUG_ON((next_pos.offset << 9) > round_up(offset, PAGE_SIZE)); /* XXX: ei->i_size locking */ - if (offset > ei->i_size) { - BUG_ON(ei->i_flags & BCH_INODE_I_SIZE_DIRTY); + if (offset > ei->ei_size) { + BUG_ON(ei->ei_flags & BCH_INODE_I_SIZE_DIRTY); if (!h->need_inode_update) { h->need_inode_update = true; @@ -241,7 +241,7 @@ bchfs_extent_update_hook(struct extent_insert_hook *hook, h->inode_u.bi_size = offset; do_pack = true; - ei->i_size = offset; + ei->ei_size = offset; if (h->op->is_dio) i_size_write(inode, offset); @@ -256,7 +256,7 @@ bchfs_extent_update_hook(struct extent_insert_hook *hook, h->inode_u.bi_sectors += sectors; do_pack = true; - atomic64_add(sectors, &ei->i_sectors); + atomic64_add(sectors, &ei->ei_sectors); h->op->sectors_added += sectors; @@ -283,7 +283,7 @@ static int bchfs_write_index_update(struct bch_write_op *wop) struct bkey_i *k = bch2_keylist_front(keys); int ret; - BUG_ON(k->k.p.inode != op->ei->vfs_inode.i_ino); + BUG_ON(k->k.p.inode != op->ei->v.i_ino); bch2_btree_iter_init(&extent_iter, wop->c, BTREE_ID_EXTENTS, bkey_start_pos(&bch2_keylist_front(keys)->k), @@ -303,7 +303,7 @@ static int bchfs_write_index_update(struct bch_write_op *wop) /* XXX: ei->i_size locking */ k = bch2_keylist_front(keys); - if (min(k->k.p.offset << 9, op->new_i_size) > op->ei->i_size) + if (min(k->k.p.offset << 9, op->new_i_size) > op->ei->ei_size) hook.need_inode_update = true; if (hook.need_inode_update) { @@ -921,7 +921,7 @@ static void bch2_writepage_io_done(struct closure *cl) * before calling end_page_writeback: */ if (io->op.sectors_added) { - struct inode *inode = &io->op.ei->vfs_inode; + struct inode *inode = &io->op.ei->v; spin_lock(&inode->i_lock); inode->i_blocks += io->op.sectors_added; @@ -957,7 +957,7 @@ static void bch2_writepage_io_alloc(struct bch_fs *c, struct bch_inode_info *ei, struct page *page) { - u64 inum = ei->vfs_inode.i_ino; + u64 inum = ei->v.i_ino; unsigned nr_replicas = page_state(page)->nr_replicas; EBUG_ON(!nr_replicas); @@ -978,9 +978,9 @@ alloc_io: (struct disk_reservation) { .nr_replicas = c->opts.data_replicas, }, - foreground_write_point(c, ei->last_dirtied), + foreground_write_point(c, ei->ei_last_dirtied), POS(inum, 0), - &ei->journal_seq, + &ei->ei_journal_seq, BCH_WRITE_THROTTLE); w->io->op.op.index_update_fn = bchfs_write_index_update; } @@ -1355,7 +1355,7 @@ int bch2_write_end(struct file *filp, struct address_space *mapping, if (!PageDirty(page)) set_page_dirty(page); - ei->last_dirtied = (unsigned long) current; + ei->ei_last_dirtied = (unsigned long) current; } else { bch2_put_page_reservation(c, page); } @@ -1554,7 +1554,7 @@ static void bch2_do_direct_IO_write(struct dio_write *dio) bch2_write_op_init(&dio->iop.op, dio->c, dio->res, foreground_write_point(dio->c, (unsigned long) current), POS(inode->i_ino, (dio->offset + dio->written) >> 9), - &ei->journal_seq, + &ei->ei_journal_seq, flags|BCH_WRITE_THROTTLE); dio->iop.op.index_update_fn = bchfs_write_index_update; @@ -1874,7 +1874,7 @@ int bch2_fsync(struct file *file, loff_t start, loff_t end, int datasync) if (c->opts.journal_flush_disabled) return 0; - return bch2_journal_flush_seq(&c->journal, ei->journal_seq); + return bch2_journal_flush_seq(&c->journal, ei->ei_journal_seq); } static int __bch2_truncate_page(struct address_space *mapping, @@ -1982,15 +1982,15 @@ int bch2_truncate(struct inode *inode, struct iattr *iattr) /* sync appends.. */ /* XXX what protects ei->i_size? */ - if (iattr->ia_size > ei->i_size) - ret = filemap_write_and_wait_range(mapping, ei->i_size, S64_MAX); + if (iattr->ia_size > ei->ei_size) + ret = filemap_write_and_wait_range(mapping, ei->ei_size, S64_MAX); if (ret) goto err_put_pagecache; - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); i_size_dirty_get(ei); ret = bch2_write_inode_size(c, ei, inode->i_size); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); if (unlikely(ret)) goto err; @@ -2018,7 +2018,7 @@ int bch2_truncate(struct inode *inode, struct iattr *iattr) ret = bch2_inode_truncate(c, inode->i_ino, round_up(iattr->ia_size, PAGE_SIZE) >> 9, &i_sectors_hook.hook, - &ei->journal_seq); + &ei->ei_journal_seq); i_sectors_dirty_put(ei, &i_sectors_hook); @@ -2026,20 +2026,20 @@ int bch2_truncate(struct inode *inode, struct iattr *iattr) goto err; } - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); setattr_copy(inode, iattr); inode->i_mtime = inode->i_ctime = current_time(inode); out: /* clear I_SIZE_DIRTY: */ i_size_dirty_put(ei); ret = bch2_write_inode_size(c, ei, inode->i_size); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); err_put_pagecache: pagecache_block_put(&mapping->add_lock); return ret; err: - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); goto out; } @@ -2092,7 +2092,7 @@ static long bch2_fpunch(struct inode *inode, loff_t offset, loff_t len) ZERO_VERSION, &disk_res, &i_sectors_hook.hook, - &ei->journal_seq); + &ei->ei_journal_seq); i_sectors_dirty_put(ei, &i_sectors_hook); bch2_disk_reservation_put(c, &disk_res); @@ -2186,7 +2186,7 @@ static long bch2_fcollapse(struct inode *inode, loff_t offset, loff_t len) BUG_ON(ret); ret = bch2_btree_insert_at(c, &disk_res, &i_sectors_hook.hook, - &ei->journal_seq, + &ei->ei_journal_seq, BTREE_INSERT_ATOMIC| BTREE_INSERT_NOFAIL, BTREE_INSERT_ENTRY(&dst, ©.k)); @@ -2204,16 +2204,16 @@ btree_iter_err: ret = bch2_inode_truncate(c, inode->i_ino, round_up(new_size, PAGE_SIZE) >> 9, &i_sectors_hook.hook, - &ei->journal_seq); + &ei->ei_journal_seq); if (ret) goto err_unwind; i_sectors_dirty_put(ei, &i_sectors_hook); - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); i_size_write(inode, new_size); ret = bch2_write_inode_size(c, ei, inode->i_size); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); pagecache_block_put(&mapping->add_lock); inode_unlock(inode); @@ -2338,7 +2338,7 @@ static long bch2_fallocate(struct inode *inode, int mode, } ret = bch2_btree_insert_at(c, &disk_res, &i_sectors_hook.hook, - &ei->journal_seq, + &ei->ei_journal_seq, BTREE_INSERT_ATOMIC| BTREE_INSERT_NOFAIL, BTREE_INSERT_ENTRY(&iter, &reservation.k_i)); @@ -2356,24 +2356,24 @@ btree_iter_err: new_size > inode->i_size) { i_size_write(inode, new_size); - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); ret = bch2_write_inode_size(c, ei, inode->i_size); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); } /* blech */ if ((mode & FALLOC_FL_KEEP_SIZE) && (mode & FALLOC_FL_ZERO_RANGE) && - ei->i_size != inode->i_size) { + ei->ei_size != inode->i_size) { /* sync appends.. */ - ret = filemap_write_and_wait_range(mapping, ei->i_size, S64_MAX); + ret = filemap_write_and_wait_range(mapping, ei->ei_size, S64_MAX); if (ret) goto err; - if (ei->i_size != inode->i_size) { - mutex_lock(&ei->update_lock); + if (ei->ei_size != inode->i_size) { + mutex_lock(&ei->ei_update_lock); ret = bch2_write_inode_size(c, ei, inode->i_size); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); } } diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 6a13489dd9cb..c5e991591796 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -67,7 +67,7 @@ int __must_check __bch2_write_inode(struct bch_fs *c, void *p) { struct btree_iter iter; - struct inode *inode = &ei->vfs_inode; + struct inode *inode = &ei->v; struct bch_inode_unpacked inode_u; struct bkey_inode_buf inode_p; u64 inum = inode->i_ino; @@ -82,7 +82,7 @@ int __must_check __bch2_write_inode(struct bch_fs *c, if (!i_nlink) return 0; - lockdep_assert_held(&ei->update_lock); + lockdep_assert_held(&ei->ei_update_lock); bch2_btree_iter_init(&iter, c, BTREE_ID_INODES, POS(inum, 0), BTREE_ITER_INTENT); @@ -125,15 +125,15 @@ int __must_check __bch2_write_inode(struct bch_fs *c, bch2_inode_pack(&inode_p, &inode_u); - ret = bch2_btree_insert_at(c, NULL, NULL, &ei->journal_seq, + ret = bch2_btree_insert_at(c, NULL, NULL, &ei->ei_journal_seq, BTREE_INSERT_ATOMIC| BTREE_INSERT_NOFAIL, BTREE_INSERT_ENTRY(&iter, &inode_p.inode.k_i)); } while (ret == -EINTR); if (!ret) { - ei->i_size = inode_u.bi_size; - ei->i_flags = inode_u.bi_flags; + ei->ei_size = inode_u.bi_size; + ei->ei_flags = inode_u.bi_flags; } out: bch2_btree_iter_unlock(&iter); @@ -151,10 +151,10 @@ int bch2_inc_nlink(struct bch_fs *c, struct bch_inode_info *ei) { int ret; - mutex_lock(&ei->update_lock); - inc_nlink(&ei->vfs_inode); + mutex_lock(&ei->ei_update_lock); + inc_nlink(&ei->v); ret = bch2_write_inode(c, ei); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); return ret; } @@ -163,10 +163,10 @@ int bch2_dec_nlink(struct bch_fs *c, struct bch_inode_info *ei) { int ret = 0; - mutex_lock(&ei->update_lock); - drop_nlink(&ei->vfs_inode); + mutex_lock(&ei->ei_update_lock); + drop_nlink(&ei->v); ret = bch2_write_inode(c, ei); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); return ret; } @@ -196,7 +196,7 @@ static struct inode *bch2_vfs_inode_get(struct super_block *sb, u64 inum) ei = to_bch_ei(inode); bch2_vfs_inode_init(c, ei, &inode_u); - ei->journal_seq = bch2_inode_journal_seq(&c->journal, inum); + ei->ei_journal_seq = bch2_inode_journal_seq(&c->journal, inum); unlock_new_inode(inode); @@ -277,9 +277,9 @@ static int bch2_vfs_dirent_create(struct bch_fs *c, struct inode *dir, struct bch_inode_info *dir_ei = to_bch_ei(dir); int ret; - ret = bch2_dirent_create(c, dir->i_ino, &dir_ei->str_hash, + ret = bch2_dirent_create(c, dir->i_ino, &dir_ei->ei_str_hash, type, name, dst->i_ino, - &dir_ei->journal_seq, + &dir_ei->ei_journal_seq, BCH_HASH_SET_MUST_CREATE); if (unlikely(ret)) return ret; @@ -312,8 +312,8 @@ static int __bch2_create(struct inode *dir, struct dentry *dentry, return ret; } - if (dir_ei->journal_seq > ei->journal_seq) - ei->journal_seq = dir_ei->journal_seq; + if (dir_ei->ei_journal_seq > ei->ei_journal_seq) + ei->ei_journal_seq = dir_ei->ei_journal_seq; d_instantiate(dentry, inode); return 0; @@ -330,7 +330,7 @@ static struct dentry *bch2_lookup(struct inode *dir, struct dentry *dentry, u64 inum; inum = bch2_dirent_lookup(c, dir->i_ino, - &dir_ei->str_hash, + &dir_ei->ei_str_hash, &dentry->d_name); if (inum) @@ -385,13 +385,13 @@ static int bch2_unlink(struct inode *dir, struct dentry *dentry) lockdep_assert_held(&inode->i_rwsem); - ret = bch2_dirent_delete(c, dir->i_ino, &dir_ei->str_hash, - &dentry->d_name, &dir_ei->journal_seq); + ret = bch2_dirent_delete(c, dir->i_ino, &dir_ei->ei_str_hash, + &dentry->d_name, &dir_ei->ei_journal_seq); if (ret) return ret; - if (dir_ei->journal_seq > ei->journal_seq) - ei->journal_seq = dir_ei->journal_seq; + if (dir_ei->ei_journal_seq > ei->ei_journal_seq) + ei->ei_journal_seq = dir_ei->ei_journal_seq; inode->i_ctime = dir->i_ctime; @@ -431,8 +431,8 @@ static int bch2_symlink(struct inode *dir, struct dentry *dentry, goto err; /* XXX: racy */ - if (dir_ei->journal_seq < ei->journal_seq) - dir_ei->journal_seq = ei->journal_seq; + if (dir_ei->ei_journal_seq < ei->ei_journal_seq) + dir_ei->ei_journal_seq = ei->ei_journal_seq; ret = bch2_vfs_dirent_create(c, dir, DT_LNK, &dentry->d_name, inode); if (unlikely(ret)) @@ -508,7 +508,7 @@ static int bch2_rename(struct inode *old_dir, struct dentry *old_dentry, ret = bch2_dirent_rename(c, old_dir, &old_dentry->d_name, new_dir, &new_dentry->d_name, - &ei->journal_seq, BCH_RENAME_OVERWRITE); + &ei->ei_journal_seq, BCH_RENAME_OVERWRITE); if (unlikely(ret)) return ret; @@ -520,7 +520,7 @@ static int bch2_rename(struct inode *old_dir, struct dentry *old_dentry, ret = bch2_dirent_rename(c, old_dir, &old_dentry->d_name, new_dir, &new_dentry->d_name, - &ei->journal_seq, BCH_RENAME_OVERWRITE); + &ei->ei_journal_seq, BCH_RENAME_OVERWRITE); if (unlikely(ret)) return ret; @@ -530,7 +530,7 @@ static int bch2_rename(struct inode *old_dir, struct dentry *old_dentry, ret = bch2_dirent_rename(c, old_dir, &old_dentry->d_name, new_dir, &new_dentry->d_name, - &ei->journal_seq, BCH_RENAME); + &ei->ei_journal_seq, BCH_RENAME); if (unlikely(ret)) return ret; @@ -540,7 +540,7 @@ static int bch2_rename(struct inode *old_dir, struct dentry *old_dentry, ret = bch2_dirent_rename(c, old_dir, &old_dentry->d_name, new_dir, &new_dentry->d_name, - &ei->journal_seq, BCH_RENAME); + &ei->ei_journal_seq, BCH_RENAME); if (unlikely(ret)) return ret; } @@ -569,7 +569,7 @@ static int bch2_rename_exchange(struct inode *old_dir, struct dentry *old_dentry ret = bch2_dirent_rename(c, old_dir, &old_dentry->d_name, new_dir, &new_dentry->d_name, - &ei->journal_seq, BCH_RENAME_EXCHANGE); + &ei->ei_journal_seq, BCH_RENAME_EXCHANGE); if (unlikely(ret)) return ret; @@ -630,10 +630,10 @@ static int bch2_setattr(struct dentry *dentry, struct iattr *iattr) if (iattr->ia_valid & ATTR_SIZE) { ret = bch2_truncate(inode, iattr); } else { - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); setattr_copy(inode, iattr); ret = bch2_write_inode(c, ei); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); } if (unlikely(ret)) @@ -774,7 +774,7 @@ static const unsigned bch_inode_flags_to_user_flags_map[] = { /* Set VFS inode flags from bcachefs inode: */ static void bch2_inode_flags_to_vfs(struct inode *inode) { - unsigned i, flags = to_bch_ei(inode)->i_flags; + unsigned i, flags = to_bch_ei(inode)->ei_flags; for (i = 0; i < ARRAY_SIZE(bch_inode_flags_to_vfs_flags_map); i++) if (flags & (1 << i)) @@ -826,7 +826,7 @@ static int bch2_inode_user_flags_set(struct bch_inode_info *ei, return -EOPNOTSUPP; bi->bi_flags = bch_flags; - ei->vfs_inode.i_ctime = current_time(&ei->vfs_inode); + ei->v.i_ctime = current_time(&ei->v); return 0; } @@ -845,7 +845,7 @@ static long bch2_fs_file_ioctl(struct file *filp, unsigned int cmd, switch (cmd) { case FS_IOC_GETFLAGS: - return put_user(bch2_inode_flags_to_user_flags(ei->i_flags), + return put_user(bch2_inode_flags_to_user_flags(ei->ei_flags), (int __user *) arg); case FS_IOC_SETFLAGS: { @@ -872,9 +872,9 @@ static long bch2_fs_file_ioctl(struct file *filp, unsigned int cmd, inode_lock(inode); - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); ret = __bch2_write_inode(c, ei, bch2_inode_user_flags_set, &flags); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); if (!ret) bch2_inode_flags_to_vfs(inode); @@ -1074,19 +1074,19 @@ static void bch2_vfs_inode_init(struct bch_fs *c, struct bch_inode_info *ei, struct bch_inode_unpacked *bi) { - struct inode *inode = &ei->vfs_inode; + struct inode *inode = &ei->v; pr_debug("init inode %llu with mode %o", bi->bi_inum, bi->bi_mode); - ei->i_flags = bi->bi_flags; - ei->i_size = bi->bi_size; + ei->ei_flags = bi->bi_flags; + ei->ei_size = bi->bi_size; inode->i_mode = bi->bi_mode; i_uid_write(inode, bi->bi_uid); i_gid_write(inode, bi->bi_gid); - atomic64_set(&ei->i_sectors, bi->bi_sectors); + atomic64_set(&ei->ei_sectors, bi->bi_sectors); inode->i_blocks = bi->bi_sectors; inode->i_ino = bi->bi_inum; @@ -1099,7 +1099,7 @@ static void bch2_vfs_inode_init(struct bch_fs *c, inode->i_ctime = bch2_time_to_timespec(c, bi->bi_ctime); bch2_inode_flags_to_vfs(inode); - ei->str_hash = bch2_hash_info_init(c, bi); + ei->ei_str_hash = bch2_hash_info_init(c, bi); inode->i_mapping->a_ops = &bch_address_space_operations; @@ -1131,15 +1131,15 @@ static struct inode *bch2_alloc_inode(struct super_block *sb) if (!ei) return NULL; - pr_debug("allocated %p", &ei->vfs_inode); + pr_debug("allocated %p", &ei->v); - inode_init_once(&ei->vfs_inode); - mutex_init(&ei->update_lock); - ei->journal_seq = 0; - atomic_long_set(&ei->i_size_dirty_count, 0); - atomic_long_set(&ei->i_sectors_dirty_count, 0); + inode_init_once(&ei->v); + mutex_init(&ei->ei_update_lock); + ei->ei_journal_seq = 0; + atomic_long_set(&ei->ei_size_dirty_count, 0); + atomic_long_set(&ei->ei_sectors_dirty_count, 0); - return &ei->vfs_inode; + return &ei->v; } static void bch2_i_callback(struct rcu_head *head) @@ -1161,15 +1161,15 @@ static int bch2_vfs_write_inode(struct inode *inode, struct bch_inode_info *ei = to_bch_ei(inode); int ret; - mutex_lock(&ei->update_lock); + mutex_lock(&ei->ei_update_lock); ret = bch2_write_inode(c, ei); - mutex_unlock(&ei->update_lock); + mutex_unlock(&ei->ei_update_lock); if (c->opts.journal_flush_disabled) return ret; if (!ret && wbc->sync_mode == WB_SYNC_ALL) - ret = bch2_journal_flush_seq(&c->journal, ei->journal_seq); + ret = bch2_journal_flush_seq(&c->journal, ei->ei_journal_seq); return ret; } @@ -1184,8 +1184,8 @@ static void bch2_evict_inode(struct inode *inode) struct bch_inode_info *ei = to_bch_ei(inode); /* XXX - we want to check this stuff iff there weren't IO errors: */ - BUG_ON(atomic_long_read(&ei->i_sectors_dirty_count)); - BUG_ON(atomic64_read(&ei->i_sectors) != inode->i_blocks); + BUG_ON(atomic_long_read(&ei->ei_sectors_dirty_count)); + BUG_ON(atomic64_read(&ei->ei_sectors) != inode->i_blocks); } clear_inode(inode); diff --git a/fs/bcachefs/fs.h b/fs/bcachefs/fs.h index 5f2c39f0f969..d255ca7c3754 100644 --- a/fs/bcachefs/fs.h +++ b/fs/bcachefs/fs.h @@ -7,30 +7,35 @@ #include <linux/stat.h> struct bch_inode_info { - struct inode vfs_inode; + struct inode v; - struct mutex update_lock; - u64 journal_seq; + struct mutex ei_update_lock; + u64 ei_journal_seq; - atomic_long_t i_size_dirty_count; + atomic_long_t ei_size_dirty_count; /* * these are updated whenever we update the inode in the btree - for * e.g. fsync */ - u64 i_size; - u32 i_flags; + u64 ei_size; + u32 ei_flags; - atomic_long_t i_sectors_dirty_count; - atomic64_t i_sectors; + atomic_long_t ei_sectors_dirty_count; + atomic64_t ei_sectors; - struct bch_hash_info str_hash; + struct bch_hash_info ei_str_hash; - unsigned long last_dirtied; + unsigned long ei_last_dirtied; }; #define to_bch_ei(_inode) \ - container_of(_inode, struct bch_inode_info, vfs_inode) + container_of_or_null(_inode, struct bch_inode_info, v) + +static inline struct bch_inode_info *file_bch_inode(struct file *file) +{ + return to_bch_ei(file_inode(file)); +} static inline u8 mode_to_type(umode_t mode) { diff --git a/fs/bcachefs/xattr.c b/fs/bcachefs/xattr.c index b2075c2e03f4..c44a5a24ac20 100644 --- a/fs/bcachefs/xattr.c +++ b/fs/bcachefs/xattr.c @@ -171,9 +171,9 @@ int bch2_xattr_get(struct bch_fs *c, struct inode *inode, struct bkey_s_c_xattr xattr; int ret; - k = bch2_hash_lookup(bch2_xattr_hash_desc, &ei->str_hash, c, - ei->vfs_inode.i_ino, &iter, - &X_SEARCH(type, name, strlen(name))); + k = bch2_hash_lookup(bch2_xattr_hash_desc, &ei->ei_str_hash, c, + ei->v.i_ino, &iter, + &X_SEARCH(type, name, strlen(name))); if (IS_ERR(k.k)) return bch2_btree_iter_unlock(&iter) ?: -ENODATA; @@ -242,9 +242,9 @@ int bch2_xattr_set(struct bch_fs *c, struct inode *inode, { struct bch_inode_info *ei = to_bch_ei(inode); - return __bch2_xattr_set(c, inode->i_ino, &ei->str_hash, - name, value, size, flags, type, - &ei->journal_seq); + return __bch2_xattr_set(c, inode->i_ino, &ei->ei_str_hash, + name, value, size, flags, type, + &ei->ei_journal_seq); } static size_t bch2_xattr_emit(struct dentry *dentry, |