From: dan.carpenter@oracle.com (Dan Carpenter)
Subject: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support
Date: Mon, 28 Jan 2019 16:33:02 +0300 [thread overview]
Message-ID: <20190128133302.GI1795@kadam> (raw)
In-Reply-To: <94daa491-40c8-4a09-a0b5-55a7e92dc3fc@huawei.com>
On Sat, Jan 26, 2019@10:48:53AM +0800, Chao Yu wrote:
> On 2019/1/26 0:10, Gao Xiang wrote:
> > Let's add .get_acl() to read the file's acl from its xattrs
> > to make POSIX ACL usable.
> >
> > Here is the on-disk detail,
> > fullname: system.posix_acl_access
> > struct erofs_xattr_entry:
> > .e_name_len = 0
> > .e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS (2)
> >
> > fullname: system.posix_acl_default
> > struct erofs_xattr_entry:
> > .e_name_len = 0
> > .e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT (3)
> >
> > Signed-off-by: Gao Xiang <gaoxiang25 at huawei.com>
> > ---
> > change log v2:
> > - add the missing SB_POSIXACL flag;
> > - fix the on-disk detail, use .e_name_len == 0 and proper prefix value;
> > - tested ok with xattr enabled erofs_mkfs;
>
> > .../erofs/Documentation/filesystems/erofs.txt | 2 ++
> > drivers/staging/erofs/inode.c | 3 ++
> > drivers/staging/erofs/namei.c | 1 +
> > drivers/staging/erofs/super.c | 8 +++++
> > drivers/staging/erofs/xattr.c | 37 ++++++++++++++++++++++
> > drivers/staging/erofs/xattr.h | 6 ++++
> > 6 files changed, 57 insertions(+)
> >
> > diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > index 803988d74c21..961ec4da7705 100644
> > --- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > +++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > @@ -36,6 +36,8 @@ Here is the main features of EROFS:
> >
> > - Support xattr inline and tail-end data inline for all files;
> >
> > + - Support POSIX.1e ACLs by using xattrs;
> > +
> > - Support transparent file compression as an option:
> > LZ4 algorithm with 4 KB fixed-output compression for high performance;
> >
> > diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
> > index 4f04f7c38cf2..924b8dfc7a8f 100644
> > --- a/drivers/staging/erofs/inode.c
> > +++ b/drivers/staging/erofs/inode.c
> > @@ -287,6 +287,7 @@ const struct inode_operations erofs_generic_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > const struct inode_operations erofs_symlink_iops = {
> > @@ -294,6 +295,7 @@ const struct inode_operations erofs_symlink_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > const struct inode_operations erofs_fast_symlink_iops = {
> > @@ -301,5 +303,6 @@ const struct inode_operations erofs_fast_symlink_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c
> > index 7fed1f996ab0..b1752adc5934 100644
> > --- a/drivers/staging/erofs/namei.c
> > +++ b/drivers/staging/erofs/namei.c
> > @@ -238,5 +238,6 @@ const struct inode_operations erofs_dir_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
> > index 176fca2af379..54cd7dac0a1f 100644
> > --- a/drivers/staging/erofs/super.c
> > +++ b/drivers/staging/erofs/super.c
> > @@ -398,6 +398,14 @@ static int erofs_read_super(struct super_block *sb,
> > if (!silent)
> > infoln("root inode @ nid %llu", ROOT_NID(sbi));
> >
> > +#ifdef CONFIG_EROFS_FS_POSIX_ACL
> > + /* Update the POSIXACL Flag */
> > + if (test_opt(sbi, POSIX_ACL))
> > + sb->s_flags |= SB_POSIXACL;
> > + else
> > + sb->s_flags &= ~SB_POSIXACL;
> > +#endif
> > +
> > #ifdef CONFIG_EROFS_FS_ZIP
> > INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
> > #endif
> > diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
> > index 7de46690d972..6759485ae862 100644
> > --- a/drivers/staging/erofs/xattr.c
> > +++ b/drivers/staging/erofs/xattr.c
> > @@ -643,3 +643,40 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> > return shared_listxattr(&it);
> > }
> >
> > +#ifdef CONFIG_EROFS_FS_POSIX_ACL
> > +struct posix_acl *erofs_get_acl(struct inode *inode, int type)
> > +{
> > + struct posix_acl *acl;
> > + int ea_prefix, rc;
> > + char *value = NULL;
> > +
> > + switch(type) {
> > + case ACL_TYPE_ACCESS:
> > + ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS;
> > + break;
> > + case ACL_TYPE_DEFAULT:
> > + ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT;
> > + break;
> > + default:
> > + return ERR_PTR(-EINVAL);
> > + }
> > +
> > + rc = erofs_getxattr(inode, ea_prefix, "", NULL, 0);
> > + if (rc > 0) {
> > + value = kvmalloc(rc, GFP_KERNEL);
>
> erofs_kmalloc() is enough?
>
> Thanks,
>
Hopefully, regular kmalloc() is enough.
Do really need the erofs_kmalloc() function? Regular kmalloc() has
fault injection already. Have you tried to use it?
regards,
dan carpenter
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Chao Yu <yuchao0@huawei.com>
Cc: Gao Xiang <gaoxiang25@huawei.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-erofs@lists.ozlabs.org,
Chao Yu <chao@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
weidu.du@huawei.com, Fang Wei <fangwei1@huawei.com>,
Miao Xie <miaoxie@huawei.com>
Subject: Re: [PATCH v2 2/2] staging: erofs: complete POSIX ACL support
Date: Mon, 28 Jan 2019 16:33:02 +0300 [thread overview]
Message-ID: <20190128133302.GI1795@kadam> (raw)
In-Reply-To: <94daa491-40c8-4a09-a0b5-55a7e92dc3fc@huawei.com>
On Sat, Jan 26, 2019 at 10:48:53AM +0800, Chao Yu wrote:
> On 2019/1/26 0:10, Gao Xiang wrote:
> > Let's add .get_acl() to read the file's acl from its xattrs
> > to make POSIX ACL usable.
> >
> > Here is the on-disk detail,
> > fullname: system.posix_acl_access
> > struct erofs_xattr_entry:
> > .e_name_len = 0
> > .e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS (2)
> >
> > fullname: system.posix_acl_default
> > struct erofs_xattr_entry:
> > .e_name_len = 0
> > .e_name_index = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT (3)
> >
> > Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> > ---
> > change log v2:
> > - add the missing SB_POSIXACL flag;
> > - fix the on-disk detail, use .e_name_len == 0 and proper prefix value;
> > - tested ok with xattr enabled erofs_mkfs;
>
> > .../erofs/Documentation/filesystems/erofs.txt | 2 ++
> > drivers/staging/erofs/inode.c | 3 ++
> > drivers/staging/erofs/namei.c | 1 +
> > drivers/staging/erofs/super.c | 8 +++++
> > drivers/staging/erofs/xattr.c | 37 ++++++++++++++++++++++
> > drivers/staging/erofs/xattr.h | 6 ++++
> > 6 files changed, 57 insertions(+)
> >
> > diff --git a/drivers/staging/erofs/Documentation/filesystems/erofs.txt b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > index 803988d74c21..961ec4da7705 100644
> > --- a/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > +++ b/drivers/staging/erofs/Documentation/filesystems/erofs.txt
> > @@ -36,6 +36,8 @@ Here is the main features of EROFS:
> >
> > - Support xattr inline and tail-end data inline for all files;
> >
> > + - Support POSIX.1e ACLs by using xattrs;
> > +
> > - Support transparent file compression as an option:
> > LZ4 algorithm with 4 KB fixed-output compression for high performance;
> >
> > diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c
> > index 4f04f7c38cf2..924b8dfc7a8f 100644
> > --- a/drivers/staging/erofs/inode.c
> > +++ b/drivers/staging/erofs/inode.c
> > @@ -287,6 +287,7 @@ const struct inode_operations erofs_generic_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > const struct inode_operations erofs_symlink_iops = {
> > @@ -294,6 +295,7 @@ const struct inode_operations erofs_symlink_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > const struct inode_operations erofs_fast_symlink_iops = {
> > @@ -301,5 +303,6 @@ const struct inode_operations erofs_fast_symlink_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c
> > index 7fed1f996ab0..b1752adc5934 100644
> > --- a/drivers/staging/erofs/namei.c
> > +++ b/drivers/staging/erofs/namei.c
> > @@ -238,5 +238,6 @@ const struct inode_operations erofs_dir_iops = {
> > #ifdef CONFIG_EROFS_FS_XATTR
> > .listxattr = erofs_listxattr,
> > #endif
> > + .get_acl = erofs_get_acl,
> > };
> >
> > diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c
> > index 176fca2af379..54cd7dac0a1f 100644
> > --- a/drivers/staging/erofs/super.c
> > +++ b/drivers/staging/erofs/super.c
> > @@ -398,6 +398,14 @@ static int erofs_read_super(struct super_block *sb,
> > if (!silent)
> > infoln("root inode @ nid %llu", ROOT_NID(sbi));
> >
> > +#ifdef CONFIG_EROFS_FS_POSIX_ACL
> > + /* Update the POSIXACL Flag */
> > + if (test_opt(sbi, POSIX_ACL))
> > + sb->s_flags |= SB_POSIXACL;
> > + else
> > + sb->s_flags &= ~SB_POSIXACL;
> > +#endif
> > +
> > #ifdef CONFIG_EROFS_FS_ZIP
> > INIT_RADIX_TREE(&sbi->workstn_tree, GFP_ATOMIC);
> > #endif
> > diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c
> > index 7de46690d972..6759485ae862 100644
> > --- a/drivers/staging/erofs/xattr.c
> > +++ b/drivers/staging/erofs/xattr.c
> > @@ -643,3 +643,40 @@ ssize_t erofs_listxattr(struct dentry *dentry,
> > return shared_listxattr(&it);
> > }
> >
> > +#ifdef CONFIG_EROFS_FS_POSIX_ACL
> > +struct posix_acl *erofs_get_acl(struct inode *inode, int type)
> > +{
> > + struct posix_acl *acl;
> > + int ea_prefix, rc;
> > + char *value = NULL;
> > +
> > + switch(type) {
> > + case ACL_TYPE_ACCESS:
> > + ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_ACCESS;
> > + break;
> > + case ACL_TYPE_DEFAULT:
> > + ea_prefix = EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT;
> > + break;
> > + default:
> > + return ERR_PTR(-EINVAL);
> > + }
> > +
> > + rc = erofs_getxattr(inode, ea_prefix, "", NULL, 0);
> > + if (rc > 0) {
> > + value = kvmalloc(rc, GFP_KERNEL);
>
> erofs_kmalloc() is enough?
>
> Thanks,
>
Hopefully, regular kmalloc() is enough.
Do really need the erofs_kmalloc() function? Regular kmalloc() has
fault injection already. Have you tried to use it?
regards,
dan carpenter
next prev parent reply other threads:[~2019-01-28 13:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 16:10 [PATCH v2 1/2] staging: erofs: use xattr_prefix to wrap up Gao Xiang
2019-01-25 16:10 ` Gao Xiang
2019-01-25 16:10 ` [PATCH v2 2/2] staging: erofs: complete POSIX ACL support Gao Xiang
2019-01-25 16:10 ` Gao Xiang
2019-01-26 2:48 ` Chao Yu
2019-01-26 2:48 ` Chao Yu
2019-01-26 3:06 ` Gao Xiang
2019-01-26 3:06 ` Gao Xiang
2019-01-28 13:33 ` Dan Carpenter [this message]
2019-01-28 13:33 ` Dan Carpenter
2019-01-28 13:48 ` Gao Xiang
2019-01-28 13:48 ` Gao Xiang
2019-01-28 14:28 ` Dan Carpenter
2019-01-28 14:28 ` Dan Carpenter
2019-01-28 15:04 ` Gao Xiang
2019-01-28 15:04 ` Gao Xiang
2019-01-28 16:41 ` Chao Yu
2019-01-28 16:41 ` Chao Yu
2019-01-28 18:30 ` Dan Carpenter
2019-01-28 18:30 ` Dan Carpenter
2019-01-29 8:03 ` Gao Xiang
2019-01-29 8:03 ` Gao Xiang
2019-02-03 2:52 ` Chao Yu
2019-02-03 2:52 ` Chao Yu
2019-02-15 2:10 ` Chao Yu
2019-02-15 2:10 ` Chao Yu
2019-02-15 7:36 ` Dan Carpenter
2019-02-15 7:36 ` Dan Carpenter
2019-02-15 9:31 ` Chao Yu
2019-02-15 9:31 ` Chao Yu
2019-01-26 2:08 ` [PATCH v2 1/2] staging: erofs: use xattr_prefix to wrap up Chao Yu
2019-01-26 2:08 ` Chao Yu
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=20190128133302.GI1795@kadam \
--to=dan.carpenter@oracle.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.