Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / os / filestore / GenericFileStoreBackend.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #ifndef CEPH_GENERICFILESTOREBACKEDN_H
16 #define CEPH_GENERICFILESTOREBACKEDN_H
17
18 #include "FileStore.h"
19
20 class SloppyCRCMap;
21
22 class GenericFileStoreBackend : public FileStoreBackend {
23 private:
24   bool ioctl_fiemap;
25   bool seek_data_hole;
26   bool use_splice;
27   bool m_filestore_fiemap;
28   bool m_filestore_seek_data_hole;
29   bool m_filestore_fsync_flushes_journal_data;
30   bool m_filestore_splice;
31   bool m_rotational = true;
32   bool m_journal_rotational = true;
33 public:
34   explicit GenericFileStoreBackend(FileStore *fs);
35   ~GenericFileStoreBackend() override {}
36
37   const char *get_name() override {
38     return "generic";
39   }
40   int detect_features() override;
41   int create_current() override;
42   bool can_checkpoint() override { return false; }
43   bool is_rotational() override {
44     return m_rotational;
45   }
46   bool is_journal_rotational() override {
47     return m_journal_rotational;
48   }
49   int list_checkpoints(list<string>& ls) override { return 0; }
50   int create_checkpoint(const string& name, uint64_t *cid) override { return -EOPNOTSUPP; }
51   int sync_checkpoint(uint64_t id) override { return -EOPNOTSUPP; }
52   int rollback_to(const string& name) override { return -EOPNOTSUPP; }
53   int destroy_checkpoint(const string& name) override { return -EOPNOTSUPP; }
54   int syncfs() override;
55   bool has_fiemap() override { return ioctl_fiemap; }
56   bool has_seek_data_hole() override { return seek_data_hole; }
57   int do_fiemap(int fd, off_t start, size_t len, struct fiemap **pfiemap) override;
58   int clone_range(int from, int to, uint64_t srcoff, uint64_t len, uint64_t dstoff) override {
59     return _copy_range(from, to, srcoff, len, dstoff);
60   }
61   int set_alloc_hint(int fd, uint64_t hint) override { return -EOPNOTSUPP; }
62   bool has_splice() const override { return use_splice; }
63 private:
64   int _crc_load_or_init(int fd, SloppyCRCMap *cm);
65   int _crc_save(int fd, SloppyCRCMap *cm);
66 public:
67   int _crc_update_write(int fd, loff_t off, size_t len, const bufferlist& bl) override;
68   int _crc_update_truncate(int fd, loff_t off) override;
69   int _crc_update_zero(int fd, loff_t off, size_t len) override;
70   int _crc_update_clone_range(int srcfd, int destfd,
71                                       loff_t srcoff, size_t len, loff_t dstoff) override;
72   int _crc_verify_read(int fd, loff_t off, size_t len, const bufferlist& bl,
73                                ostream *out) override;
74 };
75 #endif