SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
FileSystem.cc
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 
8 
9 extern "C" {
10 #include <dirent.h>
11 }
12 
13 
14 namespace SWC { namespace FS {
15 
16 
18  config->settings->file_desc.add_options()
19  ("swc.fs.ceph.path.root", Config::str(""),
20  "Ceph FileSystem's base root path")
21  ("swc.fs.ceph.cfg.dyn", Config::strs(),
22  "Dyn-config file")
23 
24  ("swc.fs.ceph.client.id", Config::str(),
25  "This ceph Client Id(name)")
26 
27  ("swc.fs.ceph.perm.group", Config::i32(),
28  "CephFs Permission Group")
29  ("swc.fs.ceph.perm.user", Config::i32(),
30  "CephFs Permission User")
31 
32  ("swc.fs.ceph.configuration.file", Config::str(),
33  "The ceph configuration file 'ceph.conf'")
34  ("swc.fs.ceph.mon.addr", Config::str(),
35  "The ceph config value for 'mon_addr'")
36 
37  ("swc.fs.ceph.metrics.enabled", Config::boo(true),
38  "Enable or Disable Metrics Tracking")
39 
40  ("swc.fs.ceph.replication", Config::i32(),
41  "CephFs default replication")
42 
43  ("swc.fs.ceph.fds.max", Config::g_i32(256),
44  "Max Open Fds for opt. without closing")
45 
46  ("swc.fs.ceph.stripe.unit", Config::g_i32(0),
47  "Size of ceph stripe unit")
48  ("swc.fs.ceph.stripe.count", Config::g_i32(0),
49  "Count of ceph stripes")
50  ("swc.fs.ceph.object.size", Config::g_i32(0),
51  "Size of ceph object")
52  ;
53 
54  config->settings->parse_file(
55  config->settings->get_str("swc.fs.ceph.cfg", ""),
56  "swc.fs.ceph.cfg.dyn"
57  );
58 
59  config->path_root = config->settings->get_str(
60  "swc.fs.ceph.path.root");
61  config->cfg_fds_max = config->settings
62  ->get<Config::Property::Value_int32_g>("swc.fs.ceph.fds.max");
63  config->stats_enabled = config->settings->get_bool(
64  "swc.fs.ceph.metrics.enabled");
65  return config;
66 }
67 
68 
69 
70 
72  : FileSystem(apply_ceph(config), ImplOptions()),
73  cfg_stripe_unit(
74  settings->get<Config::Property::Value_int32_g>(
75  "swc.fs.ceph.stripe.unit")),
76  cfg_stripe_count(
77  settings->get<Config::Property::Value_int32_g>(
78  "swc.fs.ceph.stripe.count")),
79  cfg_object_size(
80  settings->get<Config::Property::Value_int32_g>(
81  "swc.fs.ceph.object.size")),
82  m_filesystem(nullptr), m_perm(nullptr) {
84 }
85 
87 
88  uint32_t tries=0;
89  while(m_run && !initialize()) {
91  "FS-Ceph, unable to initialize connection to Ceph, try=%u",
92  ++tries);
93  std::this_thread::sleep_for(std::chrono::milliseconds(1000));
94  }
95 
96  // status check
97  int err;
98  const char* cwd = ceph_getcwd(m_filesystem);
99  if(!Condition::str_eq(path_root, cwd)) {
101  "FS-Ceph, ceph_cwd='%s' != path_root='%s' changing",
102  cwd, path_root.c_str());
103  err = ceph_chdir(m_filesystem, path_root.c_str());
104  SWC_ASSERT(!err);
105  }
106 
107  /* cfg-values set at file create (No longer available)
108  int value;
109  if((value = cfg_stripe_unit->get()))
110  ceph_set_default_file_stripe_unit(m_filesystem, value);
111  if((value = cfg_stripe_count->get()))
112  ceph_set_default_file_stripe_count(m_filesystem, value);
113  if((value = cfg_object_size->get()))
114  ceph_set_default_object_size(m_filesystem, value);
115  */
116 
117  if(settings->has("swc.fs.ceph.replication"))
118  ceph_set_default_file_replication(
119  m_filesystem, settings->get_i32("swc.fs.ceph.replication"));
120 
121  /*
122  int ceph_cfg_min_obj_sz = ceph_conf_get(
123  m_filesystem, "object_size", char *buf, size_t len)
124  int ceph_conf_set(m_filesystem, const char *option, const char *value);
125  int ceph_conf_get(m_filesystem, const char *option, char *buf, size_t len);
126 
127  int ceph_statfs(m_filesystem, const char *path, struct statvfs *stbuf);
128  */
129 
130  SWC_LOGF(LOG_DEBUG, "FS-Ceph, working Dir='%s'", cwd);
131 }
132 
134 
135  int err;
136  errno = 0;
137 
138  /*
139  if(settings->has("swc.fs.ceph.user") ||
140  settings->has("swc.fs.ceph.group"))
141  m_perm = ceph_userperm_new(c uid, gid_t gid, int ngids, gid_t *gidlist);
142  */
143 
144  std::string client_id;
145  if(settings->has("swc.fs.ceph.client.id"))
146  client_id = settings->get_str("swc.fs.ceph.client.id");
147 
148  err = ceph_create(
149  &m_filesystem, client_id.empty() ? nullptr : client_id.c_str());
150  if(err < 0 || errno) {
151  err = err ? -err : errno;
152  SWC_LOGF(LOG_ERROR, "ceph_create('%s') failed - %d(%s)",
153  client_id.c_str(), err, Error::get_text(err));
154  return false;
155  }
156 
157  bool ceph_conf;
158  if((ceph_conf = settings->has("swc.fs.ceph.configuration.file"))) {
159  const std::string conf_file = settings->get_str(
160  "swc.fs.ceph.configuration.file");
161  SWC_LOGF(LOG_INFO, "Reading ceph.configuration.file('%s')",
162  conf_file.c_str());
163  err = ceph_conf_read_file(m_filesystem, conf_file.c_str());
164  if(err < 0 || errno) {
165  err = err ? -err : errno;
166  SWC_LOGF(LOG_ERROR, "ceph_conf_read_file('%s') failed - %d(%s)",
167  conf_file.c_str(), err, Error::get_text(err));
168  stop();
169  m_run.store(true);
170  return false;
171  }
172  }
173 
174  if(!ceph_conf && settings->has("swc.fs.ceph.mon.addr")) {
175  const std::string mon_host = settings->get_str("swc.fs.ceph.mon.addr");
176  err = ceph_conf_set(m_filesystem, "mon_host", mon_host.c_str());
177  if(err < 0 || errno) {
178  err = err ? -err : errno;
179  SWC_LOGF(LOG_ERROR, "ceph_create('%s') failed - %d(%s)",
180  client_id.c_str(), err, Error::get_text(err));
181  stop();
182  m_run.store(true);
183  return false;
184  }
185  }
186 
187  std::string mon_host;
188  mon_host.resize(4096);
189  int sz = ceph_conf_get(m_filesystem, "mon_host", mon_host.data(), 4096);
190  mon_host = std::string(mon_host.data(), sz);
191  SWC_LOGF(LOG_INFO, "Connecting to ceph-mon_host('%s') sz=%d",
192  mon_host.c_str(), sz);
193 
194  //int ceph_mount_perms_set(m_filesystem, m_perm);
195  //int ceph_select_filesystem(m_filesystem, const char *fs_name);
196 
197  err = ceph_mount(m_filesystem, path_root.c_str());
198  if(err < 0 || errno) {
199  err = err ? -err : errno;
200  SWC_LOGF(LOG_ERROR, "ceph_mount('%s') failed - %d(%s)",
201  path_root.c_str(), err, Error::get_text(err));
202  stop();
203  m_run.store(true);
204  return false;
205  }
206 
207  return bool(m_filesystem);
208 }
209 
211 
213  m_run.store(false);
214 
215  if(m_perm) {
216  ceph_userperm_destroy(m_perm);
217  }
218 
219  if(m_filesystem) {
220  if(ceph_is_mounted(m_filesystem)) {
221  ceph_sync_fs(m_filesystem);
222  ceph_unmount(m_filesystem);
223  }
224  ceph_release(m_filesystem);
225  }
226 
228 }
229 
230 Type FileSystemCeph::get_type() const noexcept {
231  return Type::CEPH;
232 }
233 
234 std::string FileSystemCeph::to_string() const {
235  return format(
236  "(type=CEPH path_root=%s path_data=%s)",
237  path_root.c_str(),
238  path_data.c_str()
239  );
240 }
241 
242 
243 bool FileSystemCeph::exists(int& err, const std::string& name) {
245  SWC_FS_EXISTS_START(name);
246  std::string abspath;
247  get_abspath(name, abspath);
248 
249  errno = 0;
250  struct ceph_statx stx;
251  err = ceph_statx(m_filesystem, abspath.c_str(), &stx,
252  CEPH_STATX_CTIME, AT_SYMLINK_NOFOLLOW);
253  if(err)
254  err = -err;
255  else if(errno)
256  err = errno;
257  bool state = !err;
258  if(err == ENOENT)
259  err = Error::OK;
260  SWC_FS_EXISTS_FINISH(err, abspath, state, tracker);
261  return state;
262 }
263 
264 void FileSystemCeph::remove(int& err, const std::string& name) {
266  SWC_FS_REMOVE_START(name);
267  std::string abspath;
268  get_abspath(name, abspath);
269  errno = 0;
270 
271  err = ceph_unlink(m_filesystem, abspath.c_str());
272  if(err < 0)
273  err = -err;
274  else if(errno)
275  err = errno;
276  if(err == ENOENT)
277  err = Error::OK;
278  SWC_FS_REMOVE_FINISH(err, abspath, tracker);
279 }
280 
281 size_t FileSystemCeph::length(int& err, const std::string& name) {
283  SWC_FS_LENGTH_START(name);
284  std::string abspath;
285  get_abspath(name, abspath);
286 
287  struct ceph_statx stx;
288  errno = 0;
289  err = ceph_statx(m_filesystem, abspath.c_str(), &stx,
290  CEPH_STATX_SIZE, AT_SYMLINK_NOFOLLOW);
291  if(err < 0)
292  err = -err;
293  else if(errno)
294  err = errno;
295  size_t len = err ? 0 : stx.stx_size;
296  SWC_FS_LENGTH_FINISH(err, abspath, len, tracker);
297  return len;
298 }
299 
300 void FileSystemCeph::mkdirs(int& err, const std::string& name) {
302  SWC_FS_MKDIRS_START(name);
303  std::string abspath;
304  get_abspath(name, abspath);
305 
306  errno = 0;
307  err = ceph_mkdirs(m_filesystem, abspath.c_str(), 644);
308  if(err < 0)
309  err = -err;
310  else if(errno)
311  err = errno;
312  SWC_FS_MKDIRS_FINISH(err, abspath, tracker);
313 }
314 
315 void FileSystemCeph::readdir(int& err, const std::string& name,
316  DirentList& results) {
318  SWC_FS_READDIR_START(name);
319  std::string abspath;
320  get_abspath(name, abspath);
321 
322  errno = 0;
323  struct ceph_dir_result* dirp = nullptr;
324  err = ceph_opendir(m_filesystem, abspath.c_str(), &dirp);
325  if(err < 0)
326  err = -err;
327  else if(errno)
328  err = errno;
329  if(err)
330  goto _finish;
331 
332  struct dirent de;
333  struct ceph_statx stx;
334 
335  while((err = ceph_readdirplus_r(
336  m_filesystem, dirp, &de,
337  &stx, CEPH_STATX_INO, AT_NO_ATTR_SYNC, nullptr)) == 1) {
338  if(de.d_name[0] == '.' || !de.d_name[0])
339  continue;
340 
341  auto& entry = results.emplace_back();
342  entry.name.reserve(abspath.length() + 1 + strlen(de.d_name));
343  entry.name.append(abspath);
344  entry.name.append("/");
345  entry.name.append(de.d_name);
346  entry.is_dir = S_ISDIR(stx.stx_mode) || de.d_type == DT_DIR;
347 
348  entry.length = stx.stx_size;
349  entry.last_modification_time = stx.stx_mtime.tv_sec;
350  }
351  if(err < 0)
352  err = -err;
353  else if(errno)
354  err = errno;
355 
356  _finish:
357  if(dirp)
358  ceph_closedir(m_filesystem, dirp);
359  SWC_FS_READDIR_FINISH(err, abspath, results.size(), tracker);
360 }
361 
362 void FileSystemCeph::rmdir(int& err, const std::string& name) {
363  auto tracker = statistics.tracker(Statistics::RMDIR_SYNC);
364  SWC_FS_RMDIR_START(name);
365  std::string abspath;
366  get_abspath(name, abspath);
367 
368  errno = 0;
369  struct ceph_dir_result* dirp = nullptr;
370  err = ceph_opendir(m_filesystem, abspath.c_str(), &dirp);
371  if(err < 0)
372  err = -err;
373  else if(errno)
374  err = errno;
375  if(err)
376  goto _finish;
377 
378  struct dirent de;
379  struct ceph_statx stx;
380 
381  while((err = ceph_readdirplus_r(
382  m_filesystem, dirp, &de,
383  &stx, CEPH_STATX_INO, AT_NO_ATTR_SYNC, nullptr)) == 1) {
384  if(de.d_name[0] == '.' || !de.d_name[0])
385  continue;
386 
387  if(S_ISDIR(stx.stx_mode) || de.d_type == DT_DIR) {
388  rmdir(err, name + "/" + de.d_name);
389  if(err)
390  break;
391  }
392  }
393 
394  errno = 0;
395  err = ceph_rmdir(m_filesystem, abspath.c_str()); // recursive
396  if(err < 0)
397  err = -err;
398  else if(errno)
399  err = errno;
400  if(err == ENOENT)
401  err = Error::OK;
402 
403  _finish:
404  if(dirp)
405  ceph_closedir(m_filesystem, dirp);
406  SWC_FS_RMDIR_FINISH(err, abspath, tracker);
407 }
408 
409 void FileSystemCeph::rename(int& err, const std::string& from,
410  const std::string& to) {
413  std::string abspath_from;
414  get_abspath(from, abspath_from);
415  std::string abspath_to;
416  get_abspath(to, abspath_to);
417 
418  errno = 0;
419  err = ceph_rename(m_filesystem, abspath_from.c_str(), abspath_to.c_str());
420  if(err < 0)
421  err = -err;
422  else if(errno)
423  err = errno;
424  SWC_FS_RENAME_FINISH(err, abspath_from, abspath_to, tracker);
425 }
426 
427 
428 void FileSystemCeph::create(int& err, SmartFd::Ptr& smartfd,
429  uint8_t replication) {
431 
432  int oflags = O_WRONLY | O_CREAT;
433  if(!(smartfd->flags() & OpenFlags::OPEN_FLAG_OVERWRITE))
434  oflags |= O_APPEND;
435  else
436  oflags |= O_TRUNC;
437 
438  SWC_FS_CREATE_START(smartfd, replication);
439  std::string abspath;
440  get_abspath(smartfd->filepath(), abspath);
441 
442  errno = 0;
443  int tmperr = ceph_open_layout(
444  m_filesystem, abspath.c_str(), oflags, 644,
446  nullptr
447  );
448  if(tmperr < 0) {
449  tmperr = -tmperr;
450  } else if(tmperr > 0) {
451  smartfd->fd(tmperr);
452  fd_open_incr();
453  err = tmperr = Error::OK;
454  } else if(errno) {
455  tmperr = errno;
456  }
457  if(tmperr) {
458  smartfd->fd(-1);
459  if(tmperr == EACCES || tmperr == ENOENT)
461  else if (tmperr == EPERM)
463  else
464  err = tmperr;
465  }
466  SWC_FS_CREATE_FINISH(tmperr, smartfd, fds_open(), tracker);
467 }
468 
469 void FileSystemCeph::open(int& err, SmartFd::Ptr& smartfd) {
470  auto tracker = statistics.tracker(Statistics::OPEN_SYNC);
471  SWC_FS_OPEN_START(smartfd);
472  std::string abspath;
473  get_abspath(smartfd->filepath(), abspath);
474 
475  int oflags = O_RDONLY;
476  errno = 0;
477  int tmperr = ceph_open(m_filesystem, abspath.c_str(), oflags, 0);
478  if(tmperr < 0) {
479  tmperr = -tmperr;
480  } else if(tmperr > 0) {
481  smartfd->fd(tmperr);
482  fd_open_incr();
483  err = tmperr = Error::OK;
484  } else if(errno) {
485  tmperr = errno;
486  }
487 
488  if(tmperr) {
489  smartfd->fd(-1);
490  if(tmperr == EACCES || tmperr == ENOENT)
492  else if (tmperr == EPERM)
494  else
495  err = tmperr;
496  }
497  SWC_FS_OPEN_FINISH(tmperr, smartfd, fds_open(), tracker);
498 }
499 
500 size_t FileSystemCeph::read(int& err, SmartFd::Ptr& smartfd,
501  void *dst, size_t amount) {
502  auto tracker = statistics.tracker(Statistics::READ_SYNC);
503  SWC_FS_READ_START(smartfd, amount);
504 
505  size_t ret;
506  errno = 0;
507  ssize_t nread = ceph_read(m_filesystem, smartfd->fd(),
508  static_cast<char*>(dst), amount, smartfd->pos());
509  if(nread < 0)
510  err = -nread;
511  else if(errno)
512  err = errno;
513  else
514  err = Error::OK;
515 
516  if(err) {
517  ret = 0;
518  nread = 0;
519  } else {
520  if((ret = nread) != amount)
521  err = Error::FS_EOF;
522  smartfd->forward(nread);
523  }
524  SWC_FS_READ_FINISH(err, smartfd, ret, tracker);
525  return ret;
526 }
527 
528 
529 size_t FileSystemCeph::pread(int& err, SmartFd::Ptr& smartfd,
530  uint64_t offset, void *dst, size_t amount) {
531  auto tracker = statistics.tracker(Statistics::PREAD_SYNC);
532  SWC_FS_PREAD_START(smartfd, offset, amount);
533 
534  size_t ret;
535  errno = 0;
536  ssize_t nread = ceph_read(m_filesystem, smartfd->fd(),
537  static_cast<char*>(dst), amount, offset);
538  if(nread < 0)
539  err = -nread;
540  else if(errno)
541  err = errno;
542  else
543  err = Error::OK;
544 
545  if(err) {
546  ret = 0;
547  nread = 0;
548  } else if((ret = nread) != amount) {
549  err = Error::FS_EOF;
550  }
551  SWC_FS_PREAD_FINISH(err, smartfd, ret, tracker);
552  return ret;
553 }
554 
555 size_t FileSystemCeph::append(int& err, SmartFd::Ptr& smartfd,
556  StaticBuffer& buffer, Flags flags) {
558  SWC_FS_APPEND_START(smartfd, buffer.size, flags);
559 
560  ssize_t nwritten = 0;
561  errno = 0;
562 
563  nwritten = ceph_write(m_filesystem, smartfd->fd(),
564  reinterpret_cast<const char*>(buffer.base),
565  buffer.size, smartfd->pos());
566  if(nwritten < 0)
567  err = -nwritten;
568  else if(errno)
569  err = errno;
570  else if(nwritten != ssize_t(buffer.size))
571  err = ECANCELED;
572  else
573  err = Error::OK;
574 
575  if(!err) {
576  if (flags == Flags::FLUSH)
577  flush(err, smartfd);
578  else if (flags == Flags::SYNC)
579  sync(err, smartfd);
580  }
581  if(err) {
582  nwritten = 0;
583  } else {
584  smartfd->forward(nwritten);
585  }
586  SWC_FS_APPEND_FINISH(err, smartfd, nwritten, tracker);
587  return nwritten;
588 }
589 
590 void FileSystemCeph::seek(int& err, SmartFd::Ptr& smartfd, size_t offset) {
591  auto tracker = statistics.tracker(Statistics::SEEK_SYNC);
592  SWC_FS_SEEK_START(smartfd, offset);
593 
594  errno = 0;
595  err = ceph_lseek(m_filesystem, smartfd->fd(), offset, SEEK_SET);
596  if(err < 0)
597  err = -err;
598  else if(errno)
599  err = errno;
600  if(!err) {
601  smartfd->pos(offset);
602  }
603  SWC_FS_SEEK_FINISH(err, smartfd, tracker);
604 }
605 
606 void FileSystemCeph::flush(int& err, SmartFd::Ptr& smartfd) {
607  auto tracker = statistics.tracker(Statistics::FLUSH_SYNC);
608  SWC_FS_FLUSH_START(smartfd);
609 
610  errno = 0;
611  err = ceph_fsync(m_filesystem, smartfd->fd(), true);
612  if(err < 0)
613  err = -err;
614  else if(errno)
615  err = errno;
616  SWC_FS_FLUSH_FINISH(err, smartfd, tracker);
617 }
618 
619 void FileSystemCeph::sync(int& err, SmartFd::Ptr& smartfd) {
620  auto tracker = statistics.tracker(Statistics::SYNC_SYNC);
621  SWC_FS_SYNC_START(smartfd);
622 
623  errno = 0;
624  err = ceph_fsync(m_filesystem, smartfd->fd(), false);
625  if(err < 0)
626  err = -err;
627  else if(errno)
628  err = errno;
629  SWC_FS_SYNC_FINISH(err, smartfd, tracker);
630 }
631 
632 void FileSystemCeph::close(int& err, SmartFd::Ptr& smartfd) {
633  auto tracker = statistics.tracker(Statistics::CLOSE_SYNC);
634  SWC_FS_CLOSE_START(smartfd);
635 
636  int32_t fd = smartfd->invalidate();
637  if(fd != -1) {
638  errno = 0;
639  err = ceph_close(m_filesystem, fd);
640  if(err < 0)
641  err = -err;
642  else if(errno)
643  err = errno;
644  fd_open_decr();
645  } else {
646  err = EBADR;
647  }
648  SWC_FS_CLOSE_FINISH(err, smartfd, tracker);
649 }
650 
651 
652 
653 
654 
655 
656 }} // namespace SWC
657 
658 
659 
660 extern "C" {
662  return static_cast<SWC::FS::FileSystem*>(
663  new SWC::FS::FileSystemCeph(config));
664 }
665 }
SWC_FS_FLUSH_FINISH
#define SWC_FS_FLUSH_FINISH(_error, _smartfd, _tracker)
Definition: Logger.h:246
SWC::Config::i32
Property::Value_int32::Ptr i32(const int32_t &v)
Definition: PropertiesParser.cc:33
SWC_FS_APPEND_START
#define SWC_FS_APPEND_START(_smartfd, _amount, _flags)
Definition: Logger.h:217
SWC::FS::Statistics::FLUSH_SYNC
@ FLUSH_SYNC
Definition: Statistics.h:42
SWC::Config::g_i32
Property::Value_int32_g::Ptr g_i32(const int32_t &v)
Definition: PropertiesParser.cc:77
SWC::FS::FileSystemCeph::FileSystemCeph
FileSystemCeph(Configurables *config)
Definition: FileSystem.cc:71
SWC::FS::Statistics::REMOVE_SYNC
@ REMOVE_SYNC
Definition: Statistics.h:34
fs_make_new_ceph
SWC::FS::FileSystem * fs_make_new_ceph(SWC::FS::Configurables *config)
Definition: FileSystem.cc:661
SWC::FS::Statistics::READDIR_SYNC
@ READDIR_SYNC
Definition: Statistics.h:46
SWC_LOGF
#define SWC_LOGF(priority, fmt,...)
Definition: Logger.h:188
SWC::FS::FileSystemCeph::cfg_stripe_unit
const Config::Property::Value_int32_g::Ptr cfg_stripe_unit
Definition: FileSystem.h:107
SWC::FS::Type
Type
Definition: FileSystem.h:20
SWC::FS::Statistics::CLOSE_SYNC
@ CLOSE_SYNC
Definition: Statistics.h:26
SWC::FS::Statistics::RENAME_SYNC
@ RENAME_SYNC
Definition: Statistics.h:50
SWC::FS::Statistics::RMDIR_SYNC
@ RMDIR_SYNC
Definition: Statistics.h:44
SWC_FS_FLUSH_START
#define SWC_FS_FLUSH_START(_smartfd)
Definition: Logger.h:241
SWC::Error::FS_PERMISSION_DENIED
@ FS_PERMISSION_DENIED
Definition: Error.h:95
SWC::Error::get_text
const char * get_text(const int err) noexcept
Definition: Error.cc:173
SWC_FS_RMDIR_FINISH
#define SWC_FS_RMDIR_FINISH(_error, _path, _tracker)
Definition: Logger.h:96
SWC::FS::apply_ceph
Configurables * apply_ceph(Configurables *config)
Definition: FileSystem.cc:17
SWC::LOG_INFO
@ LOG_INFO
Definition: Logger.h:35
SWC_FS_RENAME_FINISH
#define SWC_FS_RENAME_FINISH(_error, _from, _to, _tracker)
Definition: Logger.h:108
SWC::FS::Flags
Flags
Definition: FileSystem.h:41
SWC::FS::Statistics::tracker
SWC_CAN_INLINE Metric::Tracker tracker(Command cmd) noexcept
Definition: Statistics.h:119
SWC::FS::FileSystemCeph
Definition: FileSystem.h:20
SWC::FS::FileSystemCeph::sync
void sync(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:619
SWC::FS::FileSystemCeph::m_perm
UserPerm * m_perm
Definition: FileSystem.h:112
SWC::Error::FS_PATH_NOT_FOUND
@ FS_PATH_NOT_FOUND
Definition: Error.h:97
SWC::FS::FileSystem
Definition: FileSystem.h:101
SWC::FS::FileSystemCeph::seek
void seek(int &err, SmartFd::Ptr &smartfd, size_t offset) override
Definition: FileSystem.cc:590
SWC::FS::Statistics::SYNC_SYNC
@ SYNC_SYNC
Definition: Statistics.h:52
SWC::Config::boo
Property::Value_bool::Ptr boo(const bool &v)
Definition: PropertiesParser.cc:21
SWC::Config::Property::Value_int32_g::get
SWC_CAN_INLINE int32_t get() const noexcept
Definition: Property.h:610
SWC::FS::Statistics::SEEK_SYNC
@ SEEK_SYNC
Definition: Statistics.h:32
SWC::FS::Statistics::CREATE_SYNC
@ CREATE_SYNC
Definition: Statistics.h:24
SWC_FS_PREAD_START
#define SWC_FS_PREAD_START(_smartfd, _offset, _amount)
Definition: Logger.h:185
SWC_FS_MKDIRS_FINISH
#define SWC_FS_MKDIRS_FINISH(_error, _path, _tracker)
Definition: Logger.h:72
SWC::FS::FileSystemCeph::rmdir
void rmdir(int &err, const std::string &name) override
Definition: FileSystem.cc:362
SWC::FS::Configurables
Definition: FileSystem.h:48
SWC::FS::FileSystemCeph::open
void open(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:469
SWC::FS::Statistics::MKDIRS_SYNC
@ MKDIRS_SYNC
Definition: Statistics.h:40
SWC::FS::Statistics::EXISTS_SYNC
@ EXISTS_SYNC
Definition: Statistics.h:48
SWC_FS_READDIR_FINISH
#define SWC_FS_READDIR_FINISH(_error, _path, _sz, _tracker)
Definition: Logger.h:84
SWC_FS_CLOSE_START
#define SWC_FS_CLOSE_START(_smartfd)
Definition: Logger.h:263
SWC::FS::ImplOptions
Definition: FileSystem.h:66
SWC_FS_OPEN_FINISH
#define SWC_FS_OPEN_FINISH(_error, _smartfd, _open_fds, _tracker)
Definition: Logger.h:149
SWC::Condition::str_eq
bool str_eq(const char *s1, const char *s2) noexcept SWC_ATTRIBS((SWC_ATTRIB_O3))
Definition: Comparators_basic.h:237
SWC::FS::Configurables::path_root
std::string path_root
Definition: FileSystem.h:51
SWC::Core::AtomicBase::store
constexpr SWC_CAN_INLINE void store(T v) noexcept
Definition: Atomic.h:37
SWC::Error::OK
@ OK
Definition: Error.h:45
SWC::FS::Statistics::READ_SYNC
@ READ_SYNC
Definition: Statistics.h:28
SWC::LOG_DEBUG
@ LOG_DEBUG
Definition: Logger.h:36
SWC_FS_RENAME_START
#define SWC_FS_RENAME_START(_from, _to)
Definition: Logger.h:103
SWC::Error::FS_EOF
@ FS_EOF
Definition: Error.h:96
SWC_FS_MKDIRS_START
#define SWC_FS_MKDIRS_START(_path)
Definition: Logger.h:67
SWC_FS_LENGTH_FINISH
#define SWC_FS_LENGTH_FINISH(_error, _path, _len, _tracker)
Definition: Logger.h:60
SWC_FS_CREATE_FINISH
#define SWC_FS_CREATE_FINISH(_error, _smartfd, _open_fds, _tracker)
Definition: Logger.h:137
SWC::FS::CEPH
@ CEPH
Definition: FileSystem.h:28
SWC_FS_SYNC_START
#define SWC_FS_SYNC_START(_smartfd)
Definition: Logger.h:252
SWC::Core::Buffer::base
value_type * base
Definition: Buffer.h:131
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC_FS_APPEND_FINISH
#define SWC_FS_APPEND_FINISH(_error, _smartfd, _amount, _tracker)
Definition: Logger.h:223
SWC::FS::OPEN_FLAG_OVERWRITE
@ OPEN_FLAG_OVERWRITE
Definition: FileSystem.h:35
SWC::FS::FileSystemCeph::remove
void remove(int &err, const std::string &name) override
Definition: FileSystem.cc:264
SWC::FS::Statistics::LENGTH_SYNC
@ LENGTH_SYNC
Definition: Statistics.h:36
FileSystem.h
SWC::FS::Configurables::settings
Config::Settings::Ptr settings
Definition: FileSystem.h:49
SWC::Core::Buffer
Definition: Buffer.h:18
SWC::Core::Buffer::size
size_t size
Definition: Buffer.h:130
SWC::FS::FileSystemCeph::pread
size_t pread(int &err, SmartFd::Ptr &smartfd, uint64_t offset, void *dst, size_t amount) override
Definition: FileSystem.cc:529
SWC::FS::FileSystemCeph::setup_connection
void setup_connection()
Definition: FileSystem.cc:86
SWC_FS_CREATE_START
#define SWC_FS_CREATE_START(_smartfd, _replication)
Definition: Logger.h:131
SWC::Config::strs
Property::Value_strings::Ptr strs(Strings &&v)
Definition: PropertiesParser.cc:49
SWC::FS::FileSystemCeph::to_string
std::string to_string() const override
Definition: FileSystem.cc:234
SWC::FS::Configurables::cfg_fds_max
Config::Property::Value_int32_g::Ptr cfg_fds_max
Definition: FileSystem.h:50
SWC_FS_OPEN_START
#define SWC_FS_OPEN_START(_smartfd)
Definition: Logger.h:144
SWC::Config::str
Property::Value_string::Ptr str(std::string &&v)
Definition: PropertiesParser.cc:45
SWC_FS_READ_FINISH
#define SWC_FS_READ_FINISH(_error, _smartfd, _amount, _tracker)
Definition: Logger.h:175
SWC::FS::Statistics::APPEND_SYNC
@ APPEND_SYNC
Definition: Statistics.h:30
SWC::FS::Statistics::OPEN_SYNC
@ OPEN_SYNC
Definition: Statistics.h:22
SWC::LOG_ERROR
@ LOG_ERROR
Definition: Logger.h:32
SWC::FS::FileSystemCeph::m_filesystem
struct ceph_mount_info * m_filesystem
Definition: FileSystem.h:111
SWC::FS::FileSystem::fd_open_incr
void fd_open_incr() noexcept
Definition: FileSystem.cc:155
SWC::FS::FileSystem::settings
const Config::Settings::Ptr settings
Definition: FileSystem.h:110
SWC::FS::FileSystemCeph::append
size_t append(int &err, SmartFd::Ptr &smartfd, StaticBuffer &buffer, Flags flags) override
Definition: FileSystem.cc:555
SWC::FS::FileSystemCeph::length
size_t length(int &err, const std::string &name) override
Definition: FileSystem.cc:281
SWC::format
std::string format(const char *fmt,...) __attribute__((format(printf
Definition: String.cc:17
SWC::Core::Vector< Dirent >
SWC::FS::FileSystemCeph::create
void create(int &err, SmartFd::Ptr &smartfd, uint8_t replication) override
Definition: FileSystem.cc:428
SWC::FS::Statistics::PREAD_SYNC
@ PREAD_SYNC
Definition: Statistics.h:38
SWC::Condition::from
Comp from(const char **buf, uint32_t *remainp, uint8_t extended=0x00) noexcept
Definition: Comparators.cc:15
SWC::FS::SmartFd::Ptr
std::shared_ptr< SmartFd > Ptr
Definition: SmartFd.h:37
SWC_FS_READDIR_START
#define SWC_FS_READDIR_START(_path)
Definition: Logger.h:79
SWC::FS::FileSystem::m_run
Core::AtomicBool m_run
Definition: FileSystem.h:113
SWC::FS::FileSystem::stop
virtual void stop()
Definition: FileSystem.cc:115
SWC_FS_PREAD_FINISH
#define SWC_FS_PREAD_FINISH(_error, _smartfd, _amount, _tracker)
Definition: Logger.h:191
SWC::FS::FileSystemCeph::rename
void rename(int &err, const std::string &from, const std::string &to) override
Definition: FileSystem.cc:409
SWC::FS::FileSystem::fd_open_decr
void fd_open_decr() noexcept
Definition: FileSystem.cc:159
SWC::FS::FileSystemCeph::readdir
void readdir(int &err, const std::string &name, DirentList &results) override
Definition: FileSystem.cc:315
SWC::FS::Configurables::stats_enabled
bool stats_enabled
Definition: FileSystem.h:52
SWC::FS::FLUSH
@ FLUSH
Definition: FileSystem.h:43
SWC::FS::FileSystemCeph::initialize
bool initialize()
Definition: FileSystem.cc:133
SWC::FS::FileSystemCeph::read
void read(int &err, const std::string &name, StaticBuffer *dst) override
Definition: FileSystem.h:64
SWC::FS::FileSystemCeph::mkdirs
void mkdirs(int &err, const std::string &name) override
Definition: FileSystem.cc:300
SWC::FS::FileSystem::path_root
const std::string path_root
Definition: FileSystem.h:107
SWC_FS_READ_START
#define SWC_FS_READ_START(_smartfd, _amount)
Definition: Logger.h:170
SWC_FS_SEEK_FINISH
#define SWC_FS_SEEK_FINISH(_error, _smartfd, _tracker)
Definition: Logger.h:235
SWC::FS::FileSystem::fds_open
size_t fds_open() const noexcept
Definition: FileSystem.cc:167
SWC::FS::FileSystem::path_data
const std::string path_data
Definition: FileSystem.h:108
SWC_FS_EXISTS_START
#define SWC_FS_EXISTS_START(_path)
Definition: Logger.h:31
SWC::LOG_WARN
@ LOG_WARN
Definition: Logger.h:33
SWC::FS::FileSystemCeph::exists
bool exists(int &err, const std::string &name) override
Definition: FileSystem.cc:243
SWC::FS::FileSystemCeph::cfg_object_size
const Config::Property::Value_int32_g::Ptr cfg_object_size
Definition: FileSystem.h:109
SWC_FS_RMDIR_START
#define SWC_FS_RMDIR_START(_path)
Definition: Logger.h:91
flags
uint8_t flags
Flags.
Definition: Header.h:55
SWC::FS::SYNC
@ SYNC
Definition: FileSystem.h:44
SWC::FS::FileSystemCeph::cfg_stripe_count
const Config::Property::Value_int32_g::Ptr cfg_stripe_count
Definition: FileSystem.h:108
SWC_FS_SEEK_START
#define SWC_FS_SEEK_START(_smartfd, _offset)
Definition: Logger.h:230
SWC_FS_LENGTH_START
#define SWC_FS_LENGTH_START(_path)
Definition: Logger.h:55
SWC::FS::FileSystemCeph::flush
void flush(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:606
SWC::FS::FileSystemCeph::~FileSystemCeph
virtual ~FileSystemCeph() noexcept
Definition: FileSystem.cc:210
SWC_FS_CLOSE_FINISH
#define SWC_FS_CLOSE_FINISH(_error, _smartfd, _tracker)
Definition: Logger.h:268
SWC_ASSERT
#define SWC_ASSERT(_e_)
Definition: Exception.h:165
SWC::FS::FileSystemCeph::stop
void stop() override
Definition: FileSystem.cc:212
SWC_FS_REMOVE_FINISH
#define SWC_FS_REMOVE_FINISH(_error, _path, _tracker)
Definition: Logger.h:48
SWC::FS::FileSystem::get_abspath
virtual void get_abspath(const std::string &name, std::string &abspath, size_t reserve=0)
Definition: FileSystem.cc:138
SWC::FS::FileSystemCeph::close
void close(int &err, SmartFd::Ptr &smartfd) override
Definition: FileSystem.cc:632
SWC::Core::Vector::size
constexpr SWC_CAN_INLINE size_type size() const noexcept
Definition: Vector.h:189
SWC::Core::Vector::emplace_back
SWC_CAN_INLINE reference emplace_back(ArgsT &&... args)
Definition: Vector.h:349
SWC::FS::FileSystem::statistics
Statistics statistics
Definition: FileSystem.h:114
SWC_FS_SYNC_FINISH
#define SWC_FS_SYNC_FINISH(_error, _smartfd, _tracker)
Definition: Logger.h:257
SWC_FS_REMOVE_START
#define SWC_FS_REMOVE_START(_path)
Definition: Logger.h:43
SWC::Config::Property::Value_int32_g
Definition: Property.h:586
SWC::FS::FileSystemCeph::get_type
Type SWC_CONST_FUNC get_type() const noexcept override
Definition: FileSystem.cc:230
SWC_FS_EXISTS_FINISH
#define SWC_FS_EXISTS_FINISH(_error, _path, _state, _tracker)
Definition: Logger.h:36