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) 2004-2006 Sage Weil <sage@newdream.net>
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.
19 #include "include/types.h"
31 #include "include/unordered_set.h"
32 #include "include/unordered_map.h"
33 #include "include/filepath.h"
34 #include "include/interval_set.h"
35 #include "include/lru.h"
36 #include "mds/mdstypes.h"
37 #include "msg/Dispatcher.h"
38 #include "msg/Messenger.h"
40 #include "common/Mutex.h"
41 #include "common/Timer.h"
42 #include "common/Finisher.h"
43 #include "common/compiler_extensions.h"
44 #include "common/cmdparse.h"
45 #include "common/CommandTable.h"
47 #include "osdc/ObjectCacher.h"
51 #include "include/cephfs/ceph_statx.h"
62 class MClientRequestForward
;
65 class MClientCapRelease
;
73 class WritebackHandler
;
88 class MDSCommandOp
: public CommandOp
93 MDSCommandOp(ceph_tid_t t
) : CommandOp(t
) {}
96 /* error code for ceph_fuse */
97 #define CEPH_FUSE_NO_MDS_UP -(1<<2) /* no mds up deteced in ceph_fuse */
99 // ============================================
100 // types for my local metadata cache
103 - Dentries live in an LRU loop. they get expired based on last access.
104 see include/lru.h. items can be bumped to "mid" or "top" of list, etc.
105 - Inode has ref count for each Fh, Dir, or Dentry that points to it.
106 - when Inode ref goes to 0, it's expired.
107 - when Dir is empty, it's removed (and it's Inode ref--)
116 explicit DirEntry(const string
&s
) : d_name(s
), stmask(0) {}
117 DirEntry(const string
&n
, struct stat
& s
, int stm
) : d_name(n
), st(s
), stmask(stm
) {}
129 class ceph_lock_state_t
;
132 typedef void (*client_ino_callback_t
)(void *handle
, vinodeno_t ino
, int64_t off
, int64_t len
);
134 typedef void (*client_dentry_callback_t
)(void *handle
, vinodeno_t dirino
,
135 vinodeno_t ino
, string
& name
);
136 typedef int (*client_remount_callback_t
)(void *handle
);
138 typedef int (*client_getgroups_callback_t
)(void *handle
, gid_t
**sgids
);
139 typedef void(*client_switch_interrupt_callback_t
)(void *handle
, void *data
);
140 typedef mode_t (*client_umask_callback_t
)(void *handle
);
142 /* Callback for delegation recalls */
143 typedef void (*ceph_deleg_cb_t
)(Fh
*fh
, void *priv
);
145 struct client_callback_args
{
147 client_ino_callback_t ino_cb
;
148 client_dentry_callback_t dentry_cb
;
149 client_switch_interrupt_callback_t switch_intr_cb
;
150 client_remount_callback_t remount_cb
;
151 client_getgroups_callback_t getgroups_cb
;
152 client_umask_callback_t umask_cb
;
155 // ========================================================
158 struct dir_result_t
{
159 static const int SHIFT
= 28;
160 static const int64_t MASK
= (1 << SHIFT
) - 1;
161 static const int64_t HASH
= 0xFFULL
<< (SHIFT
+ 24); // impossible frag bits
162 static const loff_t END
= 1ULL << (SHIFT
+ 32);
164 static uint64_t make_fpos(unsigned h
, unsigned l
, bool hash
) {
165 uint64_t v
= ((uint64_t)h
<< SHIFT
) | (uint64_t)l
;
169 assert((v
& HASH
) != HASH
);
172 static unsigned fpos_high(uint64_t p
) {
173 unsigned v
= (p
& (END
-1)) >> SHIFT
;
174 if ((p
& HASH
) == HASH
)
175 return ceph_frag_value(v
);
178 static unsigned fpos_low(uint64_t p
) {
181 static int fpos_cmp(uint64_t l
, uint64_t r
) {
182 int c
= ceph_frag_compare(fpos_high(l
), fpos_high(r
));
185 if (fpos_low(l
) == fpos_low(r
))
187 return fpos_low(l
) < fpos_low(r
) ? -1 : 1;
191 int64_t offset
; // hash order:
192 // (0xff << 52) | ((24 bits hash) << 28) |
193 // (the nth entry has hash collision);
195 // ((frag value) << 28) | (the nth entry in frag);
197 unsigned next_offset
; // offset of next chunk (last_name's + 1)
198 string last_name
; // last entry in previous chunk
200 uint64_t release_count
;
201 uint64_t ordered_count
;
202 unsigned cache_index
;
203 int start_shared_gen
; // dir shared_gen at start of readdir
212 dentry(int64_t o
) : offset(o
) {}
213 dentry(int64_t o
, const string
& n
, const InodeRef
& in
) :
214 offset(o
), name(n
), inode(in
) {}
216 struct dentry_off_lt
{
217 bool operator()(const dentry
& d
, int64_t off
) const {
218 return dir_result_t::fpos_cmp(d
.offset
, off
) < 0;
221 vector
<dentry
> buffer
;
223 explicit dir_result_t(Inode
*in
, const UserPerm
& perms
);
225 unsigned offset_high() { return fpos_high(offset
); }
226 unsigned offset_low() { return fpos_low(offset
); }
228 void set_end() { offset
|= END
; }
229 bool at_end() { return (offset
& END
); }
231 void set_hash_order() { offset
|= HASH
; }
232 bool hash_order() { return (offset
& HASH
) == HASH
; }
238 return buffer_frag
.contains(offset_high());
240 return buffer_frag
== frag_t(offset_high());
254 class Client
: public Dispatcher
, public md_config_obs_t
{
256 using Dispatcher::cct
;
258 std::unique_ptr
<PerfCounters
> logger
;
260 class CommandHook
: public AdminSocketHook
{
263 explicit CommandHook(Client
*client
);
264 bool call(std::string command
, cmdmap_t
&cmdmap
, std::string format
,
265 bufferlist
& out
) override
;
267 CommandHook m_command_hook
;
269 // cluster descriptors
270 std::unique_ptr
<MDSMap
> mdsmap
;
274 void *callback_handle
;
275 client_switch_interrupt_callback_t switch_interrupt_cb
;
276 client_remount_callback_t remount_cb
;
277 client_ino_callback_t ino_invalidate_cb
;
278 client_dentry_callback_t dentry_invalidate_cb
;
279 client_getgroups_callback_t getgroups_cb
;
280 client_umask_callback_t umask_cb
;
281 bool can_invalidate_dentries
;
283 Finisher async_ino_invalidator
;
284 Finisher async_dentry_invalidator
;
285 Finisher interrupt_finisher
;
286 Finisher remount_finisher
;
287 Finisher objecter_finisher
;
290 utime_t last_cap_renew
;
292 void renew_caps(MetaSession
*session
);
293 void flush_cap_releases();
297 UserPerm
pick_my_perms() {
298 uid_t uid
= user_id
>= 0 ? user_id
: -1;
299 gid_t gid
= group_id
>= 0 ? group_id
: -1;
300 return UserPerm(uid
, gid
);
303 static UserPerm
pick_my_perms(CephContext
*c
) {
304 uid_t uid
= c
->_conf
->client_mount_uid
>= 0 ? c
->_conf
->client_mount_uid
: -1;
305 gid_t gid
= c
->_conf
->client_mount_gid
>= 0 ? c
->_conf
->client_mount_gid
: -1;
306 return UserPerm(uid
, gid
);
309 Messenger
*messenger
;
310 MonClient
*monclient
;
315 int user_id
, group_id
;
318 void set_cap_epoch_barrier(epoch_t e
);
319 epoch_t cap_epoch_barrier
;
322 map
<mds_rank_t
, MetaSession
*> mds_sessions
; // mds -> push seq
323 list
<Cond
*> waiting_for_mdsmap
;
325 // FSMap, for when using mds_command
326 list
<Cond
*> waiting_for_fsmap
;
327 std::unique_ptr
<FSMap
> fsmap
;
328 std::unique_ptr
<FSMapUser
> fsmap_user
;
331 CommandTable
<MDSCommandOp
> command_table
;
332 void handle_command_reply(MCommandReply
*m
);
333 int fetch_fsmap(bool user
);
335 const std::string
&mds_spec
,
336 std::vector
<mds_gid_t
> *targets
);
338 void get_session_metadata(std::map
<std::string
, std::string
> *meta
) const;
339 bool have_open_session(mds_rank_t mds
);
340 void got_mds_push(MetaSession
*s
);
341 MetaSession
*_get_mds_session(mds_rank_t mds
, Connection
*con
); ///< return session for mds *and* con; null otherwise
342 MetaSession
*_get_or_open_mds_session(mds_rank_t mds
);
343 MetaSession
*_open_mds_session(mds_rank_t mds
);
344 void _close_mds_session(MetaSession
*s
);
345 void _closed_mds_session(MetaSession
*s
);
346 bool _any_stale_sessions() const;
347 void _kick_stale_sessions();
348 void handle_client_session(MClientSession
*m
);
349 void send_reconnect(MetaSession
*s
);
350 void resend_unsafe_requests(MetaSession
*s
);
351 void wait_unsafe_requests();
355 ceph_tid_t oldest_tid
; // oldest incomplete mds request, excluding setfilelock requests
356 map
<ceph_tid_t
, MetaRequest
*> mds_requests
;
359 ceph_tid_t last_flush_tid
;
361 void dump_mds_requests(Formatter
*f
);
362 void dump_mds_sessions(Formatter
*f
);
364 int make_request(MetaRequest
*req
, const UserPerm
& perms
,
365 InodeRef
*ptarget
= 0, bool *pcreated
= 0,
366 mds_rank_t use_mds
=-1, bufferlist
*pdirbl
=0);
367 void put_request(MetaRequest
*request
);
368 void unregister_request(MetaRequest
*request
);
370 int verify_reply_trace(int r
, MetaRequest
*request
, MClientReply
*reply
,
371 InodeRef
*ptarget
, bool *pcreated
,
372 const UserPerm
& perms
);
373 void encode_cap_releases(MetaRequest
*request
, mds_rank_t mds
);
374 int encode_inode_release(Inode
*in
, MetaRequest
*req
,
375 mds_rank_t mds
, int drop
,
376 int unless
,int force
=0);
377 void encode_dentry_release(Dentry
*dn
, MetaRequest
*req
,
378 mds_rank_t mds
, int drop
, int unless
);
379 mds_rank_t
choose_target_mds(MetaRequest
*req
, Inode
** phash_diri
=NULL
);
380 void connect_mds_targets(mds_rank_t mds
);
381 void send_request(MetaRequest
*request
, MetaSession
*session
,
382 bool drop_cap_releases
=false);
383 MClientRequest
*build_client_request(MetaRequest
*request
);
384 void kick_requests(MetaSession
*session
);
385 void kick_requests_closed(MetaSession
*session
);
386 void handle_client_request_forward(MClientRequestForward
*reply
);
387 void handle_client_reply(MClientReply
*reply
);
388 bool is_dir_operation(MetaRequest
*request
);
395 // When an MDS has sent us a REJECT, remember that and don't
396 // contact it again. Remember which inst rejected us, so that
397 // when we talk to another inst with the same rank we can
399 std::map
<mds_rank_t
, entity_inst_t
> rejected_by_mds
;
402 epoch_t local_osd_epoch
;
404 int unsafe_sync_write
;
407 entity_name_t
get_myname() { return messenger
->get_myname(); }
408 void _sync_write_commit(Inode
*in
);
409 void wait_on_list(list
<Cond
*>& ls
);
410 void signal_cond_list(list
<Cond
*>& ls
);
413 std::unique_ptr
<Filer
> filer
;
414 std::unique_ptr
<ObjectCacher
> objectcacher
;
415 std::unique_ptr
<WritebackHandler
> writeback_handler
;
418 ceph::unordered_map
<vinodeno_t
, Inode
*> inode_map
;
420 // fake inode number for 32-bits ino_t
421 ceph::unordered_map
<ino_t
, vinodeno_t
> faked_ino_map
;
422 interval_set
<ino_t
> free_faked_inos
;
423 ino_t last_used_faked_ino
;
424 void _assign_faked_ino(Inode
*in
);
425 void _release_faked_ino(Inode
*in
);
426 bool _use_faked_inos
;
427 void _reset_faked_inos();
428 vinodeno_t
_map_faked_ino(ino_t ino
);
431 map
<Inode
*, InodeRef
> root_parents
;
432 Inode
* root_ancestor
;
433 LRU lru
; // lru list of Dentry's in our local metadata cache.
435 // all inodes with caps sit on either cap_list or delayed_caps.
436 xlist
<Inode
*> delayed_caps
, cap_list
;
437 int num_flushing_caps
;
438 ceph::unordered_map
<inodeno_t
,SnapRealm
*> snap_realms
;
440 // Optional extra metadata about me to send to the MDS
441 std::map
<std::string
, std::string
> metadata
;
442 void populate_metadata(const std::string
&mount_root
);
445 /* async block write barrier support */
446 //map<uint64_t, BarrierContext* > barriers;
448 SnapRealm
*get_snap_realm(inodeno_t r
);
449 SnapRealm
*get_snap_realm_maybe(inodeno_t r
);
450 void put_snap_realm(SnapRealm
*realm
);
451 bool adjust_realm_parent(SnapRealm
*realm
, inodeno_t parent
);
452 void update_snap_trace(bufferlist
& bl
, SnapRealm
**realm_ret
, bool must_flush
=true);
453 void invalidate_snaprealm_and_children(SnapRealm
*realm
);
455 Inode
*open_snapdir(Inode
*diri
);
458 // file handles, etc.
459 interval_set
<int> free_fd_set
; // unused fds
460 ceph::unordered_map
<int, Fh
*> fd_map
;
461 set
<Fh
*> ll_unclosed_fh_set
;
462 ceph::unordered_set
<dir_result_t
*> opened_dirs
;
465 int fd
= free_fd_set
.range_start();
466 free_fd_set
.erase(fd
, 1);
469 void put_fd(int fd
) {
470 free_fd_set
.insert(fd
, 1);
474 * Resolve file descriptor, or return NULL.
476 Fh
*get_filehandle(int fd
) {
477 ceph::unordered_map
<int, Fh
*>::iterator p
= fd_map
.find(fd
);
478 if (p
== fd_map
.end())
483 // global client lock
484 // - protects Client and buffer cache both!
488 void wake_inode_waiters(MetaSession
*s
);
490 void wait_on_context_list(list
<Context
*>& ls
);
491 void signal_context_list(list
<Context
*>& ls
);
493 // -- metadata cache stuff
495 // decrease inode ref. delete if dangling.
496 void put_inode(Inode
*in
, int n
=1);
497 void close_dir(Dir
*dir
);
499 // same as unmount() but for when the client_lock is already held
502 friend class C_Client_FlushComplete
; // calls put_inode()
503 friend class C_Client_CacheInvalidate
; // calls ino_invalidate_cb
504 friend class C_Client_DentryInvalidate
; // calls dentry_invalidate_cb
505 friend class C_Block_Sync
; // Calls block map and protected helpers
506 friend class C_Client_RequestInterrupt
;
507 friend class C_Client_Remount
;
508 friend class C_Deleg_Timeout
; // Asserts on client_lock, called when a delegation is unreturned
509 friend void intrusive_ptr_release(Inode
*in
);
511 //int get_cache_size() { return lru.lru_get_size(); }
514 * Don't call this with in==NULL, use get_or_create for that
515 * leave dn set to default NULL unless you're trying to add
516 * a new inode to a pre-created Dentry
518 Dentry
* link(Dir
*dir
, const string
& name
, Inode
*in
, Dentry
*dn
);
519 void unlink(Dentry
*dn
, bool keepdir
, bool keepdentry
);
521 // path traversal for high-level interface
523 int path_walk(const filepath
& fp
, InodeRef
*end
, const UserPerm
& perms
,
524 bool followsym
=true, int mask
=0);
526 int fill_stat(Inode
*in
, struct stat
*st
, frag_info_t
*dirstat
=0, nest_info_t
*rstat
=0);
527 int fill_stat(InodeRef
& in
, struct stat
*st
, frag_info_t
*dirstat
=0, nest_info_t
*rstat
=0) {
528 return fill_stat(in
.get(), st
, dirstat
, rstat
);
531 void fill_statx(Inode
*in
, unsigned int mask
, struct ceph_statx
*stx
);
532 void fill_statx(InodeRef
& in
, unsigned int mask
, struct ceph_statx
*stx
) {
533 return fill_statx(in
.get(), mask
, stx
);
536 void touch_dn(Dentry
*dn
);
539 void trim_cache(bool trim_kernel_dcache
=false);
540 void trim_cache_for_reconnect(MetaSession
*s
);
541 void trim_dentry(Dentry
*dn
);
542 void trim_caps(MetaSession
*s
, int max
);
543 void _invalidate_kernel_dcache();
545 void dump_inode(Formatter
*f
, Inode
*in
, set
<Inode
*>& did
, bool disconnected
);
546 void dump_cache(Formatter
*f
); // debug
549 void force_session_readonly(MetaSession
*s
);
551 void dump_status(Formatter
*f
); // debug
557 Cond mount_cond
, sync_cond
;
561 friend class SyntheticClient
;
562 bool ms_dispatch(Message
*m
) override
;
564 void ms_handle_connect(Connection
*con
) override
;
565 bool ms_handle_reset(Connection
*con
) override
;
566 void ms_handle_remote_reset(Connection
*con
) override
;
567 bool ms_handle_refused(Connection
*con
) override
;
568 bool ms_get_authorizer(int dest_type
, AuthAuthorizer
**authorizer
, bool force_new
) override
;
572 Inode
* get_quota_root(Inode
*in
, const UserPerm
& perms
);
573 bool check_quota_condition(Inode
*in
, const UserPerm
& perms
,
574 std::function
<bool (const Inode
&)> test
);
575 bool is_quota_files_exceeded(Inode
*in
, const UserPerm
& perms
);
576 bool is_quota_bytes_exceeded(Inode
*in
, int64_t new_bytes
,
577 const UserPerm
& perms
);
578 bool is_quota_bytes_approaching(Inode
*in
, const UserPerm
& perms
);
580 std::map
<std::pair
<int64_t,std::string
>, int> pool_perms
;
581 list
<Cond
*> waiting_for_pool_perm
;
582 int check_pool_perm(Inode
*in
, int need
);
585 * Call this when an OSDMap is seen with a full flag (global or per pool)
588 * @param pool the pool ID affected, or -1 if all.
590 void _handle_full_flag(int64_t pool
);
592 void _close_sessions();
595 * The basic housekeeping parts of init (perf counters, admin socket)
596 * that is independent of how objecters/monclient/messengers are
602 void set_filer_flags(int flags
);
603 void clear_filer_flags(int flags
);
605 Client(Messenger
*m
, MonClient
*mc
, Objecter
*objecter_
);
607 void tear_down_cache();
609 void update_metadata(std::string
const &k
, std::string
const &v
);
611 client_t
get_nodeid() { return whoami
; }
613 inodeno_t
get_root_ino();
617 virtual void shutdown();
620 void handle_mds_map(class MMDSMap
*m
);
621 void handle_fs_map(class MFSMap
*m
);
622 void handle_fs_map_user(class MFSMapUser
*m
);
623 void handle_osd_map(class MOSDMap
*m
);
625 void handle_lease(MClientLease
*m
);
628 int uninline_data(Inode
*in
, Context
*onfinish
);
631 void check_cap_issue(Inode
*in
, Cap
*cap
, unsigned issued
);
632 void add_update_cap(Inode
*in
, MetaSession
*session
, uint64_t cap_id
,
633 unsigned issued
, unsigned seq
, unsigned mseq
, inodeno_t realm
,
634 int flags
, const UserPerm
& perms
);
635 void remove_cap(Cap
*cap
, bool queue_release
);
636 void remove_all_caps(Inode
*in
);
637 void remove_session_caps(MetaSession
*session
);
638 void mark_caps_dirty(Inode
*in
, int caps
);
639 int mark_caps_flushing(Inode
*in
, ceph_tid_t
*ptid
);
640 void adjust_session_flushing_caps(Inode
*in
, MetaSession
*old_s
, MetaSession
*new_s
);
641 void flush_caps_sync();
642 void flush_caps(Inode
*in
, MetaSession
*session
, bool sync
=false);
643 void kick_flushing_caps(MetaSession
*session
);
644 void early_kick_flushing_caps(MetaSession
*session
);
645 void kick_maxsize_requests(MetaSession
*session
);
646 int get_caps(Inode
*in
, int need
, int want
, int *have
, loff_t endoff
);
647 int get_caps_used(Inode
*in
);
649 void maybe_update_snaprealm(SnapRealm
*realm
, snapid_t snap_created
, snapid_t snap_highwater
,
650 vector
<snapid_t
>& snaps
);
652 void handle_quota(struct MClientQuota
*m
);
653 void handle_snap(struct MClientSnap
*m
);
654 void handle_caps(class MClientCaps
*m
);
655 void handle_cap_import(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
656 void handle_cap_export(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
657 void handle_cap_trunc(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
658 void handle_cap_flush_ack(MetaSession
*session
, Inode
*in
, Cap
*cap
, class MClientCaps
*m
);
659 void handle_cap_flushsnap_ack(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
660 void handle_cap_grant(MetaSession
*session
, Inode
*in
, Cap
*cap
, class MClientCaps
*m
);
661 void cap_delay_requeue(Inode
*in
);
662 void send_cap(Inode
*in
, MetaSession
*session
, Cap
*cap
, bool sync
,
663 int used
, int want
, int retain
, int flush
,
664 ceph_tid_t flush_tid
);
666 /* Flags for check_caps() */
667 #define CHECK_CAPS_NODELAY (0x1)
668 #define CHECK_CAPS_SYNCHRONOUS (0x2)
670 void check_caps(Inode
*in
, unsigned flags
);
671 void get_cap_ref(Inode
*in
, int cap
);
672 void put_cap_ref(Inode
*in
, int cap
);
673 void flush_snaps(Inode
*in
, bool all_again
=false);
674 void wait_sync_caps(Inode
*in
, ceph_tid_t want
);
675 void wait_sync_caps(ceph_tid_t want
);
676 void queue_cap_snap(Inode
*in
, SnapContext
&old_snapc
);
677 void finish_cap_snap(Inode
*in
, CapSnap
&capsnap
, int used
);
678 void _flushed_cap_snap(Inode
*in
, snapid_t seq
);
680 void _schedule_invalidate_dentry_callback(Dentry
*dn
, bool del
);
681 void _async_dentry_invalidate(vinodeno_t dirino
, vinodeno_t ino
, string
& name
);
682 void _try_to_trim_inode(Inode
*in
, bool sched_inval
);
684 void _schedule_invalidate_callback(Inode
*in
, int64_t off
, int64_t len
);
685 void _invalidate_inode_cache(Inode
*in
);
686 void _invalidate_inode_cache(Inode
*in
, int64_t off
, int64_t len
);
687 void _async_invalidate(vinodeno_t ino
, int64_t off
, int64_t len
);
688 bool _release(Inode
*in
);
691 * Initiate a flush of the data associated with the given inode.
692 * If you specify a Context, you are responsible for holding an inode
693 * reference for the duration of the flush. If not, _flush() will
694 * take the reference for you.
695 * @param in The Inode whose data you wish to flush.
696 * @param c The Context you wish us to complete once the data is
697 * flushed. If already flushed, this will be called in-line.
699 * @returns true if the data was already flushed, false otherwise.
701 bool _flush(Inode
*in
, Context
*c
);
702 void _flush_range(Inode
*in
, int64_t off
, uint64_t size
);
703 void _flushed(Inode
*in
);
704 void flush_set_callback(ObjectCacher::ObjectSet
*oset
);
706 void close_release(Inode
*in
);
707 void close_safe(Inode
*in
);
709 void lock_fh_pos(Fh
*f
);
710 void unlock_fh_pos(Fh
*f
);
713 void update_dir_dist(Inode
*in
, DirStat
*st
);
715 void clear_dir_complete_and_ordered(Inode
*diri
, bool complete
);
716 void insert_readdir_results(MetaRequest
*request
, MetaSession
*session
, Inode
*diri
);
717 Inode
* insert_trace(MetaRequest
*request
, MetaSession
*session
);
718 void update_inode_file_bits(Inode
*in
, uint64_t truncate_seq
, uint64_t truncate_size
, uint64_t size
,
719 uint64_t change_attr
, uint64_t time_warp_seq
, utime_t ctime
,
720 utime_t mtime
, utime_t atime
, version_t inline_version
,
721 bufferlist
& inline_data
, int issued
);
722 Inode
*add_update_inode(InodeStat
*st
, utime_t ttl
, MetaSession
*session
,
723 const UserPerm
& request_perms
);
724 Dentry
*insert_dentry_inode(Dir
*dir
, const string
& dname
, LeaseStat
*dlease
,
725 Inode
*in
, utime_t from
, MetaSession
*session
,
726 Dentry
*old_dentry
= NULL
);
727 void update_dentry_lease(Dentry
*dn
, LeaseStat
*dlease
, utime_t from
, MetaSession
*session
);
729 bool use_faked_inos() { return _use_faked_inos
; }
730 vinodeno_t
map_faked_ino(ino_t ino
);
732 //notify the mds to flush the mdlog
733 void flush_mdlog_sync();
734 void flush_mdlog(MetaSession
*session
);
736 // ----------------------
740 uint32_t deleg_timeout
;
741 void fill_dirent(struct dirent
*de
, const char *name
, int type
, uint64_t ino
, loff_t next_off
);
743 // some readdir helpers
744 typedef int (*add_dirent_cb_t
)(void *p
, struct dirent
*de
, struct ceph_statx
*stx
, off_t off
, Inode
*in
);
746 int _opendir(Inode
*in
, dir_result_t
**dirpp
, const UserPerm
& perms
);
747 void _readdir_drop_dirp_buffer(dir_result_t
*dirp
);
748 bool _readdir_have_frag(dir_result_t
*dirp
);
749 void _readdir_next_frag(dir_result_t
*dirp
);
750 void _readdir_rechoose_frag(dir_result_t
*dirp
);
751 int _readdir_get_frag(dir_result_t
*dirp
);
752 int _readdir_cache_cb(dir_result_t
*dirp
, add_dirent_cb_t cb
, void *p
, int caps
, bool getref
);
753 void _closedir(dir_result_t
*dirp
);
756 void _fragmap_remove_non_leaves(Inode
*in
);
757 void _fragmap_remove_stopped_mds(Inode
*in
, mds_rank_t mds
);
759 void _ll_get(Inode
*in
);
760 int _ll_put(Inode
*in
, int num
);
761 void _ll_drop_pins();
763 Fh
*_create_fh(Inode
*in
, int flags
, int cmode
, const UserPerm
& perms
);
764 int _release_fh(Fh
*fh
);
765 void _put_fh(Fh
*fh
);
767 int _do_remount(void);
768 friend class C_Client_Remount
;
770 struct C_Readahead
: public Context
{
773 C_Readahead(Client
*c
, Fh
*f
);
774 ~C_Readahead() override
;
775 void finish(int r
) override
;
778 int _read_sync(Fh
*f
, uint64_t off
, uint64_t len
, bufferlist
*bl
, bool *checkeof
);
779 int _read_async(Fh
*f
, uint64_t off
, uint64_t len
, bufferlist
*bl
);
781 // internal interface
782 // call these with client_lock held!
783 int _do_lookup(Inode
*dir
, const string
& name
, int mask
, InodeRef
*target
,
784 const UserPerm
& perms
);
786 int _lookup(Inode
*dir
, const string
& dname
, int mask
, InodeRef
*target
,
787 const UserPerm
& perm
);
789 int _link(Inode
*in
, Inode
*dir
, const char *name
, const UserPerm
& perm
,
791 int _unlink(Inode
*dir
, const char *name
, const UserPerm
& perm
);
792 int _rename(Inode
*olddir
, const char *oname
, Inode
*ndir
, const char *nname
, const UserPerm
& perm
);
793 int _mkdir(Inode
*dir
, const char *name
, mode_t mode
, const UserPerm
& perm
,
795 int _rmdir(Inode
*dir
, const char *name
, const UserPerm
& perms
);
796 int _symlink(Inode
*dir
, const char *name
, const char *target
,
797 const UserPerm
& perms
, InodeRef
*inp
= 0);
798 int _mknod(Inode
*dir
, const char *name
, mode_t mode
, dev_t rdev
,
799 const UserPerm
& perms
, InodeRef
*inp
= 0);
800 int _do_setattr(Inode
*in
, struct ceph_statx
*stx
, int mask
,
801 const UserPerm
& perms
, InodeRef
*inp
);
802 void stat_to_statx(struct stat
*st
, struct ceph_statx
*stx
);
803 int __setattrx(Inode
*in
, struct ceph_statx
*stx
, int mask
,
804 const UserPerm
& perms
, InodeRef
*inp
= 0);
805 int _setattrx(InodeRef
&in
, struct ceph_statx
*stx
, int mask
,
806 const UserPerm
& perms
);
807 int _setattr(InodeRef
&in
, struct stat
*attr
, int mask
,
808 const UserPerm
& perms
);
809 int _ll_setattrx(Inode
*in
, struct ceph_statx
*stx
, int mask
,
810 const UserPerm
& perms
, InodeRef
*inp
= 0);
811 int _getattr(Inode
*in
, int mask
, const UserPerm
& perms
, bool force
=false);
812 int _getattr(InodeRef
&in
, int mask
, const UserPerm
& perms
, bool force
=false) {
813 return _getattr(in
.get(), mask
, perms
, force
);
815 int _readlink(Inode
*in
, char *buf
, size_t size
);
816 int _getxattr(Inode
*in
, const char *name
, void *value
, size_t len
,
817 const UserPerm
& perms
);
818 int _getxattr(InodeRef
&in
, const char *name
, void *value
, size_t len
,
819 const UserPerm
& perms
);
820 int _listxattr(Inode
*in
, char *names
, size_t len
, const UserPerm
& perms
);
821 int _do_setxattr(Inode
*in
, const char *name
, const void *value
, size_t len
,
822 int flags
, const UserPerm
& perms
);
823 int _setxattr(Inode
*in
, const char *name
, const void *value
, size_t len
,
824 int flags
, const UserPerm
& perms
);
825 int _setxattr(InodeRef
&in
, const char *name
, const void *value
, size_t len
,
826 int flags
, const UserPerm
& perms
);
827 int _setxattr_check_data_pool(string
& name
, string
& value
, const OSDMap
*osdmap
);
828 void _setxattr_maybe_wait_for_osdmap(const char *name
, const void *value
, size_t len
);
829 int _removexattr(Inode
*in
, const char *nm
, const UserPerm
& perms
);
830 int _removexattr(InodeRef
&in
, const char *nm
, const UserPerm
& perms
);
831 int _open(Inode
*in
, int flags
, mode_t mode
, Fh
**fhp
,
832 const UserPerm
& perms
);
833 int _renew_caps(Inode
*in
);
834 int _create(Inode
*in
, const char *name
, int flags
, mode_t mode
, InodeRef
*inp
,
835 Fh
**fhp
, int stripe_unit
, int stripe_count
, int object_size
,
836 const char *data_pool
, bool *created
, const UserPerm
&perms
);
838 loff_t
_lseek(Fh
*fh
, loff_t offset
, int whence
);
839 int _read(Fh
*fh
, int64_t offset
, uint64_t size
, bufferlist
*bl
);
840 int _write(Fh
*fh
, int64_t offset
, uint64_t size
, const char *buf
,
841 const struct iovec
*iov
, int iovcnt
);
842 int _preadv_pwritev(int fd
, const struct iovec
*iov
, unsigned iovcnt
, int64_t offset
, bool write
);
844 int _fsync(Fh
*fh
, bool syncdataonly
);
845 int _fsync(Inode
*in
, bool syncdataonly
);
847 int _fallocate(Fh
*fh
, int mode
, int64_t offset
, int64_t length
);
848 int _getlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
);
849 int _setlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
, int sleep
);
850 int _flock(Fh
*fh
, int cmd
, uint64_t owner
);
852 int get_or_create(Inode
*dir
, const char* name
,
853 Dentry
**pdn
, bool expect_null
=false);
866 void init_groups(UserPerm
*groups
);
868 int inode_permission(Inode
*in
, const UserPerm
& perms
, unsigned want
);
869 int xattr_permission(Inode
*in
, const char *name
, unsigned want
,
870 const UserPerm
& perms
);
871 int may_setattr(Inode
*in
, struct ceph_statx
*stx
, int mask
,
872 const UserPerm
& perms
);
873 int may_open(Inode
*in
, int flags
, const UserPerm
& perms
);
874 int may_lookup(Inode
*dir
, const UserPerm
& perms
);
875 int may_create(Inode
*dir
, const UserPerm
& perms
);
876 int may_delete(Inode
*dir
, const char *name
, const UserPerm
& perms
);
877 int may_hardlink(Inode
*in
, const UserPerm
& perms
);
879 int _getattr_for_perm(Inode
*in
, const UserPerm
& perms
);
880 int _getgrouplist(gid_t
**sgids
, uid_t uid
, gid_t gid
);
882 vinodeno_t
_get_vino(Inode
*in
);
883 inodeno_t
_get_inodeno(Inode
*in
);
886 * These define virtual xattrs exposing the recursive directory
887 * statistics and layout metadata.
891 size_t (Client::*getxattr_cb
)(Inode
*in
, char *val
, size_t size
);
892 bool readonly
, hidden
;
893 bool (Client::*exists_cb
)(Inode
*in
);
896 bool _vxattrcb_quota_exists(Inode
*in
);
897 size_t _vxattrcb_quota(Inode
*in
, char *val
, size_t size
);
898 size_t _vxattrcb_quota_max_bytes(Inode
*in
, char *val
, size_t size
);
899 size_t _vxattrcb_quota_max_files(Inode
*in
, char *val
, size_t size
);
901 bool _vxattrcb_layout_exists(Inode
*in
);
902 size_t _vxattrcb_layout(Inode
*in
, char *val
, size_t size
);
903 size_t _vxattrcb_layout_stripe_unit(Inode
*in
, char *val
, size_t size
);
904 size_t _vxattrcb_layout_stripe_count(Inode
*in
, char *val
, size_t size
);
905 size_t _vxattrcb_layout_object_size(Inode
*in
, char *val
, size_t size
);
906 size_t _vxattrcb_layout_pool(Inode
*in
, char *val
, size_t size
);
907 size_t _vxattrcb_layout_pool_namespace(Inode
*in
, char *val
, size_t size
);
908 size_t _vxattrcb_dir_entries(Inode
*in
, char *val
, size_t size
);
909 size_t _vxattrcb_dir_files(Inode
*in
, char *val
, size_t size
);
910 size_t _vxattrcb_dir_subdirs(Inode
*in
, char *val
, size_t size
);
911 size_t _vxattrcb_dir_rentries(Inode
*in
, char *val
, size_t size
);
912 size_t _vxattrcb_dir_rfiles(Inode
*in
, char *val
, size_t size
);
913 size_t _vxattrcb_dir_rsubdirs(Inode
*in
, char *val
, size_t size
);
914 size_t _vxattrcb_dir_rbytes(Inode
*in
, char *val
, size_t size
);
915 size_t _vxattrcb_dir_rctime(Inode
*in
, char *val
, size_t size
);
916 size_t _vxattrs_calcu_name_size(const VXattr
*vxattrs
);
918 static const VXattr _dir_vxattrs
[];
919 static const VXattr _file_vxattrs
[];
921 static const VXattr
*_get_vxattrs(Inode
*in
);
922 static const VXattr
*_match_vxattr(Inode
*in
, const char *name
);
924 size_t _file_vxattrs_name_size
;
925 size_t _dir_vxattrs_name_size
;
926 size_t _vxattrs_name_size(const VXattr
*vxattrs
) {
927 if (vxattrs
== _dir_vxattrs
)
928 return _dir_vxattrs_name_size
;
929 else if (vxattrs
== _file_vxattrs
)
930 return _file_vxattrs_name_size
;
934 int _do_filelock(Inode
*in
, Fh
*fh
, int lock_type
, int op
, int sleep
,
935 struct flock
*fl
, uint64_t owner
, bool removing
=false);
936 int _interrupt_filelock(MetaRequest
*req
);
937 void _encode_filelocks(Inode
*in
, bufferlist
& bl
);
938 void _release_filelocks(Fh
*fh
);
939 void _update_lock_state(struct flock
*fl
, uint64_t owner
, ceph_lock_state_t
*lock_state
);
941 int _posix_acl_create(Inode
*dir
, mode_t
*mode
, bufferlist
& xattrs_bl
,
942 const UserPerm
& perms
);
943 int _posix_acl_chmod(Inode
*in
, mode_t mode
, const UserPerm
& perms
);
944 int _posix_acl_permission(Inode
*in
, const UserPerm
& perms
, unsigned want
);
946 mds_rank_t
_get_random_up_mds() const;
948 int _ll_getattr(Inode
*in
, int caps
, const UserPerm
& perms
);
951 int mount(const std::string
&mount_root
, const UserPerm
& perms
,
952 bool require_mds
=false);
956 const std::string
&mds_spec
,
957 const std::vector
<std::string
>& cmd
,
958 const bufferlist
& inbl
,
959 bufferlist
*poutbl
, std::string
*prs
, Context
*onfinish
);
961 // these shoud (more or less) mirror the actual system calls.
962 int statfs(const char *path
, struct statvfs
*stbuf
, const UserPerm
& perms
);
965 int chdir(const char *s
, std::string
&new_cwd
, const UserPerm
& perms
);
966 void _getcwd(std::string
& cwd
, const UserPerm
& perms
);
967 void getcwd(std::string
& cwd
, const UserPerm
& perms
);
970 int opendir(const char *name
, dir_result_t
**dirpp
, const UserPerm
& perms
);
971 int closedir(dir_result_t
*dirp
);
974 * Fill a directory listing from dirp, invoking cb for each entry
975 * with the given pointer, the dirent, the struct stat, the stmask,
978 * Returns 0 if it reached the end of the directory.
979 * If @a cb returns a negative error code, stop and return that.
981 int readdir_r_cb(dir_result_t
*dirp
, add_dirent_cb_t cb
, void *p
,
982 unsigned want
=0, unsigned flags
=AT_NO_ATTR_SYNC
,
985 struct dirent
* readdir(dir_result_t
*d
);
986 int readdir_r(dir_result_t
*dirp
, struct dirent
*de
);
987 int readdirplus_r(dir_result_t
*dirp
, struct dirent
*de
, struct ceph_statx
*stx
, unsigned want
, unsigned flags
, Inode
**out
);
989 int getdir(const char *relpath
, list
<string
>& names
,
990 const UserPerm
& perms
); // get the whole dir at once.
993 * Returns the length of the buffer that got filled in, or -errno.
994 * If it returns -ERANGE you just need to increase the size of the
995 * buffer and try again.
997 int _getdents(dir_result_t
*dirp
, char *buf
, int buflen
, bool ful
); // get a bunch of dentries at once
998 int getdents(dir_result_t
*dirp
, char *buf
, int buflen
) {
999 return _getdents(dirp
, buf
, buflen
, true);
1001 int getdnames(dir_result_t
*dirp
, char *buf
, int buflen
) {
1002 return _getdents(dirp
, buf
, buflen
, false);
1005 void rewinddir(dir_result_t
*dirp
);
1006 loff_t
telldir(dir_result_t
*dirp
);
1007 void seekdir(dir_result_t
*dirp
, loff_t offset
);
1009 int link(const char *existing
, const char *newname
, const UserPerm
& perm
);
1010 int unlink(const char *path
, const UserPerm
& perm
);
1011 int rename(const char *from
, const char *to
, const UserPerm
& perm
);
1014 int mkdir(const char *path
, mode_t mode
, const UserPerm
& perm
);
1015 int mkdirs(const char *path
, mode_t mode
, const UserPerm
& perms
);
1016 int rmdir(const char *path
, const UserPerm
& perms
);
1019 int readlink(const char *path
, char *buf
, loff_t size
, const UserPerm
& perms
);
1021 int symlink(const char *existing
, const char *newname
, const UserPerm
& perms
);
1024 unsigned statx_to_mask(unsigned int flags
, unsigned int want
);
1025 int stat(const char *path
, struct stat
*stbuf
, const UserPerm
& perms
,
1026 frag_info_t
*dirstat
=0, int mask
=CEPH_STAT_CAP_INODE_ALL
);
1027 int statx(const char *path
, struct ceph_statx
*stx
,
1028 const UserPerm
& perms
,
1029 unsigned int want
, unsigned int flags
);
1030 int lstat(const char *path
, struct stat
*stbuf
, const UserPerm
& perms
,
1031 frag_info_t
*dirstat
=0, int mask
=CEPH_STAT_CAP_INODE_ALL
);
1033 int setattr(const char *relpath
, struct stat
*attr
, int mask
,
1034 const UserPerm
& perms
);
1035 int setattrx(const char *relpath
, struct ceph_statx
*stx
, int mask
,
1036 const UserPerm
& perms
, int flags
=0);
1037 int fsetattr(int fd
, struct stat
*attr
, int mask
, const UserPerm
& perms
);
1038 int fsetattrx(int fd
, struct ceph_statx
*stx
, int mask
, const UserPerm
& perms
);
1039 int chmod(const char *path
, mode_t mode
, const UserPerm
& perms
);
1040 int fchmod(int fd
, mode_t mode
, const UserPerm
& perms
);
1041 int lchmod(const char *path
, mode_t mode
, const UserPerm
& perms
);
1042 int chown(const char *path
, uid_t new_uid
, gid_t new_gid
,
1043 const UserPerm
& perms
);
1044 int fchown(int fd
, uid_t new_uid
, gid_t new_gid
, const UserPerm
& perms
);
1045 int lchown(const char *path
, uid_t new_uid
, gid_t new_gid
,
1046 const UserPerm
& perms
);
1047 int utime(const char *path
, struct utimbuf
*buf
, const UserPerm
& perms
);
1048 int lutime(const char *path
, struct utimbuf
*buf
, const UserPerm
& perms
);
1049 int flock(int fd
, int operation
, uint64_t owner
);
1050 int truncate(const char *path
, loff_t size
, const UserPerm
& perms
);
1053 int mknod(const char *path
, mode_t mode
, const UserPerm
& perms
, dev_t rdev
=0);
1054 int open(const char *path
, int flags
, const UserPerm
& perms
, mode_t mode
=0);
1055 int open(const char *path
, int flags
, const UserPerm
& perms
,
1056 mode_t mode
, int stripe_unit
, int stripe_count
, int object_size
,
1057 const char *data_pool
);
1058 int lookup_hash(inodeno_t ino
, inodeno_t dirino
, const char *name
,
1059 const UserPerm
& perms
);
1060 int lookup_ino(inodeno_t ino
, const UserPerm
& perms
, Inode
**inode
=NULL
);
1061 int lookup_parent(Inode
*in
, const UserPerm
& perms
, Inode
**parent
=NULL
);
1062 int lookup_name(Inode
*in
, Inode
*parent
, const UserPerm
& perms
);
1064 loff_t
lseek(int fd
, loff_t offset
, int whence
);
1065 int read(int fd
, char *buf
, loff_t size
, loff_t offset
=-1);
1066 int preadv(int fd
, const struct iovec
*iov
, int iovcnt
, loff_t offset
=-1);
1067 int write(int fd
, const char *buf
, loff_t size
, loff_t offset
=-1);
1068 int pwritev(int fd
, const struct iovec
*iov
, int iovcnt
, loff_t offset
=-1);
1069 int fake_write_size(int fd
, loff_t size
);
1070 int ftruncate(int fd
, loff_t size
, const UserPerm
& perms
);
1071 int fsync(int fd
, bool syncdataonly
);
1072 int fstat(int fd
, struct stat
*stbuf
, const UserPerm
& perms
,
1073 int mask
=CEPH_STAT_CAP_INODE_ALL
);
1074 int fstatx(int fd
, struct ceph_statx
*stx
, const UserPerm
& perms
,
1075 unsigned int want
, unsigned int flags
);
1076 int fallocate(int fd
, int mode
, loff_t offset
, loff_t length
);
1078 // full path xattr ops
1079 int getxattr(const char *path
, const char *name
, void *value
, size_t size
,
1080 const UserPerm
& perms
);
1081 int lgetxattr(const char *path
, const char *name
, void *value
, size_t size
,
1082 const UserPerm
& perms
);
1083 int fgetxattr(int fd
, const char *name
, void *value
, size_t size
,
1084 const UserPerm
& perms
);
1085 int listxattr(const char *path
, char *list
, size_t size
, const UserPerm
& perms
);
1086 int llistxattr(const char *path
, char *list
, size_t size
, const UserPerm
& perms
);
1087 int flistxattr(int fd
, char *list
, size_t size
, const UserPerm
& perms
);
1088 int removexattr(const char *path
, const char *name
, const UserPerm
& perms
);
1089 int lremovexattr(const char *path
, const char *name
, const UserPerm
& perms
);
1090 int fremovexattr(int fd
, const char *name
, const UserPerm
& perms
);
1091 int setxattr(const char *path
, const char *name
, const void *value
,
1092 size_t size
, int flags
, const UserPerm
& perms
);
1093 int lsetxattr(const char *path
, const char *name
, const void *value
,
1094 size_t size
, int flags
, const UserPerm
& perms
);
1095 int fsetxattr(int fd
, const char *name
, const void *value
, size_t size
,
1096 int flags
, const UserPerm
& perms
);
1099 int64_t drop_caches();
1102 int lazyio_propogate(int fd
, loff_t offset
, size_t count
);
1103 int lazyio_synchronize(int fd
, loff_t offset
, size_t count
);
1105 // expose file layout
1106 int describe_layout(const char *path
, file_layout_t
* layout
,
1107 const UserPerm
& perms
);
1108 int fdescribe_layout(int fd
, file_layout_t
* layout
);
1109 int get_file_stripe_address(int fd
, loff_t offset
, vector
<entity_addr_t
>& address
);
1110 int get_file_extent_osds(int fd
, loff_t off
, loff_t
*len
, vector
<int>& osds
);
1111 int get_osd_addr(int osd
, entity_addr_t
& addr
);
1114 int64_t get_default_pool_id();
1117 int get_local_osd();
1118 int get_pool_replication(int64_t pool
);
1119 int64_t get_pool_id(const char *pool_name
);
1120 string
get_pool_name(int64_t pool
);
1121 int get_osd_crush_location(int id
, vector
<pair
<string
, string
> >& path
);
1123 int enumerate_layout(int fd
, vector
<ObjectExtent
>& result
,
1124 loff_t length
, loff_t offset
);
1126 int mksnap(const char *path
, const char *name
, const UserPerm
& perm
);
1127 int rmsnap(const char *path
, const char *name
, const UserPerm
& perm
);
1130 int get_caps_issued(int fd
);
1131 int get_caps_issued(const char *path
, const UserPerm
& perms
);
1133 // low-level interface v2
1134 inodeno_t
ll_get_inodeno(Inode
*in
) {
1135 Mutex::Locker
lock(client_lock
);
1136 return _get_inodeno(in
);
1138 snapid_t
ll_get_snapid(Inode
*in
);
1139 vinodeno_t
ll_get_vino(Inode
*in
) {
1140 Mutex::Locker
lock(client_lock
);
1141 return _get_vino(in
);
1143 // get inode from faked ino
1144 Inode
*ll_get_inode(ino_t ino
);
1145 Inode
*ll_get_inode(vinodeno_t vino
);
1146 int ll_lookup(Inode
*parent
, const char *name
, struct stat
*attr
,
1147 Inode
**out
, const UserPerm
& perms
);
1148 int ll_lookupx(Inode
*parent
, const char *name
, Inode
**out
,
1149 struct ceph_statx
*stx
, unsigned want
, unsigned flags
,
1150 const UserPerm
& perms
);
1151 bool ll_forget(Inode
*in
, int count
);
1152 bool ll_put(Inode
*in
);
1153 int ll_getattr(Inode
*in
, struct stat
*st
, const UserPerm
& perms
);
1154 int ll_getattrx(Inode
*in
, struct ceph_statx
*stx
, unsigned int want
,
1155 unsigned int flags
, const UserPerm
& perms
);
1156 int ll_setattrx(Inode
*in
, struct ceph_statx
*stx
, int mask
,
1157 const UserPerm
& perms
);
1158 int ll_setattr(Inode
*in
, struct stat
*st
, int mask
,
1159 const UserPerm
& perms
);
1160 int ll_getxattr(Inode
*in
, const char *name
, void *value
, size_t size
,
1161 const UserPerm
& perms
);
1162 int ll_setxattr(Inode
*in
, const char *name
, const void *value
, size_t size
,
1163 int flags
, const UserPerm
& perms
);
1164 int ll_removexattr(Inode
*in
, const char *name
, const UserPerm
& perms
);
1165 int ll_listxattr(Inode
*in
, char *list
, size_t size
, const UserPerm
& perms
);
1166 int ll_opendir(Inode
*in
, int flags
, dir_result_t
**dirpp
,
1167 const UserPerm
& perms
);
1168 int ll_releasedir(dir_result_t
* dirp
);
1169 int ll_fsyncdir(dir_result_t
* dirp
);
1170 int ll_readlink(Inode
*in
, char *buf
, size_t bufsize
, const UserPerm
& perms
);
1171 int ll_mknod(Inode
*in
, const char *name
, mode_t mode
, dev_t rdev
,
1172 struct stat
*attr
, Inode
**out
, const UserPerm
& perms
);
1173 int ll_mknodx(Inode
*parent
, const char *name
, mode_t mode
, dev_t rdev
,
1174 Inode
**out
, struct ceph_statx
*stx
, unsigned want
,
1175 unsigned flags
, const UserPerm
& perms
);
1176 int ll_mkdir(Inode
*in
, const char *name
, mode_t mode
, struct stat
*attr
,
1177 Inode
**out
, const UserPerm
& perm
);
1178 int ll_mkdirx(Inode
*parent
, const char *name
, mode_t mode
, Inode
**out
,
1179 struct ceph_statx
*stx
, unsigned want
, unsigned flags
,
1180 const UserPerm
& perms
);
1181 int ll_symlink(Inode
*in
, const char *name
, const char *value
,
1182 struct stat
*attr
, Inode
**out
, const UserPerm
& perms
);
1183 int ll_symlinkx(Inode
*parent
, const char *name
, const char *value
,
1184 Inode
**out
, struct ceph_statx
*stx
, unsigned want
,
1185 unsigned flags
, const UserPerm
& perms
);
1186 int ll_unlink(Inode
*in
, const char *name
, const UserPerm
& perm
);
1187 int ll_rmdir(Inode
*in
, const char *name
, const UserPerm
& perms
);
1188 int ll_rename(Inode
*parent
, const char *name
, Inode
*newparent
,
1189 const char *newname
, const UserPerm
& perm
);
1190 int ll_link(Inode
*in
, Inode
*newparent
, const char *newname
,
1191 const UserPerm
& perm
);
1192 int ll_open(Inode
*in
, int flags
, Fh
**fh
, const UserPerm
& perms
);
1193 int _ll_create(Inode
*parent
, const char *name
, mode_t mode
,
1194 int flags
, InodeRef
*in
, int caps
, Fh
**fhp
,
1195 const UserPerm
& perms
);
1196 int ll_create(Inode
*parent
, const char *name
, mode_t mode
, int flags
,
1197 struct stat
*attr
, Inode
**out
, Fh
**fhp
,
1198 const UserPerm
& perms
);
1199 int ll_createx(Inode
*parent
, const char *name
, mode_t mode
,
1200 int oflags
, Inode
**outp
, Fh
**fhp
,
1201 struct ceph_statx
*stx
, unsigned want
, unsigned lflags
,
1202 const UserPerm
& perms
);
1203 int ll_read_block(Inode
*in
, uint64_t blockid
, char *buf
, uint64_t offset
,
1204 uint64_t length
, file_layout_t
* layout
);
1206 int ll_write_block(Inode
*in
, uint64_t blockid
,
1207 char* buf
, uint64_t offset
,
1208 uint64_t length
, file_layout_t
* layout
,
1209 uint64_t snapseq
, uint32_t sync
);
1210 int ll_commit_blocks(Inode
*in
, uint64_t offset
, uint64_t length
);
1212 int ll_statfs(Inode
*in
, struct statvfs
*stbuf
, const UserPerm
& perms
);
1213 int ll_walk(const char* name
, Inode
**i
, struct ceph_statx
*stx
,
1214 unsigned int want
, unsigned int flags
, const UserPerm
& perms
);
1215 uint32_t ll_stripe_unit(Inode
*in
);
1216 int ll_file_layout(Inode
*in
, file_layout_t
*layout
);
1217 uint64_t ll_snap_seq(Inode
*in
);
1219 int ll_read(Fh
*fh
, loff_t off
, loff_t len
, bufferlist
*bl
);
1220 int ll_write(Fh
*fh
, loff_t off
, loff_t len
, const char *data
);
1221 loff_t
ll_lseek(Fh
*fh
, loff_t offset
, int whence
);
1222 int ll_flush(Fh
*fh
);
1223 int ll_fsync(Fh
*fh
, bool syncdataonly
);
1224 int ll_fallocate(Fh
*fh
, int mode
, loff_t offset
, loff_t length
);
1225 int ll_release(Fh
*fh
);
1226 int ll_getlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
);
1227 int ll_setlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
, int sleep
);
1228 int ll_flock(Fh
*fh
, int cmd
, uint64_t owner
);
1229 int ll_file_layout(Fh
*fh
, file_layout_t
*layout
);
1230 void ll_interrupt(void *d
);
1231 bool ll_handle_umask() {
1232 return acl_type
!= NO_ACL
;
1235 int ll_get_stripe_osd(struct Inode
*in
, uint64_t blockno
,
1236 file_layout_t
* layout
);
1237 uint64_t ll_get_internal_offset(struct Inode
*in
, uint64_t blockno
);
1239 int ll_num_osds(void);
1240 int ll_osdaddr(int osd
, uint32_t *addr
);
1241 int ll_osdaddr(int osd
, char* buf
, size_t size
);
1243 void ll_register_callbacks(struct client_callback_args
*args
);
1244 int test_dentry_handling(bool can_invalidate
);
1246 const char** get_tracked_conf_keys() const override
;
1247 void handle_conf_change(const struct md_config_t
*conf
,
1248 const std::set
<std::string
> &changed
) override
;
1249 uint32_t get_deleg_timeout() { return deleg_timeout
; }
1250 int set_deleg_timeout(uint32_t timeout
);
1251 int ll_delegation(Fh
*fh
, unsigned cmd
, ceph_deleg_cb_t cb
, void *priv
);
1255 * Specialization of Client that manages its own Objecter instance
1256 * and handles init/shutdown of messenger/monclient
1258 class StandaloneClient
: public Client
1261 StandaloneClient(Messenger
*m
, MonClient
*mc
);
1263 ~StandaloneClient() override
;
1265 int init() override
;
1266 void shutdown() override
;