| 880 | } |
| 881 | |
| 882 | void |
| 883 | Span::clearPermanently() |
| 884 | { |
| 885 | if (OPEN_RW_FLAG) { |
| 886 | alignas(512) static char zero[CacheStoreBlocks::SCALE]; // should be all zero, it's static. |
| 887 | std::cout << "Clearing " << _path.string() << " permanently on disk "; |
| 888 | ssize_t n = pwrite(_fd, zero, sizeof(zero), ts::CacheSpan::OFFSET); |
| 889 | if (n == sizeof(zero)) { |
| 890 | std::cout << "done"; |
| 891 | } else { |
| 892 | const char *text = strerror(errno); |
| 893 | std::cout << "failed"; |
| 894 | if (n >= 0) { |
| 895 | std::cout << " - " << n << " of " << sizeof(zero) << " bytes written"; |
| 896 | } |
| 897 | std::cout << " - " << text; |
| 898 | } |
| 899 | |
| 900 | std::cout << std::endl; |
| 901 | // clear the stripes as well |
| 902 | for (auto *strp : _stripes) { |
| 903 | strp->loadMeta(); |
| 904 | std::cout << "Clearing stripe @" << strp->_start << " of length: " << strp->_len << std::endl; |
| 905 | strp->clear(); |
| 906 | } |
| 907 | } else { |
| 908 | std::cout << "Clearing " << _path.string() << " not performed, write not enabled" << std::endl; |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | // explicit pair for random table in build_vol_hash_table |
| 913 | struct rtable_pair { |
no test coverage detected