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/assert.h"
33 #include "mds/MDSMap.h"
35 #include "include/cephfs/libcephfs.h"
38 struct ceph_mount_info
41 explicit ceph_mount_info(CephContext
*cct_
)
50 if (cct_
!= nullptr) {
64 catch (const std::exception
& e
) {
65 // we shouldn't get here, but if we do, we want to know about it.
66 lderr(cct
) << "ceph_mount_info::~ceph_mount_info: caught exception: "
76 common_init_finish(cct
);
81 monclient
= new MonClient(cct
);
82 ret
= -CEPHFS_ERROR_MON_MAP_BUILD
; //defined in libcephfs.h;
83 if (monclient
->build_initial_monmap() < 0)
87 messenger
= Messenger::create_client_messenger(cct
, "client");
90 ret
= -CEPHFS_ERROR_NEW_CLIENT
; //defined in libcephfs.h;
91 client
= new StandaloneClient(messenger
, monclient
);
95 ret
= -CEPHFS_ERROR_MESSENGER_START
; //defined in libcephfs.h;
96 if (messenger
->start() != 0)
103 default_perms
= Client::pick_my_perms(cct
);
112 int mount(const std::string
&mount_root
, const UserPerm
& perms
)
126 ret
= client
->mount(mount_root
, perms
);
155 messenger
->shutdown();
170 bool is_initialized() const
180 int conf_read_file(const char *path_list
)
182 int ret
= cct
->_conf
->parse_config_files(path_list
, NULL
, 0);
185 cct
->_conf
->apply_changes(NULL
);
186 cct
->_conf
->complain_about_parse_errors(cct
);
190 int conf_parse_argv(int argc
, const char **argv
)
193 vector
<const char*> args
;
194 argv_to_vec(argc
, argv
, args
);
195 ret
= cct
->_conf
->parse_argv(args
);
198 cct
->_conf
->apply_changes(NULL
);
202 int conf_parse_env(const char *name
)
204 md_config_t
*conf
= cct
->_conf
;
205 vector
<const char*> args
;
206 env_to_vec(args
, name
);
207 int ret
= conf
->parse_argv(args
);
210 conf
->apply_changes(NULL
);
214 int conf_set(const char *option
, const char *value
)
216 int ret
= cct
->_conf
->set_val(option
, value
);
219 cct
->_conf
->apply_changes(NULL
);
223 int conf_get(const char *option
, char *buf
, size_t len
)
226 return cct
->_conf
->get_val(option
, &tmp
, len
);
234 const char *get_cwd(const UserPerm
& perms
)
236 client
->getcwd(cwd
, perms
);
240 int chdir(const char *to
, const UserPerm
& perms
)
242 return client
->chdir(to
, cwd
, perms
);
245 CephContext
*get_ceph_context() const {
249 UserPerm default_perms
;
253 StandaloneClient
*client
;
254 MonClient
*monclient
;
255 Messenger
*messenger
;
260 static void do_out_buffer(bufferlist
& outbl
, char **outbuf
, size_t *outbuflen
)
263 if (outbl
.length() > 0) {
264 *outbuf
= (char *)malloc(outbl
.length());
265 memcpy(*outbuf
, outbl
.c_str(), outbl
.length());
271 *outbuflen
= outbl
.length();
274 static void do_out_buffer(string
& outbl
, char **outbuf
, size_t *outbuflen
)
277 if (outbl
.length() > 0) {
278 *outbuf
= (char *)malloc(outbl
.length());
279 memcpy(*outbuf
, outbl
.c_str(), outbl
.length());
285 *outbuflen
= outbl
.length();
288 extern "C" UserPerm
*ceph_userperm_new(uid_t uid
, gid_t gid
, int ngids
,
291 return new (std::nothrow
) UserPerm(uid
, gid
, ngids
, gidlist
);
294 extern "C" void ceph_userperm_destroy(UserPerm
*perm
)
299 extern "C" const char *ceph_version(int *pmajor
, int *pminor
, int *ppatch
)
301 int major
, minor
, patch
;
302 const char *v
= ceph_version_to_str();
304 int n
= sscanf(v
, "%d.%d.%d", &major
, &minor
, &patch
);
306 *pmajor
= (n
>= 1) ? major
: 0;
308 *pminor
= (n
>= 2) ? minor
: 0;
310 *ppatch
= (n
>= 3) ? patch
: 0;
314 extern "C" int ceph_create_with_context(struct ceph_mount_info
**cmount
, CephContext
*cct
)
316 *cmount
= new struct ceph_mount_info(cct
);
320 extern "C" int ceph_create_from_rados(struct ceph_mount_info
**cmount
,
323 auto rados
= (librados::RadosClient
*) cluster
;
324 auto cct
= rados
->cct
;
325 return ceph_create_with_context(cmount
, cct
);
328 extern "C" int ceph_create(struct ceph_mount_info
**cmount
, const char * const id
)
330 CephInitParameters
iparams(CEPH_ENTITY_TYPE_CLIENT
);
332 iparams
.name
.set(CEPH_ENTITY_TYPE_CLIENT
, id
);
335 CephContext
*cct
= common_preinit(iparams
, CODE_ENVIRONMENT_LIBRARY
, 0);
336 cct
->_conf
->parse_env(); // environment variables coverride
337 cct
->_conf
->apply_changes(NULL
);
338 int ret
= ceph_create_with_context(cmount
, cct
);
343 extern "C" int ceph_unmount(struct ceph_mount_info
*cmount
)
345 return cmount
->unmount();
348 extern "C" int ceph_release(struct ceph_mount_info
*cmount
)
350 if (cmount
->is_mounted())
356 extern "C" void ceph_shutdown(struct ceph_mount_info
*cmount
)
362 extern "C" int ceph_conf_read_file(struct ceph_mount_info
*cmount
, const char *path
)
364 return cmount
->conf_read_file(path
);
367 extern "C" int ceph_conf_parse_argv(struct ceph_mount_info
*cmount
, int argc
,
370 return cmount
->conf_parse_argv(argc
, argv
);
373 extern "C" int ceph_conf_parse_env(struct ceph_mount_info
*cmount
, const char *name
)
375 return cmount
->conf_parse_env(name
);
378 extern "C" int ceph_conf_set(struct ceph_mount_info
*cmount
, const char *option
,
381 return cmount
->conf_set(option
, value
);
384 extern "C" int ceph_conf_get(struct ceph_mount_info
*cmount
, const char *option
,
385 char *buf
, size_t len
)
390 return cmount
->conf_get(option
, buf
, len
);
393 extern "C" int ceph_mds_command(struct ceph_mount_info
*cmount
,
394 const char *mds_spec
,
397 const char *inbuf
, size_t inbuflen
,
398 char **outbuf
, size_t *outbuflen
,
399 char **outsbuf
, size_t *outsbuflen
)
403 std::vector
<string
> cmdv
;
406 if (!cmount
->is_initialized()) {
411 for (size_t i
= 0; i
< cmdlen
; ++i
) {
412 cmdv
.push_back(cmd
[i
]);
414 inbl
.append(inbuf
, inbuflen
);
416 // Issue remote command
418 int r
= cmount
->get_client()->mds_command(
428 // Wait for completion
432 do_out_buffer(outbl
, outbuf
, outbuflen
);
433 do_out_buffer(outs
, outsbuf
, outsbuflen
);
439 extern "C" int ceph_init(struct ceph_mount_info
*cmount
)
441 return cmount
->init();
444 extern "C" int ceph_mount(struct ceph_mount_info
*cmount
, const char *root
)
446 std::string mount_root
;
449 return cmount
->mount(mount_root
, cmount
->default_perms
);
452 extern "C" int ceph_is_mounted(struct ceph_mount_info
*cmount
)
454 return cmount
->is_mounted() ? 1 : 0;
457 extern "C" struct UserPerm
*ceph_mount_perms(struct ceph_mount_info
*cmount
)
459 return &cmount
->default_perms
;
462 extern "C" int ceph_statfs(struct ceph_mount_info
*cmount
, const char *path
,
463 struct statvfs
*stbuf
)
465 if (!cmount
->is_mounted())
467 return cmount
->get_client()->statfs(path
, stbuf
, cmount
->default_perms
);
470 extern "C" int ceph_get_local_osd(struct ceph_mount_info
*cmount
)
472 if (!cmount
->is_mounted())
474 return cmount
->get_client()->get_local_osd();
477 extern "C" const char* ceph_getcwd(struct ceph_mount_info
*cmount
)
479 return cmount
->get_cwd(cmount
->default_perms
);
482 extern "C" int ceph_chdir (struct ceph_mount_info
*cmount
, const char *s
)
484 if (!cmount
->is_mounted())
486 return cmount
->chdir(s
, cmount
->default_perms
);
489 extern "C" int ceph_opendir(struct ceph_mount_info
*cmount
,
490 const char *name
, struct ceph_dir_result
**dirpp
)
492 if (!cmount
->is_mounted())
494 return cmount
->get_client()->opendir(name
, (dir_result_t
**)dirpp
, cmount
->default_perms
);
497 extern "C" int ceph_closedir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
499 if (!cmount
->is_mounted())
501 return cmount
->get_client()->closedir(reinterpret_cast<dir_result_t
*>(dirp
));
504 extern "C" struct dirent
* ceph_readdir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
506 if (!cmount
->is_mounted()) {
507 /* Client::readdir also sets errno to signal errors. */
511 return cmount
->get_client()->readdir(reinterpret_cast<dir_result_t
*>(dirp
));
514 extern "C" int ceph_readdir_r(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
, struct dirent
*de
)
516 if (!cmount
->is_mounted())
518 return cmount
->get_client()->readdir_r(reinterpret_cast<dir_result_t
*>(dirp
), de
);
521 extern "C" int ceph_readdirplus_r(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
522 struct dirent
*de
, struct ceph_statx
*stx
, unsigned want
,
523 unsigned flags
, struct Inode
**out
)
525 if (!cmount
->is_mounted())
527 if (flags
& ~CEPH_REQ_FLAG_MASK
)
529 return cmount
->get_client()->readdirplus_r(reinterpret_cast<dir_result_t
*>(dirp
), de
, stx
, want
, flags
, out
);
532 extern "C" int ceph_getdents(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
533 char *buf
, int buflen
)
535 if (!cmount
->is_mounted())
537 return cmount
->get_client()->getdents(reinterpret_cast<dir_result_t
*>(dirp
), buf
, buflen
);
540 extern "C" int ceph_getdnames(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
,
541 char *buf
, int buflen
)
543 if (!cmount
->is_mounted())
545 return cmount
->get_client()->getdnames(reinterpret_cast<dir_result_t
*>(dirp
), buf
, buflen
);
548 extern "C" void ceph_rewinddir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
550 if (!cmount
->is_mounted())
552 cmount
->get_client()->rewinddir(reinterpret_cast<dir_result_t
*>(dirp
));
555 extern "C" int64_t ceph_telldir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
)
557 if (!cmount
->is_mounted())
559 return cmount
->get_client()->telldir(reinterpret_cast<dir_result_t
*>(dirp
));
562 extern "C" void ceph_seekdir(struct ceph_mount_info
*cmount
, struct ceph_dir_result
*dirp
, int64_t offset
)
564 if (!cmount
->is_mounted())
566 cmount
->get_client()->seekdir(reinterpret_cast<dir_result_t
*>(dirp
), offset
);
569 extern "C" int ceph_link (struct ceph_mount_info
*cmount
, const char *existing
,
572 if (!cmount
->is_mounted())
574 return cmount
->get_client()->link(existing
, newname
, cmount
->default_perms
);
577 extern "C" int ceph_unlink(struct ceph_mount_info
*cmount
, const char *path
)
579 if (!cmount
->is_mounted())
581 return cmount
->get_client()->unlink(path
, cmount
->default_perms
);
584 extern "C" int ceph_rename(struct ceph_mount_info
*cmount
, const char *from
,
587 if (!cmount
->is_mounted())
589 return cmount
->get_client()->rename(from
, to
, cmount
->default_perms
);
593 extern "C" int ceph_mkdir(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
595 if (!cmount
->is_mounted())
597 return cmount
->get_client()->mkdir(path
, mode
, cmount
->default_perms
);
600 extern "C" int ceph_mkdirs(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
602 if (!cmount
->is_mounted())
604 return cmount
->get_client()->mkdirs(path
, mode
, cmount
->default_perms
);
607 extern "C" int ceph_rmdir(struct ceph_mount_info
*cmount
, const char *path
)
609 if (!cmount
->is_mounted())
611 return cmount
->get_client()->rmdir(path
, cmount
->default_perms
);
615 extern "C" int ceph_readlink(struct ceph_mount_info
*cmount
, const char *path
,
616 char *buf
, int64_t size
)
618 if (!cmount
->is_mounted())
620 return cmount
->get_client()->readlink(path
, buf
, size
, cmount
->default_perms
);
623 extern "C" int ceph_symlink(struct ceph_mount_info
*cmount
, const char *existing
,
626 if (!cmount
->is_mounted())
628 return cmount
->get_client()->symlink(existing
, newname
, cmount
->default_perms
);
631 extern "C" int ceph_fstatx(struct ceph_mount_info
*cmount
, int fd
, struct ceph_statx
*stx
,
632 unsigned int want
, unsigned int flags
)
634 if (!cmount
->is_mounted())
636 if (flags
& ~CEPH_REQ_FLAG_MASK
)
638 return cmount
->get_client()->fstatx(fd
, stx
, cmount
->default_perms
,
642 extern "C" int ceph_statx(struct ceph_mount_info
*cmount
, const char *path
,
643 struct ceph_statx
*stx
, unsigned int want
, unsigned int flags
)
645 if (!cmount
->is_mounted())
647 if (flags
& ~CEPH_REQ_FLAG_MASK
)
649 return cmount
->get_client()->statx(path
, stx
, cmount
->default_perms
,
653 extern "C" int ceph_fsetattrx(struct ceph_mount_info
*cmount
, int fd
,
654 struct ceph_statx
*stx
, int mask
)
656 if (!cmount
->is_mounted())
658 return cmount
->get_client()->fsetattrx(fd
, stx
, mask
, cmount
->default_perms
);
661 extern "C" int ceph_setattrx(struct ceph_mount_info
*cmount
, const char *relpath
,
662 struct ceph_statx
*stx
, int mask
, int flags
)
664 if (!cmount
->is_mounted())
666 if (flags
& ~CEPH_REQ_FLAG_MASK
)
668 return cmount
->get_client()->setattrx(relpath
, stx
, mask
,
669 cmount
->default_perms
, flags
);
672 // *xattr() calls supporting samba/vfs
673 extern "C" int ceph_getxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, void *value
, size_t size
)
675 if (!cmount
->is_mounted())
678 return cmount
->get_client()->getxattr(path
, name
, value
, size
, cmount
->default_perms
);
681 extern "C" int ceph_lgetxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, void *value
, size_t size
)
683 if (!cmount
->is_mounted())
685 return cmount
->get_client()->lgetxattr(path
, name
, value
, size
, cmount
->default_perms
);
688 extern "C" int ceph_fgetxattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
, void *value
, size_t size
)
690 if (!cmount
->is_mounted())
692 return cmount
->get_client()->fgetxattr(fd
, name
, value
, size
, cmount
->default_perms
);
696 extern "C" int ceph_listxattr(struct ceph_mount_info
*cmount
, const char *path
, char *list
, size_t size
)
698 if (!cmount
->is_mounted())
700 return cmount
->get_client()->listxattr(path
, list
, size
, cmount
->default_perms
);
703 extern "C" int ceph_llistxattr(struct ceph_mount_info
*cmount
, const char *path
, char *list
, size_t size
)
705 if (!cmount
->is_mounted())
707 return cmount
->get_client()->llistxattr(path
, list
, size
, cmount
->default_perms
);
710 extern "C" int ceph_flistxattr(struct ceph_mount_info
*cmount
, int fd
, char *list
, size_t size
)
712 if (!cmount
->is_mounted())
714 return cmount
->get_client()->flistxattr(fd
, list
, size
, cmount
->default_perms
);
717 extern "C" int ceph_removexattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
)
719 if (!cmount
->is_mounted())
721 return cmount
->get_client()->removexattr(path
, name
, cmount
->default_perms
);
724 extern "C" int ceph_lremovexattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
)
726 if (!cmount
->is_mounted())
728 return cmount
->get_client()->lremovexattr(path
, name
, cmount
->default_perms
);
731 extern "C" int ceph_fremovexattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
)
733 if (!cmount
->is_mounted())
735 return cmount
->get_client()->fremovexattr(fd
, name
, cmount
->default_perms
);
738 extern "C" int ceph_setxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
740 if (!cmount
->is_mounted())
742 return cmount
->get_client()->setxattr(path
, name
, value
, size
, flags
, cmount
->default_perms
);
745 extern "C" int ceph_lsetxattr(struct ceph_mount_info
*cmount
, const char *path
, const char *name
, const void *value
, size_t size
, int flags
)
747 if (!cmount
->is_mounted())
749 return cmount
->get_client()->lsetxattr(path
, name
, value
, size
, flags
, cmount
->default_perms
);
752 extern "C" int ceph_fsetxattr(struct ceph_mount_info
*cmount
, int fd
, const char *name
, const void *value
, size_t size
, int flags
)
754 if (!cmount
->is_mounted())
756 return cmount
->get_client()->fsetxattr(fd
, name
, value
, size
, flags
, cmount
->default_perms
);
758 /* end xattr support */
760 extern "C" int ceph_chmod(struct ceph_mount_info
*cmount
, const char *path
, mode_t mode
)
762 if (!cmount
->is_mounted())
764 return cmount
->get_client()->chmod(path
, mode
, cmount
->default_perms
);
766 extern "C" int ceph_fchmod(struct ceph_mount_info
*cmount
, int fd
, mode_t mode
)
768 if (!cmount
->is_mounted())
770 return cmount
->get_client()->fchmod(fd
, mode
, cmount
->default_perms
);
772 extern "C" int ceph_chown(struct ceph_mount_info
*cmount
, const char *path
,
775 if (!cmount
->is_mounted())
777 return cmount
->get_client()->chown(path
, uid
, gid
, cmount
->default_perms
);
779 extern "C" int ceph_fchown(struct ceph_mount_info
*cmount
, int fd
,
782 if (!cmount
->is_mounted())
784 return cmount
->get_client()->fchown(fd
, uid
, gid
, cmount
->default_perms
);
786 extern "C" int ceph_lchown(struct ceph_mount_info
*cmount
, const char *path
,
789 if (!cmount
->is_mounted())
791 return cmount
->get_client()->lchown(path
, uid
, gid
, cmount
->default_perms
);
795 extern "C" int ceph_utime(struct ceph_mount_info
*cmount
, const char *path
,
798 if (!cmount
->is_mounted())
800 return cmount
->get_client()->utime(path
, buf
, cmount
->default_perms
);
803 extern "C" int ceph_flock(struct ceph_mount_info
*cmount
, int fd
, int operation
,
806 if (!cmount
->is_mounted())
808 return cmount
->get_client()->flock(fd
, operation
, owner
);
811 extern "C" int ceph_truncate(struct ceph_mount_info
*cmount
, const char *path
,
814 if (!cmount
->is_mounted())
816 return cmount
->get_client()->truncate(path
, size
, cmount
->default_perms
);
820 extern "C" int ceph_mknod(struct ceph_mount_info
*cmount
, const char *path
,
821 mode_t mode
, dev_t rdev
)
823 if (!cmount
->is_mounted())
825 return cmount
->get_client()->mknod(path
, mode
, cmount
->default_perms
, rdev
);
828 extern "C" int ceph_open(struct ceph_mount_info
*cmount
, const char *path
,
829 int flags
, mode_t mode
)
831 if (!cmount
->is_mounted())
833 return cmount
->get_client()->open(path
, flags
, cmount
->default_perms
, mode
);
836 extern "C" int ceph_open_layout(struct ceph_mount_info
*cmount
, const char *path
, int flags
,
837 mode_t mode
, int stripe_unit
, int stripe_count
, int object_size
, const char *data_pool
)
839 if (!cmount
->is_mounted())
841 return cmount
->get_client()->open(path
, flags
, cmount
->default_perms
, mode
,
842 stripe_unit
, stripe_count
,
843 object_size
, data_pool
);
846 extern "C" int ceph_close(struct ceph_mount_info
*cmount
, int fd
)
848 if (!cmount
->is_mounted())
850 return cmount
->get_client()->close(fd
);
853 extern "C" int64_t ceph_lseek(struct ceph_mount_info
*cmount
, int fd
,
854 int64_t offset
, int whence
)
856 if (!cmount
->is_mounted())
858 return cmount
->get_client()->lseek(fd
, offset
, whence
);
861 extern "C" int ceph_read(struct ceph_mount_info
*cmount
, int fd
, char *buf
,
862 int64_t size
, int64_t offset
)
864 if (!cmount
->is_mounted())
866 return cmount
->get_client()->read(fd
, buf
, size
, offset
);
869 extern "C" int ceph_preadv(struct ceph_mount_info
*cmount
, int fd
,
870 const struct iovec
*iov
, int iovcnt
, int64_t offset
)
872 if (!cmount
->is_mounted())
874 return cmount
->get_client()->preadv(fd
, iov
, iovcnt
, offset
);
877 extern "C" int ceph_write(struct ceph_mount_info
*cmount
, int fd
, const char *buf
,
878 int64_t size
, int64_t offset
)
880 if (!cmount
->is_mounted())
882 return cmount
->get_client()->write(fd
, buf
, size
, offset
);
885 extern "C" int ceph_pwritev(struct ceph_mount_info
*cmount
, int fd
,
886 const struct iovec
*iov
, int iovcnt
, int64_t offset
)
888 if (!cmount
->is_mounted())
890 return cmount
->get_client()->pwritev(fd
, iov
, iovcnt
, offset
);
893 extern "C" int ceph_ftruncate(struct ceph_mount_info
*cmount
, int fd
, int64_t size
)
895 if (!cmount
->is_mounted())
897 return cmount
->get_client()->ftruncate(fd
, size
, cmount
->default_perms
);
900 extern "C" int ceph_fsync(struct ceph_mount_info
*cmount
, int fd
, int syncdataonly
)
902 if (!cmount
->is_mounted())
904 return cmount
->get_client()->fsync(fd
, syncdataonly
);
907 extern "C" int ceph_fallocate(struct ceph_mount_info
*cmount
, int fd
, int mode
,
908 int64_t offset
, int64_t length
)
910 if (!cmount
->is_mounted())
912 return cmount
->get_client()->fallocate(fd
, mode
, offset
, length
);
915 extern "C" int ceph_sync_fs(struct ceph_mount_info
*cmount
)
917 if (!cmount
->is_mounted())
919 return cmount
->get_client()->sync_fs();
923 extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info
*cmount
, int fh
)
928 if (!cmount
->is_mounted())
930 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
933 return l
.stripe_unit
;
936 extern "C" int ceph_get_path_stripe_unit(struct ceph_mount_info
*cmount
, const char *path
)
941 if (!cmount
->is_mounted())
943 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
946 return l
.stripe_unit
;
949 extern "C" int ceph_get_file_stripe_count(struct ceph_mount_info
*cmount
, int fh
)
954 if (!cmount
->is_mounted())
956 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
959 return l
.stripe_count
;
962 extern "C" int ceph_get_path_stripe_count(struct ceph_mount_info
*cmount
, const char *path
)
967 if (!cmount
->is_mounted())
969 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
972 return l
.stripe_count
;
975 extern "C" int ceph_get_file_object_size(struct ceph_mount_info
*cmount
, int fh
)
980 if (!cmount
->is_mounted())
982 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
985 return l
.object_size
;
988 extern "C" int ceph_get_path_object_size(struct ceph_mount_info
*cmount
, const char *path
)
993 if (!cmount
->is_mounted())
995 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
998 return l
.object_size
;
1001 extern "C" int ceph_get_file_pool(struct ceph_mount_info
*cmount
, int fh
)
1006 if (!cmount
->is_mounted())
1008 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1014 extern "C" int ceph_get_path_pool(struct ceph_mount_info
*cmount
, const char *path
)
1019 if (!cmount
->is_mounted())
1021 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1027 extern "C" int ceph_get_file_pool_name(struct ceph_mount_info
*cmount
, int fh
, char *buf
, size_t len
)
1032 if (!cmount
->is_mounted())
1034 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1037 string name
= cmount
->get_client()->get_pool_name(l
.pool_id
);
1039 return name
.length();
1040 if (name
.length() > len
)
1042 strncpy(buf
, name
.c_str(), len
);
1043 return name
.length();
1046 extern "C" int ceph_get_pool_name(struct ceph_mount_info
*cmount
, int pool
, char *buf
, size_t len
)
1048 if (!cmount
->is_mounted())
1050 string name
= cmount
->get_client()->get_pool_name(pool
);
1052 return name
.length();
1053 if (name
.length() > len
)
1055 strncpy(buf
, name
.c_str(), len
);
1056 return name
.length();
1059 extern "C" int ceph_get_path_pool_name(struct ceph_mount_info
*cmount
, const char *path
, char *buf
, size_t len
)
1064 if (!cmount
->is_mounted())
1066 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1069 string name
= cmount
->get_client()->get_pool_name(l
.pool_id
);
1071 return name
.length();
1072 if (name
.length() > len
)
1074 strncpy(buf
, name
.c_str(), len
);
1075 return name
.length();
1078 extern "C" int ceph_get_default_data_pool_name(struct ceph_mount_info
*cmount
, char *buf
, size_t len
)
1080 if (!cmount
->is_mounted())
1082 int64_t pool_id
= cmount
->get_client()->get_default_pool_id();
1084 string name
= cmount
->get_client()->get_pool_name(pool_id
);
1086 return name
.length();
1087 if (name
.length() > len
)
1089 strncpy(buf
, name
.c_str(), len
);
1090 return name
.length();
1093 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
)
1098 if (!cmount
->is_mounted())
1100 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1104 *stripe_unit
= l
.stripe_unit
;
1106 *stripe_count
= l
.stripe_count
;
1108 *object_size
= l
.object_size
;
1110 *pg_pool
= l
.pool_id
;
1114 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
)
1119 if (!cmount
->is_mounted())
1121 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1125 *stripe_unit
= l
.stripe_unit
;
1127 *stripe_count
= l
.stripe_count
;
1129 *object_size
= l
.object_size
;
1131 *pg_pool
= l
.pool_id
;
1135 extern "C" int ceph_get_file_replication(struct ceph_mount_info
*cmount
, int fh
)
1140 if (!cmount
->is_mounted())
1142 r
= cmount
->get_client()->fdescribe_layout(fh
, &l
);
1145 int rep
= cmount
->get_client()->get_pool_replication(l
.pool_id
);
1149 extern "C" int ceph_get_path_replication(struct ceph_mount_info
*cmount
, const char *path
)
1154 if (!cmount
->is_mounted())
1156 r
= cmount
->get_client()->describe_layout(path
, &l
, cmount
->default_perms
);
1159 int rep
= cmount
->get_client()->get_pool_replication(l
.pool_id
);
1163 extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info
*cmount
,
1166 // this option no longer exists
1170 extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info
*cmount
,
1173 // this option no longer exists
1177 extern "C" int ceph_set_default_object_size(struct ceph_mount_info
*cmount
, int size
)
1179 // this option no longer exists
1183 extern "C" int ceph_set_default_file_replication(struct ceph_mount_info
*cmount
,
1186 // this option no longer exists
1190 extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info
*cmount
, int osd
)
1192 // this option no longer exists
1196 extern "C" int ceph_get_file_extent_osds(struct ceph_mount_info
*cmount
, int fh
,
1197 int64_t offset
, int64_t *length
, int *osds
, int nosds
)
1202 if (!cmount
->is_mounted())
1206 int ret
= cmount
->get_client()->get_file_extent_osds(fh
, offset
, length
, vosds
);
1211 return vosds
.size();
1213 if ((int)vosds
.size() > nosds
)
1216 for (int i
= 0; i
< (int)vosds
.size(); i
++)
1219 return vosds
.size();
1222 extern "C" int ceph_get_osd_crush_location(struct ceph_mount_info
*cmount
,
1223 int osd
, char *path
, size_t len
)
1225 if (!cmount
->is_mounted())
1231 vector
<pair
<string
, string
> > loc
;
1232 int ret
= cmount
->get_client()->get_osd_crush_location(osd
, loc
);
1238 vector
<pair
<string
, string
> >::iterator it
;
1239 for (it
= loc
.begin(); it
!= loc
.end(); ++it
) {
1240 string
& type
= it
->first
;
1241 string
& name
= it
->second
;
1242 needed
+= type
.size() + name
.size() + 2;
1243 if (needed
<= len
) {
1245 strcpy(path
+ cur
, type
.c_str());
1246 cur
+= type
.size() + 1;
1248 strcpy(path
+ cur
, name
.c_str());
1249 cur
+= name
.size() + 1;
1262 extern "C" int ceph_get_osd_addr(struct ceph_mount_info
*cmount
, int osd
,
1263 struct sockaddr_storage
*addr
)
1265 if (!cmount
->is_mounted())
1271 entity_addr_t address
;
1272 int ret
= cmount
->get_client()->get_osd_addr(osd
, address
);
1276 *addr
= address
.get_sockaddr_storage();
1281 extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info
*cmount
, int fh
,
1282 int64_t offset
, struct sockaddr_storage
*addr
, int naddr
)
1284 vector
<entity_addr_t
> address
;
1291 if (!cmount
->is_mounted())
1294 r
= cmount
->get_client()->get_file_stripe_address(fh
, offset
, address
);
1298 for (i
= 0; i
< (unsigned)naddr
&& i
< address
.size(); i
++)
1299 addr
[i
] = address
[i
].get_sockaddr_storage();
1301 /* naddr == 0: drop through and return actual size */
1302 if (naddr
&& (address
.size() > (unsigned)naddr
))
1305 return address
.size();
1308 extern "C" int ceph_localize_reads(struct ceph_mount_info
*cmount
, int val
)
1310 if (!cmount
->is_mounted())
1313 cmount
->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS
);
1315 cmount
->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS
);
1319 extern "C" CephContext
*ceph_get_mount_context(struct ceph_mount_info
*cmount
)
1321 return cmount
->get_ceph_context();
1324 extern "C" int ceph_debug_get_fd_caps(struct ceph_mount_info
*cmount
, int fd
)
1326 if (!cmount
->is_mounted())
1328 return cmount
->get_client()->get_caps_issued(fd
);
1331 extern "C" int ceph_debug_get_file_caps(struct ceph_mount_info
*cmount
, const char *path
)
1333 if (!cmount
->is_mounted())
1335 return cmount
->get_client()->get_caps_issued(path
, cmount
->default_perms
);
1338 extern "C" int ceph_get_stripe_unit_granularity(struct ceph_mount_info
*cmount
)
1340 if (!cmount
->is_mounted())
1342 return CEPH_MIN_STRIPE_UNIT
;
1345 extern "C" int ceph_get_pool_id(struct ceph_mount_info
*cmount
, const char *pool_name
)
1347 if (!cmount
->is_mounted())
1350 if (!pool_name
|| !pool_name
[0])
1353 /* negative range reserved for errors */
1354 int64_t pool_id
= cmount
->get_client()->get_pool_id(pool_name
);
1355 if (pool_id
> 0x7fffffff)
1358 /* get_pool_id error codes fit in int */
1359 return (int)pool_id
;
1362 extern "C" int ceph_get_pool_replication(struct ceph_mount_info
*cmount
,
1365 if (!cmount
->is_mounted())
1367 return cmount
->get_client()->get_pool_replication(pool_id
);
1369 /* Low-level exports */
1371 extern "C" int ceph_ll_lookup_root(struct ceph_mount_info
*cmount
,
1374 *parent
= cmount
->get_client()->get_root();
1380 extern "C" struct Inode
*ceph_ll_get_inode(class ceph_mount_info
*cmount
,
1383 return (cmount
->get_client())->ll_get_inode(vino
);
1388 * Populates the client cache with the requested inode, and its
1391 extern "C" int ceph_ll_lookup_inode(
1392 struct ceph_mount_info
*cmount
,
1393 struct inodeno_t ino
,
1396 int r
= (cmount
->get_client())->lookup_ino(ino
, cmount
->default_perms
, inode
);
1401 assert(inode
!= NULL
);
1402 assert(*inode
!= NULL
);
1404 // Request the parent inode, so that we can look up the name
1406 r
= (cmount
->get_client())->lookup_parent(*inode
, cmount
->default_perms
, &parent
);
1407 if (r
&& r
!= -EINVAL
) {
1409 (cmount
->get_client())->ll_forget(*inode
, 1);
1411 } else if (r
== -EINVAL
) {
1412 // EINVAL indicates node without parents (root), drop out now
1413 // and don't try to look up the non-existent dentry.
1416 // FIXME: I don't think this works; lookup_parent() returns 0 if the parent
1417 // is already in cache
1418 assert(parent
!= NULL
);
1420 // Finally, get the name (dentry) of the requested inode
1421 r
= (cmount
->get_client())->lookup_name(*inode
, parent
, cmount
->default_perms
);
1424 (cmount
->get_client())->ll_forget(parent
, 1);
1425 (cmount
->get_client())->ll_forget(*inode
, 1);
1429 (cmount
->get_client())->ll_forget(parent
, 1);
1433 extern "C" int ceph_ll_lookup(struct ceph_mount_info
*cmount
,
1434 Inode
*parent
, const char *name
, Inode
**out
,
1435 struct ceph_statx
*stx
, unsigned want
,
1436 unsigned flags
, const UserPerm
*perms
)
1438 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1440 return (cmount
->get_client())->ll_lookupx(parent
, name
, out
, stx
, want
,
1444 extern "C" int ceph_ll_put(class ceph_mount_info
*cmount
, Inode
*in
)
1446 return (cmount
->get_client()->ll_put(in
));
1449 extern "C" int ceph_ll_forget(class ceph_mount_info
*cmount
, Inode
*in
,
1452 return (cmount
->get_client()->ll_forget(in
, count
));
1455 extern "C" int ceph_ll_walk(struct ceph_mount_info
*cmount
, const char* name
, Inode
**i
,
1456 struct ceph_statx
*stx
, unsigned int want
, unsigned int flags
,
1457 const UserPerm
*perms
)
1459 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1461 return(cmount
->get_client()->ll_walk(name
, i
, stx
, want
, flags
, *perms
));
1464 extern "C" int ceph_ll_getattr(class ceph_mount_info
*cmount
,
1465 Inode
*in
, struct ceph_statx
*stx
,
1466 unsigned int want
, unsigned int flags
,
1467 const UserPerm
*perms
)
1469 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1471 return (cmount
->get_client()->ll_getattrx(in
, stx
, want
, flags
, *perms
));
1474 extern "C" int ceph_ll_setattr(class ceph_mount_info
*cmount
,
1475 Inode
*in
, struct ceph_statx
*stx
,
1476 int mask
, const UserPerm
*perms
)
1478 return (cmount
->get_client()->ll_setattrx(in
, stx
, mask
, *perms
));
1481 extern "C" int ceph_ll_open(class ceph_mount_info
*cmount
, Inode
*in
,
1482 int flags
, Fh
**fh
, const UserPerm
*perms
)
1484 return (cmount
->get_client()->ll_open(in
, flags
, fh
, *perms
));
1487 extern "C" int ceph_ll_read(class ceph_mount_info
*cmount
, Fh
* filehandle
,
1488 int64_t off
, uint64_t len
, char* buf
)
1493 r
= cmount
->get_client()->ll_read(filehandle
, off
, len
, &bl
);
1496 bl
.copy(0, bl
.length(), buf
);
1502 extern "C" int ceph_ll_read_block(class ceph_mount_info
*cmount
,
1503 Inode
*in
, uint64_t blockid
,
1504 char* buf
, uint64_t offset
,
1506 struct ceph_file_layout
* layout
)
1509 int r
= (cmount
->get_client()->ll_read_block(in
, blockid
, buf
, offset
,
1511 l
.to_legacy(layout
);
1515 extern "C" int ceph_ll_write_block(class ceph_mount_info
*cmount
,
1516 Inode
*in
, uint64_t blockid
,
1517 char *buf
, uint64_t offset
,
1519 struct ceph_file_layout
*layout
,
1520 uint64_t snapseq
, uint32_t sync
)
1523 int r
= (cmount
->get_client()->ll_write_block(in
, blockid
, buf
, offset
,
1524 length
, &l
, snapseq
, sync
));
1525 l
.to_legacy(layout
);
1529 extern "C" int ceph_ll_commit_blocks(class ceph_mount_info
*cmount
,
1530 Inode
*in
, uint64_t offset
,
1533 return (cmount
->get_client()->ll_commit_blocks(in
, offset
, range
));
1536 extern "C" int ceph_ll_fsync(class ceph_mount_info
*cmount
,
1537 Fh
*fh
, int syncdataonly
)
1539 return (cmount
->get_client()->ll_fsync(fh
, syncdataonly
));
1542 extern "C" int ceph_ll_sync_inode(class ceph_mount_info
*cmount
,
1543 Inode
*in
, int syncdataonly
)
1545 return (cmount
->get_client()->ll_sync_inode(in
, syncdataonly
));
1548 extern "C" off_t
ceph_ll_lseek(class ceph_mount_info
*cmount
,
1549 Fh
*fh
, off_t offset
, int whence
)
1551 return (cmount
->get_client()->ll_lseek(fh
, offset
, whence
));
1554 extern "C" int ceph_ll_write(class ceph_mount_info
*cmount
,
1555 Fh
*fh
, int64_t off
, uint64_t len
,
1558 return (cmount
->get_client()->ll_write(fh
, off
, len
, data
));
1561 extern "C" int64_t ceph_ll_readv(class ceph_mount_info
*cmount
,
1562 struct Fh
*fh
, const struct iovec
*iov
,
1563 int iovcnt
, int64_t off
)
1565 return -1; // TODO: implement
1568 extern "C" int64_t ceph_ll_writev(class ceph_mount_info
*cmount
,
1569 struct Fh
*fh
, const struct iovec
*iov
,
1570 int iovcnt
, int64_t off
)
1572 return -1; // TODO: implement
1575 extern "C" int ceph_ll_close(class ceph_mount_info
*cmount
, Fh
* fh
)
1577 return (cmount
->get_client()->ll_release(fh
));
1580 extern "C" int ceph_ll_create(class ceph_mount_info
*cmount
,
1581 Inode
*parent
, const char *name
, mode_t mode
,
1582 int oflags
, Inode
**outp
, Fh
**fhp
,
1583 struct ceph_statx
*stx
, unsigned want
,
1584 unsigned lflags
, const UserPerm
*perms
)
1586 if (lflags
& ~CEPH_REQ_FLAG_MASK
)
1588 return (cmount
->get_client())->ll_createx(parent
, name
, mode
, oflags
, outp
,
1589 fhp
, stx
, want
, lflags
, *perms
);
1592 extern "C" int ceph_ll_mknod(class ceph_mount_info
*cmount
, Inode
*parent
,
1593 const char *name
, mode_t mode
, dev_t rdev
,
1594 Inode
**out
, struct ceph_statx
*stx
,
1595 unsigned want
, unsigned flags
,
1596 const UserPerm
*perms
)
1598 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1600 return (cmount
->get_client())->ll_mknodx(parent
, name
, mode
, rdev
,
1601 out
, stx
, want
, flags
, *perms
);
1604 extern "C" int ceph_ll_mkdir(class ceph_mount_info
*cmount
, Inode
*parent
,
1605 const char *name
, mode_t mode
, Inode
**out
,
1606 struct ceph_statx
*stx
, unsigned want
,
1607 unsigned flags
, const UserPerm
*perms
)
1609 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1611 return cmount
->get_client()->ll_mkdirx(parent
, name
, mode
, out
, stx
, want
,
1615 extern "C" int ceph_ll_link(class ceph_mount_info
*cmount
,
1616 Inode
*in
, Inode
*newparent
,
1617 const char *name
, const UserPerm
*perms
)
1619 return cmount
->get_client()->ll_link(in
, newparent
, name
, *perms
);
1622 extern "C" int ceph_ll_opendir(class ceph_mount_info
*cmount
,
1624 struct ceph_dir_result
**dirpp
,
1625 const UserPerm
*perms
)
1627 return (cmount
->get_client()->ll_opendir(in
, O_RDONLY
, (dir_result_t
**) dirpp
,
1631 extern "C" int ceph_ll_releasedir(class ceph_mount_info
*cmount
,
1632 ceph_dir_result
*dir
)
1634 (void) cmount
->get_client()->ll_releasedir(reinterpret_cast<dir_result_t
*>(dir
));
1638 extern "C" int ceph_ll_rename(class ceph_mount_info
*cmount
,
1639 Inode
*parent
, const char *name
,
1640 Inode
*newparent
, const char *newname
,
1641 const UserPerm
*perms
)
1643 return cmount
->get_client()->ll_rename(parent
, name
, newparent
,
1647 extern "C" int ceph_ll_unlink(class ceph_mount_info
*cmount
, Inode
*in
,
1648 const char *name
, const UserPerm
*perms
)
1650 return cmount
->get_client()->ll_unlink(in
, name
, *perms
);
1653 extern "C" int ceph_ll_statfs(class ceph_mount_info
*cmount
,
1654 Inode
*in
, struct statvfs
*stbuf
)
1656 return (cmount
->get_client()->ll_statfs(in
, stbuf
, cmount
->default_perms
));
1659 extern "C" int ceph_ll_readlink(class ceph_mount_info
*cmount
, Inode
*in
,
1660 char *buf
, size_t bufsiz
,
1661 const UserPerm
*perms
)
1663 return cmount
->get_client()->ll_readlink(in
, buf
, bufsiz
, *perms
);
1666 extern "C" int ceph_ll_symlink(class ceph_mount_info
*cmount
,
1667 Inode
*in
, const char *name
,
1668 const char *value
, Inode
**out
,
1669 struct ceph_statx
*stx
, unsigned want
,
1670 unsigned flags
, const UserPerm
*perms
)
1672 if (flags
& ~CEPH_REQ_FLAG_MASK
)
1674 return (cmount
->get_client()->ll_symlinkx(in
, name
, value
, out
, stx
, want
,
1678 extern "C" int ceph_ll_rmdir(class ceph_mount_info
*cmount
,
1679 Inode
*in
, const char *name
,
1680 const UserPerm
*perms
)
1682 return cmount
->get_client()->ll_rmdir(in
, name
, *perms
);
1685 extern "C" int ceph_ll_getxattr(class ceph_mount_info
*cmount
,
1686 Inode
*in
, const char *name
, void *value
,
1687 size_t size
, const UserPerm
*perms
)
1689 return (cmount
->get_client()->ll_getxattr(in
, name
, value
, size
, *perms
));
1692 extern "C" int ceph_ll_listxattr(struct ceph_mount_info
*cmount
,
1693 Inode
*in
, char *list
,
1694 size_t buf_size
, size_t *list_size
,
1695 const UserPerm
*perms
)
1697 int res
= cmount
->get_client()->ll_listxattr(in
, list
, buf_size
, *perms
);
1699 *list_size
= (size_t)res
;
1705 extern "C" int ceph_ll_setxattr(class ceph_mount_info
*cmount
,
1706 Inode
*in
, const char *name
,
1707 const void *value
, size_t size
,
1708 int flags
, const UserPerm
*perms
)
1710 return (cmount
->get_client()->ll_setxattr(in
, name
, value
, size
, flags
, *perms
));
1713 extern "C" int ceph_ll_removexattr(class ceph_mount_info
*cmount
,
1714 Inode
*in
, const char *name
,
1715 const UserPerm
*perms
)
1717 return (cmount
->get_client()->ll_removexattr(in
, name
, *perms
));
1720 extern "C" int ceph_ll_getlk(struct ceph_mount_info
*cmount
,
1721 Fh
*fh
, struct flock
*fl
, uint64_t owner
)
1723 return (cmount
->get_client()->ll_getlk(fh
, fl
, owner
));
1726 extern "C" int ceph_ll_setlk(struct ceph_mount_info
*cmount
,
1727 Fh
*fh
, struct flock
*fl
, uint64_t owner
,
1730 return (cmount
->get_client()->ll_setlk(fh
, fl
, owner
, sleep
));
1733 extern "C" int ceph_ll_delegation(struct ceph_mount_info
*cmount
, Fh
*fh
,
1734 unsigned cmd
, ceph_deleg_cb_t cb
, void *priv
)
1736 return (cmount
->get_client()->ll_delegation(fh
, cmd
, cb
, priv
));
1739 extern "C" uint32_t ceph_ll_stripe_unit(class ceph_mount_info
*cmount
,
1742 return (cmount
->get_client()->ll_stripe_unit(in
));
1745 extern "C" uint32_t ceph_ll_file_layout(class ceph_mount_info
*cmount
,
1747 struct ceph_file_layout
*layout
)
1750 int r
= (cmount
->get_client()->ll_file_layout(in
, &l
));
1751 l
.to_legacy(layout
);
1755 uint64_t ceph_ll_snap_seq(class ceph_mount_info
*cmount
, Inode
*in
)
1757 return (cmount
->get_client()->ll_snap_seq(in
));
1760 extern "C" int ceph_ll_get_stripe_osd(class ceph_mount_info
*cmount
,
1761 Inode
*in
, uint64_t blockno
,
1762 struct ceph_file_layout
* layout
)
1765 int r
= (cmount
->get_client()->ll_get_stripe_osd(in
, blockno
, &l
));
1766 l
.to_legacy(layout
);
1770 extern "C" int ceph_ll_num_osds(class ceph_mount_info
*cmount
)
1772 return (cmount
->get_client()->ll_num_osds());
1775 extern "C" int ceph_ll_osdaddr(class ceph_mount_info
*cmount
,
1776 int osd
, uint32_t *addr
)
1778 return (cmount
->get_client()->ll_osdaddr(osd
, addr
));
1781 extern "C" uint64_t ceph_ll_get_internal_offset(class ceph_mount_info
*cmount
,
1785 return (cmount
->get_client()->ll_get_internal_offset(in
, blockno
));
1788 extern "C" void ceph_buffer_free(char *buf
)
1795 extern "C" uint32_t ceph_get_cap_return_timeout(class ceph_mount_info
*cmount
)
1797 if (!cmount
->is_mounted())
1799 return cmount
->get_client()->mdsmap
->get_session_autoclose().sec();
1802 extern "C" int ceph_set_deleg_timeout(class ceph_mount_info
*cmount
, uint32_t timeout
)
1804 if (!cmount
->is_mounted())
1806 return cmount
->get_client()->set_deleg_timeout(timeout
);