Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Overwrite with zero instead of random when shredding
Browse files Browse the repository at this point in the history
Writing zeroes is considerably faster than obtaining random
data for writing. On memory case, we should not worry so much
about possibility someone restoring old state after overwrites.
  • Loading branch information
okartau committed Feb 8, 2021
1 parent 6a6fd55 commit d42db56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ the following custom parameters in a storage class:

|key|meaning|optional|values|
|---|-------|--------|-------------|
|`eraseAfter`|Clear all data after use and before<br> deleting the volume|Yes|`true` (default),<br> `false`|
|`eraseAfter`|Clear all data by overwriting with zeroes after use and before<br> deleting the volume|Yes|`true` (default),<br> `false`|
|`kataContainers`|Prepare volume for use with DAX in Kata Containers.|Yes|`false/0/f/FALSE` (default),<br> `true/1/t/TRUE`|


Expand Down Expand Up @@ -705,7 +705,7 @@ ephemeral volumes. The volume request could use below fields as
|key|meaning|optional|values|
|---|-------|--------|-------------|
|`size`|Size of the requested ephemeral volume as [Kubernetes memory string](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#meaning-of-memory) ("1Mi" = 1024*1024 bytes, "1e3K = 1000000 bytes)|No||
|`eraseAfter`|Clear all data after use and before<br> deleting the volume|Yes|`true` (default),<br> `false`|
|`eraseAfter`|Clear all data by overwriting with zeroes after use and before<br> deleting the volume|Yes|`true` (default),<br> `false`|
|`kataContainers`|Prepare volume for use in Kata Containers.|Yes|`false/0/f/FALSE` (default),<br> `true/1/t/TRUE`|

Try out ephemeral volume usage with the provided [example
Expand Down
7 changes: 5 additions & 2 deletions pkg/pmem-device-manager/pmd-util.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ func clearDevice(dev *PmemDeviceInfo, flush bool) error {

if blocks == 0 {
klog.V(5).Infof("Wiping entire device: %s", dev.Path)
// use one iteration instead of shred's default=3 for speed
if _, err := pmemexec.RunCommand("shred", "-n", "1", dev.Path); err != nil {
// shred would write n times using random data, followed by optional write of zeroes.
// For faster operation, and because we consider zeroing enough for
// reasonable clearing in case of a memory device, we force zero iterations
// with random data, followed by one pass writing zeroes.
if _, err := pmemexec.RunCommand("shred", "-n", "0", "-z", dev.Path); err != nil {
return fmt.Errorf("device shred failure: %v", err.Error())
}
} else {
Expand Down

0 comments on commit d42db56

Please sign in to comment.