summaryrefslogtreecommitdiffstats
path: root/src/os/filestore/GenericFileStoreBackend.h
blob: de10bf9489cb2cde0b2e46527c03e18569c6a96f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 *
 */

#ifndef CEPH_GENERICFILESTOREBACKEDN_H
#define CEPH_GENERICFILESTOREBACKEDN_H

#include "FileStore.h"

class SloppyCRCMap;

class GenericFileStoreBackend : public FileStoreBackend {
private:
  bool ioctl_fiemap;
  bool seek_data_hole;
  bool use_splice;
  bool m_filestore_fiemap;
  bool m_filestore_seek_data_hole;
  bool m_filestore_fsync_flushes_journal_data;
  bool m_filestore_splice;
  bool m_rotational = true;
  bool m_journal_rotational = true;
public:
  explicit GenericFileStoreBackend(FileStore *fs);
  ~GenericFileStoreBackend() override {}

  const char *get_name() override {
    return "generic";
  }
  int detect_features() override;
  int create_current() override;
  bool can_checkpoint() override { return false; }
  bool is_rotational() override {
    return m_rotational;
  }
  bool is_journal_rotational() override {
    return m_journal_rotational;
  }
  int list_checkpoints(std::list<std::string>& ls) override { return 0; }
  int create_checkpoint(const std::string& name, uint64_t *cid) override { return -EOPNOTSUPP; }
  int sync_checkpoint(uint64_t id) override { return -EOPNOTSUPP; }
  int rollback_to(const std::string& name) override { return -EOPNOTSUPP; }
  int destroy_checkpoint(const std::string& name) override { return -EOPNOTSUPP; }
  int syncfs() override;
  bool has_fiemap() override { return ioctl_fiemap; }
  bool has_seek_data_hole() override { return seek_data_hole; }
  int do_fiemap(int fd, off_t start, size_t len, struct fiemap **pfiemap) override;
  int clone_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff) override {
    return _copy_range(from, to, srcoff, len, dstoff);
  }
  int set_alloc_hint(int fd, uint64_t hint) override { return -EOPNOTSUPP; }
  bool has_splice() const override { return use_splice; }
private:
  int _crc_load_or_init(int fd, SloppyCRCMap *cm);
  int _crc_save(int fd, SloppyCRCMap *cm);
public:
  int _crc_update_write(int fd, loff_t off, size_t len, const ceph::buffer::list& bl) override;
  int _crc_update_truncate(int fd, loff_t off) override;
  int _crc_update_zero(int fd, loff_t off, size_t len) override;
  int _crc_update_clone_range(int srcfd, int destfd,
				      loff_t srcoff, size_t len, loff_t dstoff) override;
  int _crc_verify_read(int fd, loff_t off, size_t len, const ceph::buffer::list& bl,
		       std::ostream *out) override;
};
#endif