public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2][RESEND] btrfs-progs: handle orphan directories properly
@ 2022-02-22 22:24 Josef Bacik
  2022-02-22 22:24 ` [PATCH v2 1/2] " Josef Bacik
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Josef Bacik @ 2022-02-22 22:24 UTC (permalink / raw)
  To: linux-btrfs, kernel-team

v1->v2:
- use "is_orphan" not "has_orphan_item" in the mode-lowmem code.  Somehow the
  compiler didn't warn me of this until I switched to a different branch.

--- Original email ---
Hello,

While implementing the garbage collection tree I started getting btrfsck errors
when a test would do rm -rf DIRECTORY and then immediately unmount.  This is
because we stop processing GC items during umount, and thus we left the
directory with an nlink == 0 and all of its children in the fs tree.

However this isn't a problem with just the GC tree, we can have this happen if
we fail to do the eviction work at evict time, and we leave the orphan entry in
place on disk.  btrfsck properly ignores problems with inodes that have orphan
items, except for directory inodes.

Fix this by making sure we don't add any backrefs we find from directory inodes
that we've find the inode item for and have an nlink == 0.

I generated a test image for this by simply skipping the
btrfs_truncate_inode_items() work in evict in a kernel and rm -rf'ing a
directory on a test file system.

With this patch both make test-check and make test-check-lowmem pass all the
tests, including the new testcase.  Thanks,

Josef

Josef Bacik (2):
  btrfs-progs: handle orphan directories properly
  btrfs-progs: add a test to check orphaned directories

 check/main.c                                  |  15 ++++++++++++-
 check/mode-lowmem.c                           |   6 ++++--
 .../052-orphan-directory/default.img.xz       | Bin 0 -> 1432 bytes
 tests/fsck-tests/052-orphan-directory/test.sh |  20 ++++++++++++++++++
 4 files changed, 38 insertions(+), 3 deletions(-)
 create mode 100644 tests/fsck-tests/052-orphan-directory/default.img.xz
 create mode 100755 tests/fsck-tests/052-orphan-directory/test.sh

-- 
2.26.3


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

end of thread, other threads:[~2022-03-08 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-22 22:24 [PATCH v2 0/2][RESEND] btrfs-progs: handle orphan directories properly Josef Bacik
2022-02-22 22:24 ` [PATCH v2 1/2] " Josef Bacik
2022-02-22 22:24 ` [PATCH v2 2/2] btrfs-progs: add a test to check orphaned directories Josef Bacik
2022-03-08 17:51 ` [PATCH v2 0/2][RESEND] btrfs-progs: handle orphan directories properly David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox