Commit d38eb8db authored by Tiger Yang's avatar Tiger Yang Committed by Mark Fasheh

ocfs2: implement i_op->permission

Implement .permission() in ocfs2_file_iops, ocfs2_special_file_iops and
ocfs2_dir_iops.

This helps us avoid some multi-node races with mode change and vfs
operations.
Signed-off-by: default avatarTiger Yang <tiger.yang@oracle.com>
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 58d206c2
...@@ -945,6 +945,28 @@ int ocfs2_getattr(struct vfsmount *mnt, ...@@ -945,6 +945,28 @@ int ocfs2_getattr(struct vfsmount *mnt,
return err; return err;
} }
int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
{
int ret;
mlog_entry_void();
ret = ocfs2_meta_lock(inode, NULL, 0);
if (ret) {
mlog_errno(ret);
goto out;
}
ret = generic_permission(inode, mask, NULL);
if (ret)
mlog_errno(ret);
ocfs2_meta_unlock(inode, 0);
out:
mlog_exit(ret);
return ret;
}
static int ocfs2_write_remove_suid(struct inode *inode) static int ocfs2_write_remove_suid(struct inode *inode)
{ {
int ret; int ret;
...@@ -1329,11 +1351,13 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, ...@@ -1329,11 +1351,13 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb,
struct inode_operations ocfs2_file_iops = { struct inode_operations ocfs2_file_iops = {
.setattr = ocfs2_setattr, .setattr = ocfs2_setattr,
.getattr = ocfs2_getattr, .getattr = ocfs2_getattr,
.permission = ocfs2_permission,
}; };
struct inode_operations ocfs2_special_file_iops = { struct inode_operations ocfs2_special_file_iops = {
.setattr = ocfs2_setattr, .setattr = ocfs2_setattr,
.getattr = ocfs2_getattr, .getattr = ocfs2_getattr,
.permission = ocfs2_permission,
}; };
const struct file_operations ocfs2_fops = { const struct file_operations ocfs2_fops = {
......
...@@ -48,6 +48,8 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb, ...@@ -48,6 +48,8 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb,
int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
struct kstat *stat); struct kstat *stat);
int ocfs2_permission(struct inode *inode, int mask,
struct nameidata *nd);
int ocfs2_set_inode_size(handle_t *handle, int ocfs2_set_inode_size(handle_t *handle,
struct inode *inode, struct inode *inode,
......
...@@ -2311,4 +2311,5 @@ struct inode_operations ocfs2_dir_iops = { ...@@ -2311,4 +2311,5 @@ struct inode_operations ocfs2_dir_iops = {
.rename = ocfs2_rename, .rename = ocfs2_rename,
.setattr = ocfs2_setattr, .setattr = ocfs2_setattr,
.getattr = ocfs2_getattr, .getattr = ocfs2_getattr,
.permission = ocfs2_permission,
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment