Whamcloud - gitweb
LU-3544 xattr: xattr data may be gone with lock held 52/12952/2
authorLai Siyao <lai.siyao@intel.com>
Wed, 11 Jun 2014 14:44:01 +0000 (22:44 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 Jan 2015 02:44:04 +0000 (02:44 +0000)
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 <lai.siyao@intel.com>
Change-Id: Ide3c2686a7a9f118c4c44fc5de8eb5670011f112
Reviewed-on: http://review.whamcloud.com/12952
Tested-by: Jenkins
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/xattr_cache.c

index fd32da0..413ee9f 100644 (file)
@@ -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. */