*--------------------------------------------------------------*/
struct dm_block_manager {
struct dm_bufio_client *bufio;
+ bool read_only:1;
};
struct dm_block_manager *dm_block_manager_create(struct block_device *bdev,
goto bad;
}
+ bm->read_only = false;
+
return bm;
bad:
void *p;
int r;
+ if (bm->read_only)
+ return -EPERM;
+
p = dm_bufio_read(bm->bufio, b, (struct dm_buffer **) result);
if (unlikely(IS_ERR(p)))
return PTR_ERR(p);
struct buffer_aux *aux;
void *p;
+ if (bm->read_only)
+ return -EPERM;
+
p = dm_bufio_new(bm->bufio, b, (struct dm_buffer **) result);
if (unlikely(IS_ERR(p)))
return PTR_ERR(p);
{
int r;
+ if (bm->read_only)
+ return -EPERM;
+
r = dm_bufio_write_dirty_buffers(bm->bufio);
if (unlikely(r)) {
dm_bm_unlock(superblock);
return dm_bufio_write_dirty_buffers(bm->bufio);
}
+void dm_bm_set_read_only(struct dm_block_manager *bm)
+{
+ bm->read_only = true;
+}
+EXPORT_SYMBOL_GPL(dm_bm_set_read_only);
+
u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor)
{
return crc32c(~(u32) 0, data, len) ^ init_xor;
int dm_bm_flush_and_unlock(struct dm_block_manager *bm,
struct dm_block *superblock);
+/*
+ * Switches the bm to a read only mode. Once read-only mode
+ * has been entered the following functions will return -EPERM.
+ *
+ * dm_bm_write_lock
+ * dm_bm_write_lock_zero
+ * dm_bm_flush_and_unlock
+ *
+ * Additionally you should not use dm_bm_unlock_move, however no error will
+ * be returned if you do.
+ */
+void dm_bm_set_read_only(struct dm_block_manager *bm);
+
u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor);
/*----------------------------------------------------------------*/