From: Lai Siyao Date: Wed, 11 Jun 2014 14:44:01 +0000 (+0800) Subject: LU-3544 xattr: xattr data may be gone with lock held X-Git-Tag: 2.5.3.90~3 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=fe9ad627b6d83e29039c0c6c0b555aae5f23e9a7 LU-3544 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. This patch is backported from the following one: Lustre-commit: Id6fbbef339fea540728b181b2ae91799b8151fbd Lustre-Change: http://review.whamcloud.com/10693 Signed-off-by: Lai Siyao Change-Id: Ide3c2686a7a9f118c4c44fc5de8eb5670011f112 Reviewed-on: http://review.whamcloud.com/12952 Tested-by: Jenkins Reviewed-by: Bobi Jam Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/xattr_cache.c b/lustre/llite/xattr_cache.c index fd32da0..413ee9f 100644 --- a/lustre/llite/xattr_cache.c +++ b/lustre/llite/xattr_cache.c @@ -325,13 +325,18 @@ static int ll_xattr_find_get_lock(struct inode *inode, ENTRY; 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. */