Skip to content

Commit 9e4a3af

Browse files
Martin LindsayCQ Bot
Martin Lindsay
authored and
CQ Bot
committed
[fxfs] Make profile recording generic for files and blobs.
Bug: b/337321099 Change-Id: Ib4e351bec81c68bca1e02186b64b34c3b00f5e55 Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1049613 Reviewed-by: Chris Drouillard <[email protected]> Commit-Queue: Martin Lindsay <[email protected]>
1 parent 450bf9c commit 9e4a3af

File tree

4 files changed

+776
-238
lines changed

4 files changed

+776
-238
lines changed

src/storage/fxfs/platform/src/fuchsia/fxblob/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl BlobDirectory {
2121
{
2222
let mut guard = self.volume().pager().recorder();
2323
if let Some(recorder) = &mut (*guard) {
24-
let _ = recorder.record_open(&hash);
24+
let _ = recorder.record_open(blob.0.clone());
2525
}
2626
}
2727
let vmo = blob.create_child_vmo()?;

src/storage/fxfs/platform/src/fuchsia/pager.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use {
66
crate::fuchsia::{
77
epochs::{Epochs, RefGuard},
88
errors::map_to_status,
9-
fxblob::blob::FxBlob,
109
node::FxNode,
1110
profile::Recorder,
1211
},
@@ -166,7 +165,7 @@ pub struct Pager {
166165
// need to wait for page requests for the specific file being flushed, but we should see if we
167166
// need to for performance reasons first.
168167
epochs: Arc<Epochs>,
169-
recorder: Mutex<Option<Recorder>>,
168+
recorder: Mutex<Option<Box<dyn Recorder>>>,
170169
}
171170

172171
// FileHolder is used to retain either a strong or a weak reference to a file. If there are any
@@ -202,25 +201,23 @@ impl Pager {
202201
}
203202

204203
/// Set the current profile recorder, or set to None to not record.
205-
pub fn set_recorder(&self, recorder: Option<Recorder>) {
204+
pub fn set_recorder(&self, recorder: Option<Box<dyn Recorder>>) {
206205
// Drop the old one outside of the lock.
207206
let _ = std::mem::replace(&mut (*self.recorder.lock().unwrap()), recorder);
208207
}
209208

210209
/// Borrow the profile recorder. Used to record file opens.
211-
pub fn recorder(&self) -> MutexGuard<'_, Option<Recorder>> {
210+
pub fn recorder(&self) -> MutexGuard<'_, Option<Box<dyn Recorder>>> {
212211
self.recorder.lock().unwrap()
213212
}
214213

215214
/// Record a range into a profile if one is being recorded.
216215
pub fn record_page_in<P: PagerBacked>(&self, node: Arc<P>, range: Range<u64>) {
217-
if let Ok(blob) = node.into_any().downcast::<FxBlob>() {
218-
let mut recorder_holder = self.recorder.lock().unwrap();
219-
if let Some(recorder) = &mut (*recorder_holder) {
220-
// If the message fails to send, so will all the rest.
221-
if let Err(_) = recorder.record(&blob.root(), range.start) {
222-
*recorder_holder = None;
223-
}
216+
let mut recorder_holder = self.recorder.lock().unwrap();
217+
if let Some(recorder) = &mut (*recorder_holder) {
218+
// If the message fails to send, so will all the rest.
219+
if let Err(_) = recorder.record(node, range.start) {
220+
*recorder_holder = None;
224221
}
225222
}
226223
}

0 commit comments

Comments
 (0)