diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/llite/xattr_cache.c')
-rw-r--r-- | drivers/staging/lustre/lustre/llite/xattr_cache.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index d1402762a0b2..3480ce2bb3cc 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -23,7 +23,8 @@ */ struct ll_xattr_entry { struct list_head xe_list; /* protected with - * lli_xattrs_list_rwsem */ + * lli_xattrs_list_rwsem + */ char *xe_name; /* xattr name, \0-terminated */ char *xe_value; /* xattr value */ unsigned xe_namelen; /* strlen(xe_name) + 1 */ @@ -59,9 +60,6 @@ void ll_xattr_fini(void) */ static void ll_xattr_cache_init(struct ll_inode_info *lli) { - - LASSERT(lli != NULL); - INIT_LIST_HEAD(&lli->lli_xattrs); lli->lli_flags |= LLIF_XATTR_CACHE; } @@ -83,8 +81,7 @@ static int ll_xattr_cache_find(struct list_head *cache, list_for_each_entry(entry, cache, xe_list) { /* xattr_name == NULL means look for any entry */ - if (xattr_name == NULL || - strcmp(xattr_name, entry->xe_name) == 0) { + if (!xattr_name || strcmp(xattr_name, entry->xe_name) == 0) { *xattr = entry; CDEBUG(D_CACHE, "find: [%s]=%.*s\n", entry->xe_name, entry->xe_vallen, @@ -117,8 +114,8 @@ static int ll_xattr_cache_add(struct list_head *cache, return -EPROTO; } - xattr = kmem_cache_alloc(xattr_kmem, GFP_NOFS | __GFP_ZERO); - if (xattr == NULL) { + xattr = kmem_cache_zalloc(xattr_kmem, GFP_NOFS); + if (!xattr) { CDEBUG(D_CACHE, "failed to allocate xattr\n"); return -ENOMEM; } @@ -136,8 +133,8 @@ static int ll_xattr_cache_add(struct list_head *cache, xattr->xe_vallen = xattr_val_len; list_add(&xattr->xe_list, cache); - CDEBUG(D_CACHE, "set: [%s]=%.*s\n", xattr_name, - xattr_val_len, xattr_val); + CDEBUG(D_CACHE, "set: [%s]=%.*s\n", xattr_name, xattr_val_len, + xattr_val); return 0; err_value: @@ -194,7 +191,7 @@ static int ll_xattr_cache_list(struct list_head *cache, list_for_each_entry_safe(xattr, tmp, cache, xe_list) { CDEBUG(D_CACHE, "list: buffer=%p[%d] name=%s\n", - xld_buffer, xld_tail, xattr->xe_name); + xld_buffer, xld_tail, xattr->xe_name); if (xld_buffer) { xld_size -= xattr->xe_namelen; @@ -270,7 +267,7 @@ static int ll_xattr_find_get_lock(struct inode *inode, struct lookup_intent *oit, struct ptlrpc_request **req) { - ldlm_mode_t mode; + enum ldlm_mode mode; struct lustre_handle lockh = { 0 }; struct md_op_data *op_data; struct ll_inode_info *lli = ll_i2info(inode); @@ -284,7 +281,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_valid(lli)) { /* Try matching first. */ mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, @@ -359,7 +357,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) } /* Matched but no cache? Cancelled on error by a parallel refill. */ - if (unlikely(req == NULL)) { + if (unlikely(!req)) { CDEBUG(D_CACHE, "cancelled by a parallel getxattr\n"); rc = -EIO; goto out_maybe_drop; @@ -376,19 +374,19 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); - if (body == NULL) { + if (!body) { CERROR("no MDT BODY in the refill xattr reply\n"); rc = -EPROTO; goto out_destroy; } /* do not need swab xattr data */ xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, - body->eadatasize); + body->eadatasize); xval = req_capsule_server_sized_get(&req->rq_pill, &RMF_EAVALS, - body->aclsize); + body->aclsize); xsizes = req_capsule_server_sized_get(&req->rq_pill, &RMF_EAVALS_LENS, body->max_mdsize * sizeof(__u32)); - if (xdata == NULL || xval == NULL || xsizes == NULL) { + if (!xdata || !xval || !xsizes) { CERROR("wrong setxattr reply\n"); rc = -EPROTO; goto out_destroy; @@ -404,7 +402,7 @@ static int ll_xattr_cache_refill(struct inode *inode, struct lookup_intent *oit) for (i = 0; i < body->max_mdsize; i++) { CDEBUG(D_CACHE, "caching [%s]=%.*s\n", xdata, *xsizes, xval); /* Perform consistency checks: attr names and vals in pill */ - if (memchr(xdata, 0, xtail - xdata) == NULL) { + if (!memchr(xdata, 0, xtail - xdata)) { CERROR("xattr protocol violation (names are broken)\n"); rc = -EPROTO; } else if (xval + *xsizes > xvtail) { @@ -471,11 +469,8 @@ out_destroy: * \retval -ERANGE the buffer is not large enough * \retval -ENODATA no such attr or the list is empty */ -int ll_xattr_cache_get(struct inode *inode, - const char *name, - char *buffer, - size_t size, - __u64 valid) +int ll_xattr_cache_get(struct inode *inode, const char *name, char *buffer, + size_t size, __u64 valid) { struct lookup_intent oit = { .it_op = IT_GETXATTR }; struct ll_inode_info *lli = ll_i2info(inode); @@ -504,7 +499,7 @@ int ll_xattr_cache_get(struct inode *inode, if (size != 0) { if (size >= xattr->xe_vallen) memcpy(buffer, xattr->xe_value, - xattr->xe_vallen); + xattr->xe_vallen); else rc = -ERANGE; } |