~ubuntu-branches/ubuntu/raring/ceph/raring

« back to all changes in this revision

Viewing changes to src/os/ObjectStore.h

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2012-02-05 10:07:38 UTC
  • mfrom: (1.1.7) (0.1.11 sid)
  • Revision ID: package-import@ubuntu.com-20120205100738-00s0bxx93mamy8tk
Tags: 0.41-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <sys/stat.h>
26
26
#include <vector>
27
27
 
28
 
#ifdef DARWIN
 
28
#if defined(DARWIN) || defined(__FreeBSD__)
29
29
#include <sys/statvfs.h>
30
30
#else
31
31
#include <sys/vfs.h>    /* or <sys/statfs.h> */
200
200
    int get_data_alignment() {
201
201
      if (!largest_data_len)
202
202
        return -1;
203
 
      return (largest_data_off - get_data_offset()) & ~PAGE_MASK;
 
203
      return (largest_data_off - get_data_offset()) & ~CEPH_PAGE_MASK;
204
204
    }
205
205
 
206
206
    bool empty() {
207
207
      return !ops;
208
208
    }
209
209
 
210
 
    bool have_op() {
211
 
      if (p.get_off() == 0)
212
 
        p = tbl.begin();
213
 
      return !p.end();
214
 
    }
215
210
    int get_num_ops() {
216
211
      return ops;
217
212
    }
218
 
    int get_op() {
219
 
      if (p.get_off() == 0)
220
 
        p = tbl.begin();
221
 
      __u32 op;
222
 
      ::decode(op, p);
223
 
      return op;
224
 
    }
225
 
    void get_bl(bufferlist& bl) {
226
 
      if (p.get_off() == 0)
227
 
        p = tbl.begin();
228
 
      ::decode(bl, p);
229
 
    }
230
 
    hobject_t get_oid() {
231
 
      if (p.get_off() == 0)
232
 
        p = tbl.begin();
233
 
      hobject_t hoid;
234
 
      if (sobject_encoding) {
235
 
        sobject_t soid;
236
 
        ::decode(soid, p);
237
 
        hoid.snap = soid.snap;
238
 
        hoid.oid = soid.oid;
239
 
      } else {
240
 
        ::decode(hoid, p);
241
 
      }
242
 
      return hoid;
243
 
    }
244
 
    coll_t get_cid() {
245
 
      if (p.get_off() == 0)
246
 
        p = tbl.begin();
247
 
      coll_t c;
248
 
      ::decode(c, p);
249
 
      return c;
250
 
    }
251
 
    uint64_t get_length() {
252
 
      if (p.get_off() == 0)
253
 
        p = tbl.begin();
254
 
      uint64_t len;
255
 
      ::decode(len, p);
256
 
      return len;
257
 
    }
258
 
    string get_attrname() {
259
 
      if (p.get_off() == 0)
260
 
        p = tbl.begin();
261
 
      string s;
262
 
      ::decode(s, p);
263
 
      return s;
264
 
    }
265
 
    void get_attrset(map<string,bufferptr>& aset) {
266
 
      if (p.get_off() == 0)
267
 
        p = tbl.begin();
268
 
      ::decode(aset, p);
 
213
 
 
214
    // ---- iterator ----
 
215
    class iterator {
 
216
      bufferlist::iterator p;
 
217
      bool sobject_encoding;
 
218
 
 
219
      iterator(Transaction *t)
 
220
        : p(t->tbl.begin()),
 
221
          sobject_encoding(t->sobject_encoding) {}
 
222
 
 
223
      friend class Transaction;
 
224
 
 
225
    public:
 
226
      bool have_op() {
 
227
        return !p.end();
 
228
      }
 
229
      int get_op() {
 
230
        __u32 op;
 
231
        ::decode(op, p);
 
232
        return op;
 
233
      }
 
234
      void get_bl(bufferlist& bl) {
 
235
        ::decode(bl, p);
 
236
      }
 
237
      hobject_t get_oid() {
 
238
        hobject_t hoid;
 
239
        if (sobject_encoding) {
 
240
          sobject_t soid;
 
241
          ::decode(soid, p);
 
242
          hoid.snap = soid.snap;
 
243
          hoid.oid = soid.oid;
 
244
        } else {
 
245
          ::decode(hoid, p);
 
246
        }
 
247
        return hoid;
 
248
      }
 
249
      coll_t get_cid() {
 
250
        coll_t c;
 
251
        ::decode(c, p);
 
252
        return c;
 
253
      }
 
254
      uint64_t get_length() {
 
255
        uint64_t len;
 
256
        ::decode(len, p);
 
257
        return len;
 
258
      }
 
259
      string get_attrname() {
 
260
        string s;
 
261
        ::decode(s, p);
 
262
        return s;
 
263
      }
 
264
      void get_attrset(map<string,bufferptr>& aset) {
 
265
        ::decode(aset, p);
 
266
      }
 
267
    };
 
268
 
 
269
    iterator begin() {
 
270
      return iterator(this);
269
271
    }
270
272
 
271
273
    // -----------------------------
521
523
        ::decode(tbl, bl);
522
524
      }
523
525
    }
 
526
 
 
527
    void dump(ostream& out);
524
528
  };
525
529
 
526
530
  struct C_DeleteTransaction : public Context {
563
567
 
564
568
  virtual int statfs(struct statfs *buf) = 0;
565
569
 
 
570
  /**
 
571
   * get ideal min value for collection_list_partial()
 
572
   *
 
573
   * default to some arbitrary values; the implementation will override.
 
574
   */
 
575
  virtual int get_ideal_list_min() { return 32; }
 
576
 
 
577
  /**
 
578
   * get ideal max value for collection_list_partial()
 
579
   *
 
580
   * default to some arbitrary values; the implementation will override.
 
581
   */
 
582
  virtual int get_ideal_list_max() { return 64; }
 
583
 
566
584
  // objects
567
585
  virtual bool exists(coll_t cid, const hobject_t& oid) = 0;                   // useful?
568
586
  virtual int stat(coll_t cid, const hobject_t& oid, struct stat *st) = 0;     // struct stat?
620
638
  virtual int collection_getattr(coll_t cid, const char *name, bufferlist& bl) = 0;
621
639
  virtual int collection_getattrs(coll_t cid, map<string,bufferptr> &aset) = 0;
622
640
  virtual bool collection_empty(coll_t c) = 0;
623
 
  virtual int collection_list_partial(coll_t c, snapid_t seq, vector<hobject_t>& o, int count, collection_list_handle_t *handle) = 0;
624
641
  virtual int collection_list(coll_t c, vector<hobject_t>& o) = 0;
625
642
 
 
643
 
 
644
  /**
 
645
   * list partial contents of collection relative to a hash offset/position
 
646
   *
 
647
   * @param c collection
 
648
   * @param start list objects that sort >= this value
 
649
   * @param min return at least this many results, unless we reach the end
 
650
   * @param max return no more than this many results
 
651
   * @param snapid return no objects with snap < snapid
 
652
   * @param ls [out] result
 
653
   * @param next [out] next item sorts >= this value
 
654
   * @return zero on success, or negative error
 
655
   */
 
656
  virtual int collection_list_partial(coll_t c, hobject_t start,
 
657
                                      int min, int max, snapid_t snap, 
 
658
                                      vector<hobject_t> *ls, hobject_t *next) = 0;
 
659
 
 
660
 
626
661
  /*
627
662
  virtual int _create_collection(coll_t c) = 0;
628
663
  virtual int _destroy_collection(coll_t c) = 0;
639
674
  virtual void flush() {}
640
675
  virtual void sync_and_flush() {}
641
676
 
 
677
  virtual int dump_journal(ostream& out) { return -EOPNOTSUPP; }
 
678
 
642
679
  virtual int snapshot(const string& name) { return -EOPNOTSUPP; }
643
680
    
644
681
  virtual void _fake_writes(bool b) {};
645
682
  virtual void _get_frag_stat(FragmentationStat& st) {};
646
683
 
 
684
  virtual uuid_d get_fsid() = 0;
647
685
};
648
686
 
649
687