Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
f0cfb963
Commit
f0cfb963
authored
Nov 29, 2018
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: Track nr_inodes with the key marking machinery
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
26609b61
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
11 additions
and
19 deletions
+11
-19
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs.h
+0
-3
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_gc.c
+1
-0
fs/bcachefs/btree_types.h
fs/bcachefs/btree_types.h
+1
-0
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+6
-0
fs/bcachefs/buckets_types.h
fs/bcachefs/buckets_types.h
+2
-0
fs/bcachefs/fs.c
fs/bcachefs/fs.c
+1
-6
fs/bcachefs/fsck.c
fs/bcachefs/fsck.c
+0
-8
fs/bcachefs/recovery.c
fs/bcachefs/recovery.c
+0
-2
No files found.
fs/bcachefs/bcachefs.h
View file @
f0cfb963
...
@@ -721,9 +721,6 @@ struct bch_fs {
...
@@ -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
];
...
...
fs/bcachefs/btree_gc.c
View file @
f0cfb963
...
@@ -685,6 +685,7 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
...
@@ -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
);
...
...
fs/bcachefs/btree_types.h
View file @
f0cfb963
...
@@ -439,6 +439,7 @@ static inline bool btree_node_type_needs_gc(enum btree_node_type type)
...
@@ -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:
...
...
fs/bcachefs/buckets.c
View file @
f0cfb963
...
@@ -862,6 +862,12 @@ static int __bch2_mark_key(struct bch_fs *c, struct bkey_s_c k,
...
@@ -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
;
...
...
fs/bcachefs/buckets_types.h
View file @
f0cfb963
...
@@ -73,6 +73,8 @@ struct bch_fs_usage {
...
@@ -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
;
...
...
fs/bcachefs/fs.c
View file @
f0cfb963
...
@@ -400,8 +400,6 @@ __bch2_create(struct mnt_idmap *idmap,
...
@@ -400,8 +400,6 @@ __bch2_create(struct mnt_idmap *idmap,
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)
...
@@ -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)
...
@@ -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
)
^
...
...
fs/bcachefs/fsck.c
View file @
f0cfb963
...
@@ -1314,9 +1314,6 @@ peek_nlinks: link = genradix_iter_peek(&nlinks_iter, links);
...
@@ -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)
...
@@ -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)
...
@@ -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)
...
@@ -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
;
}
}
...
...
fs/bcachefs/recovery.c
View file @
f0cfb963
...
@@ -375,8 +375,6 @@ int bch2_fs_initialize(struct bch_fs *c)
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment