xref: /spdk/python/spdk/rpc/blobfs.py (revision e8a40ada16b61c00bfd6cd2b11e7a33bc1f45e30)
1def blobfs_detect(client, bdev_name):
2    """Detect whether a blobfs exists on bdev.
3
4    Args:
5        bdev_name: block device name to detect blobfs
6
7    Returns:
8        True if a blobfs exists on the bdev; False otherwise.
9    """
10    params = {
11        'bdev_name': bdev_name
12    }
13    return client.call('blobfs_detect', params)
14
15
16def blobfs_create(client, bdev_name, cluster_sz=None):
17    """Build blobfs on bdev.
18
19    Args:
20        bdev_name: block device name to build blobfs
21        cluster_sz: Size of cluster in bytes (Optional). Must be multiple of 4KB page size. Default and minimal value is 1M.
22    """
23    params = {
24        'bdev_name': bdev_name
25    }
26    if cluster_sz:
27        params['cluster_sz'] = cluster_sz
28    return client.call('blobfs_create', params)
29
30
31def blobfs_mount(client, bdev_name, mountpoint):
32    """Mount blobfs on bdev by FUSE.
33
34    Args:
35        bdev_name: block device name where the blobfs is
36        mountpoint: Mountpoint path in host to mount blobfs
37    """
38    params = {
39        'bdev_name': bdev_name,
40        'mountpoint': mountpoint
41    }
42    return client.call('blobfs_mount', params)
43
44
45def blobfs_set_cache_size(client, size_in_mb):
46    """Set cache size for the blobstore filesystem.
47
48    Args:
49        size_in_mb: Cache size in megabytes
50
51    Returns:
52        True if cache size is set successfully; False if failed to set.
53    """
54    params = {
55        'size_in_mb': size_in_mb
56    }
57    return client.call('blobfs_set_cache_size', params)
58