linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] UBIFS: xattr deletion rework
@ 2019-04-04 22:34 Richard Weinberger
  2019-04-04 22:34 ` [PATCH 1/3] ubifs: journal: Handle xattrs like files Richard Weinberger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Richard Weinberger @ 2019-04-04 22:34 UTC (permalink / raw)
  To: linux-mtd; +Cc: Richard Weinberger, stefan

UBIFS handles xattrs in most cases just like files.
An inode can have child entries, which are inodes for xattrs.
If an inode with xattrs is unlinked, only the hosting inode is
referenced in the journal and the orphan list. Upon recovery
all xattrs will be looked up from the TNC and also deleted.

This works in theory, but not in practice. The problem is that
in many places UBIFS internally assumes that a directory inode
can only be deleted if the directory is empty. Since xattr
hosting inodes are treated like directories but you can unlink
such an inode before all xattrs are gone, this assumption is violated.
Therefore it can happen that the garbage collector consumes a LEB
which hosts the information about xattr inodes because the host inode
itself got unlinked. Upon recovery UBIFS is no longer able to
locate these inodes and the free space accounting can get confused.
This can lead to all kind of filesystem corruptions.

The solution is to log every inode in the journal upon unlink.
This approach has one downside, we need to lower the amount of allowed
xattrs per inode.
With this changes applied UBIFS still supports dozens of xattrs per
inode.

Hunting down this issue down was anything but easy.
I'd like to thank Toradex AG for supporing this bug hunt.
Special thanks to Stefan Agner for his constant support and testing my
debug patches over and over.

Richard Weinberger (3):
  ubifs: journal: Handle xattrs like files
  ubifs: orphan: Handle xattrs like files
  ubifs: Limit number of xattrs per inode

 fs/ubifs/dir.c     |  15 +++-
 fs/ubifs/journal.c |  72 ++++++++++++++++---
 fs/ubifs/misc.h    |   8 +++
 fs/ubifs/orphan.c  | 208 ++++++++++++++++++++++++++++++++++++-----------------
 fs/ubifs/super.c   |   2 +
 fs/ubifs/ubifs.h   |   4 ++
 fs/ubifs/xattr.c   |  71 ++++++++++++++++--
 7 files changed, 294 insertions(+), 86 deletions(-)

-- 
2.16.4


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2019-04-25 14:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-04 22:34 [PATCH 0/3] UBIFS: xattr deletion rework Richard Weinberger
2019-04-04 22:34 ` [PATCH 1/3] ubifs: journal: Handle xattrs like files Richard Weinberger
2019-04-04 22:34 ` [PATCH 2/3] ubifs: orphan: " Richard Weinberger
2019-04-04 22:34 ` [PATCH 3/3] ubifs: Limit number of xattrs per inode Richard Weinberger
2019-04-25 14:51 ` [PATCH 0/3] UBIFS: xattr deletion rework Stefan Agner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).