[PATCH 0/8] Snapshot deletion improvements

Kent Overstreet posted 8 patches 9 months, 1 week ago
fs/bcachefs/bcachefs.h         |   3 +-
fs/bcachefs/bcachefs_format.h  |   3 +-
fs/bcachefs/fsck.c             |  78 ++++---
fs/bcachefs/io_write.c         |   6 +
fs/bcachefs/sb-errors_format.h |   4 +-
fs/bcachefs/snapshot.c         | 389 +++++++++++++++++++++++++--------
fs/bcachefs/snapshot.h         |  32 ++-
fs/bcachefs/snapshot_format.h  |   4 +-
fs/bcachefs/snapshot_types.h   |  56 +++++
fs/bcachefs/subvolume.c        |   2 -
fs/bcachefs/subvolume.h        |   3 -
fs/bcachefs/subvolume_types.h  |  27 ---
fs/bcachefs/super.c            |   1 +
fs/bcachefs/sysfs.c            |   5 +
fs/bcachefs/xattr.c            |   5 +
15 files changed, 445 insertions(+), 173 deletions(-)
create mode 100644 fs/bcachefs/snapshot_types.h
[PATCH 0/8] Snapshot deletion improvements
Posted by Kent Overstreet 9 months, 1 week ago
Snapshot deletion performance has been reported to be an issue, so this
patch series should address that.

The important optimization relies on the fact that if an
extent/dirent/xattr exists, a version of that inode must exist in that
specific snapshot. We can make use of that to avoid a lot of scanning.

Previously only fsck relied on this, so it would spit out a warning and
correct the issue in its in memory data structures if this occurred.
Now, it's turned into a proper fsck_err() with on-disk repair if
detected.

We also want some additional safety with this: if snapshot deletion ever
screws up and doesn't delete all the keys it was supposed to, we want to
be able to automatically repair.

So there's a new on disk format version with an incompatible (i.e. must
be expliticly enabled) feature, where we never delete snapshot keys - we
just mark them as deleted.

This allows fsck to differentiate between "key for deleted snapshot, I
know how to repair this" vs. "key for missing snapshot, we're not sure
what happened and someone should probably take a look".

And snapshot deletion status is now present in sysfs, currently with
btree and position in that btree. We do have per-snapshot-id accounting,
so it might be possible to turn that into a proper progress indicator
later.

Kent Overstreet (8):
  bcachefs: snapshot delete progress indicator
  bcachefs: Add comments for inode snapshot requirements
  bcachefs: kill inode_walker_entry.snapshot
  bcachefs: BCH_FSCK_ERR_snapshot_key_missing_inode_snapshot
  bcachefs: Skip unrelated snapshot trees in snapshot deletion
  bcachefs: BCH_SNAPSHOT_DELETED -> BCH_SNAPSHOT_WILL_DELETE
  bcachefs: bcachefs_metadata_version_snapshot_deletion_v2
  bcachefs: delete_dead_snapshot_keys_v2()

 fs/bcachefs/bcachefs.h         |   3 +-
 fs/bcachefs/bcachefs_format.h  |   3 +-
 fs/bcachefs/fsck.c             |  78 ++++---
 fs/bcachefs/io_write.c         |   6 +
 fs/bcachefs/sb-errors_format.h |   4 +-
 fs/bcachefs/snapshot.c         | 389 +++++++++++++++++++++++++--------
 fs/bcachefs/snapshot.h         |  32 ++-
 fs/bcachefs/snapshot_format.h  |   4 +-
 fs/bcachefs/snapshot_types.h   |  56 +++++
 fs/bcachefs/subvolume.c        |   2 -
 fs/bcachefs/subvolume.h        |   3 -
 fs/bcachefs/subvolume_types.h  |  27 ---
 fs/bcachefs/super.c            |   1 +
 fs/bcachefs/sysfs.c            |   5 +
 fs/bcachefs/xattr.c            |   5 +
 15 files changed, 445 insertions(+), 173 deletions(-)
 create mode 100644 fs/bcachefs/snapshot_types.h

-- 
2.49.0