mirror of
https://github.com/ceph/ceph
synced 2024-12-19 09:57:05 +00:00
filejournal: add check() method
Check if a journal appears to be valid, where valid means the header is intact and has a matching fsid. Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
c498827f04
commit
a074d0b5c3
@ -343,6 +343,35 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileJournal::check()
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = _open(false, false);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
ret = read_header();
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
if (header.fsid != fsid) {
|
||||
derr << "check: ondisk fsid " << header.fsid << " doesn't match expected " << fsid
|
||||
<< ", invalid (someone else's?) journal" << dendl;
|
||||
ret = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
dout(1) << "check: header looks ok" << dendl;
|
||||
ret = 0;
|
||||
|
||||
done:
|
||||
TEMP_FAILURE_RETRY(::close(fd));
|
||||
fd = -1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int FileJournal::create()
|
||||
{
|
||||
void *buf = 0;
|
||||
|
@ -318,6 +318,7 @@ private:
|
||||
delete[] zero_buf;
|
||||
}
|
||||
|
||||
int check();
|
||||
int create();
|
||||
int open(uint64_t fs_op_seq);
|
||||
void close();
|
||||
|
@ -42,9 +42,10 @@ public:
|
||||
wait_on_full(false) { }
|
||||
virtual ~Journal() { }
|
||||
|
||||
virtual int create() = 0;
|
||||
virtual int open(uint64_t fs_op_seq) = 0;
|
||||
virtual void close() = 0;
|
||||
virtual int check() = 0; ///< check if journal appears valid
|
||||
virtual int create() = 0; ///< create a fresh journal
|
||||
virtual int open(uint64_t fs_op_seq) = 0; ///< open an existing journal
|
||||
virtual void close() = 0; ///< close an open journal
|
||||
|
||||
virtual void flush() = 0;
|
||||
virtual void throttle() = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user