On Sat, 17 Feb 2001, Andreas Gruenbacher wrote:

>        Extended attributes are name/value pairs  associated  with
>        inodes  (regular  and  special  files,  directories). Each
>        inode is associated with a set of extended attributes. The
>        name  of  an  extended  attribute consists of an namespace
>        qualifier and a name string.  The  value  of  an  extended
>        attribute  is  a chunk of arbitrary textual or binary data
>        of specified length.

Potentially 0-length?

>        EXT_ATTR_NSP_USER ("user")
>        EXT_ATTR_NSP_INODE ("inode")
>        EXT_ATTR_NSP_TRUSTED ("trusted")
>        EXT_ATTR_NSP_ACL_POSIX ("acl_posix")

I'm still uncomfortable with this selection of namespaces.  "user" and
"inode" seem alright, although "inode" is a poor name choice given that
many file systems don't have inodes.  Perhaps "owner", which would be more
in line with POSIX.1e CAP_FOWNER?

I'm not sure I like "trusted" because it seems to me that defining the
need for CAP_TRUSTED is inconsistent with the idea that your trusted
operating system policy is enforced on all user processes, and is subject
to rules.  In fact, my feeling is that "trusted" is undesirable for the
same reason that you want to define an "acl_posix" namespace: trusted tags
would likely need syntactic or semantic enforcement, and are intended for
use by the "system" and not the application. 

On to "acl_posix".  It has always seemed to me that extended attributes
should provide a general-purpose and simple mechanism for storing and
retrieving additional attribute data associated with a process, and that
aside from protections, the EA interface is really not an interface that
deals with the syntactic and semantic content of the attributes.

So it seems that "acl_posix" and "trusted" are alternate sides of the same
coin: the desire for some way to impose semantics, syntax, or special
authorization requirements on an extended attribute being written out.  It
seems that, in the name of both extensibility and portability, it would
make more sense simply to define a namespace to be used for
syntax/semantics-restricted EAs.  I.e., a "system" namespace where the
process or kernel service attempting to consume the interface can be aware
that there are special requirements on the names in the namespace, and it
should only used by applications aware of the underlying service.  That
these attributes should not be directly manipulated or backed up in binary
form because they are structured blobs potentially implemented in the
underlying file system using mechanisms other than a general EA service. 
With protection models that may depend on factors other than the visible
permissions on the object (i.e., the ACL interface can be used to change
the file owner, and so permission checking for ACL writes depends on the
contents being written out, not just the current file permissions and the
writer making the request).  So my preference here would be to remove the
special-case hacks and simply assert that a namespace exists which doesn't
provide general-purpose services, and is to be used by system services and
utilities only.  I.e., "system".

>        The ext_attr_path() and ext_attr_fd() system calls manipu-
>        late the extended attributes of a file by carrying  out  a
>        sequence of operations on them. The path and fd parameters
>        specify the file name and the file descriptor of the  file
>        whose  extended  attributes shall be manipulated.  The ops
>        array specifies a sequence of operations to be  performed.
>        The ops_size parameter specifies the size of the ops array
>        in bytes. The flags parameter specifies a bitwise combina-
>        tion  of  additional  flags that influence the behavior of
>        the  system  calls  (the  default  value  is  0;  see  the
>        EXT_ATTR_FLAG_* definitions below).

Existing interfaces with struct arrays, such as readv and writev, use the
size argument to specify the number of array entries, not the size of the
array in bytes.  Given that the argument is intended to be structured --
that is, an array of operations, having an operation count makes more
sense than a size argument, intended to describe the size of a binary
blob.  Nither helps you deal with changes in struct sizes, but this is
generally OK for portable interfaces that will never, ever be changed.

                   int             namespce;

It's OK to spell out "namespace", especially if you want the structure to
be portable to other operating systems, or some sort of standard.  And the
operation and buffer_size variable names is already longer than namespce,
so it's not as though you'd be increasing the length above some supported
maximum.

                   unsigned int    name_len;
                   const char      *name;

       name_len
           The  length  of  the  name  of the extended attribute.
           This field  is  ignored  if  the  specified  operation
           affects multiple extended attributes.

       name
           The  name  of  the  extended attribute.  This field is
           ignored if the specified  operation  affects  multiple
           extended attributes.

My understanding from earlier discussions and iterations on the POSIX.1e
mailing list was that attribute names, as with filenames, are
nul-terminated when passed as arguments, and assumed to have the same
namespace conventions as filenames in terms of permitted characters,
character-sets, etc.  This would make the name_len field unnecessary, and
require that the name pointer be documented as pointing to a
nul-terminated string.

       EXT_ATTR_FLAG_ATOMIC
           Execute  all  operations  in  ops,  or  execute  none.
           Filesystems are not required to support this flag.

I'm not sure what this means.  Does it mean "try all of them and apply any
that succeed", does it mean, "try them sequentially until the first fails,
then back out the ones that were applied and fail the operation", or what
exactly?  I'm not sure you document the relationship between individual
operation failures and the overall call sufficiently.  It also doesn't
define who "atomic" is with respect to (file system persistent, other
processes, this process and other threads, ...)

       EXT_ATTR_OP_FLAG_EXISTS
           The  operation  only  succeeds  if  the named extended
           attribute exists. If it does not exist, result is  set
           to -ENOATTR.

Generally speaking, portable application calls (such as POSIX calls)
return Ewhatever, not -Ewhatever.  This should be changed to ENOATTR, and
likewise for later calls in documented portable system interfaces.

       ERANGE  The  attribute  name  is  too  long. The attribute
               value is too long. The buffer is too small to hold
               the result.

Hmm.  The definition for ERANGE that I've always used is:

     ERANGE Numerical result out of range.  A numerical result of the func-
            tion was too large to fit in the available space (perhaps exceed-
            ed precision).

Which is a bit different from the way you describe it.  Will perror()
return a useful string for this?

       ENOTSUP Extended  attributes  are  not  supported  by this
               filesystem. This operation  is  not  supported  on
               this  filesystem. This operation is not enabled on
               this filesystem.

Generally in BSD, I've seen EOPNOTSUPP used for file system operations
rather than ENOTSUP.  Solaris seems to use EOPNOTSUPP for socket
operations, and ENOTSUP for other types of arrangements, but ENOSYS for
ACLs on file systems without ACL support.  Could you remind me of the
portability status of various ENOTSUP-style errors?

       ENOATTR The named extended attribute does not exist.

       EEXIST  The named extended attribute already exists.

Generally speaking, EEXIST refers to files and not attributes on files.
This is one reason why we wanted to introduce a new errno value for
extended attributes in the ENOATTR case.  Use of perror() and other
portable errno-related calls will result in the wrong error message in
this situation.

       ENOSPC  No  space  is  left  for  storing   the   extended
               attributes.

ENOSPC generally refers to the device being out of space, and it seems to
me that we have a number of space failure modes that don't refer to the
device, but possible administrative limits, etc.  We should discuss this
one more.

For reference, here are the errors that can be returned in the FreeBSD
extended attribute implementation:

EROFS           Read-only file system.
EOPNOTSUPP      Operation not supported.
EINVAL          Invalid argument.
ENOENT          No such file or directory.
ENOATTR         No such extended attribute. # still undergoing review
EACCES          Permission denied.
EPERM           Operation not permitted.
ENXIO           No such device or address. # for admin space limits,
                                           # device storage issues
ENOSPC          Device out of space.
EBADF           Bad file descriptor.
EDEADLK         Resource deadlock avoided. # have never gotten this
EFAULT          Bad address. # generally masked by SIGSEGV

I'd argue that a few of these could be changed, in particular with regard
to ENXIO.

A few general comments.

This is a *very* complicated interface that introduces a variety of
transactional concepts of high complexity, especially with atomic failure
mode guarantees.  While I recognize the arguments that lead to the
inclusion of many of these features, including the desire for atomic
replacement of current values, and the desire for compound operations over
multiple attributes, I find that the level of complexity makes me very
uncomfortable.  It requires the implementation of a whole new way of
carrying around compound read/write operations across the system call
interface and VFS stack, for example.  In current portable APIs, there is
one structure used to describe compound operations: struct iovec[].  It
involves one copyin operation to pull the compound operation description
into kernel, associated with a set of buffers that are to be used. Failure
as well as various successful termination conditions at some point during
the operation can result in partially filled buffers in a well-defined
state.  With regards to control of the whole operation, control
information has to be read in only once, and is static over the course of
the call regardless of events in userspace (struct iovec[] is read in at
the start of the call). 

One of the things you don't define in this interface is ordering for
read-in functions from userland.  I.e., You have a large series of nested
structures that are read into the kernel over the course of a transaction. 
There are several ways in which the reading could occur. 

>From the perspective of returning EFAULT early, as well as from a
practical desire in auditing situations to audit all arguments, it's
arguable that the arguments should be read in exactly once at the start of
the system call.  This makes a lot of sense if the system call is being
performed by RPC also, for a migrated process. 

However, you could also argue that a reasonable implementation might pull
the arguments in as it needed them, and rather than attempt to recreate
all the structures and strings in kernel, they should be read in on demand
at various points in the file system stack and system call code. 

Note that the behavior of these is actually very different if any of the
various regions described by the nested structures overlaps.  For example,
suppose two of the name pointers point at the same blob of memory.  In the
first implementation, the starting value for the buffer will be used for
all operations in the transaction.  In the second implementation, if the
value of the string changes after an operation, the new value will be used
for future operations.

In the isolation flag for the system call, you are careful to indicate
that the isolation effect is an inter-process effect.  But the atomicty
flag is apparently defined with the intent of general atomicity, even for
the same process.  This substantially complicates the implementation if
all reads and writes have to appear atomically in the process.  Remember
that threads and shared memory are increasingly popular.  When defining
atomicity, you need to define the context for the atomicity.  This is
especially an issue when considering the argument copyin and copyout
behavior above. 

Conclusion:

There are a number of tweaks and hacks that are in the description too
early in the process, including the special-cased "trusted" and
"acl_posix" behaviors.  I.e., rather than designing the mechanism to have
hacks for each namespace that doesn't quite fit the two general cases
you've identified, let's generalize a little bit for the third case.

My feeling is that this is a very complex solution to an only moderately
complex problem; right now the behavior is so complex that you are
unlikely to see portable implementations of the interface on other
platforms.  The behavior is also poorly defined, and does not lend itself
to consistent implementation in more than a single environment (and maybe
not even there once you take into account multiple file systems).  While
the desirable direction for file system handling may be transactions, the
level of complexity here will leave almost all file systems behind.  The
poor definition lies in part in the area of ordering of events, failure
modes, and the need for control structures to be pulled in once to make it
easier to audit and debug events in threaded/shared memory environments. 
To introduce transactions across process-initiated meta-data operations,
it may be desirable to have fs_{start,abort,end}transaction() calls out of
band, and only support weak consistency features in individual interfaces. 
For example, support clustered read, clustered write, and atomic
test-and-set rather than arbitrary clusters of operations. 

Also, there are a number of portability objections to the syntactic
structuring of your call that are easily addressed, including use of error
codes, variable names, and types. 

Robert N M Watson             FreeBSD Core Team, TrustedBSD Project
[EMAIL PROTECTED]      NAI Labs, Safeport Network Services



-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]

Reply via email to