X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fxattr_cache.c;h=3489f0bf23277fd257390d3e77927e8a0a269db0;hb=d5d0ff24a84f64e5196341f5ce946952d7fff8b7;hp=50dcbe7f6bb0d553c903b908ae035480131929bc;hpb=62fee20556a4c90361bd28edb903dc77c9540133;p=fs%2Flustre-release.git diff --git a/lustre/llite/xattr_cache.c b/lustre/llite/xattr_cache.c index 50dcbe7..3489f0b 100644 --- a/lustre/llite/xattr_cache.c +++ b/lustre/llite/xattr_cache.c @@ -24,7 +24,7 @@ /* * Copyright 2012 Xyratex Technology Limited * - * Copyright (c) 2013, 2016, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. * * Author: Andrew Perepechko * @@ -401,7 +401,7 @@ static int ll_xattr_cache_refill(struct inode *inode) if (unlikely(req == NULL)) { CDEBUG(D_CACHE, "cancelled by a parallel getxattr\n"); ll_intent_drop_lock(&oit); - GOTO(err_unlock, rc = -EIO); + GOTO(err_unlock, rc = -EAGAIN); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -550,3 +550,38 @@ out: RETURN(rc); } +/** + * Insert an xattr value into the cache. + * + * Add @name xattr with @buffer value and @size length for @inode. + * Init cache for @inode if necessary. + * + * \retval 0 success + * \retval < 0 from ll_xattr_cache_add(), except -EPROTO is ignored for + * LL_XATTR_NAME_ENCRYPTION_CONTEXT xattr + */ +int ll_xattr_cache_insert(struct inode *inode, + const char *name, + char *buffer, + size_t size) +{ + struct ll_inode_info *lli = ll_i2info(inode); + int rc; + + ENTRY; + + down_read(&lli->lli_xattrs_list_rwsem); + if (!ll_xattr_cache_valid(lli)) + ll_xattr_cache_init(lli); + rc = ll_xattr_cache_add(&lli->lli_xattrs, name, buffer, + size); + up_read(&lli->lli_xattrs_list_rwsem); + + if (rc == -EPROTO && + strcmp(name, LL_XATTR_NAME_ENCRYPTION_CONTEXT) == 0) + /* it means enc ctx was already in cache, + * ignore error as it cannot be modified + */ + rc = 0; + RETURN(rc); +}