summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-02-28 14:26:37 +0800
committerLei YU <mine260309@gmail.com>2019-03-13 11:01:53 +0800
commit6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14 (patch)
tree87542e570ae26f49a051a867d124c1fca9ee7b7b
parent6cecc9b4a8e11327b5c59924c2865da5865f7d7d (diff)
downloadopenpower-pnor-code-mgmt-6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14.tar.gz
openpower-pnor-code-mgmt-6da3dae3b40bdbe9663b94e1f36dd3e2833d9c14.zip
Static layout: Do not update PNOR when host is on
Static layout only has 1 active and functional PNOR. When host is running, do not update PNOR. This is done by checking the return value of freeSpace(), and if it returns false, it means there is no space for PNOR because the host is running and erase() returns false. Tested: Verify the status becomes Failed when trying to activate a PNOR while host is running. Change-Id: Ie2986b0c6fd29557685f67eb77ccc29709e1669a Signed-off-by: Lei YU <mine260309@gmail.com>
-rw-r--r--item_updater.hpp4
-rw-r--r--static/activation_static.cpp14
-rw-r--r--static/item_updater_static.cpp6
-rw-r--r--static/item_updater_static.hpp2
-rw-r--r--ubi/item_updater_ubi.cpp5
-rw-r--r--ubi/item_updater_ubi.hpp2
6 files changed, 22 insertions, 11 deletions
diff --git a/item_updater.hpp b/item_updater.hpp
index 8b1bf0d2b..e27cccc79 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -127,8 +127,10 @@ class ItemUpdater : public ItemUpdaterInherit
* needs to delete any PNOR version(s) it will delete the
* version(s) with the highest priority, skipping the
* functional PNOR version.
+ *
+ * @return - Return if space is freed or not
*/
- virtual void freeSpace() = 0;
+ virtual bool freeSpace() = 0;
/** @brief Creates an active association to the
* newly active software image
diff --git a/static/activation_static.cpp b/static/activation_static.cpp
index 9768d4157..193d6b32a 100644
--- a/static/activation_static.cpp
+++ b/static/activation_static.cpp
@@ -19,6 +19,7 @@ using namespace phosphor::logging;
auto ActivationStatic::activation(Activations value) -> Activations
{
+ auto ret = value;
if (value != softwareServer::Activation::Activations::Active)
{
redundancyPriority.reset(nullptr);
@@ -26,9 +27,14 @@ auto ActivationStatic::activation(Activations value) -> Activations
if (value == softwareServer::Activation::Activations::Activating)
{
- parent.freeSpace();
- startActivation();
- return softwareServer::Activation::activation(value);
+ if (parent.freeSpace())
+ {
+ startActivation();
+ }
+ else
+ {
+ ret = softwareServer::Activation::Activations::Failed;
+ }
}
else
{
@@ -36,7 +42,7 @@ auto ActivationStatic::activation(Activations value) -> Activations
activationProgress.reset(nullptr);
}
- return softwareServer::Activation::activation(value);
+ return softwareServer::Activation::activation(ret);
}
void ActivationStatic::startActivation()
diff --git a/static/item_updater_static.cpp b/static/item_updater_static.cpp
index 628f824f4..140d5cc5b 100644
--- a/static/item_updater_static.cpp
+++ b/static/item_updater_static.cpp
@@ -335,7 +335,7 @@ void ItemUpdaterStatic::deleteAll()
// There is no implementation for this interface
}
-void ItemUpdaterStatic::freeSpace()
+bool ItemUpdaterStatic::freeSpace()
{
// For now assume static layout only has 1 active PNOR,
// so erase the active PNOR
@@ -344,10 +344,10 @@ void ItemUpdaterStatic::freeSpace()
if (iter.second.get()->activation() ==
server::Activation::Activations::Active)
{
- erase(iter.second->versionId);
- break;
+ return erase(iter.second->versionId);
}
}
+ return false;
}
void ItemUpdaterStatic::updateFunctionalAssociation(
diff --git a/static/item_updater_static.hpp b/static/item_updater_static.hpp
index 75afedade..c3f273d37 100644
--- a/static/item_updater_static.hpp
+++ b/static/item_updater_static.hpp
@@ -33,7 +33,7 @@ class ItemUpdaterStatic : public ItemUpdater
void deleteAll() override;
- void freeSpace() override;
+ bool freeSpace() override;
void updateFunctionalAssociation(const std::string& versionId) override;
diff --git a/ubi/item_updater_ubi.cpp b/ubi/item_updater_ubi.cpp
index 875847f6e..61a8e0156 100644
--- a/ubi/item_updater_ubi.cpp
+++ b/ubi/item_updater_ubi.cpp
@@ -357,8 +357,9 @@ void ItemUpdaterUbi::deleteAll()
}
// TODO: openbmc/openbmc#1402 Monitor flash usage
-void ItemUpdaterUbi::freeSpace()
+bool ItemUpdaterUbi::freeSpace()
{
+ bool isSpaceFreed = false;
// Versions with the highest priority in front
std::priority_queue<std::pair<int, std::string>,
std::vector<std::pair<int, std::string>>,
@@ -393,7 +394,9 @@ void ItemUpdaterUbi::freeSpace()
erase(versionsPQ.top().second);
versionsPQ.pop();
count--;
+ isSpaceFreed = true;
}
+ return isSpaceFreed;
}
std::string ItemUpdaterUbi::determineId(const std::string& symlinkPath)
diff --git a/ubi/item_updater_ubi.hpp b/ubi/item_updater_ubi.hpp
index 5de51d34e..ce1b5b87d 100644
--- a/ubi/item_updater_ubi.hpp
+++ b/ubi/item_updater_ubi.hpp
@@ -35,7 +35,7 @@ class ItemUpdaterUbi : public ItemUpdater
void deleteAll() override;
- void freeSpace() override;
+ bool freeSpace() override;
bool isVersionFunctional(const std::string& versionId) override;
OpenPOWER on IntegriCloud