From: Lai Siyao Date: Thu, 26 Mar 2015 01:53:26 +0000 (-0400) Subject: staging/lustre/xattr: xattr data may be gone with lock held X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d6abc59ec8440cf3677a54d6fb12afbd20f70821;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git staging/lustre/xattr: xattr data may be gone with lock held Xattr cached data may be gone, but lock still held, in this case, refetch xattr from server, otherwise client will return error. Signed-off-by: Lai Siyao Reviewed-on: http://review.whamcloud.com/12952 Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3544 Reviewed-by: Bobi Jam Reviewed-by: Nathaniel Clark Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c index da190f92d140..69ea92adf4f1 100644 --- a/drivers/staging/lustre/lustre/llite/xattr_cache.c +++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c @@ -295,13 +295,18 @@ static int ll_xattr_find_get_lock(struct inode *inode, mutex_lock(&lli->lli_xattrs_enq_lock); - /* Try matching first. */ - mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, LCK_PR); - if (mode != 0) { - /* fake oit in mdc_revalidate_lock() manner */ - oit->d.lustre.it_lock_handle = lockh.cookie; - oit->d.lustre.it_lock_mode = mode; - goto out; + /* inode may have been shrunk and recreated, so data is gone, match lock + * only when data exists. */ + if (ll_xattr_cache_valid(lli)) { + /* Try matching first. */ + mode = ll_take_md_lock(inode, MDS_INODELOCK_XATTR, &lockh, 0, + LCK_PR); + if (mode != 0) { + /* fake oit in mdc_revalidate_lock() manner */ + oit->d.lustre.it_lock_handle = lockh.cookie; + oit->d.lustre.it_lock_mode = mode; + goto out; + } } /* Enqueue if the lock isn't cached locally. */