On 10/19/2018 02:02 AM, Chris Murphy wrote:
On Tue, Oct 16, 2018 at 10:08 PM, Anand Jain <anand.j...@oracle.com> wrote:
So a possible solution for the reproducible builds:
usual mkfs.btrfs dev
Write the data
unmount; create btrfs-image with uuid/fsid/time sanitized; mark it as a
seed (RO).
check/verify the hash of the image.
Gotcha. Generation/transid needs to be included in that list. Imagine
a fast system vs a slow system. The slow system certainly will end up
with with higher transid's for the latest completed transactions.
In a scripted build environment the transid could remain same, as
there won't extra sync or mount -o transid changes.. etc.
But also, I don't know how the kernel code chooses block numbers,
either physical (chunk allocation) or logical (extent allocation) and
if that could be made deterministic. Same for inode assignment.
The above list may not be complete. To avoid the disk size,type
related changes one can choose to create a mkfs on a file instead of
disk. But the point I am trying to make with bytenr is if a tool uses
certain items which are not explicitly EXPORTED/ioctl, that means it can
change without notice, unless these tools are inline with the btrfs
kernel changes it would break.
Another question that comes up later when creating the sprout by
removing the seed device, is how a script can know when all block
groups have successfully copied from seed to sprout, and that the
sprout can be unmounted.
Oh.
mount -o loop seed.img /seed <-- this will be RO
btrfs device add /dev/sprout /seed <-- new FSID on the same mount
point, /dev/sprout will have new SB with new FSID, and sprout device
count will include the seed device. And originally this was RW already
but we broke it somewhere. But not a big deal as we can use remount.
mount -o remount,rw /dev/sprout /seed <-- this is RW. Only _new_
writes goes to /dev/sprout, and sprout still needs seed to mount.
btrfs device delete <seed-devid> /seed <-- this will transfer all
seed blocks to /dev/sprout.
Now /dev/sprout is an independent RW FS with the contents from the
seed and its total device count is now 1.
Thanks, Anand