~ubuntu-branches/ubuntu/precise/ceph/precise

« back to all changes in this revision

Viewing changes to src/os/FileJournal.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum, Clint Byrum, Micah Gersten
  • Date: 2011-02-12 22:50:26 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110212225026-yyyw4tk0msgql3ul
Tags: 0.24.2-0ubuntu1
[ Clint Byrum <clint@ubuntu.com> ]
* New upstream release. (LP: #658670, LP: #684011)
* debian/patches/fix-mkcephfs.patch: dropped (applied upstream)
* Removed .la files from libceph1-dev, libcrush1-dev and 
  librados1-dev (per Debian policy v3.9.1 10.2).
* debian/control: adding pkg-config as a build dependency
* debian/control: depend on libcrypto++-dev instead of libssl-dev
* debian/watch: added watch file

[ Micah Gersten <micahg@ubuntu.com> ]
* debian/control: add Homepage

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    void clear() {
45
45
      start = block_size;
46
46
    }
47
 
  } header;
 
47
  } header __attribute__((__packed__, aligned(4)));
48
48
 
49
49
  struct entry_header_t {
50
50
    uint64_t seq;  // fs op seq #
63
63
        magic1 == (uint64_t)pos &&
64
64
        magic2 == (fsid ^ seq ^ len);
65
65
    }
66
 
  };
 
66
  } __attribute__((__packed__, aligned(4)));
67
67
 
68
68
private:
69
69
  string fn;
80
80
 
81
81
  uint64_t last_committed_seq;
82
82
 
83
 
  uint64_t full_commit_seq;  // don't write, wait for this seq to commit
84
 
  uint64_t full_restart_seq; // start writing again with this seq
 
83
  /*
 
84
   * full states cycle at the beginnging of each commit epoch, when commit_start()
 
85
   * is called.
 
86
   *   FULL - we just filled up during this epoch.
 
87
   *   WAIT - we filled up last epoch; now we have to wait until everything during
 
88
   *          that epoch commits to the fs before we can start writing over it.
 
89
   *   NOTFULL - all good, journal away.
 
90
   */
 
91
  enum {
 
92
    FULL_NOTFULL = 0,
 
93
    FULL_FULL = 1,
 
94
    FULL_WAIT = 2,
 
95
  } full_state;
85
96
 
86
97
  int fd;
87
98
 
88
99
  // in journal
89
100
  deque<pair<uint64_t, off64_t> > journalq;  // track seq offsets, so we can trim later.
 
101
  deque<pair<uint64_t,Context*> > completions;  // queued, writing, waiting for commit.
90
102
 
91
 
  // currently being journaled and awaiting callback.
92
 
  //  or, awaiting callback bc journal was full.
93
 
  deque<uint64_t> writing_seq;
94
 
  deque<Context*> writing_fin;
 
103
  uint64_t writing_seq, journaled_seq;
 
104
  bool plug_journal_completions;
95
105
 
96
106
  // waiting to be journaled
97
107
  struct write_item {
98
108
    uint64_t seq;
99
109
    bufferlist bl;
100
110
    int alignment;
101
 
    Context *fin;
102
 
    write_item(uint64_t s, bufferlist& b, int al, Context *f) :
103
 
      seq(s), alignment(al), fin(f) { 
 
111
    write_item(uint64_t s, bufferlist& b, int al) :
 
112
      seq(s), alignment(al) { 
104
113
      bl.claim(b);
105
114
    }
106
115
  };
117
126
  Cond commit_cond;
118
127
 
119
128
  int _open(bool wr, bool create=false);
 
129
  int _open_block_device();
 
130
  void _check_disk_write_cache() const;
 
131
  int _open_file(int64_t oldsize, blksize_t blksize, bool create);
120
132
  void print_header();
121
133
  int read_header();
122
134
  bufferptr prepare_header();
124
136
  void stop_writer();
125
137
  void write_thread_entry();
126
138
 
 
139
  void queue_completions_thru(uint64_t seq);
 
140
 
127
141
  int check_for_full(uint64_t seq, off64_t pos, off64_t size);
128
142
  int prepare_multi_write(bufferlist& bl, uint64_t& orig_ops, uint64_t& orig_bytee);
129
143
  int prepare_single_write(bufferlist& bl, off64_t& queue_pos, uint64_t& orig_ops, uint64_t& orig_bytes);
155
169
    writing(false), must_write_header(false),
156
170
    write_pos(0), read_pos(0),
157
171
    last_committed_seq(0), 
158
 
    full_commit_seq(0), full_restart_seq(0),
 
172
    full_state(FULL_NOTFULL),
159
173
    fd(-1),
 
174
    writing_seq(0), journaled_seq(0),
 
175
    plug_journal_completions(false),
160
176
    write_lock("FileJournal::write_lock"),
161
177
    write_stop(false),
162
178
    write_thread(this) { }
179
195
 
180
196
  // writes
181
197
  void submit_entry(uint64_t seq, bufferlist& bl, int alignment, Context *oncommit);  // submit an item
 
198
  void commit_start();
182
199
  void committed_thru(uint64_t seq);
183
 
  bool is_full();
 
200
  bool should_commit_now() {
 
201
    return full_state != FULL_NOTFULL;
 
202
  }
184
203
 
185
204
  void set_wait_on_full(bool b) { wait_on_full = b; }
186
205