mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge pull request #1765 from shapeblue/CLOUDSTACK-9586
Cloudstack 9586: When using local storage with Xenserver prepareTemplate does not work with multiple primary storeThe race condition will happen whenever there are multiple primary storages and the CS tries to mount the secondary store to xenserver host simultaneously. Due to synchronised block one mount will be successful and other thread will get the already mounted SR. Without the fix the two thread will try to mount it parallely and one will fail on Xenserver. * pr/1765: Cloudstack 9586: When using local storage with Xenserver prepareTemplate does not work with multiple primary store The race condition will happen whenever there are multiple primary storages and the CS tries to mount the secondary store to xenserver host simultaneously. Due to synchronised block one mount will be successful and other thread will get the already mounted SR. Without the fix the two thread will try to mount it parallely and one will fail on Xenserver. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
20aea27dc0
@ -101,35 +101,24 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor {
|
||||
|
||||
try {
|
||||
final String srname = hypervisorResource.getHost().getUuid() + path.trim();
|
||||
|
||||
final Set<SR> srs = SR.getByNameLabel(conn, srname);
|
||||
|
||||
if (srs != null && !srs.isEmpty()) {
|
||||
return srs.iterator().next();
|
||||
synchronized (srname.intern()) {
|
||||
final Set<SR> srs = SR.getByNameLabel(conn, srname);
|
||||
if (srs != null && !srs.isEmpty()) {
|
||||
return srs.iterator().next();
|
||||
}
|
||||
final Map<String, String> smConfig = new HashMap<String, String>();
|
||||
final Host host = Host.getByUuid(conn, hypervisorResource.getHost().getUuid());
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
sr = SR.introduce(conn, uuid, srname, srname, "file", "file", false, smConfig);
|
||||
final PBD.Record record = new PBD.Record();
|
||||
record.host = host;
|
||||
record.SR = sr;
|
||||
smConfig.put("location", path);
|
||||
record.deviceConfig = smConfig;
|
||||
pbd = PBD.create(conn, record);
|
||||
pbd.plug(conn);
|
||||
sr.scan(conn);
|
||||
}
|
||||
|
||||
final Map<String, String> smConfig = new HashMap<String, String>();
|
||||
|
||||
final Host host = Host.getByUuid(conn, hypervisorResource.getHost().getUuid());
|
||||
final String uuid = UUID.randomUUID().toString();
|
||||
|
||||
sr = SR.introduce(conn, uuid, srname, srname, "file", "file", false, smConfig);
|
||||
|
||||
final PBD.Record record = new PBD.Record();
|
||||
|
||||
record.host = host;
|
||||
record.SR = sr;
|
||||
|
||||
smConfig.put("location", path);
|
||||
|
||||
record.deviceConfig = smConfig;
|
||||
|
||||
pbd = PBD.create(conn, record);
|
||||
|
||||
pbd.plug(conn);
|
||||
|
||||
sr.scan(conn);
|
||||
|
||||
return sr;
|
||||
} catch (final Exception ex) {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user