• Hugh Dickins's avatar
    tmpfs,xattr: enable limited user extended attributes · 2daf18a7
    Hugh Dickins authored
    Enable "user." extended attributes on tmpfs, limiting them by tracking
    the space they occupy, and deducting that space from the limited ispace
    (unless tmpfs mounted with nr_inodes=0 to leave that ispace unlimited).
    
    tmpfs inodes and simple xattrs are both unswappable, and have to be in
    lowmem on a 32-bit highmem kernel: so the ispace limit is appropriate
    for xattrs, without any need for a further mount option.
    
    Add simple_xattr_space() to give approximate but deterministic estimate
    of the space taken up by each xattr: with simple_xattrs_free() outputting
    the space freed if required (but kernfs and even some tmpfs usages do not
    require that, so don't waste time on strlen'ing if not needed).
    
    Security and trusted xattrs were already supported: for consistency and
    simplicity, account them from the same pool; though there's a small risk
    that a tmpfs with enough space before would now be considered too small.
    
    When extended attributes are used, "df -i" does show more IUsed and less
    IFree than can be explained by the inodes: document that (manpage later).
    
    xfstests tests/generic which were not run on tmpfs before but now pass:
    020 037 062 070 077 097 103 117 337 377 454 486 523 533 611 618 728
    with no new failures.
    Signed-off-by: default avatarHugh Dickins <hughd@google.com>
    Reviewed-by: default avatarJan Kara <jack@suse.cz>
    Reviewed-by: default avatarCarlos Maiolino <cmaiolino@redhat.com>
    Message-Id: <2e63b26e-df46-5baa-c7d6-f9a8dd3282c5@google.com>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    2daf18a7
xattr.c 36 KB