2013-05-23 08:39:54 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2015-01-30 09:38:10 -05:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2013, 2014, 2015.
|
2013-05-23 08:39:54 -04:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
block.h
|
|
|
|
Blocks in the filesystem.
|
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef BLOCK_H
|
|
|
|
#define BLOCK_H
|
|
|
|
|
|
|
|
class Device;
|
|
|
|
|
|
|
|
class Block
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Block(Device* device, uint32_t block_id);
|
|
|
|
~Block();
|
|
|
|
|
|
|
|
public:
|
2015-01-30 18:19:54 -05:00
|
|
|
pthread_mutex_t modify_lock;
|
|
|
|
pthread_cond_t transit_done_cond;
|
2013-05-23 08:39:54 -04:00
|
|
|
Block* prev_block;
|
|
|
|
Block* next_block;
|
|
|
|
Block* prev_hashed;
|
|
|
|
Block* next_hashed;
|
2014-10-01 16:27:19 -04:00
|
|
|
Block* prev_dirty;
|
|
|
|
Block* next_dirty;
|
2013-05-23 08:39:54 -04:00
|
|
|
Device* device;
|
|
|
|
size_t reference_count;
|
|
|
|
uint32_t block_id;
|
|
|
|
bool dirty;
|
2015-01-30 18:19:54 -05:00
|
|
|
bool is_in_transit;
|
2013-05-23 08:39:54 -04:00
|
|
|
uint8_t* block_data;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void Refer();
|
|
|
|
void Unref();
|
|
|
|
void Sync();
|
2015-01-30 09:38:10 -05:00
|
|
|
void BeginWrite();
|
|
|
|
void FinishWrite();
|
2013-05-23 08:39:54 -04:00
|
|
|
void Use();
|
|
|
|
void Unlink();
|
|
|
|
void Prelink();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|