1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 * Copyright (C) 2012 CohortFS, LLC.
7 * This is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License version 2.1, as published by the Free Software
10 * Foundation. See file COPYING.
17 #include "include/types.h"
18 #include <boost/intrusive/list.hpp>
19 #define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
20 #include <boost/icl/interval_set.hpp>
21 #include "common/Mutex.h"
22 #include "common/Cond.h"
26 typedef boost::icl::interval<uint64_t>::type barrier_interval;
31 * we keep count of uncommitted writes on the inode, so that
32 * ll_commit_blocks can do the right thing.
34 * This is just a hacked copy of Ceph's sync callback.
39 CBlockSync_State_None, /* initial state */
40 CBlockSync_State_Unclaimed, /* outstanding write */
41 CBlockSync_State_Committing, /* commit in progress */
42 CBlockSync_State_Completed,
49 typedef boost::intrusive::list< C_Block_Sync,
50 boost::intrusive::member_hook<
52 boost::intrusive::list_member_hook<>,
53 &C_Block_Sync::intervals_hook >
60 boost::icl::interval_set<uint64_t> span;
61 BlockSyncList write_list;
64 boost::intrusive::list_member_hook<> active_commits_hook;
69 friend class BarrierContext;
72 typedef boost::intrusive::list< Barrier,
73 boost::intrusive::member_hook<
75 boost::intrusive::list_member_hook<>,
76 &Barrier::active_commits_hook >
86 // writes not claimed by a commit
87 BlockSyncList outstanding_writes;
89 // commits in progress, with their claimed writes
90 BarrierList active_commits;
93 BarrierContext(Client *c, uint64_t ino);
94 void write_nobarrier(C_Block_Sync &cbs);
95 void write_barrier(C_Block_Sync &cbs);
96 void commit_barrier(barrier_interval &civ);
97 void complete(C_Block_Sync &cbs);