Skip to content

Commit

Permalink
os/bluestore/BlueFS: add safety checks on ino 0|1 op_file_update
Browse files Browse the repository at this point in the history
We only want to log updates on ino 1 in very specific
cases, and never on ino 0.

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Sep 14, 2016
1 parent 7c1a784 commit 3759e96
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/os/bluestore/BlueFS.cc
Expand Up @@ -1029,6 +1029,7 @@ void BlueFS::_compact_log_dump_metadata(bluefs_transaction_t *t)
if (p.first == 1)
continue;
dout(20) << __func__ << " op_file_update " << p.second->fnode << dendl;
assert(p.first > 1);
t->op_file_update(p.second->fnode);
}
for (auto& p : dir_map) {
Expand Down Expand Up @@ -1427,6 +1428,7 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
}
if (must_dirty) {
h->file->fnode.mtime = ceph_clock_now(NULL);
assert(h->file->fnode.ino >= 1);
log_t.op_file_update(h->file->fnode);
if (h->file->dirty_seq == 0) {
h->file->dirty_seq = log_seq + 1;
Expand Down Expand Up @@ -1581,6 +1583,10 @@ int BlueFS::_truncate(FileWriter *h, uint64_t offset)
dout(10) << __func__ << " deleted, no-op" << dendl;
return 0;
}

// we never truncate internal log files
assert(h->file->fnode.ino > 1);

// truncate off unflushed data?
if (h->pos < offset &&
h->pos + h->buffer.length() > offset) {
Expand Down Expand Up @@ -1708,6 +1714,7 @@ int BlueFS::_preallocate(FileRef f, uint64_t off, uint64_t len)
dout(10) << __func__ << " deleted, no-op" << dendl;
return 0;
}
assert(f->fnode.ino > 1);
uint64_t allocated = f->fnode.get_allocated();
if (off + len > allocated) {
uint64_t want = off + len - allocated;
Expand Down Expand Up @@ -1806,6 +1813,7 @@ int BlueFS::open_for_write(
file->fnode.extents.clear();
}
}
assert(file->fnode.ino > 1);

file->fnode.mtime = ceph_clock_now(NULL);
file->fnode.prefer_bdev = BlueFS::BDEV_DB;
Expand Down

0 comments on commit 3759e96

Please sign in to comment.