From 867a0e5591ababddff68e451580ab1accee2ea4d Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Tue, 30 Oct 2012 16:52:55 +0800 Subject: [PATCH] LU-1337 llite: provides ll_get_acl to ->i_op->get_acl Since kernel 3.1 generic_permission() has lost the check_acl argument, ACL checking has been taken to VFS and filesystems need to provide a non-NULL ->i_op->get_acl to read an ACL from disk. This patch is a complementarity to http://review.whamcloud.com/3397 (d018b087c962b8c66e8dc479fc66e964a2e5fd94), to fix failure of test_25 of sanityn.sh. Signed-off-by: Liu Xuezhao Change-Id: Ica96adac03c1792e2e8b668b959457a4ffec9a43 Reviewed-on: http://review.whamcloud.com/3885 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 21 ++++++++++++++++ lustre/llite/file.c | 56 ++++++++++++++++++++++++++---------------- lustre/llite/llite_internal.h | 3 +++ lustre/llite/namei.c | 54 ++++++++++++++++++++++------------------ 4 files changed, 89 insertions(+), 45 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index fa0d526..02c3f10 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1835,6 +1835,26 @@ LB_LINUX_TRY_COMPILE([ ]) # +# 3.1 adds get_acl method to inode_operations to read ACL from disk. +# see kernel commit 4e34e719e457f2e031297175410fc0bd4016a085 +# +AC_DEFUN([LC_IOP_GET_ACL], +[AC_MSG_CHECKING([inode_operations has .get_acl member function]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct inode_operations iop; + iop.get_acl = NULL; +],[ + AC_DEFINE(HAVE_IOP_GET_ACL, 1, + [inode_operations has .get_acl member function]) + AC_MSG_RESULT([yes]) +],[ + AC_MSG_RESULT([no]) +]) +]) + +# # 3.1.1 has ext4_blocks_for_truncate # AC_DEFUN([LC_BLOCKS_FOR_TRUNCATE], @@ -2037,6 +2057,7 @@ AC_DEFUN([LC_PROG_LINUX], # 3.1 LC_LM_XXX_LOCK_MANAGER_OPS LC_INODE_DIO_WAIT + LC_IOP_GET_ACL # 3.1.1 LC_BLOCKS_FOR_TRUNCATE diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 276a617..b73dfed 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2549,16 +2549,29 @@ int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, } #endif +struct posix_acl * ll_get_acl(struct inode *inode, int type) +{ + struct ll_inode_info *lli = ll_i2info(inode); + struct posix_acl *acl = NULL; + ENTRY; + + cfs_spin_lock(&lli->lli_lock); + /* VFS' acl_permission_check->check_acl will release the refcount */ + acl = posix_acl_dup(lli->lli_posix_acl); + cfs_spin_unlock(&lli->lli_lock); + + RETURN(acl); +} + #ifndef HAVE_GENERIC_PERMISSION_2ARGS static int # ifdef HAVE_GENERIC_PERMISSION_4ARGS -lustre_check_acl(struct inode *inode, int mask, unsigned int flags) +ll_check_acl(struct inode *inode, int mask, unsigned int flags) # else -lustre_check_acl(struct inode *inode, int mask) +ll_check_acl(struct inode *inode, int mask) # endif { # ifdef CONFIG_FS_POSIX_ACL - struct ll_inode_info *lli = ll_i2info(inode); struct posix_acl *acl; int rc; ENTRY; @@ -2567,9 +2580,7 @@ lustre_check_acl(struct inode *inode, int mask) if (flags & IPERM_FLAG_RCU) return -ECHILD; # endif - cfs_spin_lock(&lli->lli_lock); - acl = posix_acl_dup(lli->lli_posix_acl); - cfs_spin_unlock(&lli->lli_lock); + acl = ll_get_acl(inode, ACL_TYPE_ACCESS); if (!acl) RETURN(-EAGAIN); @@ -2617,16 +2628,16 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd) RETURN(rc); } - CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), inode mode %x mask %o\n", - inode->i_ino, inode->i_generation, inode, inode->i_mode, mask); + CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), inode mode %x mask %o\n", + inode->i_ino, inode->i_generation, inode, inode->i_mode, mask); - if (ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT) - return lustre_check_remote_perm(inode, mask); + if (ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT) + return lustre_check_remote_perm(inode, mask); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); - rc = ll_generic_permission(inode, mask, flags, lustre_check_acl); + ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); + rc = ll_generic_permission(inode, mask, flags, ll_check_acl); - RETURN(rc); + RETURN(rc); } #ifdef HAVE_FILE_READV @@ -2708,15 +2719,18 @@ struct file_operations ll_file_operations_noflock = { }; struct inode_operations ll_file_inode_operations = { - .setattr = ll_setattr, - .getattr = ll_getattr, - .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, - .listxattr = ll_listxattr, - .removexattr = ll_removexattr, + .setattr = ll_setattr, + .getattr = ll_getattr, + .permission = ll_inode_permission, + .setxattr = ll_setxattr, + .getxattr = ll_getxattr, + .listxattr = ll_listxattr, + .removexattr = ll_removexattr, #ifdef HAVE_LINUX_FIEMAP_H - .fiemap = ll_fiemap, + .fiemap = ll_fiemap, +#endif +#ifdef HAVE_IOP_GET_ACL + .get_acl = ll_get_acl, #endif }; diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 58ff340..8e26139 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -739,6 +739,8 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, struct lookup_intent *it, struct kstat *stat); int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat); struct ll_file_data *ll_file_data_get(void); +struct posix_acl * ll_get_acl(struct inode *inode, int type); + #ifdef HAVE_GENERIC_PERMISSION_4ARGS int ll_inode_permission(struct inode *inode, int mask, unsigned int flags); #else @@ -748,6 +750,7 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd); int ll_inode_permission(struct inode *inode, int mask); # endif #endif + int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, int flags, struct lov_user_md *lum, int lum_size); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 008ede5..84e8f73 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -1176,31 +1176,37 @@ static int ll_rename(struct inode *old_dir, struct dentry *old_dentry, } struct inode_operations ll_dir_inode_operations = { - .mknod = ll_mknod, - .lookup = ll_lookup_nd, - .create = ll_create_nd, - /* We need all these non-raw things for NFSD, to not patch it. */ - .unlink = ll_unlink, - .mkdir = ll_mkdir, - .rmdir = ll_rmdir, - .symlink = ll_symlink, - .link = ll_link, - .rename = ll_rename, - .setattr = ll_setattr, - .getattr = ll_getattr, - .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, - .listxattr = ll_listxattr, - .removexattr = ll_removexattr, + .mknod = ll_mknod, + .lookup = ll_lookup_nd, + .create = ll_create_nd, + /* We need all these non-raw things for NFSD, to not patch it. */ + .unlink = ll_unlink, + .mkdir = ll_mkdir, + .rmdir = ll_rmdir, + .symlink = ll_symlink, + .link = ll_link, + .rename = ll_rename, + .setattr = ll_setattr, + .getattr = ll_getattr, + .permission = ll_inode_permission, + .setxattr = ll_setxattr, + .getxattr = ll_getxattr, + .listxattr = ll_listxattr, + .removexattr = ll_removexattr, +#ifdef HAVE_IOP_GET_ACL + .get_acl = ll_get_acl, +#endif }; struct inode_operations ll_special_inode_operations = { - .setattr = ll_setattr, - .getattr = ll_getattr, - .permission = ll_inode_permission, - .setxattr = ll_setxattr, - .getxattr = ll_getxattr, - .listxattr = ll_listxattr, - .removexattr = ll_removexattr, + .setattr = ll_setattr, + .getattr = ll_getattr, + .permission = ll_inode_permission, + .setxattr = ll_setxattr, + .getxattr = ll_getxattr, + .listxattr = ll_listxattr, + .removexattr = ll_removexattr, +#ifdef HAVE_IOP_GET_ACL + .get_acl = ll_get_acl, +#endif }; -- 1.8.3.1