new_log_writer = _create_writer(new_log);
new_log_writer->append(bl);
- new_log_writer->lock.lock();
- new_log->lock.lock();
// 3. flush
r = _flush_special(new_log_writer);
ceph_assert(r == 0);
// 4. wait
_flush_bdev(new_log_writer);
- new_log->lock.unlock();
- new_log_writer->lock.unlock();
// 5. update our log fnode
// we need to append to new_log the extents that were allocated in step 1.1
// we do it by inverse logic - we drop 'old_log_jump_to' bytes and keep rest
if (lsi != dirty.files.end()) {
dout(20) << __func__ << " " << lsi->second.size() << " dirty.files" << dendl;
for (auto &f : lsi->second) {
+ // fnode here is protected indirectly
+ // the only path that adds to dirty.files goes from _fsync()
+ // _fsync() is executed under writer lock,
+ // and does not exit until syncing log is done
dout(20) << __func__ << " op_file_update_inc " << f.fnode << dendl;
log.t.op_file_update_inc(f.fnode);
}
const unsigned length,
const bluefs_super_t& super)
{
- ceph_assert(ceph_mutex_is_locked(this->lock) || file->fnode.ino == 1);
+ ceph_assert(ceph_mutex_is_locked(this->lock) || file->fnode.ino <= 1);
ceph::bufferlist bl;
if (partial) {
tail_block.splice(0, tail_block.length(), &bl);
int BlueFS::_flush_data(FileWriter *h, uint64_t offset, uint64_t length, bool buffered)
{
- if (h->file->fnode.ino != 1) {
+ if (h->file->fnode.ino > 1) {
ceph_assert(ceph_mutex_is_locked(h->lock));
ceph_assert(ceph_mutex_is_locked(h->file->lock));
}
int BlueFS::fsync(FileWriter *h)
{
+ std::unique_lock hl(h->lock);
uint64_t old_dirty_seq = 0;
{
- std::unique_lock hl(h->lock);
dout(10) << __func__ << " " << h << " " << h->file->fnode << dendl;
int r = _flush_F(h, true);
if (r < 0)
// be careful - either h->file->lock or log.lock must be taken
void BlueFS::_flush_bdev(FileWriter *h)
{
- if (h->file->fnode.ino != 1) {
+ if (h->file->fnode.ino > 1) {
ceph_assert(ceph_mutex_is_locked(h->lock));
- } else {
+ } else if (h->file->fnode.ino == 1) {
ceph_assert(ceph_mutex_is_locked(log.lock));
}
std::array<bool, MAX_BDEV> flush_devs = h->dirty_devs;