File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -1956,7 +1956,20 @@ impl Zfs {
19561956 // Retry twice in the face of "dataset is busy", another part of
19571957 // sled-agent may be accessing the list of datasets and volumes, or
19581958 // properties of the volume.
1959- for i in 0 ..3 {
1959+ let mut i = 0 ;
1960+
1961+ // This looks like some nonsense, but it ensures that the mutable ref is
1962+ // captured by the closure below, and not i by value, which would add 1
1963+ // to 0 every time the closure is called.
1964+ let j = & mut i;
1965+
1966+ let mut retryable = || {
1967+ let res = * j < 2 ;
1968+ * j += 1 ;
1969+ res
1970+ } ;
1971+
1972+ loop {
19601973 match execute_async ( cmd) . await {
19611974 Ok ( _) => {
19621975 return Ok ( ( ) ) ;
@@ -1969,7 +1982,8 @@ impl Zfs {
19691982 }
19701983
19711984 Err ( crate :: ExecutionError :: CommandFailure ( info) )
1972- if info. stderr . contains ( "dataset is busy" ) && i < 2 =>
1985+ if info. stderr . contains ( "dataset is busy" )
1986+ && retryable ( ) =>
19731987 {
19741988 tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 1 ) )
19751989 . await ;
@@ -1984,9 +1998,6 @@ impl Zfs {
19841998 }
19851999 }
19862000 }
1987-
1988- // Execution should never reach here?
1989- Ok ( ( ) )
19902001 }
19912002}
19922003
You can’t perform that action at this time.
0 commit comments