Prevent deletion of in-use extents

This commit is contained in:
Jamie Cameron
2012-09-04 18:03:12 -07:00
parent 2567220d1d
commit 16d47895fa
2 changed files with 43 additions and 0 deletions

View File

@@ -265,5 +265,43 @@ else {
}
}
# find_extent_users(&config, &extent|&device)
# Returns a list of all targets or devices using some extent or device
sub find_extent_users
{
my ($conf, $obj) = @_;
my $name = $obj->{'type'}.$obj->{'num'};
my @rv;
foreach my $c (@$conf) {
if ($c->{'type'} eq 'target' && $c->{'export'} eq $name) {
push(@rv, $c);
}
elsif ($c->{'type'} eq 'device' &&
&indexof($name, @{$c->{'extents'}}) >= 0) {
push(@rv, $c);
}
}
return @rv;
}
# describe_object(&object)
# Returns a human-readable description of some extent, device or target
sub describe_object
{
my ($obj) = @_;
if ($obj->{'type'} eq 'extent') {
return &text('desc_extent', &mount::device_name($obj->{'device'}));
}
elsif ($obj->{'type'} eq 'device') {
return &text('desc_device', "<tt>$obj->{'type'}$obj->{'num'}</tt>");
}
elsif ($obj->{'type'} eq 'target') {
return &text('desc_target', $obj->{'network'});
}
else {
return "Unknown $obj->{'type'} object";
}
}
1;

View File

@@ -42,10 +42,12 @@ extent_other=Other file or device
extents_rusure=Are you sure you want to delete the shared device $1? Its contents will be preserved, but it will no longer be accessible to iSCSI clients.
extent_sure=Delete Device
extent_err=Failed to save device to share
extent_derr=Failed to delete device to share
extent_eother=File to share does not exist
extent_estart=Start of extent must be a number
extent_esize=Size of extent must be a number
extent_esizemax=End of extent cannot be larger than the device size of $1
extent_einuse=This device cannot be deleted, as it is in use by : $1
devices_title=Devices Combinations
devices_none=No device combinations have been created yet.
@@ -68,3 +70,6 @@ targets_network=Share with network
targets_add=Add a new sharing target.
targets_delete=Delete Selected Targets
desc_extent=Device to share $1
desc_device=Device combination $1
desc_target=Sharing target $1