EXIT;
out:
- if (rc)
+ if (rc) {
mdt_unlock_list(info, link_locks, rc);
- else if (local_lnkp_cnt > RS_MAX_LOCKS - 6)
+ } else if (local_lnkp_cnt > RS_MAX_LOCKS - 5) {
+ CDEBUG(D_INFO, "Too many links (%d), sync operations\n",
+ local_lnkp_cnt);
/*
* parent may have 3 local objects: master object and 2 stripes
- * (if it's being migrated too); source may have 2 local
- * objects: master and 1 stripe; target has 1 local object.
+ * (if it's being migrated too); source may have 1 local object
+ * if regular file: master and 1 stripe; target has 1 local
+ * object.
+ * Note, if source is directory it may also have 2 local objects
+ * but can't has hardlinks, so consider only regular files here.
*/
rc = 1;
+ }
return rc;
}
mdt_object_child(tobj), &info->mti_spec, ma);
EXIT;
- mdt_object_unlock(info, tobj, lht, rc);
+ mdt_object_unlock(info, tobj, lht, rc || do_sync);
put_target:
mdt_object_put(env, tobj);
unlock_source:
mdt_migrate_object_unlock(info, sobj, lhs, seinfo,
- &child_slave_locks, rc);
+ &child_slave_locks, rc || do_sync);
unlock_open_sem:
if (open_sem_locked)
up_write(&sobj->mot_open_sem);
unlock_links:
- mdt_unlock_list(info, &link_locks, rc);
+ mdt_unlock_list(info, &link_locks, rc || do_sync);
put_source:
mdt_object_put(env, sobj);
mdt_object_put(env, spobj);
unlock_parent:
mdt_migrate_object_unlock(info, pobj, lhp, peinfo,
- &parent_slave_locks, rc);
+ &parent_slave_locks, rc || do_sync);
put_parent:
mdt_object_put(env, pobj);
unlock_rename:
}
run_test 230m "xattrs not changed after dir migration"
+test_230r() {
+ [[ $PARALLEL != "yes" ]] || skip "skip parallel run"
+ [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
+ [[ $MDS1_VERSION -ge $(version_code 2.12.5) ]] ||
+ skip "Need MDS version at least 2.12.5"
+
+ # maximum amount of local locks:
+ # parent striped dir - 2 locks
+ # new stripe in parent to migrate to - 1 lock
+ # source and target - 2 locks
+ # Total 5 locks for regular file
+ mkdir -p $DIR/$tdir
+ $LFS mkdir -i1 -c2 $DIR/$tdir/dir1
+ touch $DIR/$tdir/dir1/eee
+
+ # create 4 hardlink for 4 more locks
+ # Total: 9 locks > RS_MAX_LOCKS (8)
+ $LFS mkdir -i1 -c1 $DIR/$tdir/dir2
+ $LFS mkdir -i1 -c1 $DIR/$tdir/dir3
+ $LFS mkdir -i1 -c1 $DIR/$tdir/dir4
+ $LFS mkdir -i1 -c1 $DIR/$tdir/dir5
+ ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir2/eee
+ ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir3/eee
+ ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir4/eee
+ ln $DIR/$tdir/dir1/eee $DIR/$tdir/dir5/eee
+
+ cancel_lru_locks mdc
+
+ $LFS migrate -m1 -c1 $DIR/$tdir/dir1 ||
+ error "migrate dir fails"
+
+ rm -rf $DIR/$tdir || error "rm dir failed after migration"
+}
+run_test 230r "migrate with too many local locks"
+
test_231a()
{
# For simplicity this test assumes that max_pages_per_rpc