super_blk.cc (13940:33cc30e2de52) | super_blk.cc (13947:4cf8087cab09) |
---|---|
1/** 2 * Copyright (c) 2018 Inria 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 80 unchanged lines hidden (view full) --- 89CompressionBlk::print() const 90{ 91 return csprintf("%s compressed: %d size: %llu decompression latency: %d", 92 SectorSubBlk::print(), isCompressed(), getSizeBits(), 93 getDecompressionLatency()); 94} 95 96bool | 1/** 2 * Copyright (c) 2018 Inria 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 80 unchanged lines hidden (view full) --- 89CompressionBlk::print() const 90{ 91 return csprintf("%s compressed: %d size: %llu decompression latency: %d", 92 SectorSubBlk::print(), isCompressed(), getSizeBits(), 93 getDecompressionLatency()); 94} 95 96bool |
97SuperBlk::isCompressed() const | 97SuperBlk::isCompressed(const CompressionBlk* ignored_blk) const |
98{ 99 for (const auto& blk : blks) { | 98{ 99 for (const auto& blk : blks) { |
100 if (blk->isValid()) { | 100 if (blk->isValid() && (blk != ignored_blk)) { |
101 return static_cast<CompressionBlk*>(blk)->isCompressed(); 102 } 103 } 104 105 // An invalid block is seen as compressed 106 return true; 107} | 101 return static_cast<CompressionBlk*>(blk)->isCompressed(); 102 } 103 } 104 105 // An invalid block is seen as compressed 106 return true; 107} |
108 109bool 110SuperBlk::canCoAllocate(const std::size_t compressed_size) const 111{ 112 // Simple co-allocation function: at most numBlocksPerSector blocks that 113 // compress at least to (100/numBlocksPerSector)% of their original size 114 // can share a superblock 115 return (compressed_size <= (blkSize * 8) / blks.size()); 116} 117 118void 119SuperBlk::setBlkSize(const std::size_t blk_size) 120{ 121 assert(blkSize == 0); 122 blkSize = blk_size; 123} |
|