From: Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org>
To: Li Xi <pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Ext4 Developers List
<linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>,
Andreas Dilger <adilger-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org>,
Jan Kara <jack-AlSwsSmVLrQ@public.gmane.org>,
"viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org"
<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
"hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org"
<hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Dmitry Monakhov
<dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
Subject: Re: [v5 5/5] Adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support for ext4
Date: Tue, 28 Oct 2014 09:40:58 +1100 [thread overview]
Message-ID: <20141027224058.GB16186@dastard> (raw)
In-Reply-To: <CAPTn0cAAbfnqYgnCEESZeY8XaK=DSGB673Srn_TVYxETG89_OQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Mon, Oct 27, 2014 at 09:09:19AM +0800, Li Xi wrote:
> On Mon, Oct 27, 2014 at 5:56 AM, Dave Chinner <david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org> wrote:
> > On Sun, Oct 26, 2014 at 01:22:53PM +0800, Li Xi wrote:
> >> This patch adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR ioctl interface
> >> support for ext4. The interface is kept consistent with
> >> XFS_IOC_FSGETXATTR/XFS_IOC_FSGETXATTR.
> >
> > What you haven't mentioned is that you also changed the fsxattr
> > interface structure to add functionality and new behaviours that
> > isn't supported by XFS or existing applications that use the
> > interface.
> >
> > There is no need to modify the interface *at all* for ext4 to use
> > it. Fields that ext4 does not use can be zeroed on getxattr, and
> > ignored on setxattr - you do not need to add new fields to say what
> > fields are valid.
> Sorry, I don't want to change the interfaces either. But, the problem
> is that zero might be valid value for some fields. How can we
> distinguish an unsupported attribute and an attribute whose value
> is zero?
You don't. Userspace has no concept of what parts of the struct
fsxattr are valid or not, nor what are valid values the filesystem
will accept or reject.
> It is common case the only part of the fields are supported.
> So, for example, if we don't have valid flags, how can use space
> application tell kernel which attributes should be skipped when it
> tries to set only a part of atrributes?
It *doesn't*. Userspace requires the kernel to initialise the struct
fsxattr before it tries to modify anything, just like
fcntl(F_[GS]ETFL) and other similar "file flag change" syscall APIs.
IOWs, you have to initialise the struct fsxattr by calling
FS_IOC_FSGETXATTR before you call FS_IOC_FSSETXATTR. The
intialisation sets all the fields to the current (correct) values,
and hence when the set call is made all the fields then have the
same/correct values in them except for what the application changed.
E.g. this code from xfs_quota to clear the project ID on a given
file or directory:
if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1) {
// error handling ....
} else if (xfsctl(path, fd, XFS_IOC_FSGETXATTR, &fsx) < 0) {
// error handling ....
}
fsx.fsx_projid = 0;
fsx.fsx_xflags &= ~XFS_XFLAG_PROJINHERIT;
if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &fsx) < 0) {
// error handling ....
}
close(fd);
This ensures that *only* the project ID and the specific project ID
inheritance flag is cleared, and none of the other inode flags or
state are modified....
Cheers,
Dave.
--
Dave Chinner
david-FqsqvQoI3Ljby3iVrkZq2A@public.gmane.org
prev parent reply other threads:[~2014-10-27 22:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-26 5:22 [v5 0/5] quota: add project quota support for ext4 Li Xi
[not found] ` <1414300973-1118-1-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2014-10-26 5:22 ` [v5 1/5] Adds general codes to enforces project quota limits Li Xi
2014-10-30 16:05 ` Jan Kara
2014-10-26 5:22 ` [v5 2/5] Adds project ID support for ext4 Li Xi
[not found] ` <1414300973-1118-3-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2014-10-30 16:18 ` Jan Kara
2014-10-26 5:22 ` [v5 3/5] Adds project quota " Li Xi
[not found] ` <1414300973-1118-4-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2014-10-30 16:50 ` Jan Kara
2014-10-26 5:22 ` [v5 4/5] Adds ioctl interface support for ext4 project Li Xi
[not found] ` <1414300973-1118-5-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2014-10-26 7:49 ` Arnd Bergmann
2014-10-26 21:57 ` Dave Chinner
2014-10-30 16:51 ` Jan Kara
2014-10-26 5:22 ` [v5 5/5] Adds FS_IOC_FSSETXATTR/FS_IOC_FSGETXATTR interface support for ext4 Li Xi
[not found] ` <1414300973-1118-6-git-send-email-lixi-LfVdkaOWEx8@public.gmane.org>
2014-10-26 21:56 ` Dave Chinner
2014-10-27 1:09 ` Li Xi
[not found] ` <CAPTn0cAAbfnqYgnCEESZeY8XaK=DSGB673Srn_TVYxETG89_OQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-10-27 22:40 ` Dave Chinner [this message]
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=20141027224058.GB16186@dastard \
--to=david-fqsqvqoi3ljby3ivrkzq2a@public.gmane.org \
--cc=adilger-m1MBpc4rdrD3fQ9qLvQP4Q@public.gmane.org \
--cc=dmonakhov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
--cc=hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=jack-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-ext4-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=pkuelelixi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=tytso-3s7WtUTddSA@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/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).