* 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;
lu_kmem_fini(xattr_caches);
}
-/**
+/*
* Initializes xattr cache for an inode.
*
* This initializes the xattr list and marks cache presence.
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
*/
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);
RETURN(rc);
}
-/**
+/*
* ll_xattr_cache_empty - empty xattr cache for @ino
*
* Similar to ll_xattr_cache_destroy(), but preserves encryption context.
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);
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,
*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);
}
} 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 */
* 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);