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
3e0745e2
Commit
3e0745e2
authored
Jan 24, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: initialize fs usage summary in recovery
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
42b72e0b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
3 deletions
+42
-3
fs/bcachefs/buckets.c
fs/bcachefs/buckets.c
+27
-0
fs/bcachefs/buckets.h
fs/bcachefs/buckets.h
+1
-0
fs/bcachefs/recovery.c
fs/bcachefs/recovery.c
+8
-0
fs/bcachefs/super.c
fs/bcachefs/super.c
+6
-3
No files found.
fs/bcachefs/buckets.c
View file @
3e0745e2
...
@@ -114,6 +114,33 @@ void bch2_bucket_seq_cleanup(struct bch_fs *c)
...
@@ -114,6 +114,33 @@ void bch2_bucket_seq_cleanup(struct bch_fs *c)
}
}
}
}
void
bch2_fs_usage_initialize
(
struct
bch_fs
*
c
)
{
struct
bch_fs_usage
*
usage
;
unsigned
i
,
nr
;
percpu_down_write
(
&
c
->
mark_lock
);
nr
=
sizeof
(
struct
bch_fs_usage
)
/
sizeof
(
u64
)
+
c
->
replicas
.
nr
;
usage
=
(
void
*
)
bch2_acc_percpu_u64s
((
void
*
)
c
->
usage
[
0
],
nr
);
for
(
i
=
0
;
i
<
c
->
replicas
.
nr
;
i
++
)
{
struct
bch_replicas_entry
*
e
=
cpu_replicas_entry
(
&
c
->
replicas
,
i
);
switch
(
e
->
data_type
)
{
case
BCH_DATA_BTREE
:
case
BCH_DATA_USER
:
usage
->
s
.
data
+=
usage
->
data
[
i
];
break
;
case
BCH_DATA_CACHED
:
usage
->
s
.
cached
+=
usage
->
data
[
i
];
break
;
}
}
percpu_up_write
(
&
c
->
mark_lock
);
}
#define bch2_usage_read_raw(_stats) \
#define bch2_usage_read_raw(_stats) \
({ \
({ \
typeof(*this_cpu_ptr(_stats)) _acc; \
typeof(*this_cpu_ptr(_stats)) _acc; \
...
...
fs/bcachefs/buckets.h
View file @
3e0745e2
...
@@ -248,6 +248,7 @@ static inline u64 bch2_fs_sectors_free(struct bch_fs *c)
...
@@ -248,6 +248,7 @@ static inline u64 bch2_fs_sectors_free(struct bch_fs *c)
/* key/bucket marking: */
/* key/bucket marking: */
void
bch2_bucket_seq_cleanup
(
struct
bch_fs
*
);
void
bch2_bucket_seq_cleanup
(
struct
bch_fs
*
);
void
bch2_fs_usage_initialize
(
struct
bch_fs
*
);
void
bch2_invalidate_bucket
(
struct
bch_fs
*
,
struct
bch_dev
*
,
void
bch2_invalidate_bucket
(
struct
bch_fs
*
,
struct
bch_dev
*
,
size_t
,
struct
bucket_mark
*
);
size_t
,
struct
bucket_mark
*
);
...
...
fs/bcachefs/recovery.c
View file @
3e0745e2
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#include "btree_update.h"
#include "btree_update.h"
#include "btree_update_interior.h"
#include "btree_update_interior.h"
#include "btree_io.h"
#include "btree_io.h"
#include "buckets.h"
#include "dirent.h"
#include "dirent.h"
#include "ec.h"
#include "ec.h"
#include "error.h"
#include "error.h"
...
@@ -251,6 +252,8 @@ int bch2_fs_recovery(struct bch_fs *c)
...
@@ -251,6 +252,8 @@ int bch2_fs_recovery(struct bch_fs *c)
}
}
}
}
bch2_fs_usage_initialize
(
c
);
for
(
i
=
0
;
i
<
BTREE_ID_NR
;
i
++
)
{
for
(
i
=
0
;
i
<
BTREE_ID_NR
;
i
++
)
{
struct
btree_root
*
r
=
&
c
->
btree_roots
[
i
];
struct
btree_root
*
r
=
&
c
->
btree_roots
[
i
];
...
@@ -384,6 +387,11 @@ int bch2_fs_initialize(struct bch_fs *c)
...
@@ -384,6 +387,11 @@ int bch2_fs_initialize(struct bch_fs *c)
bch_notice
(
c
,
"initializing new filesystem"
);
bch_notice
(
c
,
"initializing new filesystem"
);
mutex_lock
(
&
c
->
sb_lock
);
for_each_online_member
(
ca
,
c
,
i
)
bch2_mark_dev_superblock
(
c
,
ca
,
0
);
mutex_unlock
(
&
c
->
sb_lock
);
set_bit
(
BCH_FS_ALLOC_READ_DONE
,
&
c
->
flags
);
set_bit
(
BCH_FS_ALLOC_READ_DONE
,
&
c
->
flags
);
for
(
i
=
0
;
i
<
BTREE_ID_NR
;
i
++
)
for
(
i
=
0
;
i
<
BTREE_ID_NR
;
i
++
)
...
...
fs/bcachefs/super.c
View file @
3e0745e2
...
@@ -1071,9 +1071,12 @@ static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb)
...
@@ -1071,9 +1071,12 @@ static int bch2_dev_attach_bdev(struct bch_fs *c, struct bch_sb_handle *sb)
if
(
ret
)
if
(
ret
)
return
ret
;
return
ret
;
mutex_lock
(
&
c
->
sb_lock
);
if
(
test_bit
(
BCH_FS_ALLOC_READ_DONE
,
&
c
->
flags
)
&&
bch2_mark_dev_superblock
(
ca
->
fs
,
ca
,
0
);
!
percpu_u64_get
(
&
ca
->
usage
[
0
]
->
buckets
[
BCH_DATA_SB
]))
{
mutex_unlock
(
&
c
->
sb_lock
);
mutex_lock
(
&
c
->
sb_lock
);
bch2_mark_dev_superblock
(
ca
->
fs
,
ca
,
0
);
mutex_unlock
(
&
c
->
sb_lock
);
}
bch2_dev_sysfs_online
(
c
,
ca
);
bch2_dev_sysfs_online
(
c
,
ca
);
...
...
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