Whamcloud - gitweb
LU-3669 xattr: separate ACL and XATTR caches
[fs/lustre-release.git] / lustre / llite / xattr.c
index c6b9cfb..56decef 100644 (file)
@@ -183,17 +183,11 @@ int ll_setxattr_common(struct inode *inode, const char *name,
                 valid |= rce_ops2valid(rce->rce_ops);
         }
 #endif
-       if (sbi->ll_xattr_cache_enabled &&
-           (rce == NULL || rce->rce_ops == RMT_LSETFACL)) {
-               rc = ll_xattr_cache_update(inode, name, pv, size, valid, flags);
-       } else {
-               oc = ll_mdscapa_get(inode);
-               rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
-                               valid, name, pv, size, 0, flags,
-                               ll_i2suppgid(inode), &req);
-               capa_put(oc);
-       }
-
+       oc = ll_mdscapa_get(inode);
+       rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
+                       valid, name, pv, size, 0, flags,
+                       ll_i2suppgid(inode), &req);
+       capa_put(oc);
 #ifdef CONFIG_FS_POSIX_ACL
         if (new_value != NULL)
                 lustre_posix_acl_xattr_free(new_value, size);
@@ -292,6 +286,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
         void *xdata;
         struct obd_capa *oc;
         struct rmtacl_ctl_entry *rce = NULL;
+       struct ll_inode_info *lli = ll_i2info(inode);
         ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n",
@@ -340,7 +335,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
          */
         if (xattr_type == XATTR_ACL_ACCESS_T &&
             !(sbi->ll_flags & LL_SBI_RMT_CLIENT)) {
-                struct ll_inode_info *lli = ll_i2info(inode);
+
                 struct posix_acl *acl;
 
                spin_lock(&lli->lli_lock);
@@ -359,13 +354,27 @@ int ll_getxattr_common(struct inode *inode, const char *name,
 #endif
 
 do_getxattr:
-       if (sbi->ll_xattr_cache_enabled && (rce == NULL ||
-                                           rce->rce_ops == RMT_LGETFACL ||
-                                           rce->rce_ops == RMT_LSETFACL)) {
+       if (sbi->ll_xattr_cache_enabled && xattr_type != XATTR_ACL_ACCESS_T) {
                rc = ll_xattr_cache_get(inode, name, buffer, size, valid);
+               if (rc == -EAGAIN)
+                       goto getxattr_nocache;
                if (rc < 0)
                        GOTO(out_xattr, rc);
+
+               /* Add "system.posix_acl_access" to the list */
+               if (lli->lli_posix_acl != NULL && valid & OBD_MD_FLXATTRLS) {
+                       if (size == 0) {
+                               rc += sizeof(XATTR_NAME_ACL_ACCESS);
+                       } else if (size - rc >= sizeof(XATTR_NAME_ACL_ACCESS)) {
+                               memcpy(buffer + rc, XATTR_NAME_ACL_ACCESS,
+                                      sizeof(XATTR_NAME_ACL_ACCESS));
+                               rc += sizeof(XATTR_NAME_ACL_ACCESS);
+                       } else {
+                               GOTO(out_xattr, rc = -ERANGE);
+                       }
+               }
        } else {
+getxattr_nocache:
                oc = ll_mdscapa_get(inode);
                rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
                                valid | (rce ? rce_ops2valid(rce->rce_ops) : 0),