Skip to content

Commit

Permalink
chore: warn if DirectFileDevice is used in a fs (#730)
Browse files Browse the repository at this point in the history
Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx authored Sep 20, 2024
1 parent f1490da commit 553a9cb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions foyer-storage/src/device/direct_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ impl Dev for DirectFileDevice {
let file = opts.open(&options.path)?;

if file.metadata().unwrap().is_file() {
tracing::warn!(
"{}\n{}\n{}",
"It seems a `DirectFileDevice` is used within a normal file system, which is inefficient.",
"Please use `DirectFileDevice` directly on a raw block device.",
"Or use `DirectFsDevice` within a normal file system.",
);
file.set_len(options.capacity as _)?;
}

Expand Down

0 comments on commit 553a9cb

Please sign in to comment.