Skip to contentSkip to conversation

Array-driven persistent-data structure

DISCUSSION Eric Wheeler 2 participants 3 messages Mar 9, 2016 – Mar 10, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

Hello all,

I'm considering writing an array-driven persistent-data structure for arbitrary metadata. The implementation is intended to be trivial but reusable:

The metadata would be an on-disk array mapping an opaque metadata chunk which is accessible by index. The opaque metadata would be conducive to holding anything of fixed size that can be indexed by an integer.

Nothing is written yet and I'm soliciting feedback on the subject since persistent-data.txt indicates that "[...] something with an array-like interface would see a lot of use."

For example:

a = dm_array_client_create(
bdev, // metadata device
chunksize // metadata chunk size in bytes, eg: sizeof(mystruct) )

Then one might be able to do something like this:

	dm_array_read(a, index_number, &mystruct);
	mystruct.something++;
	dm_array_write(a, index_number, &mystruct);
	dm_array_write_dirty(a);

I'm guessing that dm-bufio would be the way to go in terms of handling backend io but I'm open to suggestions if dm-io (or something else) would have a place here. I seem to recall that dm-io can deadlock inside of .map function calls (is this true about dm-io? Does dm-bufio solve that?).

Thinking from the perspective of a devicemapper target writer, what would be the preferred way to implement dm_array_write_dirty?
dm_bufio_write_dirty_buffers? dm_bufio_write_dirty_buffers_async? or both?
Are these safe to call within the .map function?

What else should I consider here before starting an implementation?

-Eric

--
Eric Wheeler

#2 lore raw
In reply to Eric Wheeler
Quoted 7 lines · Nikolay Borisov
Quoted 7 lines · Eric Wheeler

Hello all,

I'm considering writing an array-driven persistent-data structure for arbitrary metadata. The implementation is intended to be trivial but reusable:

[...]

Quoted 3 lines

Have you checked the existing:
http://lxr.free-electrons.com/source/drivers/md/persistent-data/dm-array.h

Interesting, I hadn't, looking now. dm-bitset looks useful too.

It is neat to see a transactional array; that provides some correctness guarantees. Having the ability to hold multiple roots could be useful too.

While the transactional correctness guarantee outweighs the need for O(1) IMHO, it would be neat to see O(1) since btree is O(lg(n)). O(1) should be attainable since the chunksize is known, so offset=chunksize*index ---but then one would need to manage their own crash recovery.

I'll look at using dm-array and/or dm-bitset for our purpose. I think it will do nicely.

Thank you for the hint!

-Eric

--
Eric Wheeler

Quoted 6 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel