All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] btrfs: send: correctly recreate changed inodes
@ 2021-01-25 19:42 Roman Anasal
  2021-01-25 19:42 ` [PATCH v2 1/4] btrfs: send: rename send_ctx.cur_inode_new_gen to cur_inode_recreated Roman Anasal
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Roman Anasal @ 2021-01-25 19:42 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Roman Anasal

This is v2 of the patch set submitted in [1]. Changes in the patch set:
- fixed mixed code/declarations according to feedback
- add patch to also handle the case of differing rdev with same gen
- add patch to fix invalid commands when using disconnected roots, see [2]

[1] https://lore.kernel.org/linux-btrfs/20210111190243.4152-1-roman.anasal@bdsu.de/
[2] https://lore.kernel.org/linux-btrfs/424d62853024d8b0bc5ca03206eeca35be6014a2.camel@bdsu.de/


TL;DR: the patches address issues arising only in edge cases when snapshots
used for incremental send are not stricly based off of a single writable
parent, i.e. when
- the subvolumes do not share a common anchestor
- the subvolumes are (based off of) snapshots that were modified within the
  same transaction after they were created

Outside of these cases it is safe to assume that an inode will only need to
be recreated if the generation changed - which happens when the inode was
deleted and a new inode reused the same inode number - because creating a
snapshot forces a transaction commit.

But in the above cases it is possible that inodes that are created within
same transaction in both subvolumes end up having the same inode number as
well as same generation. These would the produce invalid commands streams
that cause the receiver to fail or produce incorrect results.


I am aware that these edge cases lie clearly outside the expected use case
which is sending only related subvolumes incrementally. The reason I updated
the patches anyway was that I felt challenged by this and wanted to get some
programming/debugging practice with the kernel and get a deeper
understanding of btrfs.

I tried as good as I could to limit any effects of the patches to the
particluar cases I discovered and am fairly confident that they won't affect
the behavior in other cases - but of course am open to be correct here
by the far more experienced eyes on this.
But even if the patches will be rejected because the issues can only occur
in unsupported use of btrfs send/receive I wanted to document my findings
here; maybe they can still be picked up later.

In any case I'd appreciate any feedback and the code/patches themselves
since it's my first contribution (attempt) to the kernel (=


Roman Anasal (4):
  btrfs: send: rename send_ctx.cur_inode_new_gen to cur_inode_recreated
  btrfs: send: fix invalid commands for inodes with changed type but
    same gen
  btrfs: send: fix invalid commands for inodes with changed rdev but
    same gen
  btrfs: send: fix invalid commands for inodes in disconnected roots

 fs/btrfs/send.c | 69 ++++++++++++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 24 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-02-03 16:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 19:42 [PATCH v2 0/4] btrfs: send: correctly recreate changed inodes Roman Anasal
2021-01-25 19:42 ` [PATCH v2 1/4] btrfs: send: rename send_ctx.cur_inode_new_gen to cur_inode_recreated Roman Anasal
2021-01-25 19:42 ` [PATCH v2 2/4] btrfs: send: fix invalid commands for inodes with changed type but same gen Roman Anasal
2021-01-25 19:42 ` [PATCH v2 3/4] btrfs: send: fix invalid commands for inodes with changed rdev " Roman Anasal
2021-01-25 20:51   ` Filipe Manana
2021-01-26 19:19     ` Roman Anasal | BDSU
2021-01-27 10:53       ` Filipe Manana
2021-01-31 15:52     ` Roman Anasal | BDSU
2021-02-02 11:56       ` Filipe Manana
2021-02-03 16:20         ` Roman Anasal | BDSU
2021-01-25 19:42 ` [PATCH v2 4/4] btrfs: send: fix invalid commands for inodes in disconnected roots Roman Anasal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.