linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: linux-fsdevel@vger.kernel.org, David Howells <dhowells@redhat.com>
Subject: Re: Clarification of statx->attributes_mask meaning?
Date: Wed, 25 Nov 2020 13:25:23 -0800	[thread overview]
Message-ID: <20201125212523.GB14534@magnolia> (raw)
In-Reply-To: <33d38621-b65c-b825-b053-eda8870281d1@sandeen.net>

On Wed, Nov 25, 2020 at 01:19:48PM -0600, Eric Sandeen wrote:
> The way attributes_mask is used in various filesystems seems a bit
> inconsistent.
> 
> Most filesystems set only the bits for features that are possible to enable
> on that filesystem, i.e. XFS:
> 
>         if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
>                 stat->attributes |= STATX_ATTR_IMMUTABLE;
>         if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
>                 stat->attributes |= STATX_ATTR_APPEND;
>         if (ip->i_d.di_flags & XFS_DIFLAG_NODUMP)
>                 stat->attributes |= STATX_ATTR_NODUMP;
> 
>         stat->attributes_mask |= (STATX_ATTR_IMMUTABLE |
>                                   STATX_ATTR_APPEND |
>                                   STATX_ATTR_NODUMP);
> 
> btrfs, cifs, erofs, ext4, f2fs, hfsplus, orangefs and ubifs are similar.
> 
> But others seem to set the mask to everything it can definitively answer,
> i.e. "Encryption and compression are off, and we really mean it" even though
> it will never be set to one in ->attributes, i.e. on gfs2:
> 
>         if (gfsflags & GFS2_DIF_APPENDONLY)
>                 stat->attributes |= STATX_ATTR_APPEND;
>         if (gfsflags & GFS2_DIF_IMMUTABLE)
>                 stat->attributes |= STATX_ATTR_IMMUTABLE;
> 
>         stat->attributes_mask |= (STATX_ATTR_APPEND |
>                                   STATX_ATTR_COMPRESSED |
>                                   STATX_ATTR_ENCRYPTED |
>                                   STATX_ATTR_IMMUTABLE |
>                                   STATX_ATTR_NODUMP);
> 
> ext2 is similar (it adds STATX_ATTR_ENCRYPTED to the mask but will never set
> it in attributes)
> 
> The commit 3209f68b3ca4 which added attributes_mask says:
> 
> "Include a mask in struct stat to indicate which bits of stx_attributes the
> filesystem actually supports."
> 
> The manpage says:
> 
> "A mask indicating which bits in stx_attributes are supported by the VFS and
> the filesystem."
> 
> -and-
> 
> "Note that any attribute that is not indicated as supported by stx_attributes_mask
> has no usable value here."
> 
> So is this intended to indicate which bits of statx->attributes are valid, whether
> they are 1 or 0, or which bits could possibly be set to 1 by the filesystem?
> 
> If the former, then we should move attributes_mask into the VFS to set all flags
> known by the kernel, but David's original commit did not do that so I'm left
> wondering...

Personally I thought that attributes_mask tells you which bits actually
make any sense for the given filesystem, which means:

mask=1 bit=0: "attribute not set on this file"
mask=1 bit=1: "attribute is set on this file"
mask=0 bit=0: "attribute doesn't fit into the design of this fs"
mask=0 bit=1: "filesystem is lying snake"

It's up to the fs driver and not the vfs to set attributes_mask, and
therefore (as I keep pointing out to XiaoLi Feng) xfs_vn_getattr should
be setting the mask.

--D

> 
> Thanks,
> -Eric

  reply	other threads:[~2020-11-25 21:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25 19:19 Clarification of statx->attributes_mask meaning? Eric Sandeen
2020-11-25 21:25 ` Darrick J. Wong [this message]
2020-11-25 21:42   ` Eric Sandeen
2020-11-25 21:50 ` David Howells
2020-11-30 23:29   ` Eric Sandeen
2020-12-01  3:20     ` Theodore Y. Ts'o
2020-12-01  3:37       ` Eric Sandeen
2020-12-01  3:50         ` Eric Sandeen
2020-12-01 15:39         ` Theodore Y. Ts'o
2020-12-01 16:25           ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201125212523.GB14534@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).