mirror of
https://codeberg.org/shufflecake/shufflecake-c.git
synced 2026-01-07 03:25:26 -05:00
fix
This commit is contained in:
parent
1bf6e3c6aa
commit
57cd2d2850
1 changed files with 15 additions and 5 deletions
|
|
@ -60,7 +60,8 @@ The lock is then re-acquired at the end, once the CWBs return, to effectively ma
|
|||
Let us start with the FLUSH handler, and its helper functions:
|
||||
|
||||
```rust
|
||||
fn flush():
|
||||
fn flush()
|
||||
{
|
||||
RWSEM.down_write();
|
||||
// Populate the FLUSH state, while we are holding the locks
|
||||
err = prepare_cwbs();
|
||||
|
|
@ -83,10 +84,12 @@ fn flush():
|
|||
RWSEM.up_write();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// Under rwsem
|
||||
fn prepare_cwbs():
|
||||
fn prepare_cwbs()
|
||||
{
|
||||
for_each_set_bit(DIRTY, block)
|
||||
first_lsi = block*1024;
|
||||
last_lsi = first_lsi + 1024;
|
||||
|
|
@ -97,10 +100,12 @@ fn prepare_cwbs():
|
|||
// At the end, the whole SNAP_SEQNUM is equal to SEQNUM and
|
||||
// the whole FLUSH_PENDING is equal to DIRTY.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// No lock
|
||||
fn send_cwbs():
|
||||
fn send_cwbs()
|
||||
{
|
||||
// Completion of all callbacks
|
||||
atomic_t pending = 1;
|
||||
struct completion compl;
|
||||
|
|
@ -121,10 +126,12 @@ fn send_cwbs():
|
|||
wait_for_completion(compl);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
// Async callback of CWB
|
||||
fn cwb_callback(err, ctx):
|
||||
fn cwb_callback(err, ctx)
|
||||
{
|
||||
if (err)
|
||||
// Many callbacks could be executing concurrently
|
||||
spin_lock(CWB_ERROR_LOCK);
|
||||
|
|
@ -135,10 +142,12 @@ fn cwb_callback(err, ctx):
|
|||
complete(ctx.compl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Under rwsem again
|
||||
fn mark_blocks_clean():
|
||||
fn mark_blocks_clean()
|
||||
{
|
||||
err = false;
|
||||
|
||||
for_each_set_bit(FLUSH_PENDING, block)
|
||||
|
|
@ -150,6 +159,7 @@ fn mark_blocks_clean():
|
|||
|
||||
// Only return err = false if no CWB failed
|
||||
return err;
|
||||
}
|
||||
```
|
||||
|
||||
A few things to notice:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue