diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-12 21:59:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-05-12 22:28:05 -0400 |
commit | 1a39ba99b5d533647c5dac45cd6a3e0baa7cb66a (patch) | |
tree | 24f0508c7d380168e333f9ee8921d8b8550f9ef6 /fs/gfs2/inode.c | |
parent | b971e94e8f4c09ff775cfb2c4f846b4431a00598 (diff) |
gfs2: Switch to generic xattr handlers
Switch to the generic xattr handlers and take the necessary glocks at
the layer below. The following are the new xattr "entry points"; they
are called with the glock held already in the following cases:
gfs2_xattr_get: From SELinux, during lookups.
gfs2_xattr_set: The glock is never held.
gfs2_get_acl: From gfs2_create_inode -> posix_acl_create and
gfs2_setattr -> posix_acl_chmod.
gfs2_set_acl: From gfs2_setattr -> posix_acl_chmod.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/gfs2/inode.c')
-rw-r--r-- | fs/gfs2/inode.c | 82 |
1 files changed, 11 insertions, 71 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 45f516cada78..72e9c64ae371 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -692,12 +692,12 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
692 | considered free. Any failures need to undo | 692 | considered free. Any failures need to undo |
693 | the gfs2 structures. */ | 693 | the gfs2 structures. */ |
694 | if (default_acl) { | 694 | if (default_acl) { |
695 | error = gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); | 695 | error = __gfs2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); |
696 | posix_acl_release(default_acl); | 696 | posix_acl_release(default_acl); |
697 | } | 697 | } |
698 | if (acl) { | 698 | if (acl) { |
699 | if (!error) | 699 | if (!error) |
700 | error = gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS); | 700 | error = __gfs2_set_acl(inode, acl, ACL_TYPE_ACCESS); |
701 | posix_acl_release(acl); | 701 | posix_acl_release(acl); |
702 | } | 702 | } |
703 | 703 | ||
@@ -1948,66 +1948,6 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
1948 | return 0; | 1948 | return 0; |
1949 | } | 1949 | } |
1950 | 1950 | ||
1951 | static int gfs2_setxattr(struct dentry *dentry, const char *name, | ||
1952 | const void *data, size_t size, int flags) | ||
1953 | { | ||
1954 | struct inode *inode = d_inode(dentry); | ||
1955 | struct gfs2_inode *ip = GFS2_I(inode); | ||
1956 | struct gfs2_holder gh; | ||
1957 | int ret; | ||
1958 | |||
1959 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | ||
1960 | ret = gfs2_glock_nq(&gh); | ||
1961 | if (ret == 0) { | ||
1962 | ret = gfs2_rsqa_alloc(ip); | ||
1963 | if (ret == 0) | ||
1964 | ret = generic_setxattr(dentry, name, data, size, flags); | ||
1965 | gfs2_glock_dq(&gh); | ||
1966 | } | ||
1967 | gfs2_holder_uninit(&gh); | ||
1968 | return ret; | ||
1969 | } | ||
1970 | |||
1971 | static ssize_t gfs2_getxattr(struct dentry *dentry, struct inode *inode, | ||
1972 | const char *name, void *data, size_t size) | ||
1973 | { | ||
1974 | struct gfs2_inode *ip = GFS2_I(inode); | ||
1975 | struct gfs2_holder gh; | ||
1976 | int ret; | ||
1977 | |||
1978 | /* For selinux during lookup */ | ||
1979 | if (gfs2_glock_is_locked_by_me(ip->i_gl)) | ||
1980 | return generic_getxattr(dentry, inode, name, data, size); | ||
1981 | |||
1982 | gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); | ||
1983 | ret = gfs2_glock_nq(&gh); | ||
1984 | if (ret == 0) { | ||
1985 | ret = generic_getxattr(dentry, inode, name, data, size); | ||
1986 | gfs2_glock_dq(&gh); | ||
1987 | } | ||
1988 | gfs2_holder_uninit(&gh); | ||
1989 | return ret; | ||
1990 | } | ||
1991 | |||
1992 | static int gfs2_removexattr(struct dentry *dentry, const char *name) | ||
1993 | { | ||
1994 | struct inode *inode = d_inode(dentry); | ||
1995 | struct gfs2_inode *ip = GFS2_I(inode); | ||
1996 | struct gfs2_holder gh; | ||
1997 | int ret; | ||
1998 | |||
1999 | gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | ||
2000 | ret = gfs2_glock_nq(&gh); | ||
2001 | if (ret == 0) { | ||
2002 | ret = gfs2_rsqa_alloc(ip); | ||
2003 | if (ret == 0) | ||
2004 | ret = generic_removexattr(dentry, name); | ||
2005 | gfs2_glock_dq(&gh); | ||
2006 | } | ||
2007 | gfs2_holder_uninit(&gh); | ||
2008 | return ret; | ||
2009 | } | ||
2010 | |||
2011 | static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | 1951 | static int gfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
2012 | u64 start, u64 len) | 1952 | u64 start, u64 len) |
2013 | { | 1953 | { |
@@ -2054,10 +1994,10 @@ const struct inode_operations gfs2_file_iops = { | |||
2054 | .permission = gfs2_permission, | 1994 | .permission = gfs2_permission, |
2055 | .setattr = gfs2_setattr, | 1995 | .setattr = gfs2_setattr, |
2056 | .getattr = gfs2_getattr, | 1996 | .getattr = gfs2_getattr, |
2057 | .setxattr = gfs2_setxattr, | 1997 | .setxattr = generic_setxattr, |
2058 | .getxattr = gfs2_getxattr, | 1998 | .getxattr = generic_getxattr, |
2059 | .listxattr = gfs2_listxattr, | 1999 | .listxattr = gfs2_listxattr, |
2060 | .removexattr = gfs2_removexattr, | 2000 | .removexattr = generic_removexattr, |
2061 | .fiemap = gfs2_fiemap, | 2001 | .fiemap = gfs2_fiemap, |
2062 | .get_acl = gfs2_get_acl, | 2002 | .get_acl = gfs2_get_acl, |
2063 | .set_acl = gfs2_set_acl, | 2003 | .set_acl = gfs2_set_acl, |
@@ -2076,10 +2016,10 @@ const struct inode_operations gfs2_dir_iops = { | |||
2076 | .permission = gfs2_permission, | 2016 | .permission = gfs2_permission, |
2077 | .setattr = gfs2_setattr, | 2017 | .setattr = gfs2_setattr, |
2078 | .getattr = gfs2_getattr, | 2018 | .getattr = gfs2_getattr, |
2079 | .setxattr = gfs2_setxattr, | 2019 | .setxattr = generic_setxattr, |
2080 | .getxattr = gfs2_getxattr, | 2020 | .getxattr = generic_getxattr, |
2081 | .listxattr = gfs2_listxattr, | 2021 | .listxattr = gfs2_listxattr, |
2082 | .removexattr = gfs2_removexattr, | 2022 | .removexattr = generic_removexattr, |
2083 | .fiemap = gfs2_fiemap, | 2023 | .fiemap = gfs2_fiemap, |
2084 | .get_acl = gfs2_get_acl, | 2024 | .get_acl = gfs2_get_acl, |
2085 | .set_acl = gfs2_set_acl, | 2025 | .set_acl = gfs2_set_acl, |
@@ -2092,10 +2032,10 @@ const struct inode_operations gfs2_symlink_iops = { | |||
2092 | .permission = gfs2_permission, | 2032 | .permission = gfs2_permission, |
2093 | .setattr = gfs2_setattr, | 2033 | .setattr = gfs2_setattr, |
2094 | .getattr = gfs2_getattr, | 2034 | .getattr = gfs2_getattr, |
2095 | .setxattr = gfs2_setxattr, | 2035 | .setxattr = generic_setxattr, |
2096 | .getxattr = gfs2_getxattr, | 2036 | .getxattr = generic_getxattr, |
2097 | .listxattr = gfs2_listxattr, | 2037 | .listxattr = gfs2_listxattr, |
2098 | .removexattr = gfs2_removexattr, | 2038 | .removexattr = generic_removexattr, |
2099 | .fiemap = gfs2_fiemap, | 2039 | .fiemap = gfs2_fiemap, |
2100 | }; | 2040 | }; |
2101 | 2041 | ||