Whamcloud - gitweb
LU-4712 llite: lock the inode to be migrated 89/9689/8
authorwang di <di.wang@intel.com>
Mon, 17 Mar 2014 18:23:02 +0000 (11:23 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 4 Feb 2015 02:47:18 +0000 (02:47 +0000)
Because the inode and its connected dentries will be cleared
out of the cache after migration, the inode needs to be locked
during the migration.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Ibbbb33473de1a67df85ef8930debcf22cd775bcb
Reviewed-on: http://review.whamcloud.com/9689
Tested-by: Jenkins
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/file.c

index 230a41f..0ee0dde 100644 (file)
@@ -3030,11 +3030,14 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
        qstr.name = name;
        qstr.len = namelen;
        dchild = d_lookup(file->f_dentry, &qstr);
-       if (dchild != NULL && dchild->d_inode != NULL) {
-               op_data->op_fid3 = *ll_inode2fid(dchild->d_inode);
+       if (dchild != NULL) {
                if (dchild->d_inode != NULL) {
                        child_inode = igrab(dchild->d_inode);
-                       ll_invalidate_aliases(child_inode);
+                       if (child_inode != NULL) {
+                               mutex_lock(&child_inode->i_mutex);
+                               op_data->op_fid3 = *ll_inode2fid(child_inode);
+                               ll_invalidate_aliases(child_inode);
+                       }
                }
                dput(dchild);
        } else {
@@ -3075,6 +3078,7 @@ int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
 out_free:
        if (child_inode != NULL) {
                clear_nlink(child_inode);
+               mutex_unlock(&child_inode->i_mutex);
                iput(child_inode);
        }