fuchsia_storage_benchmarks/filesystems/
f2fs.rs

1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::filesystems::FsManagementFilesystemInstance;
6use async_trait::async_trait;
7use storage_benchmarks::{BlockDeviceConfig, BlockDeviceFactory, FilesystemConfig};
8
9/// Config object for starting F2fs instances.
10#[derive(Clone)]
11pub struct F2fs;
12
13#[async_trait]
14impl FilesystemConfig for F2fs {
15    type Filesystem = FsManagementFilesystemInstance;
16
17    async fn start_filesystem(
18        &self,
19        block_device_factory: &dyn BlockDeviceFactory,
20    ) -> FsManagementFilesystemInstance {
21        let block_device = block_device_factory
22            .create_block_device(&BlockDeviceConfig {
23                requires_fvm: true,
24                use_zxcrypt: true,
25                // f2fs requires a minimum of 50MiB volume for fsync test (rounded up to FVM's
26                // slice size)
27                volume_size: Some(56 * 1024 * 1024),
28            })
29            .await;
30        FsManagementFilesystemInstance::new(
31            fs_management::F2fs::default(),
32            block_device,
33            None,
34            /*as_blob=*/ false,
35        )
36        .await
37    }
38
39    fn name(&self) -> String {
40        "f2fs".to_owned()
41    }
42}
43
44#[cfg(test)]
45mod tests {
46    use super::F2fs;
47    use crate::filesystems::testing::check_filesystem;
48
49    #[fuchsia::test]
50    async fn start_f2fs() {
51        check_filesystem(F2fs).await;
52    }
53}