Commit d38eb8db6aa359c060dfb72a29cf8d94a96657d8

Authored by Tiger Yang
Committed by Mark Fasheh
1 parent 58d206c2fa

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: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>

Showing 3 changed files with 27 additions and 0 deletions Side-by-side Diff

... ... @@ -945,6 +945,28 @@
945 945 return err;
946 946 }
947 947  
  948 +int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
  949 +{
  950 + int ret;
  951 +
  952 + mlog_entry_void();
  953 +
  954 + ret = ocfs2_meta_lock(inode, NULL, 0);
  955 + if (ret) {
  956 + mlog_errno(ret);
  957 + goto out;
  958 + }
  959 +
  960 + ret = generic_permission(inode, mask, NULL);
  961 + if (ret)
  962 + mlog_errno(ret);
  963 +
  964 + ocfs2_meta_unlock(inode, 0);
  965 +out:
  966 + mlog_exit(ret);
  967 + return ret;
  968 +}
  969 +
948 970 static int ocfs2_write_remove_suid(struct inode *inode)
949 971 {
950 972 int ret;
951 973  
... ... @@ -1329,11 +1351,13 @@
1329 1351 struct inode_operations ocfs2_file_iops = {
1330 1352 .setattr = ocfs2_setattr,
1331 1353 .getattr = ocfs2_getattr,
  1354 + .permission = ocfs2_permission,
1332 1355 };
1333 1356  
1334 1357 struct inode_operations ocfs2_special_file_iops = {
1335 1358 .setattr = ocfs2_setattr,
1336 1359 .getattr = ocfs2_getattr,
  1360 + .permission = ocfs2_permission,
1337 1361 };
1338 1362  
1339 1363 const struct file_operations ocfs2_fops = {
... ... @@ -48,6 +48,8 @@
48 48 int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
49 49 int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
50 50 struct kstat *stat);
  51 +int ocfs2_permission(struct inode *inode, int mask,
  52 + struct nameidata *nd);
51 53  
52 54 int ocfs2_set_inode_size(handle_t *handle,
53 55 struct inode *inode,
... ... @@ -2311,5 +2311,6 @@
2311 2311 .rename = ocfs2_rename,
2312 2312 .setattr = ocfs2_setattr,
2313 2313 .getattr = ocfs2_getattr,
  2314 + .permission = ocfs2_permission,
2314 2315 };