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