mirror of
https://github.com/torvalds/linux.git
synced 2024-11-13 23:51:39 +00:00
bcachefs: Track nr_inodes with the key marking machinery
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
26609b619f
commit
f0cfb963ec
@ -721,9 +721,6 @@ struct bch_fs {
|
|||||||
struct mutex fsck_error_lock;
|
struct mutex fsck_error_lock;
|
||||||
bool fsck_alloc_err;
|
bool fsck_alloc_err;
|
||||||
|
|
||||||
/* FILESYSTEM */
|
|
||||||
atomic_long_t nr_inodes;
|
|
||||||
|
|
||||||
/* QUOTAS */
|
/* QUOTAS */
|
||||||
struct bch_memquota_type quotas[QTYP_NR];
|
struct bch_memquota_type quotas[QTYP_NR];
|
||||||
|
|
||||||
|
@ -685,6 +685,7 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
|
|||||||
for (b = 0; b < BCH_DATA_NR; b++)
|
for (b = 0; b < BCH_DATA_NR; b++)
|
||||||
copy_fs_field(buckets[b],
|
copy_fs_field(buckets[b],
|
||||||
"buckets[%s]", bch2_data_types[b]);
|
"buckets[%s]", bch2_data_types[b]);
|
||||||
|
copy_fs_field(nr_inodes, "nr_inodes");
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu) {
|
||||||
p = per_cpu_ptr(c->usage[0], cpu);
|
p = per_cpu_ptr(c->usage[0], cpu);
|
||||||
|
@ -439,6 +439,7 @@ static inline bool btree_node_type_needs_gc(enum btree_node_type type)
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case BKEY_TYPE_BTREE:
|
case BKEY_TYPE_BTREE:
|
||||||
case BKEY_TYPE_EXTENTS:
|
case BKEY_TYPE_EXTENTS:
|
||||||
|
case BKEY_TYPE_INODES:
|
||||||
case BKEY_TYPE_EC:
|
case BKEY_TYPE_EC:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
@ -862,6 +862,12 @@ static int __bch2_mark_key(struct bch_fs *c, struct bkey_s_c k,
|
|||||||
ret = bch2_mark_stripe(c, k, inserting,
|
ret = bch2_mark_stripe(c, k, inserting,
|
||||||
stats, journal_seq, flags, gc);
|
stats, journal_seq, flags, gc);
|
||||||
break;
|
break;
|
||||||
|
case KEY_TYPE_alloc:
|
||||||
|
if (inserting)
|
||||||
|
stats->nr_inodes++;
|
||||||
|
else
|
||||||
|
stats->nr_inodes--;
|
||||||
|
break;
|
||||||
case KEY_TYPE_reservation: {
|
case KEY_TYPE_reservation: {
|
||||||
unsigned replicas = bkey_s_c_to_reservation(k).v->nr_replicas;
|
unsigned replicas = bkey_s_c_to_reservation(k).v->nr_replicas;
|
||||||
|
|
||||||
|
@ -73,6 +73,8 @@ struct bch_fs_usage {
|
|||||||
|
|
||||||
u64 buckets[BCH_DATA_NR];
|
u64 buckets[BCH_DATA_NR];
|
||||||
|
|
||||||
|
u64 nr_inodes;
|
||||||
|
|
||||||
/* fields starting here aren't touched by gc: */
|
/* fields starting here aren't touched by gc: */
|
||||||
u64 online_reserved;
|
u64 online_reserved;
|
||||||
u64 available_cache;
|
u64 available_cache;
|
||||||
|
@ -400,8 +400,6 @@ retry:
|
|||||||
if (unlikely(ret))
|
if (unlikely(ret))
|
||||||
goto err_trans;
|
goto err_trans;
|
||||||
|
|
||||||
atomic_long_inc(&c->nr_inodes);
|
|
||||||
|
|
||||||
if (!tmpfile) {
|
if (!tmpfile) {
|
||||||
bch2_inode_update_after_write(c, dir, &dir_u,
|
bch2_inode_update_after_write(c, dir, &dir_u,
|
||||||
ATTR_MTIME|ATTR_CTIME);
|
ATTR_MTIME|ATTR_CTIME);
|
||||||
@ -1418,9 +1416,6 @@ static void bch2_evict_inode(struct inode *vinode)
|
|||||||
bch2_quota_acct(c, inode->ei_qid, Q_INO, -1,
|
bch2_quota_acct(c, inode->ei_qid, Q_INO, -1,
|
||||||
KEY_TYPE_QUOTA_WARN);
|
KEY_TYPE_QUOTA_WARN);
|
||||||
bch2_inode_rm(c, inode->v.i_ino);
|
bch2_inode_rm(c, inode->v.i_ino);
|
||||||
|
|
||||||
WARN_ONCE(atomic_long_dec_return(&c->nr_inodes) < 0,
|
|
||||||
"nr_inodes < 0");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1439,7 +1434,7 @@ static int bch2_statfs(struct dentry *dentry, struct kstatfs *buf)
|
|||||||
buf->f_blocks = (c->capacity - hidden_metadata) >> shift;
|
buf->f_blocks = (c->capacity - hidden_metadata) >> shift;
|
||||||
buf->f_bfree = (c->capacity - bch2_fs_sectors_used(c, usage)) >> shift;
|
buf->f_bfree = (c->capacity - bch2_fs_sectors_used(c, usage)) >> shift;
|
||||||
buf->f_bavail = buf->f_bfree;
|
buf->f_bavail = buf->f_bfree;
|
||||||
buf->f_files = atomic_long_read(&c->nr_inodes);
|
buf->f_files = usage.nr_inodes;
|
||||||
buf->f_ffree = U64_MAX;
|
buf->f_ffree = U64_MAX;
|
||||||
|
|
||||||
fsid = le64_to_cpup((void *) c->sb.user_uuid.b) ^
|
fsid = le64_to_cpup((void *) c->sb.user_uuid.b) ^
|
||||||
|
@ -1314,9 +1314,6 @@ peek_nlinks: link = genradix_iter_peek(&nlinks_iter, links);
|
|||||||
BUG_ON(ret == -EINTR);
|
BUG_ON(ret == -EINTR);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (link->count)
|
|
||||||
atomic_long_inc(&c->nr_inodes);
|
|
||||||
} else {
|
} else {
|
||||||
/* Should have been caught by dirents pass: */
|
/* Should have been caught by dirents pass: */
|
||||||
need_fsck_err_on(link->count, c,
|
need_fsck_err_on(link->count, c,
|
||||||
@ -1380,7 +1377,6 @@ static int check_inodes_fast(struct bch_fs *c)
|
|||||||
struct btree_iter iter;
|
struct btree_iter iter;
|
||||||
struct bkey_s_c k;
|
struct bkey_s_c k;
|
||||||
struct bkey_s_c_inode inode;
|
struct bkey_s_c_inode inode;
|
||||||
unsigned long nr_inodes = 0;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
for_each_btree_key(&iter, c, BTREE_ID_INODES, POS_MIN, 0, k) {
|
for_each_btree_key(&iter, c, BTREE_ID_INODES, POS_MIN, 0, k) {
|
||||||
@ -1389,9 +1385,6 @@ static int check_inodes_fast(struct bch_fs *c)
|
|||||||
|
|
||||||
inode = bkey_s_c_to_inode(k);
|
inode = bkey_s_c_to_inode(k);
|
||||||
|
|
||||||
if (!(inode.v->bi_flags & BCH_INODE_UNLINKED))
|
|
||||||
nr_inodes++;
|
|
||||||
|
|
||||||
if (inode.v->bi_flags &
|
if (inode.v->bi_flags &
|
||||||
(BCH_INODE_I_SIZE_DIRTY|
|
(BCH_INODE_I_SIZE_DIRTY|
|
||||||
BCH_INODE_I_SECTORS_DIRTY|
|
BCH_INODE_I_SECTORS_DIRTY|
|
||||||
@ -1405,7 +1398,6 @@ static int check_inodes_fast(struct bch_fs *c)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
atomic_long_set(&c->nr_inodes, nr_inodes);
|
|
||||||
fsck_err:
|
fsck_err:
|
||||||
return bch2_btree_iter_unlock(&iter) ?: ret;
|
return bch2_btree_iter_unlock(&iter) ?: ret;
|
||||||
}
|
}
|
||||||
|
@ -375,8 +375,6 @@ int bch2_fs_initialize(struct bch_fs *c)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
atomic_long_set(&c->nr_inodes, 2);
|
|
||||||
|
|
||||||
if (enabled_qtypes(c)) {
|
if (enabled_qtypes(c)) {
|
||||||
ret = bch2_fs_quota_read(c);
|
ret = bch2_fs_quota_read(c);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
Loading…
Reference in New Issue
Block a user