libext2fs: add ea_inode support to set xattr

This patch is a major update to how we decide where to put extended
attributes.  The main motivation is to enable creating values in
extended attribute inodes.  While doing this, we want to implement a
behavior that is as close to kernel as possible.

Existing set ea code deviates from kernel behavior which makes it harder
to implement ea_inode feature:

 - kernel only sorts ea entries in xattr block, e2fsprogs implementation
   sorts all entries on every update.

 - e2fsprogs implementation shuffled things on every update so the order
   of updates does not matter. Kernel does not reshuffle things.

 - e2fsprogs could evacuate entries from inode body to xattr block and
   vice versa. This behavior does not exist in kernel.

Such differences could lead to inconsistent behavior between fuse2fs and
a kernel mount.

With ea_inode feature, we also need to decide whether to put a value
in an inode or keep it 'inline'.  In kernel implementation this
depends on current placement of entries.

To close the behavioral gap, ext2fs_xattr_set() now takes over the
decision about where to place ea values.  This also allows it to raise
errors early instead of delaying them to a separate
ext2fs_xattrs_write() call later.

Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 files changed