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
05b3d5ac
Commit
05b3d5ac
authored
Mar 28, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: simplify gc locking a bit
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
f13f5a8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
16 deletions
+11
-16
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_gc.c
+11
-16
No files found.
fs/bcachefs/btree_gc.c
View file @
05b3d5ac
...
@@ -480,12 +480,8 @@ static void bch2_gc_free(struct bch_fs *c)
...
@@ -480,12 +480,8 @@ static void bch2_gc_free(struct bch_fs *c)
ca
->
usage
[
1
]
=
NULL
;
ca
->
usage
[
1
]
=
NULL
;
}
}
percpu_down_write
(
&
c
->
mark_lock
);
free_percpu
(
c
->
usage
[
1
]);
free_percpu
(
c
->
usage
[
1
]);
c
->
usage
[
1
]
=
NULL
;
c
->
usage
[
1
]
=
NULL
;
percpu_up_write
(
&
c
->
mark_lock
);
}
}
static
void
bch2_gc_done
(
struct
bch_fs
*
c
,
bool
initial
)
static
void
bch2_gc_done
(
struct
bch_fs
*
c
,
bool
initial
)
...
@@ -526,8 +522,6 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
...
@@ -526,8 +522,6 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
#define copy_fs_field(_f, _msg, ...) \
#define copy_fs_field(_f, _msg, ...) \
copy_field(_f, "fs has wrong " _msg, ##__VA_ARGS__)
copy_field(_f, "fs has wrong " _msg, ##__VA_ARGS__)
percpu_down_write
(
&
c
->
mark_lock
);
{
{
struct
genradix_iter
dst_iter
=
genradix_iter_init
(
&
c
->
stripes
[
0
],
0
);
struct
genradix_iter
dst_iter
=
genradix_iter_init
(
&
c
->
stripes
[
0
],
0
);
struct
genradix_iter
src_iter
=
genradix_iter_init
(
&
c
->
stripes
[
1
],
0
);
struct
genradix_iter
src_iter
=
genradix_iter_init
(
&
c
->
stripes
[
1
],
0
);
...
@@ -635,8 +629,6 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
...
@@ -635,8 +629,6 @@ static void bch2_gc_done(struct bch_fs *c, bool initial)
}
}
}
}
percpu_up_write
(
&
c
->
mark_lock
);
#undef copy_fs_field
#undef copy_fs_field
#undef copy_dev_field
#undef copy_dev_field
#undef copy_bucket_field
#undef copy_bucket_field
...
@@ -649,8 +641,6 @@ static int bch2_gc_start(struct bch_fs *c)
...
@@ -649,8 +641,6 @@ static int bch2_gc_start(struct bch_fs *c)
struct
bch_dev
*
ca
;
struct
bch_dev
*
ca
;
unsigned
i
;
unsigned
i
;
percpu_down_write
(
&
c
->
mark_lock
);
/*
/*
* indicate to stripe code that we need to allocate for the gc stripes
* indicate to stripe code that we need to allocate for the gc stripes
* radix tree, too
* radix tree, too
...
@@ -661,8 +651,6 @@ static int bch2_gc_start(struct bch_fs *c)
...
@@ -661,8 +651,6 @@ static int bch2_gc_start(struct bch_fs *c)
c
->
usage
[
1
]
=
__alloc_percpu_gfp
(
fs_usage_u64s
(
c
)
*
sizeof
(
u64
),
c
->
usage
[
1
]
=
__alloc_percpu_gfp
(
fs_usage_u64s
(
c
)
*
sizeof
(
u64
),
sizeof
(
u64
),
GFP_KERNEL
);
sizeof
(
u64
),
GFP_KERNEL
);
percpu_up_write
(
&
c
->
mark_lock
);
if
(
!
c
->
usage
[
1
])
if
(
!
c
->
usage
[
1
])
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -685,8 +673,6 @@ static int bch2_gc_start(struct bch_fs *c)
...
@@ -685,8 +673,6 @@ static int bch2_gc_start(struct bch_fs *c)
}
}
}
}
percpu_down_write
(
&
c
->
mark_lock
);
for_each_member_device
(
ca
,
c
,
i
)
{
for_each_member_device
(
ca
,
c
,
i
)
{
struct
bucket_array
*
dst
=
__bucket_array
(
ca
,
1
);
struct
bucket_array
*
dst
=
__bucket_array
(
ca
,
1
);
struct
bucket_array
*
src
=
__bucket_array
(
ca
,
0
);
struct
bucket_array
*
src
=
__bucket_array
(
ca
,
0
);
...
@@ -703,8 +689,6 @@ static int bch2_gc_start(struct bch_fs *c)
...
@@ -703,8 +689,6 @@ static int bch2_gc_start(struct bch_fs *c)
}
}
};
};
percpu_up_write
(
&
c
->
mark_lock
);
return
bch2_ec_mem_alloc
(
c
,
true
);
return
bch2_ec_mem_alloc
(
c
,
true
);
}
}
...
@@ -737,7 +721,10 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
...
@@ -737,7 +721,10 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
down_write
(
&
c
->
gc_lock
);
down_write
(
&
c
->
gc_lock
);
again:
again:
percpu_down_write
(
&
c
->
mark_lock
);
ret
=
bch2_gc_start
(
c
);
ret
=
bch2_gc_start
(
c
);
percpu_up_write
(
&
c
->
mark_lock
);
if
(
ret
)
if
(
ret
)
goto
out
;
goto
out
;
...
@@ -762,7 +749,11 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
...
@@ -762,7 +749,11 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
bch_info
(
c
,
"Fixed gens, restarting mark and sweep:"
);
bch_info
(
c
,
"Fixed gens, restarting mark and sweep:"
);
clear_bit
(
BCH_FS_FIXED_GENS
,
&
c
->
flags
);
clear_bit
(
BCH_FS_FIXED_GENS
,
&
c
->
flags
);
__gc_pos_set
(
c
,
gc_phase
(
GC_PHASE_NOT_RUNNING
));
__gc_pos_set
(
c
,
gc_phase
(
GC_PHASE_NOT_RUNNING
));
percpu_down_write
(
&
c
->
mark_lock
);
bch2_gc_free
(
c
);
bch2_gc_free
(
c
);
percpu_up_write
(
&
c
->
mark_lock
);
goto
again
;
goto
again
;
}
}
...
@@ -770,6 +761,8 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
...
@@ -770,6 +761,8 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
}
}
percpu_down_write
(
&
c
->
mark_lock
);
if
(
!
ret
)
if
(
!
ret
)
bch2_gc_done
(
c
,
initial
);
bch2_gc_done
(
c
,
initial
);
...
@@ -777,6 +770,8 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
...
@@ -777,6 +770,8 @@ int bch2_gc(struct bch_fs *c, struct list_head *journal, bool initial)
__gc_pos_set
(
c
,
gc_phase
(
GC_PHASE_NOT_RUNNING
));
__gc_pos_set
(
c
,
gc_phase
(
GC_PHASE_NOT_RUNNING
));
bch2_gc_free
(
c
);
bch2_gc_free
(
c
);
percpu_up_write
(
&
c
->
mark_lock
);
up_write
(
&
c
->
gc_lock
);
up_write
(
&
c
->
gc_lock
);
trace_gc_end
(
c
);
trace_gc_end
(
c
);
...
...
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