1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2009-2011 New Dream Network
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.
20 #include "auth/Crypto.h"
21 #include "client/Client.h"
22 #include "librados/RadosClient.h"
23 #include "common/ceph_argparse.h"
24 #include "common/common_init.h"
25 #include "common/config.h"
26 #include "common/version.h"
27 #include "mon/MonClient.h"
28 #include "include/str_list.h"
29 #include "messages/MMonMap.h"
30 #include "msg/Messenger.h"
31 #include "include/ceph_assert.h"
32 #include "mds/MDSMap.h"
34 #include "include/cephfs/libcephfs.h"
36 #define DEFAULT_UMASK 002
38 static mode_t
umask_cb(void *);
40 struct ceph_mount_info
42 mode_t umask
= DEFAULT_UMASK
;
44 explicit ceph_mount_info(CephContext
*cct_
)
67 catch (const std::exception
& e
) {
68 // we shouldn't get here, but if we do, we want to know about it.
69 lderr(cct
) << "ceph_mount_info::~ceph_mount_info: caught exception: "
81 if (cct
->_conf
->log_early
&&
82 !cct
->_log
->is_started()) {
87 MonClient
mc_bootstrap(cct
);
88 ret
= mc_bootstrap
.get_monmap_and_config();
93 common_init_finish(cct
);
96 monclient
= new MonClient(cct
);
97 ret
= -CEPHFS_ERROR_MON_MAP_BUILD
; //defined in libcephfs.h;
98 if (monclient
->build_initial_monmap() < 0)
102 messenger
= Messenger::create_client_messenger(cct
, "client");
105 ret
= -CEPHFS_ERROR_NEW_CLIENT
; //defined in libcephfs.h;
106 client
= new StandaloneClient(messenger
, monclient
);
110 ret
= -CEPHFS_ERROR_MESSENGER_START
; //defined in libcephfs.h;
111 if (messenger
->start() != 0)
114 ret
= client
->init();
119 client_callback_args args
= {};
121 args
.umask_cb
= umask_cb
;
122 client
->ll_register_callbacks(&args
);
125 default_perms
= Client::pick_my_perms(cct
);
134 int select_filesystem(const std::string
&fs_name_
)
144 const std::string
& get_filesystem(void)
149 int mount(const std::string
&mount_root
, const UserPerm
& perms
)
163 ret
= client
->mount(mount_root
, perms
, false, fs_name
);
183 client
->abort_conn();
200 messenger
->shutdown();
215 bool is_initialized() const
225 mode_t
set_umask(mode_t umask
)
231 std::string
getaddrs()
233 CachedStackStringStream cos
;
234 *cos
<< messenger
->get_myaddrs();
235 return std::string(cos
->strv());
238 int conf_read_file(const char *path_list
)
240 int ret
= cct
->_conf
.parse_config_files(path_list
, nullptr, 0);
243 cct
->_conf
.apply_changes(nullptr);
244 cct
->_conf
.complain_about_parse_error(cct
);
248 int conf_parse_argv(int argc
, const char **argv
)
251 vector
<const char*> args
;
252 argv_to_vec(argc
, argv
, args
);
253 ret
= cct
->_conf
.parse_argv(args
);
256 cct
->_conf
.apply_changes(nullptr);
260 int conf_parse_env(const char *name
)
262 auto& conf
= cct
->_conf
;
263 conf
.parse_env(cct
->get_module_type(), name
);
264 conf
.apply_changes(nullptr);
268 int conf_set(const char *option
, const char *value
)
270 int ret
= cct
->_conf
.set_val(option
, value
);
273 cct
->_conf
.apply_changes(nullptr);
277 int conf_get(const char *option
, char *buf
, size_t len
)
280 return cct
->_conf
.get_val(option
, &tmp
, len
);
288 const char *get_cwd(const UserPerm
& perms
)
290 client
->getcwd(cwd
, perms
);
294 int chdir(const char *to
, const UserPerm
& perms
)
296 return client
->chdir(to
, cwd
, perms
);
299 CephContext
*get_ceph_context() const {
303 UserPerm default_perms
;
307 StandaloneClient
*client
;
308 MonClient
*monclient
;
309 Messenger
*messenger
;
315 static mode_t
umask_cb(void *handle
)
317 return ((struct ceph_mount_info
*)handle
)->umask
;
320 static void do_out_buffer(bufferlist
& outbl
, char **outbuf
, size_t *outbuflen
)
323 if (outbl
.length() > 0) {
324 *outbuf
= (char *)malloc(outbl
.length());
325 memcpy(*outbuf
, outbl
.c_str(), outbl
.length());
331 *outbuflen
= outbl
.length();
334 static void do_out_buffer(string
& outbl
, char **outbuf
, size_t *outbuflen
)
337 if (outbl
.length() > 0) {
338 *outbuf
= (char *)malloc(outbl
.length());
339 memcpy(*outbuf
, outbl
.c_str(), outbl
.length());
345 *outbuflen
= outbl
.length();
348 extern "C" UserPerm
*ceph_userperm_new(uid_t uid
, gid_t gid
, int ngids
,
351 return new (std::nothrow
) UserPerm(uid
, gid
, ngids
, gidlist
);
354 extern "C" void ceph_userperm_destroy(UserPerm
*perm
)
359 extern "C" const char *ceph_version(int *pmajor
, int *pminor
, int *ppatch
)
361 int major
, minor
, patch
;
362 const char *v
= ceph_version_to_str();
364 int n
= sscanf(v
, "%d.%d.%d", &major
, &minor
, &patch
);
366 *pmajor
= (n
>= 1) ? major
: 0;
368 *pminor
= (n
>= 2) ? minor
: 0;
370 *ppatch
= (n
>= 3) ? patch
: 0;
371 return PROJECT_VERSION
;
374 extern "C" int ceph_create_with_context(struct ceph_mount_info
**cmount
, CephContext
*cct
)
376 *cmount
= new struct ceph_mount_info(cct
);
380 extern "C" int ceph_create_from_rados(struct ceph_mount_info
**cmount
,
383 auto rados
= (librados::RadosClient
*) cluster
;
384 auto cct
= rados
->cct
;
385 return ceph_create_with_context(cmount
, cct
);
388 extern "C" int ceph_create(struct ceph_mount_info
**cmount
, const char * const id
)
390 CephInitParameters
iparams(CEPH_ENTITY_TYPE_CLIENT
);
392 iparams
.name
.set(CEPH_ENTITY_TYPE_CLIENT
, id
);
395 CephContext
*cct
= common_preinit(iparams
, CODE_ENVIRONMENT_LIBRARY
, 0);
396 cct
->_conf
.parse_env(cct
->get_module_type()); // environment variables coverride
397 cct
->_conf
.apply_changes(nullptr);
398 int ret
= ceph_create_with_context(cmount
, cct
);
404 extern "C" int ceph_unmount(struct ceph_mount_info
*cmount
)
406 return cmount
->unmount();
409 extern "C" int ceph_abort_conn(struct ceph_mount_info
*cmount
)
411 return cmount
->abort_conn();
414 extern "C" int ceph_release(struct ceph_mount_info
*cmount
)
416 if (cmount
->is_mounted())
423 extern "C" void ceph_shutdown(struct ceph_mount_info
*cmount
)
430 extern "C" uint64_t ceph_get_instance_id(struct ceph_mount_info
*cmount
)
432 if (cmount
->is_initialized())
433 return cmount
->get_client()->get_nodeid().v
;
437 extern "C" int ceph_getaddrs(struct ceph_mount_info
*cmount
, char** addrs
)
439 if (!cmount
->is_initialized())
441 auto s
= cmount
->getaddrs();
442 *addrs
= strdup(s
.c_str());
446 extern "C" int ceph_conf_read_file(struct ceph_mount_info
*cmount
, const char *path
)
448 return cmount
->conf_read_file(path
);
451 extern "C" mode_t
ceph_umask(struct ceph_mount_info
*cmount
, mode_t mode
)
453 return cmount
->set_umask(mode
);
456 extern "C" int ceph_conf_parse_argv(struct ceph_mount_info
*cmount
, int argc
,
459 return cmount
->conf_parse_argv(argc
, argv
);
462 extern "C" int ceph_conf_parse_env(struct ceph_mount_info
*cmount
, const char *name
)
464 return cmount
->conf_parse_env(name
);
467 extern "C" int ceph_conf_set(struct ceph_mount_info
*cmount
, const char *option
,
470 return cmount
->conf_set(option
, value
);
473 extern "C" int ceph_conf_get(struct ceph_mount_info
*cmount
, const char *option
,
474 char *buf
, size_t len
)
479 return cmount
->conf_get(option
, buf
, len
);
482 extern "C" int ceph_mds_command(struct ceph_mount_info
*cmount
,
483 const char *mds_spec
,
486 const char *inbuf
, size_t inbuflen
,
487 char **outbuf
, size_t *outbuflen
,
488 char **outsbuf
, size_t *outsbuflen
)
492 std::vector
<string
> cmdv
;
495 if (!cmount
->is_initialized()) {
500 for (size_t i
= 0; i
< cmdlen
; ++i
) {
501 cmdv
.push_back(cmd
[i
]);
503 inbl
.append(inbuf
, inbuflen
);
505 // Issue remote command
507 int r
= cmount
->get_client()->mds_command(
517 // Wait for completion
521 do_out_buffer(outbl
, outbuf
, outbuflen
);
522 do_out_buffer(outs
, outsbuf
, outsbuflen
);
528 extern "C" int ceph_init(struct ceph_mount_info
*cmount
)
530 return cmount
->init();
533 extern "C" int ceph_select_filesystem(struct ceph_mount_info
*cmount
,
536 if (fs_name
== nullptr) {
540 return cmount
->select_filesystem(fs_name
);
543 extern "C" int ceph_mount(struct ceph_mount_info
*cmount
, const char *root
)
545 std::string mount_root
;
548 return cmount
->mount(mount_root
, cmount
->default_perms
);
551 extern "C" int ceph_is_mounted(struct ceph_mount_info
*cmount
)
553 return cmount
->is_mounted() ? 1 : 0;
556 extern "C" struct UserPerm
*ceph_mount_perms(struct ceph_mount_info
*cmount
)
558 return &cmount
->default_perms
;
561 extern "C" int64_t ceph_get_fs_cid(struct ceph_mount_info
*cmount
)
563 if (!cmount
->is_mounted())
565 return cmount
->get_client()->get_fs_cid();
568 extern "C" int ceph_mount_perms_set(struct ceph_mount_info
*cmount
,
569 struct UserPerm
*perms
)
571 if (cmount
->is_mounted())
573 cmount
->default_perms
= *perms
;
577 extern "C" int ceph_statfs(struct ceph_mount_info
*cmount
, const char *path
,
578 struct statvfs
*stbuf
)
580 if (!cmount
->is_mounted())
582 return cmount
->get_client()->statfs(path
, stbuf
, cmount
->default_perms
);
585 extern "C" int ceph_get_local_osd(struct ceph_mount_info
*cmount
)
587 if (!cmount
->is_mounted())
589 return cmount
->get_client()->get_local_osd();
592 extern "C" const char* ceph_getcwd(struct ceph_mount_info
*cmount
)
594 return cmount
->get_cwd(cmount
->default_perms
);
597 extern "C" int ceph_chdir (struct ceph_mount_info
*cmount
, const char *s
)
599 if (!cmount
->is_mounted())
601 return cmount
->chdir(s
, cmount
->default_perms
);
604 extern "C" int ceph_opendir(struct ceph_mount_info
*cmount
,
605 const char *name
, struct ceph_dir_result
**dirpp
)
607 if (!cmount
->is_mounted())
609 return cmount
->get_client()->opendir(name
, (dir_result_t
**)dirpp
, cmount
->default_perms
);
612 extern "C" int ceph_closedir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
614 if (!cmount
->is_mounted())
616 return cmount
->get_client()->closedir(reinterpret_cast<dir_result_t
*>(dirp
));
619 extern "C" struct dirent
* ceph_readdir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
621 if (!cmount
->is_mounted()) {
622 /* Client::readdir also sets errno to signal errors. */
626 return cmount
->get_client()->readdir(reinterpret_cast<dir_result_t
*>(dirp
));
629 extern "C" int ceph_readdir_r(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
, struct dirent
*de
)
631 if (!cmount
->is_mounted())
633 return cmount
->get_client()->readdir_r(reinterpret_cast<dir_result_t
*>(dirp
), de
);
636 extern "C" int ceph_readdirplus_r(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
637 struct dirent
*de
, struct ceph_statx
*stx
, unsigned want
,
638 unsigned flags
, struct Inode
**out
)
640 if (!cmount
->is_mounted())
642 if (flags
& ~CEPH_REQ_FLAG_MASK
)
644 return cmount
->get_client()->readdirplus_r(reinterpret_cast<dir_result_t
*>(dirp
), de
, stx
, want
, flags
, out
);
647 extern "C" int ceph_getdents(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
648 char *buf
, int buflen
)
650 if (!cmount
->is_mounted())
652 return cmount
->get_client()->getdents(reinterpret_cast<dir_result_t
*>(dirp
), buf
, buflen
);
655 extern "C" int ceph_getdnames(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
656 char *buf
, int buflen
)
658 if (!cmount
->is_mounted())
660 return cmount
->get_client()->getdnames(reinterpret_cast<dir_result_t
*>(dirp
), buf
, buflen
);
663 extern "C" void ceph_rewinddir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
665 if (!cmount
->is_mounted())
667 cmount
->get_client()->rewinddir(reinterpret_cast<dir_result_t
*>(dirp
));
670 extern "C" int64_t ceph_telldir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
672 if (!cmount
->is_mounted())
674 return cmount
->get_client()->telldir(reinterpret_cast<dir_result_t
*>(dirp
));
677 extern "C" void ceph_seekdir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
, int64_t offset
)
679 if (!cmount
->is_mounted())
681 cmount
->get_client()->seekdir(reinterpret_cast<dir_result_t
*>(dirp
), offset
);
684 extern "C" int ceph_link (struct ceph_mount_info
*cmount
, const char *existing
,
687 if (!cmount
->is_mounted())
689 return cmount
->get_client()->link(existing
, newname
, cmount
->default_perms
);
692 extern "C" int ceph_unlink(struct ceph_mount_info
*cmount
, const char *path
)
694 if (!cmount
->is_mounted())
696 return cmount
->get_client()->unlink(path
, cmount
->default_perms
);
699 extern "C" int ceph_rename(struct ceph_mount_info
*cmount
, const char *from
,
702 if (!cmount
->is_mounted())
704 return cmount
->get_client()->rename(from
, to
, cmount
->default_perms
);
708 extern "C" int ceph_mkdir(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
710 if (!cmount
->is_mounted())
712 return cmount
->get_client()->mkdir(path
, mode
, cmount
->default_perms
);
715 extern "C" int ceph_mkdirs(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
717 if (!cmount
->is_mounted())
719 return cmount
->get_client()->mkdirs(path
, mode
, cmount
->default_perms
);
722 extern "C" int ceph_rmdir(struct ceph_mount_info
*cmount
, const char *path
)
724 if (!cmount
->is_mounted())
726 return cmount
->get_client()->rmdir(path
, cmount
->default_perms
);
730 extern "C" int ceph_readlink(struct ceph_mount_info
*cmount
, const char *path
,
731 char *buf
, int64_t size
)
733 if (!cmount
->is_mounted())
735 return cmount
->get_client()->readlink(path
, buf
, size
, cmount
->default_perms
);
738 extern "C" int ceph_symlink(struct ceph_mount_info
*cmount
, const char *existing
,
741 if (!cmount
->is_mounted())
743 return cmount
->get_client()->symlink(existing
, newname
, cmount
->default_perms
);
746 extern "C" int ceph_fstatx(struct ceph_mount_info
*cmount
, int fd
, struct ceph_statx
*stx
,
747 unsigned int want
, unsigned int flags
)
749 if (!cmount
->is_mounted())
751 if (flags
& ~CEPH_REQ_FLAG_MASK
)
753 return cmount
->get_client()->fstatx(fd
, stx
, cmount
->default_perms
,
757 extern "C" int ceph_statx(struct ceph_mount_info
*cmount
, const char *path
,
758 struct ceph_statx
*stx
, unsigned int want
, unsigned int flags
)
760 if (!cmount
->is_mounted())
762 if (flags
& ~CEPH_REQ_FLAG_MASK
)
764 return cmount
->get_client()->statx(path
, stx
, cmount
->default_perms
,
768 extern "C" int ceph_fsetattrx(struct ceph_mount_info
*cmount
, int fd
,
769 struct ceph_statx
*stx
, int mask
)
771 if (!cmount
->is_mounted())
773 return cmount
->get_client()->fsetattrx(fd
, stx
, mask
, cmount
->default_perms
);
776 extern "C" int ceph_setattrx(struct ceph_mount_info
*cmount
, const char *relpath
,
777 struct ceph_statx
*stx
, int mask
, int flags
)
779 if (!cmount
->is_mounted())
781 if (flags
& ~CEPH_REQ_FLAG_MASK
)
783 return cmount
->get_client()->setattrx(relpath
, stx
, mask
,
784 cmount
->default_perms
, flags
);
787 // *xattr() calls supporting samba/vfs
788 extern "C" int ceph_getxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, void *value
, size_t size
)
790 if (!cmount
->is_mounted())
793 return cmount
->get_client()->getxattr(path
, name
, value
, size
, cmount
->default_perms
);
796 extern "C" int ceph_lgetxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, void *value
, size_t size
)
798 if (!cmount
->is_mounted())
800 return cmount
->get_client()->lgetxattr(path
, name
, value
, size
, cmount
->default_perms
);
803 extern "C" int ceph_fgetxattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
, void *value
, size_t size
)
805 if (!cmount
->is_mounted())
807 return cmount
->get_client()->fgetxattr(fd
, name
, value
, size
, cmount
->default_perms
);
811 extern "C" int ceph_listxattr(struct ceph_mount_info
*cmount
, const char *path
, char *list
, size_t size
)
813 if (!cmount
->is_mounted())
815 return cmount
->get_client()->listxattr(path
, list
, size
, cmount
->default_perms
);
818 extern "C" int ceph_llistxattr(struct ceph_mount_info
*cmount
, const char *path
, char *list
, size_t size
)
820 if (!cmount
->is_mounted())
822 return cmount
->get_client()->llistxattr(path
, list
, size
, cmount
->default_perms
);
825 extern "C" int ceph_flistxattr(struct ceph_mount_info
*cmount
, int fd
, char *list
, size_t size
)
827 if (!cmount
->is_mounted())
829 return cmount
->get_client()->flistxattr(fd
, list
, size
, cmount
->default_perms
);
832 extern "C" int ceph_removexattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
)
834 if (!cmount
->is_mounted())
836 return cmount
->get_client()->removexattr(path
, name
, cmount
->default_perms
);
839 extern "C" int ceph_lremovexattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
)
841 if (!cmount
->is_mounted())
843 return cmount
->get_client()->lremovexattr(path
, name
, cmount
->default_perms
);
846 extern "C" int ceph_fremovexattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
)
848 if (!cmount
->is_mounted())
850 return cmount
->get_client()->fremovexattr(fd
, name
, cmount
->default_perms
);
853 extern "C" int ceph_setxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
855 if (!cmount
->is_mounted())
857 return cmount
->get_client()->setxattr(path
, name
, value
, size
, flags
, cmount
->default_perms
);
860 extern "C" int ceph_lsetxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
862 if (!cmount
->is_mounted())
864 return cmount
->get_client()->lsetxattr(path
, name
, value
, size
, flags
, cmount
->default_perms
);
867 extern "C" int ceph_fsetxattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
, const void *value
, size_t size
, int flags
)
869 if (!cmount
->is_mounted())
871 return cmount
->get_client()->fsetxattr(fd
, name
, value
, size
, flags
, cmount
->default_perms
);
873 /* end xattr support */
875 extern "C" int ceph_stat(struct ceph_mount_info
*cmount
, const char *path
, struct stat
*stbuf
)
877 if (!cmount
->is_mounted())
879 return cmount
->get_client()->stat(path
, stbuf
, cmount
->default_perms
);
882 extern "C" int ceph_fstat(struct ceph_mount_info
*cmount
, int fd
, struct stat
*stbuf
)
884 if (!cmount
->is_mounted())
886 return cmount
->get_client()->fstat(fd
, stbuf
, cmount
->default_perms
);
889 extern int ceph_lstat(struct ceph_mount_info
*cmount
, const char *path
, struct stat
*stbuf
)
891 if (!cmount
->is_mounted())
893 return cmount
->get_client()->lstat(path
, stbuf
, cmount
->default_perms
);
896 extern "C" int ceph_chmod(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
898 if (!cmount
->is_mounted())
900 return cmount
->get_client()->chmod(path
, mode
, cmount
->default_perms
);
902 extern "C" int ceph_fchmod(struct ceph_mount_info
*cmount
, int fd
, mode_t mode
)
904 if (!cmount
->is_mounted())
906 return cmount
->get_client()->fchmod(fd
, mode
, cmount
->default_perms
);
908 extern "C" int ceph_chown(struct ceph_mount_info
*cmount
, const char *path
,
911 if (!cmount
->is_mounted())
913 return cmount
->get_client()->chown(path
, uid
, gid
, cmount
->default_perms
);
915 extern "C" int ceph_fchown(struct ceph_mount_info
*cmount
, int fd
,
918 if (!cmount
->is_mounted())
920 return cmount
->get_client()->fchown(fd
, uid
, gid
, cmount
->default_perms
);
922 extern "C" int ceph_lchown(struct ceph_mount_info
*cmount
, const char *path
,
925 if (!cmount
->is_mounted())
927 return cmount
->get_client()->lchown(path
, uid
, gid
, cmount
->default_perms
);
931 extern "C" int ceph_utime(struct ceph_mount_info
*cmount
, const char *path
,
934 if (!cmount
->is_mounted())
936 return cmount
->get_client()->utime(path
, buf
, cmount
->default_perms
);
939 extern "C" int ceph_futime(struct ceph_mount_info
*cmount
, int fd
,
942 if (!cmount
->is_mounted())
944 return cmount
->get_client()->futime(fd
, buf
, cmount
->default_perms
);
947 extern "C" int ceph_utimes(struct ceph_mount_info
*cmount
, const char *path
,
948 struct timeval times
[2])
950 if (!cmount
->is_mounted())
952 return cmount
->get_client()->utimes(path
, times
, cmount
->default_perms
);
955 extern "C" int ceph_lutimes(struct ceph_mount_info
*cmount
, const char *path
,
956 struct timeval times
[2])
958 if (!cmount
->is_mounted())
960 return cmount
->get_client()->lutimes(path
, times
, cmount
->default_perms
);
963 extern "C" int ceph_futimes(struct ceph_mount_info
*cmount
, int fd
,
964 struct timeval times
[2])
966 if (!cmount
->is_mounted())
968 return cmount
->get_client()->futimes(fd
, times
, cmount
->default_perms
);
971 extern "C" int ceph_futimens(struct ceph_mount_info
*cmount
, int fd
,
972 struct timespec times
[2])
974 if (!cmount
->is_mounted())
976 return cmount
->get_client()->futimens(fd
, times
, cmount
->default_perms
);
979 extern "C" int ceph_flock(struct ceph_mount_info
*cmount
, int fd
, int operation
,
982 if (!cmount
->is_mounted())
984 return cmount
->get_client()->flock(fd
, operation
, owner
);
987 extern "C" int ceph_truncate(struct ceph_mount_info
*cmount
, const char *path
,
990 if (!cmount
->is_mounted())
992 return cmount
->get_client()->truncate(path
, size
, cmount
->default_perms
);
996 extern "C" int ceph_mknod(struct ceph_mount_info
*cmount
, const char *path
,
997 mode_t mode
, dev_t rdev
)
999 if (!cmount
->is_mounted())
1001 return cmount
->get_client()->mknod(path
, mode
, cmount
->default_perms
, rdev
);
1004 extern "C" int ceph_open(struct ceph_mount_info
*cmount
, const char *path
,
1005 int flags
, mode_t mode
)
1007 if (!cmount
->is_mounted())
1009 return cmount
->get_client()->open(path
, flags
, cmount
->default_perms
, mode
);
1012 extern "C" int ceph_open_layout(struct ceph_mount_info
*cmount
, const char *path
, int flags
,
1013 mode_t mode
, int stripe_unit
, int stripe_count
, int object_size
, const char *data_pool
)
1015 if (!cmount
->is_mounted())
1017 return cmount
->get_client()->open(path
, flags
, cmount
->default_perms
, mode
,
1018 stripe_unit
, stripe_count
,
1019 object_size
, data_pool
);
1022 extern "C" int ceph_close(struct ceph_mount_info
*cmount
, int fd
)
1024 if (!cmount
->is_mounted())
1026 return cmount
->get_client()->close(fd
);
1029 extern "C" int64_t ceph_lseek(struct ceph_mount_info
*cmount
, int fd
,
1030 int64_t offset
, int whence
)
1032 if (!cmount
->is_mounted())
1034 return cmount
->get_client()->lseek(fd
, offset
, whence
);
1037 extern "C" int ceph_read(struct ceph_mount_info
*cmount
, int fd
, char *buf
,
1038 int64_t size
, int64_t offset
)
1040 if (!cmount
->is_mounted())
1042 return cmount
->get_client()->read(fd
, buf
, size
, offset
);
1045 extern "C" int ceph_preadv(struct ceph_mount_info
*cmount
, int fd
,
1046 const struct iovec
*iov
, int iovcnt
, int64_t offset
)
1048 if (!cmount
->is_mounted())
1050 return cmount
->get_client()->preadv(fd
, iov
, iovcnt
, offset
);
1053 extern "C" int ceph_write(struct ceph_mount_info
*cmount
, int fd
, const char *buf
,
1054 int64_t size
, int64_t offset
)
1056 if (!cmount
->is_mounted())
1058 return cmount
->get_client()->write(fd
, buf
, size
, offset
);
1061 extern "C" int ceph_pwritev(struct ceph_mount_info
*cmount
, int fd
,
1062 const struct iovec
*iov
, int iovcnt
, int64_t offset
)
1064 if (!cmount
->is_mounted())
1066 return cmount
->get_client()->pwritev(fd
, iov
, iovcnt
, offset
);
1069 extern "C" int ceph_ftruncate(struct ceph_mount_info
*cmount
, int fd
, int64_t size
)
1071 if (!cmount
->is_mounted())
1073 return cmount
->get_client()->ftruncate(fd
, size
, cmount
->default_perms
);
1076 extern "C" int ceph_fsync(struct ceph_mount_info
*cmount
, int fd
, int syncdataonly
)
1078 if (!cmount
->is_mounted())
1080 return cmount
->get_client()->fsync(fd
, syncdataonly
);
1083 extern "C" int ceph_fallocate(struct ceph_mount_info
*cmount
, int fd
, int mode
,
1084 int64_t offset
, int64_t length
)
1086 if (!cmount
->is_mounted())
1088 return cmount
->get_client()->fallocate(fd
, mode
, offset
, length
);
1091 extern "C" int ceph_lazyio(class ceph_mount_info
*cmount
,
1094 return (cmount
->get_client()->lazyio(fd
, enable
));
1097 extern "C" int ceph_lazyio_propagate(class ceph_mount_info
*cmount
,
1098 int fd
, int64_t offset
, size_t count
)
1100 if (!cmount
->is_mounted())
1102 return (cmount
->get_client()->lazyio_propagate(fd
, offset
, count
));
1105 extern "C" int ceph_lazyio_synchronize(class ceph_mount_info
*cmount
,
1106 int fd
, int64_t offset
, size_t count
)
1108 if (!cmount
->is_mounted())
1110 return (cmount
->get_client()->lazyio_synchronize(fd
, offset
, count
));
1114 extern "C" int ceph_sync_fs(struct ceph_mount_info
*cmount
)
1116 if (!cmount
->is_mounted())
1118 return cmount
->get_client()->sync_fs();
1121 extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info
*cmount
, int fh
)
1126 if (!cmount
->is_mounted())
1128 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1131 return l
.stripe_unit
;
1134 extern "C" int ceph_get_path_stripe_unit(struct ceph_mount_info
*cmount
, const char *path
)
1139 if (!cmount
->is_mounted())
1141 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1144 return l
.stripe_unit
;
1147 extern "C" int ceph_get_file_stripe_count(struct ceph_mount_info
*cmount
, int fh
)
1152 if (!cmount
->is_mounted())
1154 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1157 return l
.stripe_count
;
1160 extern "C" int ceph_get_path_stripe_count(struct ceph_mount_info
*cmount
, const char *path
)
1165 if (!cmount
->is_mounted())
1167 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1170 return l
.stripe_count
;
1173 extern "C" int ceph_get_file_object_size(struct ceph_mount_info
*cmount
, int fh
)
1178 if (!cmount
->is_mounted())
1180 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1183 return l
.object_size
;
1186 extern "C" int ceph_get_path_object_size(struct ceph_mount_info
*cmount
, const char *path
)
1191 if (!cmount
->is_mounted())
1193 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1196 return l
.object_size
;
1199 extern "C" int ceph_get_file_pool(struct ceph_mount_info
*cmount
, int fh
)
1204 if (!cmount
->is_mounted())
1206 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1212 extern "C" int ceph_get_path_pool(struct ceph_mount_info
*cmount
, const char *path
)
1217 if (!cmount
->is_mounted())
1219 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1225 extern "C" int ceph_get_file_pool_name(struct ceph_mount_info
*cmount
, int fh
, char *buf
, size_t len
)
1230 if (!cmount
->is_mounted())
1232 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1235 string name
= cmount
->get_client()->get_pool_name(l
.pool_id
);
1237 return name
.length();
1238 if (name
.length() > len
)
1240 strncpy(buf
, name
.c_str(), len
);
1241 return name
.length();
1244 extern "C" int ceph_get_pool_name(struct ceph_mount_info
*cmount
, int pool
, char *buf
, size_t len
)
1246 if (!cmount
->is_mounted())
1248 string name
= cmount
->get_client()->get_pool_name(pool
);
1250 return name
.length();
1251 if (name
.length() > len
)
1253 strncpy(buf
, name
.c_str(), len
);
1254 return name
.length();
1257 extern "C" int ceph_get_path_pool_name(struct ceph_mount_info
*cmount
, const char *path
, char *buf
, size_t len
)
1262 if (!cmount
->is_mounted())
1264 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1267 string name
= cmount
->get_client()->get_pool_name(l
.pool_id
);
1269 return name
.length();
1270 if (name
.length() > len
)
1272 strncpy(buf
, name
.c_str(), len
);
1273 return name
.length();
1276 extern "C" int ceph_get_default_data_pool_name(struct ceph_mount_info
*cmount
, char *buf
, size_t len
)
1278 if (!cmount
->is_mounted())
1280 int64_t pool_id
= cmount
->get_client()->get_default_pool_id();
1282 string name
= cmount
->get_client()->get_pool_name(pool_id
);
1284 return name
.length();
1285 if (name
.length() > len
)
1287 strncpy(buf
, name
.c_str(), len
);
1288 return name
.length();
1291 extern "C" int ceph_get_file_layout(struct ceph_mount_info
*cmount
, int fh
, int *stripe_unit
, int *stripe_count
, int *object_size
, int *pg_pool
)
1296 if (!cmount
->is_mounted())
1298 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1302 *stripe_unit
= l
.stripe_unit
;
1304 *stripe_count
= l
.stripe_count
;
1306 *object_size
= l
.object_size
;
1308 *pg_pool
= l
.pool_id
;
1312 extern "C" int ceph_get_path_layout(struct ceph_mount_info
*cmount
, const char *path
, int *stripe_unit
, int *stripe_count
, int *object_size
, int *pg_pool
)
1317 if (!cmount
->is_mounted())
1319 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1323 *stripe_unit
= l
.stripe_unit
;
1325 *stripe_count
= l
.stripe_count
;
1327 *object_size
= l
.object_size
;
1329 *pg_pool
= l
.pool_id
;
1333 extern "C" int ceph_get_file_replication(struct ceph_mount_info
*cmount
, int fh
)
1338 if (!cmount
->is_mounted())
1340 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1343 int rep
= cmount
->get_client()->get_pool_replication(l
.pool_id
);
1347 extern "C" int ceph_get_path_replication(struct ceph_mount_info
*cmount
, const char *path
)
1352 if (!cmount
->is_mounted())
1354 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1357 int rep
= cmount
->get_client()->get_pool_replication(l
.pool_id
);
1361 extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info
*cmount
,
1364 // this option no longer exists
1368 extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info
*cmount
,
1371 // this option no longer exists
1375 extern "C" int ceph_set_default_object_size(struct ceph_mount_info
*cmount
, int size
)
1377 // this option no longer exists
1381 extern "C" int ceph_set_default_file_replication(struct ceph_mount_info
*cmount
,
1384 // this option no longer exists
1388 extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info
*cmount
, int osd
)
1390 // this option no longer exists
1394 extern "C" int ceph_get_file_extent_osds(struct ceph_mount_info
*cmount
, int fh
,
1395 int64_t offset
, int64_t *length
, int *osds
, int nosds
)
1400 if (!cmount
->is_mounted())
1404 int ret
= cmount
->get_client()->get_file_extent_osds(fh
, offset
, length
, vosds
);
1409 return vosds
.size();
1411 if ((int)vosds
.size() > nosds
)
1414 for (int i
= 0; i
< (int)vosds
.size(); i
++)
1417 return vosds
.size();
1420 extern "C" int ceph_get_osd_crush_location(struct ceph_mount_info
*cmount
,
1421 int osd
, char *path
, size_t len
)
1423 if (!cmount
->is_mounted())
1429 vector
<pair
<string
, string
> > loc
;
1430 int ret
= cmount
->get_client()->get_osd_crush_location(osd
, loc
);
1436 vector
<pair
<string
, string
> >::iterator it
;
1437 for (it
= loc
.begin(); it
!= loc
.end(); ++it
) {
1438 string
& type
= it
->first
;
1439 string
& name
= it
->second
;
1440 needed
+= type
.size() + name
.size() + 2;
1441 if (needed
<= len
) {
1443 strcpy(path
+ cur
, type
.c_str());
1444 cur
+= type
.size() + 1;
1446 strcpy(path
+ cur
, name
.c_str());
1447 cur
+= name
.size() + 1;
1460 extern "C" int ceph_get_osd_addr(struct ceph_mount_info
*cmount
, int osd
,
1461 struct sockaddr_storage
*addr
)
1463 if (!cmount
->is_mounted())
1469 entity_addr_t address
;
1470 int ret
= cmount
->get_client()->get_osd_addr(osd
, address
);
1474 *addr
= address
.get_sockaddr_storage();
1479 extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info
*cmount
, int fh
,
1480 int64_t offset
, struct sockaddr_storage
*addr
, int naddr
)
1482 vector
<entity_addr_t
> address
;
1489 if (!cmount
->is_mounted())
1492 r
= cmount
->get_client()->get_file_stripe_address(fh
, offset
, address
);
1496 for (i
= 0; i
< (unsigned)naddr
&& i
< address
.size(); i
++)
1497 addr
[i
] = address
[i
].get_sockaddr_storage();
1499 /* naddr == 0: drop through and return actual size */
1500 if (naddr
&& (address
.size() > (unsigned)naddr
))
1503 return address
.size();
1506 extern "C" int ceph_localize_reads(struct ceph_mount_info
*cmount
, int val
)
1508 if (!cmount
->is_mounted())
1511 cmount
->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS
);
1513 cmount
->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS
);
1517 extern "C" CephContext
*ceph_get_mount_context(struct ceph_mount_info
*cmount
)
1519 return cmount
->get_ceph_context();
1522 extern "C" int ceph_debug_get_fd_caps(struct ceph_mount_info
*cmount
, int fd
)
1524 if (!cmount
->is_mounted())
1526 return cmount
->get_client()->get_caps_issued(fd
);
1529 extern "C" int ceph_debug_get_file_caps(struct ceph_mount_info
*cmount
, const char *path
)
1531 if (!cmount
->is_mounted())
1533 return cmount
->get_client()->get_caps_issued(path
, cmount
->default_perms
);
1536 extern "C" int ceph_get_stripe_unit_granularity(struct ceph_mount_info
*cmount
)
1538 if (!cmount
->is_mounted())
1540 return CEPH_MIN_STRIPE_UNIT
;
1543 extern "C" int ceph_get_pool_id(struct ceph_mount_info
*cmount
, const char *pool_name
)
1545 if (!cmount
->is_mounted())
1548 if (!pool_name
|| !pool_name
[0])
1551 /* negative range reserved for errors */
1552 int64_t pool_id
= cmount
->get_client()->get_pool_id(pool_name
);
1553 if (pool_id
> 0x7fffffff)
1556 /* get_pool_id error codes fit in int */
1557 return (int)pool_id
;
1560 extern "C" int ceph_get_pool_replication(struct ceph_mount_info
*cmount
,
1563 if (!cmount
->is_mounted())
1565 return cmount
->get_client()->get_pool_replication(pool_id
);
1567 /* Low-level exports */
1569 extern "C" int ceph_ll_lookup_root(struct ceph_mount_info
*cmount
,
1572 *parent
= cmount
->get_client()->get_root();
1578 extern "C" struct Inode
*ceph_ll_get_inode(class ceph_mount_info
*cmount
,
1581 return (cmount
->get_client())->ll_get_inode(vino
);
1586 * Populates the client cache with the requested inode, and its
1589 extern "C" int ceph_ll_lookup_inode(
1590 struct ceph_mount_info
*cmount
,
1591 struct inodeno_t ino
,
1594 return (cmount
->get_client())->ll_lookup_inode(ino
, cmount
->default_perms
, inode
);
1597 extern "C" int ceph_ll_lookup(struct ceph_mount_info
*cmount
,
1598 Inode
*parent
, const char *name
, Inode
**out
,
1599 struct ceph_statx
*stx
, unsigned want
,
1600 unsigned flags
, const UserPerm
*perms
)
1602 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1604 return (cmount
->get_client())->ll_lookupx(parent
, name
, out
, stx
, want
,
1608 extern "C" int ceph_ll_put(class ceph_mount_info
*cmount
, Inode
*in
)
1610 return (cmount
->get_client()->ll_put(in
));
1613 extern "C" int ceph_ll_forget(class ceph_mount_info
*cmount
, Inode
*in
,
1616 return (cmount
->get_client()->ll_forget(in
, count
));
1619 extern "C" int ceph_ll_walk(struct ceph_mount_info
*cmount
, const char* name
, Inode
**i
,
1620 struct ceph_statx
*stx
, unsigned int want
, unsigned int flags
,
1621 const UserPerm
*perms
)
1623 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1625 return(cmount
->get_client()->ll_walk(name
, i
, stx
, want
, flags
, *perms
));
1628 extern "C" int ceph_ll_getattr(class ceph_mount_info
*cmount
,
1629 Inode
*in
, struct ceph_statx
*stx
,
1630 unsigned int want
, unsigned int flags
,
1631 const UserPerm
*perms
)
1633 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1635 return (cmount
->get_client()->ll_getattrx(in
, stx
, want
, flags
, *perms
));
1638 extern "C" int ceph_ll_setattr(class ceph_mount_info
*cmount
,
1639 Inode
*in
, struct ceph_statx
*stx
,
1640 int mask
, const UserPerm
*perms
)
1642 return (cmount
->get_client()->ll_setattrx(in
, stx
, mask
, *perms
));
1645 extern "C" int ceph_ll_open(class ceph_mount_info
*cmount
, Inode
*in
,
1646 int flags
, Fh
**fh
, const UserPerm
*perms
)
1648 return (cmount
->get_client()->ll_open(in
, flags
, fh
, *perms
));
1651 extern "C" int ceph_ll_read(class ceph_mount_info
*cmount
, Fh
* filehandle
,
1652 int64_t off
, uint64_t len
, char* buf
)
1657 r
= cmount
->get_client()->ll_read(filehandle
, off
, len
, &bl
);
1660 bl
.begin().copy(bl
.length(), buf
);
1666 extern "C" int ceph_ll_read_block(class ceph_mount_info
*cmount
,
1667 Inode
*in
, uint64_t blockid
,
1668 char* buf
, uint64_t offset
,
1670 struct ceph_file_layout
* layout
)
1673 int r
= (cmount
->get_client()->ll_read_block(in
, blockid
, buf
, offset
,
1675 l
.to_legacy(layout
);
1679 extern "C" int ceph_ll_write_block(class ceph_mount_info
*cmount
,
1680 Inode
*in
, uint64_t blockid
,
1681 char *buf
, uint64_t offset
,
1683 struct ceph_file_layout
*layout
,
1684 uint64_t snapseq
, uint32_t sync
)
1687 int r
= (cmount
->get_client()->ll_write_block(in
, blockid
, buf
, offset
,
1688 length
, &l
, snapseq
, sync
));
1689 l
.to_legacy(layout
);
1693 extern "C" int ceph_ll_commit_blocks(class ceph_mount_info
*cmount
,
1694 Inode
*in
, uint64_t offset
,
1697 return (cmount
->get_client()->ll_commit_blocks(in
, offset
, range
));
1700 extern "C" int ceph_ll_fsync(class ceph_mount_info
*cmount
,
1701 Fh
*fh
, int syncdataonly
)
1703 return (cmount
->get_client()->ll_fsync(fh
, syncdataonly
));
1706 extern "C" int ceph_ll_sync_inode(class ceph_mount_info
*cmount
,
1707 Inode
*in
, int syncdataonly
)
1709 return (cmount
->get_client()->ll_sync_inode(in
, syncdataonly
));
1712 extern "C" int ceph_ll_fallocate(class ceph_mount_info
*cmount
, Fh
*fh
,
1713 int mode
, int64_t offset
, int64_t length
)
1715 return cmount
->get_client()->ll_fallocate(fh
, mode
, offset
, length
);
1718 extern "C" off_t
ceph_ll_lseek(class ceph_mount_info
*cmount
,
1719 Fh
*fh
, off_t offset
, int whence
)
1721 return (cmount
->get_client()->ll_lseek(fh
, offset
, whence
));
1724 extern "C" int ceph_ll_write(class ceph_mount_info
*cmount
,
1725 Fh
*fh
, int64_t off
, uint64_t len
,
1728 return (cmount
->get_client()->ll_write(fh
, off
, len
, data
));
1731 extern "C" int64_t ceph_ll_readv(class ceph_mount_info
*cmount
,
1732 struct Fh
*fh
, const struct iovec
*iov
,
1733 int iovcnt
, int64_t off
)
1735 return (cmount
->get_client()->ll_readv(fh
, iov
, iovcnt
, off
));
1738 extern "C" int64_t ceph_ll_writev(class ceph_mount_info
*cmount
,
1739 struct Fh
*fh
, const struct iovec
*iov
,
1740 int iovcnt
, int64_t off
)
1742 return (cmount
->get_client()->ll_writev(fh
, iov
, iovcnt
, off
));
1745 extern "C" int ceph_ll_close(class ceph_mount_info
*cmount
, Fh
* fh
)
1747 return (cmount
->get_client()->ll_release(fh
));
1750 extern "C" int ceph_ll_create(class ceph_mount_info
*cmount
,
1751 Inode
*parent
, const char *name
, mode_t mode
,
1752 int oflags
, Inode
**outp
, Fh
**fhp
,
1753 struct ceph_statx
*stx
, unsigned want
,
1754 unsigned lflags
, const UserPerm
*perms
)
1756 if (lflags
& ~CEPH_REQ_FLAG_MASK
)
1758 return (cmount
->get_client())->ll_createx(parent
, name
, mode
, oflags
, outp
,
1759 fhp
, stx
, want
, lflags
, *perms
);
1762 extern "C" int ceph_ll_mknod(class ceph_mount_info
*cmount
, Inode
*parent
,
1763 const char *name
, mode_t mode
, dev_t rdev
,
1764 Inode
**out
, struct ceph_statx
*stx
,
1765 unsigned want
, unsigned flags
,
1766 const UserPerm
*perms
)
1768 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1770 return (cmount
->get_client())->ll_mknodx(parent
, name
, mode
, rdev
,
1771 out
, stx
, want
, flags
, *perms
);
1774 extern "C" int ceph_ll_mkdir(class ceph_mount_info
*cmount
, Inode
*parent
,
1775 const char *name
, mode_t mode
, Inode
**out
,
1776 struct ceph_statx
*stx
, unsigned want
,
1777 unsigned flags
, const UserPerm
*perms
)
1779 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1781 return cmount
->get_client()->ll_mkdirx(parent
, name
, mode
, out
, stx
, want
,
1785 extern "C" int ceph_ll_link(class ceph_mount_info
*cmount
,
1786 Inode
*in
, Inode
*newparent
,
1787 const char *name
, const UserPerm
*perms
)
1789 return cmount
->get_client()->ll_link(in
, newparent
, name
, *perms
);
1792 extern "C" int ceph_ll_opendir(class ceph_mount_info
*cmount
,
1794 struct ceph_dir_result
**dirpp
,
1795 const UserPerm
*perms
)
1797 return (cmount
->get_client()->ll_opendir(in
, O_RDONLY
, (dir_result_t
**) dirpp
,
1801 extern "C" int ceph_ll_releasedir(class ceph_mount_info
*cmount
,
1802 ceph_dir_result
*dir
)
1804 return cmount
->get_client()->ll_releasedir(reinterpret_cast<dir_result_t
*>(dir
));
1807 extern "C" int ceph_ll_rename(class ceph_mount_info
*cmount
,
1808 Inode
*parent
, const char *name
,
1809 Inode
*newparent
, const char *newname
,
1810 const UserPerm
*perms
)
1812 return cmount
->get_client()->ll_rename(parent
, name
, newparent
,
1816 extern "C" int ceph_ll_unlink(class ceph_mount_info
*cmount
, Inode
*in
,
1817 const char *name
, const UserPerm
*perms
)
1819 return cmount
->get_client()->ll_unlink(in
, name
, *perms
);
1822 extern "C" int ceph_ll_statfs(class ceph_mount_info
*cmount
,
1823 Inode
*in
, struct statvfs
*stbuf
)
1825 return (cmount
->get_client()->ll_statfs(in
, stbuf
, cmount
->default_perms
));
1828 extern "C" int ceph_ll_readlink(class ceph_mount_info
*cmount
, Inode
*in
,
1829 char *buf
, size_t bufsiz
,
1830 const UserPerm
*perms
)
1832 return cmount
->get_client()->ll_readlink(in
, buf
, bufsiz
, *perms
);
1835 extern "C" int ceph_ll_symlink(class ceph_mount_info
*cmount
,
1836 Inode
*in
, const char *name
,
1837 const char *value
, Inode
**out
,
1838 struct ceph_statx
*stx
, unsigned want
,
1839 unsigned flags
, const UserPerm
*perms
)
1841 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1843 return (cmount
->get_client()->ll_symlinkx(in
, name
, value
, out
, stx
, want
,
1847 extern "C" int ceph_ll_rmdir(class ceph_mount_info
*cmount
,
1848 Inode
*in
, const char *name
,
1849 const UserPerm
*perms
)
1851 return cmount
->get_client()->ll_rmdir(in
, name
, *perms
);
1854 extern "C" int ceph_ll_getxattr(class ceph_mount_info
*cmount
,
1855 Inode
*in
, const char *name
, void *value
,
1856 size_t size
, const UserPerm
*perms
)
1858 return (cmount
->get_client()->ll_getxattr(in
, name
, value
, size
, *perms
));
1861 extern "C" int ceph_ll_listxattr(struct ceph_mount_info
*cmount
,
1862 Inode
*in
, char *list
,
1863 size_t buf_size
, size_t *list_size
,
1864 const UserPerm
*perms
)
1866 int res
= cmount
->get_client()->ll_listxattr(in
, list
, buf_size
, *perms
);
1868 *list_size
= (size_t)res
;
1874 extern "C" int ceph_ll_setxattr(class ceph_mount_info
*cmount
,
1875 Inode
*in
, const char *name
,
1876 const void *value
, size_t size
,
1877 int flags
, const UserPerm
*perms
)
1879 return (cmount
->get_client()->ll_setxattr(in
, name
, value
, size
, flags
, *perms
));
1882 extern "C" int ceph_ll_removexattr(class ceph_mount_info
*cmount
,
1883 Inode
*in
, const char *name
,
1884 const UserPerm
*perms
)
1886 return (cmount
->get_client()->ll_removexattr(in
, name
, *perms
));
1889 extern "C" int ceph_ll_getlk(struct ceph_mount_info
*cmount
,
1890 Fh
*fh
, struct flock
*fl
, uint64_t owner
)
1892 return (cmount
->get_client()->ll_getlk(fh
, fl
, owner
));
1895 extern "C" int ceph_ll_setlk(struct ceph_mount_info
*cmount
,
1896 Fh
*fh
, struct flock
*fl
, uint64_t owner
,
1899 return (cmount
->get_client()->ll_setlk(fh
, fl
, owner
, sleep
));
1902 extern "C" int ceph_ll_lazyio(class ceph_mount_info
*cmount
,
1905 return (cmount
->get_client()->ll_lazyio(fh
, enable
));
1908 extern "C" int ceph_ll_delegation(struct ceph_mount_info
*cmount
, Fh
*fh
,
1909 unsigned cmd
, ceph_deleg_cb_t cb
, void *priv
)
1911 return (cmount
->get_client()->ll_delegation(fh
, cmd
, cb
, priv
));
1914 extern "C" uint32_t ceph_ll_stripe_unit(class ceph_mount_info
*cmount
,
1917 return (cmount
->get_client()->ll_stripe_unit(in
));
1920 extern "C" uint32_t ceph_ll_file_layout(class ceph_mount_info
*cmount
,
1922 struct ceph_file_layout
*layout
)
1925 int r
= (cmount
->get_client()->ll_file_layout(in
, &l
));
1926 l
.to_legacy(layout
);
1930 uint64_t ceph_ll_snap_seq(class ceph_mount_info
*cmount
, Inode
*in
)
1932 return (cmount
->get_client()->ll_snap_seq(in
));
1935 extern "C" int ceph_ll_get_stripe_osd(class ceph_mount_info
*cmount
,
1936 Inode
*in
, uint64_t blockno
,
1937 struct ceph_file_layout
* layout
)
1940 int r
= (cmount
->get_client()->ll_get_stripe_osd(in
, blockno
, &l
));
1941 l
.to_legacy(layout
);
1945 extern "C" int ceph_ll_num_osds(class ceph_mount_info
*cmount
)
1947 return (cmount
->get_client()->ll_num_osds());
1950 extern "C" int ceph_ll_osdaddr(class ceph_mount_info
*cmount
,
1951 int osd
, uint32_t *addr
)
1953 return (cmount
->get_client()->ll_osdaddr(osd
, addr
));
1956 extern "C" uint64_t ceph_ll_get_internal_offset(class ceph_mount_info
*cmount
,
1960 return (cmount
->get_client()->ll_get_internal_offset(in
, blockno
));
1963 extern "C" void ceph_buffer_free(char *buf
)
1970 extern "C" uint32_t ceph_get_cap_return_timeout(class ceph_mount_info
*cmount
)
1972 if (!cmount
->is_mounted())
1974 return cmount
->get_client()->mdsmap
->get_session_autoclose().sec();
1977 extern "C" int ceph_set_deleg_timeout(class ceph_mount_info
*cmount
, uint32_t timeout
)
1979 if (!cmount
->is_mounted())
1981 return cmount
->get_client()->set_deleg_timeout(timeout
);
1984 extern "C" void ceph_set_session_timeout(class ceph_mount_info
*cmount
, unsigned timeout
)
1986 cmount
->get_client()->set_session_timeout(timeout
);
1989 extern "C" void ceph_set_uuid(class ceph_mount_info
*cmount
, const char *uuid
)
1991 cmount
->get_client()->set_uuid(std::string(uuid
));
1994 extern "C" int ceph_start_reclaim(class ceph_mount_info
*cmount
,
1995 const char *uuid
, unsigned flags
)
1997 if (!cmount
->is_initialized()) {
1998 int ret
= cmount
->init();
2002 return cmount
->get_client()->start_reclaim(std::string(uuid
), flags
,
2003 cmount
->get_filesystem());
2006 extern "C" void ceph_finish_reclaim(class ceph_mount_info
*cmount
)
2008 cmount
->get_client()->finish_reclaim();