@@ -325,24 +325,42 @@ impl ExtentInner for RawInner {
325
325
// operation atomic.
326
326
self . set_flush_number ( new_flush, new_gen) ?;
327
327
328
- // Now, we fsync to ensure data is flushed to disk. It's okay to crash
329
- // before this point, because setting the flush number is atomic.
330
- cdt:: extent__flush__file__start!( || {
331
- ( job_id. get( ) , self . extent_number, 0 )
332
- } ) ;
333
- if let Err ( e) = self . file . sync_all ( ) {
334
- /*
335
- * XXX Retry? Mark extent as broken?
336
- */
337
- return Err ( CrucibleError :: IoError ( format ! (
338
- "extent {}: fsync 1 failure: {e:?}" ,
339
- self . extent_number,
340
- ) ) ) ;
328
+ if cfg ! ( feature = "omicron-build" ) {
329
+ // no-op, FIOFFS will be called in region_flush
330
+ } else {
331
+ // Now, we fsync to ensure data is flushed to disk. It's okay to crash
332
+ // before this point, because setting the flush number is atomic.
333
+ cdt:: extent__flush__file__start!( || {
334
+ ( job_id. get( ) , self . extent_number, 0 )
335
+ } ) ;
336
+
337
+ if let Err ( e) = self . file . sync_all ( ) {
338
+ /*
339
+ * XXX Retry? Mark extent as broken?
340
+ */
341
+ return Err ( CrucibleError :: IoError ( format ! (
342
+ "extent {}: fsync 1 failure: {e:?}" ,
343
+ self . extent_number,
344
+ ) ) ) ;
345
+ }
346
+
347
+ cdt:: extent__flush__file__done!( || {
348
+ ( job_id. get( ) , self . extent_number, 0 )
349
+ } ) ;
341
350
}
351
+
352
+ cdt:: extent__flush__done!( || { ( job_id. get( ) , self . extent_number, 0 ) } ) ;
353
+
354
+ Ok ( ( ) )
355
+ }
356
+
357
+ fn post_flush (
358
+ & mut self ,
359
+ _new_flush : u64 ,
360
+ _new_gen : u64 ,
361
+ _job_id : JobOrReconciliationId ,
362
+ ) -> Result < ( ) , CrucibleError > {
342
363
self . context_slot_dirty . fill ( 0 ) ;
343
- cdt:: extent__flush__file__done!( || {
344
- ( job_id. get( ) , self . extent_number, 0 )
345
- } ) ;
346
364
347
365
// Check for fragmentation in the context slots leading to worse
348
366
// performance, and defragment if that's the case.
@@ -352,15 +370,11 @@ impl ExtentInner for RawInner {
352
370
. unwrap_or ( 0 ) ;
353
371
self . extra_syscall_count = 0 ;
354
372
self . extra_syscall_denominator = 0 ;
355
- let r = if extra_syscalls_per_rw > DEFRAGMENT_THRESHOLD {
373
+ if extra_syscalls_per_rw > DEFRAGMENT_THRESHOLD {
356
374
self . defragment ( )
357
375
} else {
358
376
Ok ( ( ) )
359
- } ;
360
-
361
- cdt:: extent__flush__done!( || { ( job_id. get( ) , self . extent_number, 0 ) } ) ;
362
-
363
- r
377
+ }
364
378
}
365
379
366
380
#[ cfg( test) ]
@@ -1852,6 +1866,7 @@ mod test {
1852
1866
1853
1867
// Flush! This will mark all slots as synched
1854
1868
inner. flush ( 12 , 12 , JobId ( 11 ) . into ( ) ) ?;
1869
+ inner. post_flush ( 12 , 12 , JobId ( 11 ) . into ( ) ) ?;
1855
1870
assert_eq ! ( inner. active_context[ 0 ] , ContextSlot :: B ) ;
1856
1871
assert_eq ! ( inner. context_slot_dirty[ 0 ] , 0b00 ) ;
1857
1872
@@ -1904,6 +1919,7 @@ mod test {
1904
1919
1905
1920
// Flush! This will mark all slots as synched
1906
1921
inner. flush ( 12 , 12 , JobId ( 11 ) . into ( ) ) ?;
1922
+ inner. post_flush ( 12 , 12 , JobId ( 11 ) . into ( ) ) ?;
1907
1923
assert_eq ! ( inner. active_context[ 0 ] , ContextSlot :: A ) ;
1908
1924
assert_eq ! ( inner. context_slot_dirty[ 0 ] , 0b00 ) ;
1909
1925
@@ -2029,6 +2045,7 @@ mod test {
2029
2045
assert_eq ! ( inner. extra_syscall_count, 0 ) ;
2030
2046
assert_eq ! ( inner. extra_syscall_denominator, 5 ) ;
2031
2047
inner. flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2048
+ inner. post_flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2032
2049
assert ! ( inner. context_slot_dirty. iter( ) . all( |v| * v == 0 ) ) ;
2033
2050
2034
2051
// This should not have changed active context slots!
@@ -2080,6 +2097,7 @@ mod test {
2080
2097
// trigger defragmentation; after the flush, every context slot should
2081
2098
// be in array A.
2082
2099
inner. flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2100
+ inner. post_flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2083
2101
2084
2102
for i in 0 ..10 {
2085
2103
assert_eq ! (
@@ -2132,6 +2150,7 @@ mod test {
2132
2150
assert_eq ! ( inner. extra_syscall_count, 0 ) ;
2133
2151
assert_eq ! ( inner. extra_syscall_denominator, 3 ) ;
2134
2152
inner. flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2153
+ inner. post_flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2135
2154
2136
2155
// This should not have changed active context slots!
2137
2156
for i in 0 ..10 {
@@ -2185,6 +2204,7 @@ mod test {
2185
2204
// trigger defragmentation; after the flush, every context slot should
2186
2205
// be in array B (which minimizes copies)
2187
2206
inner. flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2207
+ inner. post_flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2188
2208
2189
2209
for i in 0 ..10 {
2190
2210
assert_eq ! (
@@ -2239,6 +2259,7 @@ mod test {
2239
2259
assert_eq ! ( inner. extra_syscall_count, 0 ) ;
2240
2260
assert_eq ! ( inner. extra_syscall_denominator, 3 ) ;
2241
2261
inner. flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2262
+ inner. post_flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2242
2263
2243
2264
// This should not have changed active context slots!
2244
2265
for i in 0 ..10 {
@@ -2293,6 +2314,7 @@ mod test {
2293
2314
// trigger defragmentation; after the flush, every context slot should
2294
2315
// be in array A (which minimizes copies)
2295
2316
inner. flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2317
+ inner. post_flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2296
2318
2297
2319
for i in 0 ..10 {
2298
2320
assert_eq ! (
@@ -2347,6 +2369,7 @@ mod test {
2347
2369
assert_eq ! ( inner. extra_syscall_count, 0 ) ;
2348
2370
assert_eq ! ( inner. extra_syscall_denominator, 2 ) ;
2349
2371
inner. flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2372
+ inner. post_flush ( 10 , 10 , JobId ( 10 ) . into ( ) ) ?;
2350
2373
2351
2374
// This should not have changed active context slots!
2352
2375
for i in 0 ..10 {
@@ -2400,6 +2423,7 @@ mod test {
2400
2423
// This write didn't add enough extra syscalls to trigger
2401
2424
// defragmentation.
2402
2425
inner. flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2426
+ inner. post_flush ( 11 , 11 , JobId ( 11 ) . into ( ) ) ?;
2403
2427
2404
2428
// These should be the same!
2405
2429
for i in 0 ..10 {
0 commit comments