X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fxattr_cache.c;h=5b1d917cbc1d5c33d9dc59fda7042c88e636ebdd;hb=fa08092d9a1554dc733640b6328fcaf3e85fec36;hp=9de6b6d9cd740a185d242d6f55f49dbede12bff7;hpb=192902851d73ec246af92a2ff7be8f23b08c4343;p=fs%2Flustre-release.git diff --git a/lustre/llite/xattr_cache.c b/lustre/llite/xattr_cache.c index 9de6b6d..5b1d917 100644 --- a/lustre/llite/xattr_cache.c +++ b/lustre/llite/xattr_cache.c @@ -43,12 +43,11 @@ * using a hash or a tree structure instead of list for faster lookups. */ struct ll_xattr_entry { - struct list_head xe_list; /* protected with - * lli_xattrs_list_rwsem */ - char *xe_name; /* xattr name, \0-terminated */ - char *xe_value; /* xattr value */ - unsigned xe_namelen; /* strlen(xe_name) + 1 */ - unsigned xe_vallen; /* xattr value length */ + struct list_head xe_list; /* protected by lli_xattrs_list_rwsem */ + char *xe_name; /* xattr name, \0-terminated */ + char *xe_value; /* xattr value */ + unsigned int xe_namelen; /* strlen(xe_name) + 1 */ + unsigned int xe_vallen; /* xattr value length */ }; static struct kmem_cache *xattr_kmem; @@ -73,7 +72,7 @@ void ll_xattr_fini(void) lu_kmem_fini(xattr_caches); } -/** +/* * Initializes xattr cache for an inode. * * This initializes the xattr list and marks cache presence. @@ -132,14 +131,15 @@ static int ll_xattr_cache_find(struct list_head *cache, static int ll_xattr_cache_add(struct list_head *cache, const char *xattr_name, const char *xattr_val, - unsigned xattr_val_len) + unsigned int xattr_val_len) { struct ll_xattr_entry *xattr; ENTRY; if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) { - if (!strcmp(xattr_name, LL_XATTR_NAME_ENCRYPTION_CONTEXT)) + if (!strcmp(xattr_name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) || + !strcmp(xattr_name, LL_XATTR_NAME_ENCRYPTION_CONTEXT_OLD)) /* it means enc ctx was already in cache, * ignore error as it cannot be modified */ @@ -292,7 +292,7 @@ static int ll_xattr_cache_destroy_locked(struct ll_inode_info *lli) RETURN(0); while (ll_xattr_cache_del(&lli->lli_xattrs, NULL) == 0) - /* empty loop */ ; + ; /* empty loop */ clear_bit(LLIF_XATTR_CACHE_FILLED, &lli->lli_flags); clear_bit(LLIF_XATTR_CACHE, &lli->lli_flags); @@ -314,7 +314,7 @@ int ll_xattr_cache_destroy(struct inode *inode) RETURN(rc); } -/** +/* * ll_xattr_cache_empty - empty xattr cache for @ino * * Similar to ll_xattr_cache_destroy(), but preserves encryption context. @@ -333,8 +333,7 @@ int ll_xattr_cache_empty(struct inode *inode) GOTO(out_empty, 0); list_for_each_entry_safe(entry, n, &lli->lli_xattrs, xe_list) { - if (strcmp(entry->xe_name, - LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0) + if (strcmp(entry->xe_name, xattr_for_enc(inode)) == 0) continue; CDEBUG(D_CACHE, "delete: %s\n", entry->xe_name); @@ -378,7 +377,8 @@ static int ll_xattr_find_get_lock(struct inode *inode, mutex_lock(&lli->lli_xattrs_enq_lock); /* inode may have been shrunk and recreated, so data is gone, match lock - * only when data exists. */ + * only when data exists. + */ if (ll_xattr_cache_filled(lli)) { /* Try matching first. */ mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, @@ -406,8 +406,9 @@ static int ll_xattr_find_get_lock(struct inode *inode, *req = oit->it_request; if (rc < 0) { - CDEBUG(D_CACHE, "md_intent_lock failed with %d for fid "DFID"\n", - rc, PFID(ll_inode2fid(inode))); + CDEBUG(D_CACHE, + "md_intent_lock failed with %d for fid "DFID"\n", rc, + PFID(ll_inode2fid(inode))); mutex_unlock(&lli->lli_xattrs_enq_lock); RETURN(rc); } @@ -498,16 +499,16 @@ static int ll_xattr_cache_refill(struct inode *inode) } else if (xval + *xsizes > xvtail) { CERROR("xattr protocol violation (vals are broken)\n"); rc = -EPROTO; - } else if (OBD_FAIL_CHECK(OBD_FAIL_LLITE_XATTR_ENOMEM)) { + } else if (CFS_FAIL_CHECK(OBD_FAIL_LLITE_XATTR_ENOMEM)) { rc = -ENOMEM; } else if (!strcmp(xdata, XATTR_NAME_ACL_ACCESS)) { /* Filter out ACL ACCESS since it's cached separately */ CDEBUG(D_CACHE, "not caching %s\n", XATTR_NAME_ACL_ACCESS); rc = 0; - } else if (!strcmp(xdata, "security.selinux")) { - /* Filter out security.selinux, it is cached in slab */ - CDEBUG(D_CACHE, "not caching security.selinux\n"); + } else if (ll_xattr_is_seclabel(xdata)) { + /* Filter out security label, it is cached in slab */ + CDEBUG(D_CACHE, "not caching %s\n", xdata); rc = 0; } else if (!strcmp(xdata, XATTR_NAME_SOM)) { /* Filter out trusted.som, it is not cached on client */ @@ -583,7 +584,7 @@ int ll_xattr_cache_get(struct inode *inode, * cache if we are just interested in encryption context. */ if ((valid & OBD_MD_FLXATTRLS || - strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) != 0) && + strcmp(name, xattr_for_enc(inode)) != 0) && !ll_xattr_cache_filled(lli)) { up_read(&lli->lli_xattrs_list_rwsem); rc = ll_xattr_cache_refill(inode);