-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ncm-afsclt: fix handling of size AUTOMATIC #816
Changes from 1 commit
4cb5a41
56af89a
7c72faa
845fa03
f508894
d5f71bc
fb49435
5be2b85
c8cb6a4
209704a
79d39f2
c7fae1d
a546dd8
31e8126
5c15bd3
086142f
f9ce48f
f831796
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Fixes #815.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,9 +106,8 @@ sub Configure_Cache { | |
$self->warn("Cannot determine current AFS cache size, changing only config file"); | ||
} | ||
|
||
my $afs_cacheinfo_fh = CAF::FileEditor->new( $AFS_CACHEINFO, log => $self ); # TODO use FileReader | ||
$afs_cacheinfo_fh->cancel(); | ||
if ( "$afs_cacheinfo_fh" =~ m;^([^:]+):([^:]+):(\d+)$; ) { | ||
my $afs_cacheinfo_fh = CAF::FileReader->new( $AFS_CACHEINFO, log => $self ); | ||
if ( "$afs_cacheinfo_fh" =~ m;^([^:]+):([^:]+):(\d+|AUTOMATIC)$; ) { | ||
$file_afsmount = $1; | ||
$file_cachemount = $2; | ||
$file_cache = $3; | ||
|
@@ -119,21 +118,24 @@ sub Configure_Cache { | |
} | ||
$afs_cacheinfo_fh->close(); | ||
|
||
# sanity check - don't allow cachesize bigger than 95% of a partition size | ||
$proc = CAF::Process->new( [ "df", "-k", $file_cachemount ], log => $self, keeps_state => 1 ); | ||
foreach my $line ( split ( "\n", $proc->output() ) ) { | ||
if ($line =~ m{^.*?\s+(\d+)\s+\d+\s+\d+\s+\d+%\s+(.*)}) { | ||
my $disk_cachesize = $1; | ||
my $mount = $2; | ||
if ( $mount eq $file_cachemount && $new_cache > 0.95 * $disk_cachesize ) { | ||
$self->error("Cache size ($disk_cachesize) on $mount cannot exceed 95% of its partition size. Not changing."); | ||
return 1; | ||
unless ( $new_cache eq "AUTOMATIC" ) { | ||
# sanity check - don't allow cachesize bigger than 95% of a partition size | ||
$proc = CAF::Process->new( [ "df", "-k", $file_cachemount ], log => $self, keeps_state => 1 ); | ||
foreach my $line ( split ( "\n", $proc->output() ) ) { | ||
if ($line =~ m{^.*?\s+(\d+)\s+\d+\s+\d+\s+\d+%\s+(.*)}) { | ||
my $disk_cachesize = $1; | ||
my $mount = $2; | ||
if ( $mount eq $file_cachemount && $new_cache > 0.95 * $disk_cachesize ) { | ||
$self->error("Cache size ($disk_cachesize) on $mount cannot exceed 95% of its partition size. Not changing."); | ||
return 1; | ||
} | ||
} | ||
} | ||
} | ||
|
||
# adjust stored cache size (gets overwritten on restart for OpenAFS-1.4) | ||
if ( $new_cache != $file_cache ) { | ||
# Force string interpolation of cache size as it can be AUTOMATIC | ||
if ( "$new_cache" ne "$file_cache" ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with this check, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
my $afs_cacheinfo_fh = CAF::FileWriter->new( $AFS_CACHEINFO, log => $self ); | ||
print $afs_cacheinfo_fh "$file_afsmount:$file_cachemount:$new_cache\n"; | ||
if ( $afs_cacheinfo_fh->close() ) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
if ($new_cache ne "AUTOMATIC") {
?