![]() |
![]() |
![]() |
libblockdev Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <kbd.h> enum BDKBDBcacheMode; BDKBDBcacheStats; enum BDKBDError; BDKBDZramStats; #define BD_KBD_ERROR gboolean bd_kbd_bcache_attach (gchar *c_set_uuid
,gchar *bcache_device
,GError **error
); gboolean bd_kbd_bcache_create (gchar *backing_device
,gchar *cache_device
,gchar **bcache_device
,GError **error
); gboolean bd_kbd_bcache_destroy (gchar *bcache_device
,GError **error
); gboolean bd_kbd_bcache_detach (gchar *bcache_device
,gchar **c_set_uuid
,GError **error
); gchar * bd_kbd_bcache_get_backing_device (gchar *bcache_device
,GError **error
); gchar * bd_kbd_bcache_get_cache_device (gchar *bcache_device
,GError **error
); BDKBDBcacheMode bd_kbd_bcache_get_mode (gchar *bcache_device
,GError **error
); BDKBDBcacheMode bd_kbd_bcache_get_mode_from_str (gchar *mode_str
,GError **error
); const gchar * bd_kbd_bcache_get_mode_str (BDKBDBcacheMode mode
,GError **error
); gboolean bd_kbd_bcache_set_mode (gchar *bcache_device
,BDKBDBcacheMode mode
,GError **error
); BDKBDBcacheStats * bd_kbd_bcache_stats_copy (BDKBDBcacheStats *data
); void bd_kbd_bcache_stats_free (BDKBDBcacheStats *data
); BDKBDBcacheStats * bd_kbd_bcache_status (gchar *bcache_device
,GError **error
); GQuark bd_kbd_error_quark (void
); gboolean bd_kbd_zram_create_devices (guint64 num_devices
,guint64 *sizes
,guint64 *nstreams
,GError **error
); gboolean bd_kbd_zram_destroy_devices (GError **error
); BDKBDZramStats * bd_kbd_zram_get_stats (gchar *device
,GError **error
); BDKBDZramStats * bd_kbd_zram_stats_copy (BDKBDZramStats *data
); void bd_kbd_zram_stats_free (BDKBDZramStats *data
);
typedef enum { BD_KBD_MODE_WRITETHROUGH, BD_KBD_MODE_WRITEBACK, BD_KBD_MODE_WRITEAROUND, BD_KBD_MODE_NONE, BD_KBD_MODE_UNKNOWN, } BDKBDBcacheMode;
typedef struct { gchar *state; guint64 block_size; guint64 cache_size; guint64 cache_used; guint64 hits; guint64 misses; guint64 bypass_hits; guint64 bypass_misses; } BDKBDBcacheStats;
typedef enum { BD_KBD_ERROR_INVAL, BD_KBD_ERROR_KMOD_INIT_FAIL, BD_KBD_ERROR_MODULE_FAIL, BD_KBD_ERROR_MODULE_NOEXIST, BD_KBD_ERROR_ZRAM_NOEXIST, BD_KBD_ERROR_ZRAM_INVAL, BD_KBD_ERROR_BCACHE_PARSE, BD_KBD_ERROR_BCACHE_SETUP_FAIL, BD_KBD_ERROR_BCACHE_DETACH_FAIL, BD_KBD_ERROR_BCACHE_NOT_ATTACHED, BD_KBD_ERROR_BCACHE_UUID, BD_KBD_ERROR_BCACHE_MODE_FAIL, BD_KBD_ERROR_BCACHE_MODE_INVAL, BD_KBD_ERROR_BCACHE_NOEXIST, BD_KBD_ERROR_BCACHE_INVAL, } BDKBDError;
typedef struct { guint64 disksize; guint64 num_reads; guint64 num_writes; guint64 invalid_io; guint64 zero_pages; guint64 max_comp_streams; gchar* comp_algorithm; guint64 orig_data_size; guint64 compr_data_size; guint64 mem_used_total; } BDKBDZramStats;
gboolean bd_kbd_bcache_attach (gchar *c_set_uuid
,gchar *bcache_device
,GError **error
);
|
cache set UUID of the cache to attach |
|
bcache device to attach c_set_uuid cache to |
|
place to store error (if any). [out] |
Returns : |
whether the c_set_uuid cache was successfully attached to bcache_device or not |
gboolean bd_kbd_bcache_create (gchar *backing_device
,gchar *cache_device
,gchar **bcache_device
,GError **error
);
|
backing (slow) device of the cache |
|
cache (fast) device of the cache |
|
place to store the name of the new bcache device (if any). [out][allow-none] |
|
place to store error (if any). [out] |
Returns : |
whether the bcache device was successfully created or not |
gboolean bd_kbd_bcache_destroy (gchar *bcache_device
,GError **error
);
|
bcache device to destroy |
|
place to store error (if any). [out] |
Returns : |
whether the bcache device bcache_device was successfully destroyed or not |
gboolean bd_kbd_bcache_detach (gchar *bcache_device
,gchar **c_set_uuid
,GError **error
);
|
bcache device to detach the cache from |
|
cache set UUID of the detached cache. [out][allow-none][transfer full] |
|
place to store error (if any). [out] |
Returns : |
whether the bcache device bcache_device was successfully destroyed or not
Note: Flushes the cache first. |
gchar * bd_kbd_bcache_get_backing_device (gchar *bcache_device
,GError **error
);
|
Bcache device to get the backing device for |
|
place to store error (if any). [out] |
Returns : |
name of the backing device of the bcache_device
or NULL if failed to determine (error is populated). [transfer full]
|
gchar * bd_kbd_bcache_get_cache_device (gchar *bcache_device
,GError **error
);
|
Bcache device to get the cache device for |
|
place to store error (if any). [out] |
Returns : |
name of the cache device of the bcache_device
or NULL if failed to determine (error is populated)
Note: returns the name of the first cache device of bcache_device (in case
there are more). [transfer full]
|
BDKBDBcacheMode bd_kbd_bcache_get_mode (gchar *bcache_device
,GError **error
);
|
device to get mode of |
|
place to store error (if any). [out] |
Returns : |
current mode of the bcache_device
|
BDKBDBcacheMode bd_kbd_bcache_get_mode_from_str (gchar *mode_str
,GError **error
);
|
string representation of mode |
|
place to store error (if any). [out] |
Returns : |
mode matching the mode_str given or BD_KBD_MODE_UNKNOWN in case of no match |
const gchar * bd_kbd_bcache_get_mode_str (BDKBDBcacheMode mode
,GError **error
);
|
mode to get string representation of |
|
place to store error (if any). [out] |
Returns : |
string representation of mode or NULL in case of error. [transfer none]
|
gboolean bd_kbd_bcache_set_mode (gchar *bcache_device
,BDKBDBcacheMode mode
,GError **error
);
|
bcache device to set mode of |
|
mode to set |
|
place to store error (if any). [out] |
Returns : |
whether the mode was successfully set or not |
BDKBDBcacheStats * bd_kbd_bcache_stats_copy (BDKBDBcacheStats *data
);
Creates a new copy of data
.
BDKBDBcacheStats * bd_kbd_bcache_status (gchar *bcache_device
,GError **error
);
|
bcache device to get status for |
|
place to store error (if any). [out] |
Returns : |
status of the bcache_device or NULL in case of
error (error is set). [transfer full]
|
gboolean bd_kbd_zram_create_devices (guint64 num_devices
,guint64 *sizes
,guint64 *nstreams
,GError **error
);
|
number of devices to create |
|
requested sizes (in bytes) for created zRAM devices. [array zero-terminated=1] |
|
numbers of streams for created zRAM devices. [allow-none][array zero-terminated=1] |
|
place to store error (if any). [out] |
Returns : |
whether num_devices zRAM devices were successfully created or not
**Lengths of size and nstreams (if given) have to be >= num_devices !** |
gboolean bd_kbd_zram_destroy_devices (GError **error
);
|
place to store error (if any). [out] |
Returns : |
whether zRAM devices were successfully destroyed or not The only way how to destroy zRAM device right now is to unload the 'zram' module and thus destroy all of them. That's why this function doesn't allow specification of which devices should be destroyed. |
BDKBDZramStats * bd_kbd_zram_get_stats (gchar *device
,GError **error
);
|
zRAM device to get stats for |
|
place to store error (if any). [out] |
Returns : |
statistics for the zRAM device. [transfer full] |
BDKBDZramStats * bd_kbd_zram_stats_copy (BDKBDZramStats *data
);
Creates a new copy of data
.