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/Mutex.h"
24 #include "common/ceph_argparse.h"
25 #include "common/common_init.h"
26 #include "common/config.h"
27 #include "common/version.h"
28 #include "mon/MonClient.h"
29 #include "include/str_list.h"
30 #include "messages/MMonMap.h"
31 #include "msg/Messenger.h"
32 #include "include/ceph_assert.h"
33 #include "mds/MDSMap.h"
35 #include "include/cephfs/libcephfs.h"
37 #define DEFAULT_UMASK 002
39 static mode_t
umask_cb(void *);
41 struct ceph_mount_info
43 mode_t umask
= DEFAULT_UMASK
;
45 explicit ceph_mount_info(CephContext
*cct_
)
68 catch (const std::exception
& e
) {
69 // we shouldn't get here, but if we do, we want to know about it.
70 lderr(cct
) << "ceph_mount_info::~ceph_mount_info: caught exception: "
82 if (cct
->_conf
->log_early
&&
83 !cct
->_log
->is_started()) {
88 MonClient
mc_bootstrap(cct
);
89 ret
= mc_bootstrap
.get_monmap_and_config();
94 common_init_finish(cct
);
97 monclient
= new MonClient(cct
);
98 ret
= -CEPHFS_ERROR_MON_MAP_BUILD
; //defined in libcephfs.h;
99 if (monclient
->build_initial_monmap() < 0)
103 messenger
= Messenger::create_client_messenger(cct
, "client");
106 ret
= -CEPHFS_ERROR_NEW_CLIENT
; //defined in libcephfs.h;
107 client
= new StandaloneClient(messenger
, monclient
);
111 ret
= -CEPHFS_ERROR_MESSENGER_START
; //defined in libcephfs.h;
112 if (messenger
->start() != 0)
115 ret
= client
->init();
120 client_callback_args args
= {};
122 args
.umask_cb
= umask_cb
;
123 client
->ll_register_callbacks(&args
);
126 default_perms
= Client::pick_my_perms(cct
);
135 int select_filesystem(const std::string
&fs_name_
)
145 const std::string
& get_filesystem(void)
150 int mount(const std::string
&mount_root
, const UserPerm
& perms
)
164 ret
= client
->mount(mount_root
, perms
, false, fs_name
);
184 client
->abort_conn();
201 messenger
->shutdown();
216 bool is_initialized() const
226 mode_t
set_umask(mode_t umask
)
232 int conf_read_file(const char *path_list
)
234 int ret
= cct
->_conf
.parse_config_files(path_list
, nullptr, 0);
237 cct
->_conf
.apply_changes(nullptr);
238 cct
->_conf
.complain_about_parse_errors(cct
);
242 int conf_parse_argv(int argc
, const char **argv
)
245 vector
<const char*> args
;
246 argv_to_vec(argc
, argv
, args
);
247 ret
= cct
->_conf
.parse_argv(args
);
250 cct
->_conf
.apply_changes(nullptr);
254 int conf_parse_env(const char *name
)
256 auto& conf
= cct
->_conf
;
257 conf
.parse_env(cct
->get_module_type(), name
);
258 conf
.apply_changes(nullptr);
262 int conf_set(const char *option
, const char *value
)
264 int ret
= cct
->_conf
.set_val(option
, value
);
267 cct
->_conf
.apply_changes(nullptr);
271 int conf_get(const char *option
, char *buf
, size_t len
)
274 return cct
->_conf
.get_val(option
, &tmp
, len
);
282 const char *get_cwd(const UserPerm
& perms
)
284 client
->getcwd(cwd
, perms
);
288 int chdir(const char *to
, const UserPerm
& perms
)
290 return client
->chdir(to
, cwd
, perms
);
293 CephContext
*get_ceph_context() const {
297 UserPerm default_perms
;
301 StandaloneClient
*client
;
302 MonClient
*monclient
;
303 Messenger
*messenger
;
309 static mode_t
umask_cb(void *handle
)
311 return ((struct ceph_mount_info
*)handle
)->umask
;
314 static void do_out_buffer(bufferlist
& outbl
, char **outbuf
, size_t *outbuflen
)
317 if (outbl
.length() > 0) {
318 *outbuf
= (char *)malloc(outbl
.length());
319 memcpy(*outbuf
, outbl
.c_str(), outbl
.length());
325 *outbuflen
= outbl
.length();
328 static void do_out_buffer(string
& outbl
, char **outbuf
, size_t *outbuflen
)
331 if (outbl
.length() > 0) {
332 *outbuf
= (char *)malloc(outbl
.length());
333 memcpy(*outbuf
, outbl
.c_str(), outbl
.length());
339 *outbuflen
= outbl
.length();
342 extern "C" UserPerm
*ceph_userperm_new(uid_t uid
, gid_t gid
, int ngids
,
345 return new (std::nothrow
) UserPerm(uid
, gid
, ngids
, gidlist
);
348 extern "C" void ceph_userperm_destroy(UserPerm
*perm
)
353 extern "C" const char *ceph_version(int *pmajor
, int *pminor
, int *ppatch
)
355 int major
, minor
, patch
;
356 const char *v
= ceph_version_to_str();
358 int n
= sscanf(v
, "%d.%d.%d", &major
, &minor
, &patch
);
360 *pmajor
= (n
>= 1) ? major
: 0;
362 *pminor
= (n
>= 2) ? minor
: 0;
364 *ppatch
= (n
>= 3) ? patch
: 0;
368 extern "C" int ceph_create_with_context(struct ceph_mount_info
**cmount
, CephContext
*cct
)
370 *cmount
= new struct ceph_mount_info(cct
);
374 extern "C" int ceph_create_from_rados(struct ceph_mount_info
**cmount
,
377 auto rados
= (librados::RadosClient
*) cluster
;
378 auto cct
= rados
->cct
;
379 return ceph_create_with_context(cmount
, cct
);
382 extern "C" int ceph_create(struct ceph_mount_info
**cmount
, const char * const id
)
384 CephInitParameters
iparams(CEPH_ENTITY_TYPE_CLIENT
);
386 iparams
.name
.set(CEPH_ENTITY_TYPE_CLIENT
, id
);
389 CephContext
*cct
= common_preinit(iparams
, CODE_ENVIRONMENT_LIBRARY
, 0);
390 cct
->_conf
.parse_env(cct
->get_module_type()); // environment variables coverride
391 cct
->_conf
.apply_changes(nullptr);
392 int ret
= ceph_create_with_context(cmount
, cct
);
398 extern "C" int ceph_unmount(struct ceph_mount_info
*cmount
)
400 return cmount
->unmount();
403 extern "C" int ceph_abort_conn(struct ceph_mount_info
*cmount
)
405 return cmount
->abort_conn();
408 extern "C" int ceph_release(struct ceph_mount_info
*cmount
)
410 if (cmount
->is_mounted())
417 extern "C" void ceph_shutdown(struct ceph_mount_info
*cmount
)
424 extern "C" uint64_t ceph_get_instance_id(struct ceph_mount_info
*cmount
)
426 if (cmount
->is_initialized())
427 return cmount
->get_client()->get_nodeid().v
;
431 extern "C" int ceph_conf_read_file(struct ceph_mount_info
*cmount
, const char *path
)
433 return cmount
->conf_read_file(path
);
436 extern "C" mode_t
ceph_umask(struct ceph_mount_info
*cmount
, mode_t mode
)
438 return cmount
->set_umask(mode
);
441 extern "C" int ceph_conf_parse_argv(struct ceph_mount_info
*cmount
, int argc
,
444 return cmount
->conf_parse_argv(argc
, argv
);
447 extern "C" int ceph_conf_parse_env(struct ceph_mount_info
*cmount
, const char *name
)
449 return cmount
->conf_parse_env(name
);
452 extern "C" int ceph_conf_set(struct ceph_mount_info
*cmount
, const char *option
,
455 return cmount
->conf_set(option
, value
);
458 extern "C" int ceph_conf_get(struct ceph_mount_info
*cmount
, const char *option
,
459 char *buf
, size_t len
)
464 return cmount
->conf_get(option
, buf
, len
);
467 extern "C" int ceph_mds_command(struct ceph_mount_info
*cmount
,
468 const char *mds_spec
,
471 const char *inbuf
, size_t inbuflen
,
472 char **outbuf
, size_t *outbuflen
,
473 char **outsbuf
, size_t *outsbuflen
)
477 std::vector
<string
> cmdv
;
480 if (!cmount
->is_initialized()) {
485 for (size_t i
= 0; i
< cmdlen
; ++i
) {
486 cmdv
.push_back(cmd
[i
]);
488 inbl
.append(inbuf
, inbuflen
);
490 // Issue remote command
492 int r
= cmount
->get_client()->mds_command(
502 // Wait for completion
506 do_out_buffer(outbl
, outbuf
, outbuflen
);
507 do_out_buffer(outs
, outsbuf
, outsbuflen
);
513 extern "C" int ceph_init(struct ceph_mount_info
*cmount
)
515 return cmount
->init();
518 extern "C" int ceph_select_filesystem(struct ceph_mount_info
*cmount
,
521 if (fs_name
== nullptr) {
525 return cmount
->select_filesystem(fs_name
);
528 extern "C" int ceph_mount(struct ceph_mount_info
*cmount
, const char *root
)
530 std::string mount_root
;
533 return cmount
->mount(mount_root
, cmount
->default_perms
);
536 extern "C" int ceph_is_mounted(struct ceph_mount_info
*cmount
)
538 return cmount
->is_mounted() ? 1 : 0;
541 extern "C" struct UserPerm
*ceph_mount_perms(struct ceph_mount_info
*cmount
)
543 return &cmount
->default_perms
;
546 extern "C" int64_t ceph_get_fs_cid(struct ceph_mount_info
*cmount
)
548 if (!cmount
->is_mounted())
550 return cmount
->get_client()->get_fs_cid();
553 extern "C" int ceph_mount_perms_set(struct ceph_mount_info
*cmount
,
554 struct UserPerm
*perms
)
556 if (cmount
->is_mounted())
558 cmount
->default_perms
= *perms
;
562 extern "C" int ceph_statfs(struct ceph_mount_info
*cmount
, const char *path
,
563 struct statvfs
*stbuf
)
565 if (!cmount
->is_mounted())
567 return cmount
->get_client()->statfs(path
, stbuf
, cmount
->default_perms
);
570 extern "C" int ceph_get_local_osd(struct ceph_mount_info
*cmount
)
572 if (!cmount
->is_mounted())
574 return cmount
->get_client()->get_local_osd();
577 extern "C" const char* ceph_getcwd(struct ceph_mount_info
*cmount
)
579 return cmount
->get_cwd(cmount
->default_perms
);
582 extern "C" int ceph_chdir (struct ceph_mount_info
*cmount
, const char *s
)
584 if (!cmount
->is_mounted())
586 return cmount
->chdir(s
, cmount
->default_perms
);
589 extern "C" int ceph_opendir(struct ceph_mount_info
*cmount
,
590 const char *name
, struct ceph_dir_result
**dirpp
)
592 if (!cmount
->is_mounted())
594 return cmount
->get_client()->opendir(name
, (dir_result_t
**)dirpp
, cmount
->default_perms
);
597 extern "C" int ceph_closedir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
599 if (!cmount
->is_mounted())
601 return cmount
->get_client()->closedir(reinterpret_cast<dir_result_t
*>(dirp
));
604 extern "C" struct dirent
* ceph_readdir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
606 if (!cmount
->is_mounted()) {
607 /* Client::readdir also sets errno to signal errors. */
611 return cmount
->get_client()->readdir(reinterpret_cast<dir_result_t
*>(dirp
));
614 extern "C" int ceph_readdir_r(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
, struct dirent
*de
)
616 if (!cmount
->is_mounted())
618 return cmount
->get_client()->readdir_r(reinterpret_cast<dir_result_t
*>(dirp
), de
);
621 extern "C" int ceph_readdirplus_r(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
622 struct dirent
*de
, struct ceph_statx
*stx
, unsigned want
,
623 unsigned flags
, struct Inode
**out
)
625 if (!cmount
->is_mounted())
627 if (flags
& ~CEPH_REQ_FLAG_MASK
)
629 return cmount
->get_client()->readdirplus_r(reinterpret_cast<dir_result_t
*>(dirp
), de
, stx
, want
, flags
, out
);
632 extern "C" int ceph_getdents(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
633 char *buf
, int buflen
)
635 if (!cmount
->is_mounted())
637 return cmount
->get_client()->getdents(reinterpret_cast<dir_result_t
*>(dirp
), buf
, buflen
);
640 extern "C" int ceph_getdnames(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
641 char *buf
, int buflen
)
643 if (!cmount
->is_mounted())
645 return cmount
->get_client()->getdnames(reinterpret_cast<dir_result_t
*>(dirp
), buf
, buflen
);
648 extern "C" void ceph_rewinddir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
650 if (!cmount
->is_mounted())
652 cmount
->get_client()->rewinddir(reinterpret_cast<dir_result_t
*>(dirp
));
655 extern "C" int64_t ceph_telldir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
657 if (!cmount
->is_mounted())
659 return cmount
->get_client()->telldir(reinterpret_cast<dir_result_t
*>(dirp
));
662 extern "C" void ceph_seekdir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
, int64_t offset
)
664 if (!cmount
->is_mounted())
666 cmount
->get_client()->seekdir(reinterpret_cast<dir_result_t
*>(dirp
), offset
);
669 extern "C" int ceph_link (struct ceph_mount_info
*cmount
, const char *existing
,
672 if (!cmount
->is_mounted())
674 return cmount
->get_client()->link(existing
, newname
, cmount
->default_perms
);
677 extern "C" int ceph_unlink(struct ceph_mount_info
*cmount
, const char *path
)
679 if (!cmount
->is_mounted())
681 return cmount
->get_client()->unlink(path
, cmount
->default_perms
);
684 extern "C" int ceph_rename(struct ceph_mount_info
*cmount
, const char *from
,
687 if (!cmount
->is_mounted())
689 return cmount
->get_client()->rename(from
, to
, cmount
->default_perms
);
693 extern "C" int ceph_mkdir(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
695 if (!cmount
->is_mounted())
697 return cmount
->get_client()->mkdir(path
, mode
, cmount
->default_perms
);
700 extern "C" int ceph_mkdirs(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
702 if (!cmount
->is_mounted())
704 return cmount
->get_client()->mkdirs(path
, mode
, cmount
->default_perms
);
707 extern "C" int ceph_rmdir(struct ceph_mount_info
*cmount
, const char *path
)
709 if (!cmount
->is_mounted())
711 return cmount
->get_client()->rmdir(path
, cmount
->default_perms
);
715 extern "C" int ceph_readlink(struct ceph_mount_info
*cmount
, const char *path
,
716 char *buf
, int64_t size
)
718 if (!cmount
->is_mounted())
720 return cmount
->get_client()->readlink(path
, buf
, size
, cmount
->default_perms
);
723 extern "C" int ceph_symlink(struct ceph_mount_info
*cmount
, const char *existing
,
726 if (!cmount
->is_mounted())
728 return cmount
->get_client()->symlink(existing
, newname
, cmount
->default_perms
);
731 extern "C" int ceph_fstatx(struct ceph_mount_info
*cmount
, int fd
, struct ceph_statx
*stx
,
732 unsigned int want
, unsigned int flags
)
734 if (!cmount
->is_mounted())
736 if (flags
& ~CEPH_REQ_FLAG_MASK
)
738 return cmount
->get_client()->fstatx(fd
, stx
, cmount
->default_perms
,
742 extern "C" int ceph_statx(struct ceph_mount_info
*cmount
, const char *path
,
743 struct ceph_statx
*stx
, unsigned int want
, unsigned int flags
)
745 if (!cmount
->is_mounted())
747 if (flags
& ~CEPH_REQ_FLAG_MASK
)
749 return cmount
->get_client()->statx(path
, stx
, cmount
->default_perms
,
753 extern "C" int ceph_fsetattrx(struct ceph_mount_info
*cmount
, int fd
,
754 struct ceph_statx
*stx
, int mask
)
756 if (!cmount
->is_mounted())
758 return cmount
->get_client()->fsetattrx(fd
, stx
, mask
, cmount
->default_perms
);
761 extern "C" int ceph_setattrx(struct ceph_mount_info
*cmount
, const char *relpath
,
762 struct ceph_statx
*stx
, int mask
, int flags
)
764 if (!cmount
->is_mounted())
766 if (flags
& ~CEPH_REQ_FLAG_MASK
)
768 return cmount
->get_client()->setattrx(relpath
, stx
, mask
,
769 cmount
->default_perms
, flags
);
772 // *xattr() calls supporting samba/vfs
773 extern "C" int ceph_getxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, void *value
, size_t size
)
775 if (!cmount
->is_mounted())
778 return cmount
->get_client()->getxattr(path
, name
, value
, size
, cmount
->default_perms
);
781 extern "C" int ceph_lgetxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, void *value
, size_t size
)
783 if (!cmount
->is_mounted())
785 return cmount
->get_client()->lgetxattr(path
, name
, value
, size
, cmount
->default_perms
);
788 extern "C" int ceph_fgetxattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
, void *value
, size_t size
)
790 if (!cmount
->is_mounted())
792 return cmount
->get_client()->fgetxattr(fd
, name
, value
, size
, cmount
->default_perms
);
796 extern "C" int ceph_listxattr(struct ceph_mount_info
*cmount
, const char *path
, char *list
, size_t size
)
798 if (!cmount
->is_mounted())
800 return cmount
->get_client()->listxattr(path
, list
, size
, cmount
->default_perms
);
803 extern "C" int ceph_llistxattr(struct ceph_mount_info
*cmount
, const char *path
, char *list
, size_t size
)
805 if (!cmount
->is_mounted())
807 return cmount
->get_client()->llistxattr(path
, list
, size
, cmount
->default_perms
);
810 extern "C" int ceph_flistxattr(struct ceph_mount_info
*cmount
, int fd
, char *list
, size_t size
)
812 if (!cmount
->is_mounted())
814 return cmount
->get_client()->flistxattr(fd
, list
, size
, cmount
->default_perms
);
817 extern "C" int ceph_removexattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
)
819 if (!cmount
->is_mounted())
821 return cmount
->get_client()->removexattr(path
, name
, cmount
->default_perms
);
824 extern "C" int ceph_lremovexattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
)
826 if (!cmount
->is_mounted())
828 return cmount
->get_client()->lremovexattr(path
, name
, cmount
->default_perms
);
831 extern "C" int ceph_fremovexattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
)
833 if (!cmount
->is_mounted())
835 return cmount
->get_client()->fremovexattr(fd
, name
, cmount
->default_perms
);
838 extern "C" int ceph_setxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
840 if (!cmount
->is_mounted())
842 return cmount
->get_client()->setxattr(path
, name
, value
, size
, flags
, cmount
->default_perms
);
845 extern "C" int ceph_lsetxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
847 if (!cmount
->is_mounted())
849 return cmount
->get_client()->lsetxattr(path
, name
, value
, size
, flags
, cmount
->default_perms
);
852 extern "C" int ceph_fsetxattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
, const void *value
, size_t size
, int flags
)
854 if (!cmount
->is_mounted())
856 return cmount
->get_client()->fsetxattr(fd
, name
, value
, size
, flags
, cmount
->default_perms
);
858 /* end xattr support */
860 extern "C" int ceph_stat(struct ceph_mount_info
*cmount
, const char *path
, struct stat
*stbuf
)
862 if (!cmount
->is_mounted())
864 return cmount
->get_client()->stat(path
, stbuf
, cmount
->default_perms
);
867 extern "C" int ceph_fstat(struct ceph_mount_info
*cmount
, int fd
, struct stat
*stbuf
)
869 if (!cmount
->is_mounted())
871 return cmount
->get_client()->fstat(fd
, stbuf
, cmount
->default_perms
);
874 extern int ceph_lstat(struct ceph_mount_info
*cmount
, const char *path
, struct stat
*stbuf
)
876 if (!cmount
->is_mounted())
878 return cmount
->get_client()->lstat(path
, stbuf
, cmount
->default_perms
);
881 extern "C" int ceph_chmod(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
883 if (!cmount
->is_mounted())
885 return cmount
->get_client()->chmod(path
, mode
, cmount
->default_perms
);
887 extern "C" int ceph_fchmod(struct ceph_mount_info
*cmount
, int fd
, mode_t mode
)
889 if (!cmount
->is_mounted())
891 return cmount
->get_client()->fchmod(fd
, mode
, cmount
->default_perms
);
893 extern "C" int ceph_chown(struct ceph_mount_info
*cmount
, const char *path
,
896 if (!cmount
->is_mounted())
898 return cmount
->get_client()->chown(path
, uid
, gid
, cmount
->default_perms
);
900 extern "C" int ceph_fchown(struct ceph_mount_info
*cmount
, int fd
,
903 if (!cmount
->is_mounted())
905 return cmount
->get_client()->fchown(fd
, uid
, gid
, cmount
->default_perms
);
907 extern "C" int ceph_lchown(struct ceph_mount_info
*cmount
, const char *path
,
910 if (!cmount
->is_mounted())
912 return cmount
->get_client()->lchown(path
, uid
, gid
, cmount
->default_perms
);
916 extern "C" int ceph_utime(struct ceph_mount_info
*cmount
, const char *path
,
919 if (!cmount
->is_mounted())
921 return cmount
->get_client()->utime(path
, buf
, cmount
->default_perms
);
924 extern "C" int ceph_futime(struct ceph_mount_info
*cmount
, int fd
,
927 if (!cmount
->is_mounted())
929 return cmount
->get_client()->futime(fd
, buf
, cmount
->default_perms
);
932 extern "C" int ceph_utimes(struct ceph_mount_info
*cmount
, const char *path
,
933 struct timeval times
[2])
935 if (!cmount
->is_mounted())
937 return cmount
->get_client()->utimes(path
, times
, cmount
->default_perms
);
940 extern "C" int ceph_lutimes(struct ceph_mount_info
*cmount
, const char *path
,
941 struct timeval times
[2])
943 if (!cmount
->is_mounted())
945 return cmount
->get_client()->lutimes(path
, times
, cmount
->default_perms
);
948 extern "C" int ceph_futimes(struct ceph_mount_info
*cmount
, int fd
,
949 struct timeval times
[2])
951 if (!cmount
->is_mounted())
953 return cmount
->get_client()->futimes(fd
, times
, cmount
->default_perms
);
956 extern "C" int ceph_futimens(struct ceph_mount_info
*cmount
, int fd
,
957 struct timespec times
[2])
959 if (!cmount
->is_mounted())
961 return cmount
->get_client()->futimens(fd
, times
, cmount
->default_perms
);
964 extern "C" int ceph_flock(struct ceph_mount_info
*cmount
, int fd
, int operation
,
967 if (!cmount
->is_mounted())
969 return cmount
->get_client()->flock(fd
, operation
, owner
);
972 extern "C" int ceph_truncate(struct ceph_mount_info
*cmount
, const char *path
,
975 if (!cmount
->is_mounted())
977 return cmount
->get_client()->truncate(path
, size
, cmount
->default_perms
);
981 extern "C" int ceph_mknod(struct ceph_mount_info
*cmount
, const char *path
,
982 mode_t mode
, dev_t rdev
)
984 if (!cmount
->is_mounted())
986 return cmount
->get_client()->mknod(path
, mode
, cmount
->default_perms
, rdev
);
989 extern "C" int ceph_open(struct ceph_mount_info
*cmount
, const char *path
,
990 int flags
, mode_t mode
)
992 if (!cmount
->is_mounted())
994 return cmount
->get_client()->open(path
, flags
, cmount
->default_perms
, mode
);
997 extern "C" int ceph_open_layout(struct ceph_mount_info
*cmount
, const char *path
, int flags
,
998 mode_t mode
, int stripe_unit
, int stripe_count
, int object_size
, const char *data_pool
)
1000 if (!cmount
->is_mounted())
1002 return cmount
->get_client()->open(path
, flags
, cmount
->default_perms
, mode
,
1003 stripe_unit
, stripe_count
,
1004 object_size
, data_pool
);
1007 extern "C" int ceph_close(struct ceph_mount_info
*cmount
, int fd
)
1009 if (!cmount
->is_mounted())
1011 return cmount
->get_client()->close(fd
);
1014 extern "C" int64_t ceph_lseek(struct ceph_mount_info
*cmount
, int fd
,
1015 int64_t offset
, int whence
)
1017 if (!cmount
->is_mounted())
1019 return cmount
->get_client()->lseek(fd
, offset
, whence
);
1022 extern "C" int ceph_read(struct ceph_mount_info
*cmount
, int fd
, char *buf
,
1023 int64_t size
, int64_t offset
)
1025 if (!cmount
->is_mounted())
1027 return cmount
->get_client()->read(fd
, buf
, size
, offset
);
1030 extern "C" int ceph_preadv(struct ceph_mount_info
*cmount
, int fd
,
1031 const struct iovec
*iov
, int iovcnt
, int64_t offset
)
1033 if (!cmount
->is_mounted())
1035 return cmount
->get_client()->preadv(fd
, iov
, iovcnt
, offset
);
1038 extern "C" int ceph_write(struct ceph_mount_info
*cmount
, int fd
, const char *buf
,
1039 int64_t size
, int64_t offset
)
1041 if (!cmount
->is_mounted())
1043 return cmount
->get_client()->write(fd
, buf
, size
, offset
);
1046 extern "C" int ceph_pwritev(struct ceph_mount_info
*cmount
, int fd
,
1047 const struct iovec
*iov
, int iovcnt
, int64_t offset
)
1049 if (!cmount
->is_mounted())
1051 return cmount
->get_client()->pwritev(fd
, iov
, iovcnt
, offset
);
1054 extern "C" int ceph_ftruncate(struct ceph_mount_info
*cmount
, int fd
, int64_t size
)
1056 if (!cmount
->is_mounted())
1058 return cmount
->get_client()->ftruncate(fd
, size
, cmount
->default_perms
);
1061 extern "C" int ceph_fsync(struct ceph_mount_info
*cmount
, int fd
, int syncdataonly
)
1063 if (!cmount
->is_mounted())
1065 return cmount
->get_client()->fsync(fd
, syncdataonly
);
1068 extern "C" int ceph_fallocate(struct ceph_mount_info
*cmount
, int fd
, int mode
,
1069 int64_t offset
, int64_t length
)
1071 if (!cmount
->is_mounted())
1073 return cmount
->get_client()->fallocate(fd
, mode
, offset
, length
);
1076 extern "C" int ceph_lazyio(class ceph_mount_info
*cmount
,
1079 return (cmount
->get_client()->lazyio(fd
, enable
));
1082 extern "C" int ceph_sync_fs(struct ceph_mount_info
*cmount
)
1084 if (!cmount
->is_mounted())
1086 return cmount
->get_client()->sync_fs();
1089 extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info
*cmount
, int fh
)
1094 if (!cmount
->is_mounted())
1096 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1099 return l
.stripe_unit
;
1102 extern "C" int ceph_get_path_stripe_unit(struct ceph_mount_info
*cmount
, const char *path
)
1107 if (!cmount
->is_mounted())
1109 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1112 return l
.stripe_unit
;
1115 extern "C" int ceph_get_file_stripe_count(struct ceph_mount_info
*cmount
, int fh
)
1120 if (!cmount
->is_mounted())
1122 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1125 return l
.stripe_count
;
1128 extern "C" int ceph_get_path_stripe_count(struct ceph_mount_info
*cmount
, const char *path
)
1133 if (!cmount
->is_mounted())
1135 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1138 return l
.stripe_count
;
1141 extern "C" int ceph_get_file_object_size(struct ceph_mount_info
*cmount
, int fh
)
1146 if (!cmount
->is_mounted())
1148 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1151 return l
.object_size
;
1154 extern "C" int ceph_get_path_object_size(struct ceph_mount_info
*cmount
, const char *path
)
1159 if (!cmount
->is_mounted())
1161 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1164 return l
.object_size
;
1167 extern "C" int ceph_get_file_pool(struct ceph_mount_info
*cmount
, int fh
)
1172 if (!cmount
->is_mounted())
1174 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1180 extern "C" int ceph_get_path_pool(struct ceph_mount_info
*cmount
, const char *path
)
1185 if (!cmount
->is_mounted())
1187 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1193 extern "C" int ceph_get_file_pool_name(struct ceph_mount_info
*cmount
, int fh
, char *buf
, size_t len
)
1198 if (!cmount
->is_mounted())
1200 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1203 string name
= cmount
->get_client()->get_pool_name(l
.pool_id
);
1205 return name
.length();
1206 if (name
.length() > len
)
1208 strncpy(buf
, name
.c_str(), len
);
1209 return name
.length();
1212 extern "C" int ceph_get_pool_name(struct ceph_mount_info
*cmount
, int pool
, char *buf
, size_t len
)
1214 if (!cmount
->is_mounted())
1216 string name
= cmount
->get_client()->get_pool_name(pool
);
1218 return name
.length();
1219 if (name
.length() > len
)
1221 strncpy(buf
, name
.c_str(), len
);
1222 return name
.length();
1225 extern "C" int ceph_get_path_pool_name(struct ceph_mount_info
*cmount
, const char *path
, char *buf
, size_t len
)
1230 if (!cmount
->is_mounted())
1232 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
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_default_data_pool_name(struct ceph_mount_info
*cmount
, char *buf
, size_t len
)
1246 if (!cmount
->is_mounted())
1248 int64_t pool_id
= cmount
->get_client()->get_default_pool_id();
1250 string name
= cmount
->get_client()->get_pool_name(pool_id
);
1252 return name
.length();
1253 if (name
.length() > len
)
1255 strncpy(buf
, name
.c_str(), len
);
1256 return name
.length();
1259 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
)
1264 if (!cmount
->is_mounted())
1266 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1270 *stripe_unit
= l
.stripe_unit
;
1272 *stripe_count
= l
.stripe_count
;
1274 *object_size
= l
.object_size
;
1276 *pg_pool
= l
.pool_id
;
1280 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
)
1285 if (!cmount
->is_mounted())
1287 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1291 *stripe_unit
= l
.stripe_unit
;
1293 *stripe_count
= l
.stripe_count
;
1295 *object_size
= l
.object_size
;
1297 *pg_pool
= l
.pool_id
;
1301 extern "C" int ceph_get_file_replication(struct ceph_mount_info
*cmount
, int fh
)
1306 if (!cmount
->is_mounted())
1308 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1311 int rep
= cmount
->get_client()->get_pool_replication(l
.pool_id
);
1315 extern "C" int ceph_get_path_replication(struct ceph_mount_info
*cmount
, const char *path
)
1320 if (!cmount
->is_mounted())
1322 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1325 int rep
= cmount
->get_client()->get_pool_replication(l
.pool_id
);
1329 extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info
*cmount
,
1332 // this option no longer exists
1336 extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info
*cmount
,
1339 // this option no longer exists
1343 extern "C" int ceph_set_default_object_size(struct ceph_mount_info
*cmount
, int size
)
1345 // this option no longer exists
1349 extern "C" int ceph_set_default_file_replication(struct ceph_mount_info
*cmount
,
1352 // this option no longer exists
1356 extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info
*cmount
, int osd
)
1358 // this option no longer exists
1362 extern "C" int ceph_get_file_extent_osds(struct ceph_mount_info
*cmount
, int fh
,
1363 int64_t offset
, int64_t *length
, int *osds
, int nosds
)
1368 if (!cmount
->is_mounted())
1372 int ret
= cmount
->get_client()->get_file_extent_osds(fh
, offset
, length
, vosds
);
1377 return vosds
.size();
1379 if ((int)vosds
.size() > nosds
)
1382 for (int i
= 0; i
< (int)vosds
.size(); i
++)
1385 return vosds
.size();
1388 extern "C" int ceph_get_osd_crush_location(struct ceph_mount_info
*cmount
,
1389 int osd
, char *path
, size_t len
)
1391 if (!cmount
->is_mounted())
1397 vector
<pair
<string
, string
> > loc
;
1398 int ret
= cmount
->get_client()->get_osd_crush_location(osd
, loc
);
1404 vector
<pair
<string
, string
> >::iterator it
;
1405 for (it
= loc
.begin(); it
!= loc
.end(); ++it
) {
1406 string
& type
= it
->first
;
1407 string
& name
= it
->second
;
1408 needed
+= type
.size() + name
.size() + 2;
1409 if (needed
<= len
) {
1411 strcpy(path
+ cur
, type
.c_str());
1412 cur
+= type
.size() + 1;
1414 strcpy(path
+ cur
, name
.c_str());
1415 cur
+= name
.size() + 1;
1428 extern "C" int ceph_get_osd_addr(struct ceph_mount_info
*cmount
, int osd
,
1429 struct sockaddr_storage
*addr
)
1431 if (!cmount
->is_mounted())
1437 entity_addr_t address
;
1438 int ret
= cmount
->get_client()->get_osd_addr(osd
, address
);
1442 *addr
= address
.get_sockaddr_storage();
1447 extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info
*cmount
, int fh
,
1448 int64_t offset
, struct sockaddr_storage
*addr
, int naddr
)
1450 vector
<entity_addr_t
> address
;
1457 if (!cmount
->is_mounted())
1460 r
= cmount
->get_client()->get_file_stripe_address(fh
, offset
, address
);
1464 for (i
= 0; i
< (unsigned)naddr
&& i
< address
.size(); i
++)
1465 addr
[i
] = address
[i
].get_sockaddr_storage();
1467 /* naddr == 0: drop through and return actual size */
1468 if (naddr
&& (address
.size() > (unsigned)naddr
))
1471 return address
.size();
1474 extern "C" int ceph_localize_reads(struct ceph_mount_info
*cmount
, int val
)
1476 if (!cmount
->is_mounted())
1479 cmount
->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS
);
1481 cmount
->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS
);
1485 extern "C" CephContext
*ceph_get_mount_context(struct ceph_mount_info
*cmount
)
1487 return cmount
->get_ceph_context();
1490 extern "C" int ceph_debug_get_fd_caps(struct ceph_mount_info
*cmount
, int fd
)
1492 if (!cmount
->is_mounted())
1494 return cmount
->get_client()->get_caps_issued(fd
);
1497 extern "C" int ceph_debug_get_file_caps(struct ceph_mount_info
*cmount
, const char *path
)
1499 if (!cmount
->is_mounted())
1501 return cmount
->get_client()->get_caps_issued(path
, cmount
->default_perms
);
1504 extern "C" int ceph_get_stripe_unit_granularity(struct ceph_mount_info
*cmount
)
1506 if (!cmount
->is_mounted())
1508 return CEPH_MIN_STRIPE_UNIT
;
1511 extern "C" int ceph_get_pool_id(struct ceph_mount_info
*cmount
, const char *pool_name
)
1513 if (!cmount
->is_mounted())
1516 if (!pool_name
|| !pool_name
[0])
1519 /* negative range reserved for errors */
1520 int64_t pool_id
= cmount
->get_client()->get_pool_id(pool_name
);
1521 if (pool_id
> 0x7fffffff)
1524 /* get_pool_id error codes fit in int */
1525 return (int)pool_id
;
1528 extern "C" int ceph_get_pool_replication(struct ceph_mount_info
*cmount
,
1531 if (!cmount
->is_mounted())
1533 return cmount
->get_client()->get_pool_replication(pool_id
);
1535 /* Low-level exports */
1537 extern "C" int ceph_ll_lookup_root(struct ceph_mount_info
*cmount
,
1540 *parent
= cmount
->get_client()->get_root();
1546 extern "C" struct Inode
*ceph_ll_get_inode(class ceph_mount_info
*cmount
,
1549 return (cmount
->get_client())->ll_get_inode(vino
);
1554 * Populates the client cache with the requested inode, and its
1557 extern "C" int ceph_ll_lookup_inode(
1558 struct ceph_mount_info
*cmount
,
1559 struct inodeno_t ino
,
1562 return (cmount
->get_client())->ll_lookup_inode(ino
, cmount
->default_perms
, inode
);
1565 extern "C" int ceph_ll_lookup(struct ceph_mount_info
*cmount
,
1566 Inode
*parent
, const char *name
, Inode
**out
,
1567 struct ceph_statx
*stx
, unsigned want
,
1568 unsigned flags
, const UserPerm
*perms
)
1570 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1572 return (cmount
->get_client())->ll_lookupx(parent
, name
, out
, stx
, want
,
1576 extern "C" int ceph_ll_put(class ceph_mount_info
*cmount
, Inode
*in
)
1578 return (cmount
->get_client()->ll_put(in
));
1581 extern "C" int ceph_ll_forget(class ceph_mount_info
*cmount
, Inode
*in
,
1584 return (cmount
->get_client()->ll_forget(in
, count
));
1587 extern "C" int ceph_ll_walk(struct ceph_mount_info
*cmount
, const char* name
, Inode
**i
,
1588 struct ceph_statx
*stx
, unsigned int want
, unsigned int flags
,
1589 const UserPerm
*perms
)
1591 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1593 return(cmount
->get_client()->ll_walk(name
, i
, stx
, want
, flags
, *perms
));
1596 extern "C" int ceph_ll_getattr(class ceph_mount_info
*cmount
,
1597 Inode
*in
, struct ceph_statx
*stx
,
1598 unsigned int want
, unsigned int flags
,
1599 const UserPerm
*perms
)
1601 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1603 return (cmount
->get_client()->ll_getattrx(in
, stx
, want
, flags
, *perms
));
1606 extern "C" int ceph_ll_setattr(class ceph_mount_info
*cmount
,
1607 Inode
*in
, struct ceph_statx
*stx
,
1608 int mask
, const UserPerm
*perms
)
1610 return (cmount
->get_client()->ll_setattrx(in
, stx
, mask
, *perms
));
1613 extern "C" int ceph_ll_open(class ceph_mount_info
*cmount
, Inode
*in
,
1614 int flags
, Fh
**fh
, const UserPerm
*perms
)
1616 return (cmount
->get_client()->ll_open(in
, flags
, fh
, *perms
));
1619 extern "C" int ceph_ll_read(class ceph_mount_info
*cmount
, Fh
* filehandle
,
1620 int64_t off
, uint64_t len
, char* buf
)
1625 r
= cmount
->get_client()->ll_read(filehandle
, off
, len
, &bl
);
1628 bl
.copy(0, bl
.length(), buf
);
1634 extern "C" int ceph_ll_read_block(class ceph_mount_info
*cmount
,
1635 Inode
*in
, uint64_t blockid
,
1636 char* buf
, uint64_t offset
,
1638 struct ceph_file_layout
* layout
)
1641 int r
= (cmount
->get_client()->ll_read_block(in
, blockid
, buf
, offset
,
1643 l
.to_legacy(layout
);
1647 extern "C" int ceph_ll_write_block(class ceph_mount_info
*cmount
,
1648 Inode
*in
, uint64_t blockid
,
1649 char *buf
, uint64_t offset
,
1651 struct ceph_file_layout
*layout
,
1652 uint64_t snapseq
, uint32_t sync
)
1655 int r
= (cmount
->get_client()->ll_write_block(in
, blockid
, buf
, offset
,
1656 length
, &l
, snapseq
, sync
));
1657 l
.to_legacy(layout
);
1661 extern "C" int ceph_ll_commit_blocks(class ceph_mount_info
*cmount
,
1662 Inode
*in
, uint64_t offset
,
1665 return (cmount
->get_client()->ll_commit_blocks(in
, offset
, range
));
1668 extern "C" int ceph_ll_fsync(class ceph_mount_info
*cmount
,
1669 Fh
*fh
, int syncdataonly
)
1671 return (cmount
->get_client()->ll_fsync(fh
, syncdataonly
));
1674 extern "C" int ceph_ll_sync_inode(class ceph_mount_info
*cmount
,
1675 Inode
*in
, int syncdataonly
)
1677 return (cmount
->get_client()->ll_sync_inode(in
, syncdataonly
));
1680 extern "C" int ceph_ll_fallocate(class ceph_mount_info
*cmount
, Fh
*fh
,
1681 int mode
, int64_t offset
, int64_t length
)
1683 return cmount
->get_client()->ll_fallocate(fh
, mode
, offset
, length
);
1686 extern "C" off_t
ceph_ll_lseek(class ceph_mount_info
*cmount
,
1687 Fh
*fh
, off_t offset
, int whence
)
1689 return (cmount
->get_client()->ll_lseek(fh
, offset
, whence
));
1692 extern "C" int ceph_ll_write(class ceph_mount_info
*cmount
,
1693 Fh
*fh
, int64_t off
, uint64_t len
,
1696 return (cmount
->get_client()->ll_write(fh
, off
, len
, data
));
1699 extern "C" int64_t ceph_ll_readv(class ceph_mount_info
*cmount
,
1700 struct Fh
*fh
, const struct iovec
*iov
,
1701 int iovcnt
, int64_t off
)
1703 return (cmount
->get_client()->ll_readv(fh
, iov
, iovcnt
, off
));
1706 extern "C" int64_t ceph_ll_writev(class ceph_mount_info
*cmount
,
1707 struct Fh
*fh
, const struct iovec
*iov
,
1708 int iovcnt
, int64_t off
)
1710 return (cmount
->get_client()->ll_writev(fh
, iov
, iovcnt
, off
));
1713 extern "C" int ceph_ll_close(class ceph_mount_info
*cmount
, Fh
* fh
)
1715 return (cmount
->get_client()->ll_release(fh
));
1718 extern "C" int ceph_ll_create(class ceph_mount_info
*cmount
,
1719 Inode
*parent
, const char *name
, mode_t mode
,
1720 int oflags
, Inode
**outp
, Fh
**fhp
,
1721 struct ceph_statx
*stx
, unsigned want
,
1722 unsigned lflags
, const UserPerm
*perms
)
1724 if (lflags
& ~CEPH_REQ_FLAG_MASK
)
1726 return (cmount
->get_client())->ll_createx(parent
, name
, mode
, oflags
, outp
,
1727 fhp
, stx
, want
, lflags
, *perms
);
1730 extern "C" int ceph_ll_mknod(class ceph_mount_info
*cmount
, Inode
*parent
,
1731 const char *name
, mode_t mode
, dev_t rdev
,
1732 Inode
**out
, struct ceph_statx
*stx
,
1733 unsigned want
, unsigned flags
,
1734 const UserPerm
*perms
)
1736 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1738 return (cmount
->get_client())->ll_mknodx(parent
, name
, mode
, rdev
,
1739 out
, stx
, want
, flags
, *perms
);
1742 extern "C" int ceph_ll_mkdir(class ceph_mount_info
*cmount
, Inode
*parent
,
1743 const char *name
, mode_t mode
, Inode
**out
,
1744 struct ceph_statx
*stx
, unsigned want
,
1745 unsigned flags
, const UserPerm
*perms
)
1747 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1749 return cmount
->get_client()->ll_mkdirx(parent
, name
, mode
, out
, stx
, want
,
1753 extern "C" int ceph_ll_link(class ceph_mount_info
*cmount
,
1754 Inode
*in
, Inode
*newparent
,
1755 const char *name
, const UserPerm
*perms
)
1757 return cmount
->get_client()->ll_link(in
, newparent
, name
, *perms
);
1760 extern "C" int ceph_ll_opendir(class ceph_mount_info
*cmount
,
1762 struct ceph_dir_result
**dirpp
,
1763 const UserPerm
*perms
)
1765 return (cmount
->get_client()->ll_opendir(in
, O_RDONLY
, (dir_result_t
**) dirpp
,
1769 extern "C" int ceph_ll_releasedir(class ceph_mount_info
*cmount
,
1770 ceph_dir_result
*dir
)
1772 (void) cmount
->get_client()->ll_releasedir(reinterpret_cast<dir_result_t
*>(dir
));
1776 extern "C" int ceph_ll_rename(class ceph_mount_info
*cmount
,
1777 Inode
*parent
, const char *name
,
1778 Inode
*newparent
, const char *newname
,
1779 const UserPerm
*perms
)
1781 return cmount
->get_client()->ll_rename(parent
, name
, newparent
,
1785 extern "C" int ceph_ll_unlink(class ceph_mount_info
*cmount
, Inode
*in
,
1786 const char *name
, const UserPerm
*perms
)
1788 return cmount
->get_client()->ll_unlink(in
, name
, *perms
);
1791 extern "C" int ceph_ll_statfs(class ceph_mount_info
*cmount
,
1792 Inode
*in
, struct statvfs
*stbuf
)
1794 return (cmount
->get_client()->ll_statfs(in
, stbuf
, cmount
->default_perms
));
1797 extern "C" int ceph_ll_readlink(class ceph_mount_info
*cmount
, Inode
*in
,
1798 char *buf
, size_t bufsiz
,
1799 const UserPerm
*perms
)
1801 return cmount
->get_client()->ll_readlink(in
, buf
, bufsiz
, *perms
);
1804 extern "C" int ceph_ll_symlink(class ceph_mount_info
*cmount
,
1805 Inode
*in
, const char *name
,
1806 const char *value
, Inode
**out
,
1807 struct ceph_statx
*stx
, unsigned want
,
1808 unsigned flags
, const UserPerm
*perms
)
1810 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1812 return (cmount
->get_client()->ll_symlinkx(in
, name
, value
, out
, stx
, want
,
1816 extern "C" int ceph_ll_rmdir(class ceph_mount_info
*cmount
,
1817 Inode
*in
, const char *name
,
1818 const UserPerm
*perms
)
1820 return cmount
->get_client()->ll_rmdir(in
, name
, *perms
);
1823 extern "C" int ceph_ll_getxattr(class ceph_mount_info
*cmount
,
1824 Inode
*in
, const char *name
, void *value
,
1825 size_t size
, const UserPerm
*perms
)
1827 return (cmount
->get_client()->ll_getxattr(in
, name
, value
, size
, *perms
));
1830 extern "C" int ceph_ll_listxattr(struct ceph_mount_info
*cmount
,
1831 Inode
*in
, char *list
,
1832 size_t buf_size
, size_t *list_size
,
1833 const UserPerm
*perms
)
1835 int res
= cmount
->get_client()->ll_listxattr(in
, list
, buf_size
, *perms
);
1837 *list_size
= (size_t)res
;
1843 extern "C" int ceph_ll_setxattr(class ceph_mount_info
*cmount
,
1844 Inode
*in
, const char *name
,
1845 const void *value
, size_t size
,
1846 int flags
, const UserPerm
*perms
)
1848 return (cmount
->get_client()->ll_setxattr(in
, name
, value
, size
, flags
, *perms
));
1851 extern "C" int ceph_ll_removexattr(class ceph_mount_info
*cmount
,
1852 Inode
*in
, const char *name
,
1853 const UserPerm
*perms
)
1855 return (cmount
->get_client()->ll_removexattr(in
, name
, *perms
));
1858 extern "C" int ceph_ll_getlk(struct ceph_mount_info
*cmount
,
1859 Fh
*fh
, struct flock
*fl
, uint64_t owner
)
1861 return (cmount
->get_client()->ll_getlk(fh
, fl
, owner
));
1864 extern "C" int ceph_ll_setlk(struct ceph_mount_info
*cmount
,
1865 Fh
*fh
, struct flock
*fl
, uint64_t owner
,
1868 return (cmount
->get_client()->ll_setlk(fh
, fl
, owner
, sleep
));
1871 extern "C" int ceph_ll_lazyio(class ceph_mount_info
*cmount
,
1874 return (cmount
->get_client()->ll_lazyio(fh
, enable
));
1877 extern "C" int ceph_ll_delegation(struct ceph_mount_info
*cmount
, Fh
*fh
,
1878 unsigned cmd
, ceph_deleg_cb_t cb
, void *priv
)
1880 return (cmount
->get_client()->ll_delegation(fh
, cmd
, cb
, priv
));
1883 extern "C" uint32_t ceph_ll_stripe_unit(class ceph_mount_info
*cmount
,
1886 return (cmount
->get_client()->ll_stripe_unit(in
));
1889 extern "C" uint32_t ceph_ll_file_layout(class ceph_mount_info
*cmount
,
1891 struct ceph_file_layout
*layout
)
1894 int r
= (cmount
->get_client()->ll_file_layout(in
, &l
));
1895 l
.to_legacy(layout
);
1899 uint64_t ceph_ll_snap_seq(class ceph_mount_info
*cmount
, Inode
*in
)
1901 return (cmount
->get_client()->ll_snap_seq(in
));
1904 extern "C" int ceph_ll_get_stripe_osd(class ceph_mount_info
*cmount
,
1905 Inode
*in
, uint64_t blockno
,
1906 struct ceph_file_layout
* layout
)
1909 int r
= (cmount
->get_client()->ll_get_stripe_osd(in
, blockno
, &l
));
1910 l
.to_legacy(layout
);
1914 extern "C" int ceph_ll_num_osds(class ceph_mount_info
*cmount
)
1916 return (cmount
->get_client()->ll_num_osds());
1919 extern "C" int ceph_ll_osdaddr(class ceph_mount_info
*cmount
,
1920 int osd
, uint32_t *addr
)
1922 return (cmount
->get_client()->ll_osdaddr(osd
, addr
));
1925 extern "C" uint64_t ceph_ll_get_internal_offset(class ceph_mount_info
*cmount
,
1929 return (cmount
->get_client()->ll_get_internal_offset(in
, blockno
));
1932 extern "C" void ceph_buffer_free(char *buf
)
1939 extern "C" uint32_t ceph_get_cap_return_timeout(class ceph_mount_info
*cmount
)
1941 if (!cmount
->is_mounted())
1943 return cmount
->get_client()->mdsmap
->get_session_autoclose().sec();
1946 extern "C" int ceph_set_deleg_timeout(class ceph_mount_info
*cmount
, uint32_t timeout
)
1948 if (!cmount
->is_mounted())
1950 return cmount
->get_client()->set_deleg_timeout(timeout
);
1953 extern "C" void ceph_set_session_timeout(class ceph_mount_info
*cmount
, unsigned timeout
)
1955 cmount
->get_client()->set_session_timeout(timeout
);
1958 extern "C" void ceph_set_uuid(class ceph_mount_info
*cmount
, const char *uuid
)
1960 cmount
->get_client()->set_uuid(std::string(uuid
));
1963 extern "C" int ceph_start_reclaim(class ceph_mount_info
*cmount
,
1964 const char *uuid
, unsigned flags
)
1966 if (!cmount
->is_initialized()) {
1967 int ret
= cmount
->init();
1971 return cmount
->get_client()->start_reclaim(std::string(uuid
), flags
,
1972 cmount
->get_filesystem());
1975 extern "C" void ceph_finish_reclaim(class ceph_mount_info
*cmount
)
1977 cmount
->get_client()->finish_reclaim();