[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1265002505-8387-16-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Date: Mon, 1 Feb 2010 11:04:57 +0530
From: "Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
To: sfrench@...ibm.com, ffilz@...ibm.com, agruen@...e.de,
adilger@....com, sandeen@...hat.com, tytso@....edu,
staubach@...hat.com, bfields@...i.umich.edu, jlayton@...hat.com
Cc: aneesh.kumar@...ux.vnet.ibm.com, linux-fsdevel@...r.kernel.org,
nfsv4@...ux-nfs.org, linux-ext4@...r.kernel.org
Subject: [PATCH 15/23] richacl: Delete posix acl if present on richacl set
When trying to set richacl on a file system object if we
have ACL4_POSIX_MAPPED flag set on the acl delete posix
acl stored with the object. This helps us to migrate from
posix acl to richacl. If we have posix acl stored with
the inode, a getxattr on the inode would return a mapped
richacl with ACL4_POSIX_MAPPED set. Now when we set the
acl back it will result in posix acl being deleted and
richacl being stored.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>
---
fs/ext4/acl.c | 2 +-
fs/ext4/acl.h | 2 ++
fs/ext4/richacl.c | 26 ++++++++++++++++++++++++--
3 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index e17e1a9..3dd3058 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -203,7 +203,7 @@ ext4_get_acl(struct inode *inode, int type)
*
* inode->i_mutex: down unless called from ext4_new_inode
*/
-static int
+int
ext4_set_acl(handle_t *handle, struct inode *inode, int type,
struct posix_acl *acl)
{
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
index 3e47cf3..adcb6e7 100644
--- a/fs/ext4/acl.h
+++ b/fs/ext4/acl.h
@@ -58,6 +58,8 @@ extern int ext4_check_acl(struct inode *, int);
extern int ext4_acl_chmod(struct inode *);
extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
extern struct posix_acl *ext4_get_acl(struct inode *inode, int type);
+extern int ext4_set_acl(handle_t *handle, struct inode *inode, int type,
+ struct posix_acl *acl);
#else /* CONFIG_EXT4_FS_POSIX_ACL */
#include <linux/sched.h>
diff --git a/fs/ext4/richacl.c b/fs/ext4/richacl.c
index 73c14dd..ca8f28e 100644
--- a/fs/ext4/richacl.c
+++ b/fs/ext4/richacl.c
@@ -368,6 +368,7 @@ ext4_xattr_set_richacl(struct dentry *dentry, const char *name,
{
handle_t *handle;
struct richacl *acl = NULL;
+ struct posix_acl *pacl = NULL, *pdacl = NULL;
int retval, retries = 0;
struct inode *inode = dentry->d_inode;
@@ -388,18 +389,39 @@ ext4_xattr_set_richacl(struct dentry *dentry, const char *name,
inode->i_mode &= ~S_IRWXUGO;
inode->i_mode |= richacl_masks_to_mode(acl);
- }
+ /*
+ * check whether we have posix acl. If so delete them
+ *
+ */
+ if (acl->a_flags & ACL4_POSIX_MAPPED) {
+ pacl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
+ pdacl = ext4_get_acl(inode, ACL_TYPE_DEFAULT);
+ acl->a_flags &= ~ACL4_POSIX_MAPPED;
+ }
+ }
retry:
handle = ext4_journal_start(inode, EXT4_DATA_TRANS_BLOCKS(inode->i_sb));
if (IS_ERR(handle))
return PTR_ERR(handle);
ext4_mark_inode_dirty(handle, inode);
+ if (pacl)
+ ext4_set_acl(handle, inode, ACL_TYPE_ACCESS, NULL);
+ if (pdacl)
+ ext4_set_acl(handle, inode, ACL_TYPE_DEFAULT, NULL);
+
retval = ext4_set_richacl(handle, inode, acl);
ext4_journal_stop(handle);
- if (retval == ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+ if (retval == ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) {
+ posix_acl_release(pacl);
+ posix_acl_release(pdacl);
+ pacl = pdacl = NULL;
goto retry;
+ }
richacl_put(acl);
+ posix_acl_release(pacl);
+ posix_acl_release(pdacl);
+ pacl = pdacl = NULL;
return retval;
}
--
1.7.0.rc0.48.gdace5
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists