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 struct client_callback_args
{
144 client_ino_callback_t ino_cb
;
145 client_dentry_callback_t dentry_cb
;
146 client_switch_interrupt_callback_t switch_intr_cb
;
147 client_remount_callback_t remount_cb
;
148 client_getgroups_callback_t getgroups_cb
;
149 client_umask_callback_t umask_cb
;
152 // ========================================================
155 struct dir_result_t
{
156 static const int SHIFT
= 28;
157 static const int64_t MASK
= (1 << SHIFT
) - 1;
158 static const int64_t HASH
= 0xFFULL
<< (SHIFT
+ 24); // impossible frag bits
159 static const loff_t END
= 1ULL << (SHIFT
+ 32);
161 static uint64_t make_fpos(unsigned h
, unsigned l
, bool hash
) {
162 uint64_t v
= ((uint64_t)h
<< SHIFT
) | (uint64_t)l
;
166 assert((v
& HASH
) != HASH
);
169 static unsigned fpos_high(uint64_t p
) {
170 unsigned v
= (p
& (END
-1)) >> SHIFT
;
171 if ((p
& HASH
) == HASH
)
172 return ceph_frag_value(v
);
175 static unsigned fpos_low(uint64_t p
) {
178 static int fpos_cmp(uint64_t l
, uint64_t r
) {
179 int c
= ceph_frag_compare(fpos_high(l
), fpos_high(r
));
182 if (fpos_low(l
) == fpos_low(r
))
184 return fpos_low(l
) < fpos_low(r
) ? -1 : 1;
188 int64_t offset
; // hash order:
189 // (0xff << 52) | ((24 bits hash) << 28) |
190 // (the nth entry has hash collision);
192 // ((frag value) << 28) | (the nth entry in frag);
194 unsigned next_offset
; // offset of next chunk (last_name's + 1)
195 string last_name
; // last entry in previous chunk
197 uint64_t release_count
;
198 uint64_t ordered_count
;
199 unsigned cache_index
;
200 int start_shared_gen
; // dir shared_gen at start of readdir
209 dentry(int64_t o
) : offset(o
) {}
210 dentry(int64_t o
, const string
& n
, const InodeRef
& in
) :
211 offset(o
), name(n
), inode(in
) {}
213 struct dentry_off_lt
{
214 bool operator()(const dentry
& d
, int64_t off
) const {
215 return dir_result_t::fpos_cmp(d
.offset
, off
) < 0;
218 vector
<dentry
> buffer
;
220 explicit dir_result_t(Inode
*in
, const UserPerm
& perms
);
222 unsigned offset_high() { return fpos_high(offset
); }
223 unsigned offset_low() { return fpos_low(offset
); }
225 void set_end() { offset
|= END
; }
226 bool at_end() { return (offset
& END
); }
228 void set_hash_order() { offset
|= HASH
; }
229 bool hash_order() { return (offset
& HASH
) == HASH
; }
235 return buffer_frag
.contains(offset_high());
237 return buffer_frag
== frag_t(offset_high());
251 class Client
: public Dispatcher
, public md_config_obs_t
{
253 using Dispatcher::cct
;
255 std::unique_ptr
<PerfCounters
> logger
;
257 class CommandHook
: public AdminSocketHook
{
260 explicit CommandHook(Client
*client
);
261 bool call(std::string command
, cmdmap_t
&cmdmap
, std::string format
,
262 bufferlist
& out
) override
;
264 CommandHook m_command_hook
;
266 // cluster descriptors
267 std::unique_ptr
<MDSMap
> mdsmap
;
271 void *callback_handle
;
272 client_switch_interrupt_callback_t switch_interrupt_cb
;
273 client_remount_callback_t remount_cb
;
274 client_ino_callback_t ino_invalidate_cb
;
275 client_dentry_callback_t dentry_invalidate_cb
;
276 client_getgroups_callback_t getgroups_cb
;
277 client_umask_callback_t umask_cb
;
278 bool can_invalidate_dentries
;
279 bool require_remount
;
281 Finisher async_ino_invalidator
;
282 Finisher async_dentry_invalidator
;
283 Finisher interrupt_finisher
;
284 Finisher remount_finisher
;
285 Finisher objecter_finisher
;
288 utime_t last_cap_renew
;
290 void renew_caps(MetaSession
*session
);
291 void flush_cap_releases();
295 UserPerm
pick_my_perms() {
296 uid_t uid
= user_id
>= 0 ? user_id
: -1;
297 gid_t gid
= group_id
>= 0 ? group_id
: -1;
298 return UserPerm(uid
, gid
);
301 static UserPerm
pick_my_perms(CephContext
*c
) {
302 uid_t uid
= c
->_conf
->client_mount_uid
>= 0 ? c
->_conf
->client_mount_uid
: -1;
303 gid_t gid
= c
->_conf
->client_mount_gid
>= 0 ? c
->_conf
->client_mount_gid
: -1;
304 return UserPerm(uid
, gid
);
307 Messenger
*messenger
;
308 MonClient
*monclient
;
313 int user_id
, group_id
;
316 void set_cap_epoch_barrier(epoch_t e
);
317 epoch_t cap_epoch_barrier
;
320 map
<mds_rank_t
, MetaSession
*> mds_sessions
; // mds -> push seq
321 list
<Cond
*> waiting_for_mdsmap
;
323 // FSMap, for when using mds_command
324 list
<Cond
*> waiting_for_fsmap
;
325 std::unique_ptr
<FSMap
> fsmap
;
326 std::unique_ptr
<FSMapUser
> fsmap_user
;
329 CommandTable
<MDSCommandOp
> command_table
;
330 void handle_command_reply(MCommandReply
*m
);
331 int fetch_fsmap(bool user
);
333 const std::string
&mds_spec
,
334 std::vector
<mds_gid_t
> *targets
);
336 void get_session_metadata(std::map
<std::string
, std::string
> *meta
) const;
337 bool have_open_session(mds_rank_t mds
);
338 void got_mds_push(MetaSession
*s
);
339 MetaSession
*_get_mds_session(mds_rank_t mds
, Connection
*con
); ///< return session for mds *and* con; null otherwise
340 MetaSession
*_get_or_open_mds_session(mds_rank_t mds
);
341 MetaSession
*_open_mds_session(mds_rank_t mds
);
342 void _close_mds_session(MetaSession
*s
);
343 void _closed_mds_session(MetaSession
*s
);
344 bool _any_stale_sessions() const;
345 void _kick_stale_sessions();
346 void handle_client_session(MClientSession
*m
);
347 void send_reconnect(MetaSession
*s
);
348 void resend_unsafe_requests(MetaSession
*s
);
349 void wait_unsafe_requests();
353 ceph_tid_t oldest_tid
; // oldest incomplete mds request, excluding setfilelock requests
354 map
<ceph_tid_t
, MetaRequest
*> mds_requests
;
357 ceph_tid_t last_flush_tid
;
359 void dump_mds_requests(Formatter
*f
);
360 void dump_mds_sessions(Formatter
*f
);
362 int make_request(MetaRequest
*req
, const UserPerm
& perms
,
363 InodeRef
*ptarget
= 0, bool *pcreated
= 0,
364 mds_rank_t use_mds
=-1, bufferlist
*pdirbl
=0);
365 void put_request(MetaRequest
*request
);
366 void unregister_request(MetaRequest
*request
);
368 int verify_reply_trace(int r
, MetaRequest
*request
, MClientReply
*reply
,
369 InodeRef
*ptarget
, bool *pcreated
,
370 const UserPerm
& perms
);
371 void encode_cap_releases(MetaRequest
*request
, mds_rank_t mds
);
372 int encode_inode_release(Inode
*in
, MetaRequest
*req
,
373 mds_rank_t mds
, int drop
,
374 int unless
,int force
=0);
375 void encode_dentry_release(Dentry
*dn
, MetaRequest
*req
,
376 mds_rank_t mds
, int drop
, int unless
);
377 mds_rank_t
choose_target_mds(MetaRequest
*req
, Inode
** phash_diri
=NULL
);
378 void connect_mds_targets(mds_rank_t mds
);
379 void send_request(MetaRequest
*request
, MetaSession
*session
,
380 bool drop_cap_releases
=false);
381 MClientRequest
*build_client_request(MetaRequest
*request
);
382 void kick_requests(MetaSession
*session
);
383 void kick_requests_closed(MetaSession
*session
);
384 void handle_client_request_forward(MClientRequestForward
*reply
);
385 void handle_client_reply(MClientReply
*reply
);
386 bool is_dir_operation(MetaRequest
*request
);
393 // When an MDS has sent us a REJECT, remember that and don't
394 // contact it again. Remember which inst rejected us, so that
395 // when we talk to another inst with the same rank we can
397 std::map
<mds_rank_t
, entity_inst_t
> rejected_by_mds
;
400 epoch_t local_osd_epoch
;
402 int unsafe_sync_write
;
405 entity_name_t
get_myname() { return messenger
->get_myname(); }
406 void _sync_write_commit(Inode
*in
);
409 std::unique_ptr
<Filer
> filer
;
410 std::unique_ptr
<ObjectCacher
> objectcacher
;
411 std::unique_ptr
<WritebackHandler
> writeback_handler
;
414 ceph::unordered_map
<vinodeno_t
, Inode
*> inode_map
;
416 // fake inode number for 32-bits ino_t
417 ceph::unordered_map
<ino_t
, vinodeno_t
> faked_ino_map
;
418 interval_set
<ino_t
> free_faked_inos
;
419 ino_t last_used_faked_ino
;
420 void _assign_faked_ino(Inode
*in
);
421 void _release_faked_ino(Inode
*in
);
422 bool _use_faked_inos
;
423 void _reset_faked_inos();
424 vinodeno_t
_map_faked_ino(ino_t ino
);
427 map
<Inode
*, InodeRef
> root_parents
;
428 Inode
* root_ancestor
;
429 LRU lru
; // lru list of Dentry's in our local metadata cache.
431 // all inodes with caps sit on either cap_list or delayed_caps.
432 xlist
<Inode
*> delayed_caps
, cap_list
;
433 int num_flushing_caps
;
434 ceph::unordered_map
<inodeno_t
,SnapRealm
*> snap_realms
;
436 // Optional extra metadata about me to send to the MDS
437 std::map
<std::string
, std::string
> metadata
;
438 void populate_metadata(const std::string
&mount_root
);
441 /* async block write barrier support */
442 //map<uint64_t, BarrierContext* > barriers;
444 SnapRealm
*get_snap_realm(inodeno_t r
);
445 SnapRealm
*get_snap_realm_maybe(inodeno_t r
);
446 void put_snap_realm(SnapRealm
*realm
);
447 bool adjust_realm_parent(SnapRealm
*realm
, inodeno_t parent
);
448 void update_snap_trace(bufferlist
& bl
, SnapRealm
**realm_ret
, bool must_flush
=true);
449 void invalidate_snaprealm_and_children(SnapRealm
*realm
);
451 Inode
*open_snapdir(Inode
*diri
);
454 // file handles, etc.
455 interval_set
<int> free_fd_set
; // unused fds
456 ceph::unordered_map
<int, Fh
*> fd_map
;
457 set
<Fh
*> ll_unclosed_fh_set
;
458 ceph::unordered_set
<dir_result_t
*> opened_dirs
;
461 int fd
= free_fd_set
.range_start();
462 free_fd_set
.erase(fd
, 1);
465 void put_fd(int fd
) {
466 free_fd_set
.insert(fd
, 1);
470 * Resolve file descriptor, or return NULL.
472 Fh
*get_filehandle(int fd
) {
473 ceph::unordered_map
<int, Fh
*>::iterator p
= fd_map
.find(fd
);
474 if (p
== fd_map
.end())
479 // global client lock
480 // - protects Client and buffer cache both!
484 void wake_inode_waiters(MetaSession
*s
);
485 void wait_on_list(list
<Cond
*>& ls
);
486 void signal_cond_list(list
<Cond
*>& ls
);
488 void wait_on_context_list(list
<Context
*>& ls
);
489 void signal_context_list(list
<Context
*>& ls
);
491 // -- metadata cache stuff
493 // decrease inode ref. delete if dangling.
494 void put_inode(Inode
*in
, int n
=1);
495 void close_dir(Dir
*dir
);
497 friend class C_Client_FlushComplete
; // calls put_inode()
498 friend class C_Client_CacheInvalidate
; // calls ino_invalidate_cb
499 friend class C_Client_DentryInvalidate
; // calls dentry_invalidate_cb
500 friend class C_Block_Sync
; // Calls block map and protected helpers
501 friend class C_C_Tick
; // Asserts on client_lock
502 friend class C_Client_RequestInterrupt
;
503 friend class C_Client_Remount
;
504 friend void intrusive_ptr_release(Inode
*in
);
506 //int get_cache_size() { return lru.lru_get_size(); }
507 //void set_cache_size(int m) { lru.lru_set_max(m); }
510 * Don't call this with in==NULL, use get_or_create for that
511 * leave dn set to default NULL unless you're trying to add
512 * a new inode to a pre-created Dentry
514 Dentry
* link(Dir
*dir
, const string
& name
, Inode
*in
, Dentry
*dn
);
515 void unlink(Dentry
*dn
, bool keepdir
, bool keepdentry
);
517 // path traversal for high-level interface
519 int path_walk(const filepath
& fp
, InodeRef
*end
, const UserPerm
& perms
,
520 bool followsym
=true, int mask
=0);
522 int fill_stat(Inode
*in
, struct stat
*st
, frag_info_t
*dirstat
=0, nest_info_t
*rstat
=0);
523 int fill_stat(InodeRef
& in
, struct stat
*st
, frag_info_t
*dirstat
=0, nest_info_t
*rstat
=0) {
524 return fill_stat(in
.get(), st
, dirstat
, rstat
);
527 void fill_statx(Inode
*in
, unsigned int mask
, struct ceph_statx
*stx
);
528 void fill_statx(InodeRef
& in
, unsigned int mask
, struct ceph_statx
*stx
) {
529 return fill_statx(in
.get(), mask
, stx
);
532 void touch_dn(Dentry
*dn
);
535 void trim_cache(bool trim_kernel_dcache
=false);
536 void trim_cache_for_reconnect(MetaSession
*s
);
537 void trim_dentry(Dentry
*dn
);
538 void trim_caps(MetaSession
*s
, int max
);
539 void _invalidate_kernel_dcache();
541 void dump_inode(Formatter
*f
, Inode
*in
, set
<Inode
*>& did
, bool disconnected
);
542 void dump_cache(Formatter
*f
); // debug
545 void force_session_readonly(MetaSession
*s
);
547 void dump_status(Formatter
*f
); // debug
553 Cond mount_cond
, sync_cond
;
557 friend class SyntheticClient
;
558 bool ms_dispatch(Message
*m
) override
;
560 void ms_handle_connect(Connection
*con
) override
;
561 bool ms_handle_reset(Connection
*con
) override
;
562 void ms_handle_remote_reset(Connection
*con
) override
;
563 bool ms_handle_refused(Connection
*con
) override
;
564 bool ms_get_authorizer(int dest_type
, AuthAuthorizer
**authorizer
, bool force_new
) override
;
568 Inode
* get_quota_root(Inode
*in
, const UserPerm
& perms
);
569 bool check_quota_condition(Inode
*in
, const UserPerm
& perms
,
570 std::function
<bool (const Inode
&)> test
);
571 bool is_quota_files_exceeded(Inode
*in
, const UserPerm
& perms
);
572 bool is_quota_bytes_exceeded(Inode
*in
, int64_t new_bytes
,
573 const UserPerm
& perms
);
574 bool is_quota_bytes_approaching(Inode
*in
, const UserPerm
& perms
);
576 std::map
<std::pair
<int64_t,std::string
>, int> pool_perms
;
577 list
<Cond
*> waiting_for_pool_perm
;
578 int check_pool_perm(Inode
*in
, int need
);
581 * Call this when an OSDMap is seen with a full flag (global or per pool)
584 * @param pool the pool ID affected, or -1 if all.
586 void _handle_full_flag(int64_t pool
);
588 void _close_sessions();
591 * The basic housekeeping parts of init (perf counters, admin socket)
592 * that is independent of how objecters/monclient/messengers are
598 void set_filer_flags(int flags
);
599 void clear_filer_flags(int flags
);
601 Client(Messenger
*m
, MonClient
*mc
, Objecter
*objecter_
);
603 void tear_down_cache();
605 void update_metadata(std::string
const &k
, std::string
const &v
);
607 client_t
get_nodeid() { return whoami
; }
609 inodeno_t
get_root_ino();
613 virtual void shutdown();
616 void handle_mds_map(class MMDSMap
*m
);
617 void handle_fs_map(class MFSMap
*m
);
618 void handle_fs_map_user(class MFSMapUser
*m
);
619 void handle_osd_map(class MOSDMap
*m
);
621 void handle_lease(MClientLease
*m
);
624 int uninline_data(Inode
*in
, Context
*onfinish
);
627 void check_cap_issue(Inode
*in
, Cap
*cap
, unsigned issued
);
628 void add_update_cap(Inode
*in
, MetaSession
*session
, uint64_t cap_id
,
629 unsigned issued
, unsigned seq
, unsigned mseq
, inodeno_t realm
,
630 int flags
, const UserPerm
& perms
);
631 void remove_cap(Cap
*cap
, bool queue_release
);
632 void remove_all_caps(Inode
*in
);
633 void remove_session_caps(MetaSession
*session
);
634 void mark_caps_dirty(Inode
*in
, int caps
);
635 int mark_caps_flushing(Inode
*in
, ceph_tid_t
*ptid
);
636 void adjust_session_flushing_caps(Inode
*in
, MetaSession
*old_s
, MetaSession
*new_s
);
637 void flush_caps_sync();
638 void flush_caps(Inode
*in
, MetaSession
*session
, bool sync
=false);
639 void kick_flushing_caps(MetaSession
*session
);
640 void early_kick_flushing_caps(MetaSession
*session
);
641 void kick_maxsize_requests(MetaSession
*session
);
642 int get_caps(Inode
*in
, int need
, int want
, int *have
, loff_t endoff
);
643 int get_caps_used(Inode
*in
);
645 void maybe_update_snaprealm(SnapRealm
*realm
, snapid_t snap_created
, snapid_t snap_highwater
,
646 vector
<snapid_t
>& snaps
);
648 void handle_quota(struct MClientQuota
*m
);
649 void handle_snap(struct MClientSnap
*m
);
650 void handle_caps(class MClientCaps
*m
);
651 void handle_cap_import(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
652 void handle_cap_export(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
653 void handle_cap_trunc(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
654 void handle_cap_flush_ack(MetaSession
*session
, Inode
*in
, Cap
*cap
, class MClientCaps
*m
);
655 void handle_cap_flushsnap_ack(MetaSession
*session
, Inode
*in
, class MClientCaps
*m
);
656 void handle_cap_grant(MetaSession
*session
, Inode
*in
, Cap
*cap
, class MClientCaps
*m
);
657 void cap_delay_requeue(Inode
*in
);
658 void send_cap(Inode
*in
, MetaSession
*session
, Cap
*cap
, bool sync
,
659 int used
, int want
, int retain
, int flush
,
660 ceph_tid_t flush_tid
);
662 /* Flags for check_caps() */
663 #define CHECK_CAPS_NODELAY (0x1)
664 #define CHECK_CAPS_SYNCHRONOUS (0x2)
666 void check_caps(Inode
*in
, unsigned flags
);
667 void get_cap_ref(Inode
*in
, int cap
);
668 void put_cap_ref(Inode
*in
, int cap
);
669 void flush_snaps(Inode
*in
, bool all_again
=false);
670 void wait_sync_caps(Inode
*in
, ceph_tid_t want
);
671 void wait_sync_caps(ceph_tid_t want
);
672 void queue_cap_snap(Inode
*in
, SnapContext
&old_snapc
);
673 void finish_cap_snap(Inode
*in
, CapSnap
&capsnap
, int used
);
674 void _flushed_cap_snap(Inode
*in
, snapid_t seq
);
676 void _schedule_invalidate_dentry_callback(Dentry
*dn
, bool del
);
677 void _async_dentry_invalidate(vinodeno_t dirino
, vinodeno_t ino
, string
& name
);
678 void _try_to_trim_inode(Inode
*in
, bool sched_inval
);
680 void _schedule_invalidate_callback(Inode
*in
, int64_t off
, int64_t len
);
681 void _invalidate_inode_cache(Inode
*in
);
682 void _invalidate_inode_cache(Inode
*in
, int64_t off
, int64_t len
);
683 void _async_invalidate(vinodeno_t ino
, int64_t off
, int64_t len
);
684 bool _release(Inode
*in
);
687 * Initiate a flush of the data associated with the given inode.
688 * If you specify a Context, you are responsible for holding an inode
689 * reference for the duration of the flush. If not, _flush() will
690 * take the reference for you.
691 * @param in The Inode whose data you wish to flush.
692 * @param c The Context you wish us to complete once the data is
693 * flushed. If already flushed, this will be called in-line.
695 * @returns true if the data was already flushed, false otherwise.
697 bool _flush(Inode
*in
, Context
*c
);
698 void _flush_range(Inode
*in
, int64_t off
, uint64_t size
);
699 void _flushed(Inode
*in
);
700 void flush_set_callback(ObjectCacher::ObjectSet
*oset
);
702 void close_release(Inode
*in
);
703 void close_safe(Inode
*in
);
705 void lock_fh_pos(Fh
*f
);
706 void unlock_fh_pos(Fh
*f
);
709 void update_dir_dist(Inode
*in
, DirStat
*st
);
711 void clear_dir_complete_and_ordered(Inode
*diri
, bool complete
);
712 void insert_readdir_results(MetaRequest
*request
, MetaSession
*session
, Inode
*diri
);
713 Inode
* insert_trace(MetaRequest
*request
, MetaSession
*session
);
714 void update_inode_file_bits(Inode
*in
, uint64_t truncate_seq
, uint64_t truncate_size
, uint64_t size
,
715 uint64_t change_attr
, uint64_t time_warp_seq
, utime_t ctime
,
716 utime_t mtime
, utime_t atime
, version_t inline_version
,
717 bufferlist
& inline_data
, int issued
);
718 Inode
*add_update_inode(InodeStat
*st
, utime_t ttl
, MetaSession
*session
,
719 const UserPerm
& request_perms
);
720 Dentry
*insert_dentry_inode(Dir
*dir
, const string
& dname
, LeaseStat
*dlease
,
721 Inode
*in
, utime_t from
, MetaSession
*session
,
722 Dentry
*old_dentry
= NULL
);
723 void update_dentry_lease(Dentry
*dn
, LeaseStat
*dlease
, utime_t from
, MetaSession
*session
);
725 bool use_faked_inos() { return _use_faked_inos
; }
726 vinodeno_t
map_faked_ino(ino_t ino
);
728 //notify the mds to flush the mdlog
729 void flush_mdlog_sync();
730 void flush_mdlog(MetaSession
*session
);
732 // ----------------------
736 void fill_dirent(struct dirent
*de
, const char *name
, int type
, uint64_t ino
, loff_t next_off
);
738 // some readdir helpers
739 typedef int (*add_dirent_cb_t
)(void *p
, struct dirent
*de
, struct ceph_statx
*stx
, off_t off
, Inode
*in
);
741 int _opendir(Inode
*in
, dir_result_t
**dirpp
, const UserPerm
& perms
);
742 void _readdir_drop_dirp_buffer(dir_result_t
*dirp
);
743 bool _readdir_have_frag(dir_result_t
*dirp
);
744 void _readdir_next_frag(dir_result_t
*dirp
);
745 void _readdir_rechoose_frag(dir_result_t
*dirp
);
746 int _readdir_get_frag(dir_result_t
*dirp
);
747 int _readdir_cache_cb(dir_result_t
*dirp
, add_dirent_cb_t cb
, void *p
, int caps
, bool getref
);
748 void _closedir(dir_result_t
*dirp
);
751 void _fragmap_remove_non_leaves(Inode
*in
);
752 void _fragmap_remove_stopped_mds(Inode
*in
, mds_rank_t mds
);
754 void _ll_get(Inode
*in
);
755 int _ll_put(Inode
*in
, int num
);
756 void _ll_drop_pins();
758 Fh
*_create_fh(Inode
*in
, int flags
, int cmode
, const UserPerm
& perms
);
759 int _release_fh(Fh
*fh
);
760 void _put_fh(Fh
*fh
);
763 struct C_Readahead
: public Context
{
766 C_Readahead(Client
*c
, Fh
*f
);
767 ~C_Readahead() override
;
768 void finish(int r
) override
;
771 int _read_sync(Fh
*f
, uint64_t off
, uint64_t len
, bufferlist
*bl
, bool *checkeof
);
772 int _read_async(Fh
*f
, uint64_t off
, uint64_t len
, bufferlist
*bl
);
774 // internal interface
775 // call these with client_lock held!
776 int _do_lookup(Inode
*dir
, const string
& name
, int mask
, InodeRef
*target
,
777 const UserPerm
& perms
);
779 int _lookup(Inode
*dir
, const string
& dname
, int mask
, InodeRef
*target
,
780 const UserPerm
& perm
);
782 int _link(Inode
*in
, Inode
*dir
, const char *name
, const UserPerm
& perm
,
784 int _unlink(Inode
*dir
, const char *name
, const UserPerm
& perm
);
785 int _rename(Inode
*olddir
, const char *oname
, Inode
*ndir
, const char *nname
, const UserPerm
& perm
);
786 int _mkdir(Inode
*dir
, const char *name
, mode_t mode
, const UserPerm
& perm
,
788 int _rmdir(Inode
*dir
, const char *name
, const UserPerm
& perms
);
789 int _symlink(Inode
*dir
, const char *name
, const char *target
,
790 const UserPerm
& perms
, InodeRef
*inp
= 0);
791 int _mknod(Inode
*dir
, const char *name
, mode_t mode
, dev_t rdev
,
792 const UserPerm
& perms
, InodeRef
*inp
= 0);
793 int _do_setattr(Inode
*in
, struct ceph_statx
*stx
, int mask
,
794 const UserPerm
& perms
, InodeRef
*inp
);
795 void stat_to_statx(struct stat
*st
, struct ceph_statx
*stx
);
796 int __setattrx(Inode
*in
, struct ceph_statx
*stx
, int mask
,
797 const UserPerm
& perms
, InodeRef
*inp
= 0);
798 int _setattrx(InodeRef
&in
, struct ceph_statx
*stx
, int mask
,
799 const UserPerm
& perms
);
800 int _setattr(InodeRef
&in
, struct stat
*attr
, int mask
,
801 const UserPerm
& perms
);
802 int _ll_setattrx(Inode
*in
, struct ceph_statx
*stx
, int mask
,
803 const UserPerm
& perms
, InodeRef
*inp
= 0);
804 int _getattr(Inode
*in
, int mask
, const UserPerm
& perms
, bool force
=false);
805 int _getattr(InodeRef
&in
, int mask
, const UserPerm
& perms
, bool force
=false) {
806 return _getattr(in
.get(), mask
, perms
, force
);
808 int _readlink(Inode
*in
, char *buf
, size_t size
);
809 int _getxattr(Inode
*in
, const char *name
, void *value
, size_t len
,
810 const UserPerm
& perms
);
811 int _getxattr(InodeRef
&in
, const char *name
, void *value
, size_t len
,
812 const UserPerm
& perms
);
813 int _listxattr(Inode
*in
, char *names
, size_t len
, const UserPerm
& perms
);
814 int _do_setxattr(Inode
*in
, const char *name
, const void *value
, size_t len
,
815 int flags
, const UserPerm
& perms
);
816 int _setxattr(Inode
*in
, const char *name
, const void *value
, size_t len
,
817 int flags
, const UserPerm
& perms
);
818 int _setxattr(InodeRef
&in
, const char *name
, const void *value
, size_t len
,
819 int flags
, const UserPerm
& perms
);
820 int _setxattr_check_data_pool(string
& name
, string
& value
, const OSDMap
*osdmap
);
821 void _setxattr_maybe_wait_for_osdmap(const char *name
, const void *value
, size_t len
);
822 int _removexattr(Inode
*in
, const char *nm
, const UserPerm
& perms
);
823 int _removexattr(InodeRef
&in
, const char *nm
, const UserPerm
& perms
);
824 int _open(Inode
*in
, int flags
, mode_t mode
, Fh
**fhp
,
825 const UserPerm
& perms
);
826 int _renew_caps(Inode
*in
);
827 int _create(Inode
*in
, const char *name
, int flags
, mode_t mode
, InodeRef
*inp
,
828 Fh
**fhp
, int stripe_unit
, int stripe_count
, int object_size
,
829 const char *data_pool
, bool *created
, const UserPerm
&perms
);
831 loff_t
_lseek(Fh
*fh
, loff_t offset
, int whence
);
832 int _read(Fh
*fh
, int64_t offset
, uint64_t size
, bufferlist
*bl
);
833 int _write(Fh
*fh
, int64_t offset
, uint64_t size
, const char *buf
,
834 const struct iovec
*iov
, int iovcnt
);
835 int _preadv_pwritev(int fd
, const struct iovec
*iov
, unsigned iovcnt
, int64_t offset
, bool write
);
837 int _fsync(Fh
*fh
, bool syncdataonly
);
838 int _fsync(Inode
*in
, bool syncdataonly
);
840 int _fallocate(Fh
*fh
, int mode
, int64_t offset
, int64_t length
);
841 int _getlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
);
842 int _setlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
, int sleep
);
843 int _flock(Fh
*fh
, int cmd
, uint64_t owner
);
845 int get_or_create(Inode
*dir
, const char* name
,
846 Dentry
**pdn
, bool expect_null
=false);
859 void init_groups(UserPerm
*groups
);
861 int inode_permission(Inode
*in
, const UserPerm
& perms
, unsigned want
);
862 int xattr_permission(Inode
*in
, const char *name
, unsigned want
,
863 const UserPerm
& perms
);
864 int may_setattr(Inode
*in
, struct ceph_statx
*stx
, int mask
,
865 const UserPerm
& perms
);
866 int may_open(Inode
*in
, int flags
, const UserPerm
& perms
);
867 int may_lookup(Inode
*dir
, const UserPerm
& perms
);
868 int may_create(Inode
*dir
, const UserPerm
& perms
);
869 int may_delete(Inode
*dir
, const char *name
, const UserPerm
& perms
);
870 int may_hardlink(Inode
*in
, const UserPerm
& perms
);
872 int _getattr_for_perm(Inode
*in
, const UserPerm
& perms
);
873 int _getgrouplist(gid_t
**sgids
, uid_t uid
, gid_t gid
);
875 vinodeno_t
_get_vino(Inode
*in
);
876 inodeno_t
_get_inodeno(Inode
*in
);
879 * These define virtual xattrs exposing the recursive directory
880 * statistics and layout metadata.
884 size_t (Client::*getxattr_cb
)(Inode
*in
, char *val
, size_t size
);
885 bool readonly
, hidden
;
886 bool (Client::*exists_cb
)(Inode
*in
);
889 bool _vxattrcb_quota_exists(Inode
*in
);
890 size_t _vxattrcb_quota(Inode
*in
, char *val
, size_t size
);
891 size_t _vxattrcb_quota_max_bytes(Inode
*in
, char *val
, size_t size
);
892 size_t _vxattrcb_quota_max_files(Inode
*in
, char *val
, size_t size
);
894 bool _vxattrcb_layout_exists(Inode
*in
);
895 size_t _vxattrcb_layout(Inode
*in
, char *val
, size_t size
);
896 size_t _vxattrcb_layout_stripe_unit(Inode
*in
, char *val
, size_t size
);
897 size_t _vxattrcb_layout_stripe_count(Inode
*in
, char *val
, size_t size
);
898 size_t _vxattrcb_layout_object_size(Inode
*in
, char *val
, size_t size
);
899 size_t _vxattrcb_layout_pool(Inode
*in
, char *val
, size_t size
);
900 size_t _vxattrcb_layout_pool_namespace(Inode
*in
, char *val
, size_t size
);
901 size_t _vxattrcb_dir_entries(Inode
*in
, char *val
, size_t size
);
902 size_t _vxattrcb_dir_files(Inode
*in
, char *val
, size_t size
);
903 size_t _vxattrcb_dir_subdirs(Inode
*in
, char *val
, size_t size
);
904 size_t _vxattrcb_dir_rentries(Inode
*in
, char *val
, size_t size
);
905 size_t _vxattrcb_dir_rfiles(Inode
*in
, char *val
, size_t size
);
906 size_t _vxattrcb_dir_rsubdirs(Inode
*in
, char *val
, size_t size
);
907 size_t _vxattrcb_dir_rbytes(Inode
*in
, char *val
, size_t size
);
908 size_t _vxattrcb_dir_rctime(Inode
*in
, char *val
, size_t size
);
909 size_t _vxattrs_calcu_name_size(const VXattr
*vxattrs
);
911 static const VXattr _dir_vxattrs
[];
912 static const VXattr _file_vxattrs
[];
914 static const VXattr
*_get_vxattrs(Inode
*in
);
915 static const VXattr
*_match_vxattr(Inode
*in
, const char *name
);
917 size_t _file_vxattrs_name_size
;
918 size_t _dir_vxattrs_name_size
;
919 size_t _vxattrs_name_size(const VXattr
*vxattrs
) {
920 if (vxattrs
== _dir_vxattrs
)
921 return _dir_vxattrs_name_size
;
922 else if (vxattrs
== _file_vxattrs
)
923 return _file_vxattrs_name_size
;
927 int _do_filelock(Inode
*in
, Fh
*fh
, int lock_type
, int op
, int sleep
,
928 struct flock
*fl
, uint64_t owner
, bool removing
=false);
929 int _interrupt_filelock(MetaRequest
*req
);
930 void _encode_filelocks(Inode
*in
, bufferlist
& bl
);
931 void _release_filelocks(Fh
*fh
);
932 void _update_lock_state(struct flock
*fl
, uint64_t owner
, ceph_lock_state_t
*lock_state
);
934 int _posix_acl_create(Inode
*dir
, mode_t
*mode
, bufferlist
& xattrs_bl
,
935 const UserPerm
& perms
);
936 int _posix_acl_chmod(Inode
*in
, mode_t mode
, const UserPerm
& perms
);
937 int _posix_acl_permission(Inode
*in
, const UserPerm
& perms
, unsigned want
);
939 mds_rank_t
_get_random_up_mds() const;
941 int _ll_getattr(Inode
*in
, int caps
, const UserPerm
& perms
);
944 int mount(const std::string
&mount_root
, const UserPerm
& perms
,
945 bool require_mds
=false);
949 const std::string
&mds_spec
,
950 const std::vector
<std::string
>& cmd
,
951 const bufferlist
& inbl
,
952 bufferlist
*poutbl
, std::string
*prs
, Context
*onfinish
);
954 // these shoud (more or less) mirror the actual system calls.
955 int statfs(const char *path
, struct statvfs
*stbuf
, const UserPerm
& perms
);
958 int chdir(const char *s
, std::string
&new_cwd
, const UserPerm
& perms
);
959 void getcwd(std::string
& cwd
, const UserPerm
& perms
);
962 int opendir(const char *name
, dir_result_t
**dirpp
, const UserPerm
& perms
);
963 int closedir(dir_result_t
*dirp
);
966 * Fill a directory listing from dirp, invoking cb for each entry
967 * with the given pointer, the dirent, the struct stat, the stmask,
970 * Returns 0 if it reached the end of the directory.
971 * If @a cb returns a negative error code, stop and return that.
973 int readdir_r_cb(dir_result_t
*dirp
, add_dirent_cb_t cb
, void *p
,
974 unsigned want
=0, unsigned flags
=AT_NO_ATTR_SYNC
,
977 struct dirent
* readdir(dir_result_t
*d
);
978 int readdir_r(dir_result_t
*dirp
, struct dirent
*de
);
979 int readdirplus_r(dir_result_t
*dirp
, struct dirent
*de
, struct ceph_statx
*stx
, unsigned want
, unsigned flags
, Inode
**out
);
981 int getdir(const char *relpath
, list
<string
>& names
,
982 const UserPerm
& perms
); // get the whole dir at once.
985 * Returns the length of the buffer that got filled in, or -errno.
986 * If it returns -ERANGE you just need to increase the size of the
987 * buffer and try again.
989 int _getdents(dir_result_t
*dirp
, char *buf
, int buflen
, bool ful
); // get a bunch of dentries at once
990 int getdents(dir_result_t
*dirp
, char *buf
, int buflen
) {
991 return _getdents(dirp
, buf
, buflen
, true);
993 int getdnames(dir_result_t
*dirp
, char *buf
, int buflen
) {
994 return _getdents(dirp
, buf
, buflen
, false);
997 void rewinddir(dir_result_t
*dirp
);
998 loff_t
telldir(dir_result_t
*dirp
);
999 void seekdir(dir_result_t
*dirp
, loff_t offset
);
1001 int link(const char *existing
, const char *newname
, const UserPerm
& perm
);
1002 int unlink(const char *path
, const UserPerm
& perm
);
1003 int rename(const char *from
, const char *to
, const UserPerm
& perm
);
1006 int mkdir(const char *path
, mode_t mode
, const UserPerm
& perm
);
1007 int mkdirs(const char *path
, mode_t mode
, const UserPerm
& perms
);
1008 int rmdir(const char *path
, const UserPerm
& perms
);
1011 int readlink(const char *path
, char *buf
, loff_t size
, const UserPerm
& perms
);
1013 int symlink(const char *existing
, const char *newname
, const UserPerm
& perms
);
1016 unsigned statx_to_mask(unsigned int flags
, unsigned int want
);
1017 int stat(const char *path
, struct stat
*stbuf
, const UserPerm
& perms
,
1018 frag_info_t
*dirstat
=0, int mask
=CEPH_STAT_CAP_INODE_ALL
);
1019 int statx(const char *path
, struct ceph_statx
*stx
,
1020 const UserPerm
& perms
,
1021 unsigned int want
, unsigned int flags
);
1022 int lstat(const char *path
, struct stat
*stbuf
, const UserPerm
& perms
,
1023 frag_info_t
*dirstat
=0, int mask
=CEPH_STAT_CAP_INODE_ALL
);
1025 int setattr(const char *relpath
, struct stat
*attr
, int mask
,
1026 const UserPerm
& perms
);
1027 int setattrx(const char *relpath
, struct ceph_statx
*stx
, int mask
,
1028 const UserPerm
& perms
, int flags
=0);
1029 int fsetattr(int fd
, struct stat
*attr
, int mask
, const UserPerm
& perms
);
1030 int fsetattrx(int fd
, struct ceph_statx
*stx
, int mask
, const UserPerm
& perms
);
1031 int chmod(const char *path
, mode_t mode
, const UserPerm
& perms
);
1032 int fchmod(int fd
, mode_t mode
, const UserPerm
& perms
);
1033 int lchmod(const char *path
, mode_t mode
, const UserPerm
& perms
);
1034 int chown(const char *path
, uid_t new_uid
, gid_t new_gid
,
1035 const UserPerm
& perms
);
1036 int fchown(int fd
, uid_t new_uid
, gid_t new_gid
, const UserPerm
& perms
);
1037 int lchown(const char *path
, uid_t new_uid
, gid_t new_gid
,
1038 const UserPerm
& perms
);
1039 int utime(const char *path
, struct utimbuf
*buf
, const UserPerm
& perms
);
1040 int lutime(const char *path
, struct utimbuf
*buf
, const UserPerm
& perms
);
1041 int flock(int fd
, int operation
, uint64_t owner
);
1042 int truncate(const char *path
, loff_t size
, const UserPerm
& perms
);
1045 int mknod(const char *path
, mode_t mode
, const UserPerm
& perms
, dev_t rdev
=0);
1046 int open(const char *path
, int flags
, const UserPerm
& perms
, mode_t mode
=0);
1047 int open(const char *path
, int flags
, const UserPerm
& perms
,
1048 mode_t mode
, int stripe_unit
, int stripe_count
, int object_size
,
1049 const char *data_pool
);
1050 int lookup_hash(inodeno_t ino
, inodeno_t dirino
, const char *name
,
1051 const UserPerm
& perms
);
1052 int lookup_ino(inodeno_t ino
, const UserPerm
& perms
, Inode
**inode
=NULL
);
1053 int lookup_parent(Inode
*in
, const UserPerm
& perms
, Inode
**parent
=NULL
);
1054 int lookup_name(Inode
*in
, Inode
*parent
, const UserPerm
& perms
);
1056 loff_t
lseek(int fd
, loff_t offset
, int whence
);
1057 int read(int fd
, char *buf
, loff_t size
, loff_t offset
=-1);
1058 int preadv(int fd
, const struct iovec
*iov
, int iovcnt
, loff_t offset
=-1);
1059 int write(int fd
, const char *buf
, loff_t size
, loff_t offset
=-1);
1060 int pwritev(int fd
, const struct iovec
*iov
, int iovcnt
, loff_t offset
=-1);
1061 int fake_write_size(int fd
, loff_t size
);
1062 int ftruncate(int fd
, loff_t size
, const UserPerm
& perms
);
1063 int fsync(int fd
, bool syncdataonly
);
1064 int fstat(int fd
, struct stat
*stbuf
, const UserPerm
& perms
,
1065 int mask
=CEPH_STAT_CAP_INODE_ALL
);
1066 int fstatx(int fd
, struct ceph_statx
*stx
, const UserPerm
& perms
,
1067 unsigned int want
, unsigned int flags
);
1068 int fallocate(int fd
, int mode
, loff_t offset
, loff_t length
);
1070 // full path xattr ops
1071 int getxattr(const char *path
, const char *name
, void *value
, size_t size
,
1072 const UserPerm
& perms
);
1073 int lgetxattr(const char *path
, const char *name
, void *value
, size_t size
,
1074 const UserPerm
& perms
);
1075 int fgetxattr(int fd
, const char *name
, void *value
, size_t size
,
1076 const UserPerm
& perms
);
1077 int listxattr(const char *path
, char *list
, size_t size
, const UserPerm
& perms
);
1078 int llistxattr(const char *path
, char *list
, size_t size
, const UserPerm
& perms
);
1079 int flistxattr(int fd
, char *list
, size_t size
, const UserPerm
& perms
);
1080 int removexattr(const char *path
, const char *name
, const UserPerm
& perms
);
1081 int lremovexattr(const char *path
, const char *name
, const UserPerm
& perms
);
1082 int fremovexattr(int fd
, const char *name
, const UserPerm
& perms
);
1083 int setxattr(const char *path
, const char *name
, const void *value
,
1084 size_t size
, int flags
, const UserPerm
& perms
);
1085 int lsetxattr(const char *path
, const char *name
, const void *value
,
1086 size_t size
, int flags
, const UserPerm
& perms
);
1087 int fsetxattr(int fd
, const char *name
, const void *value
, size_t size
,
1088 int flags
, const UserPerm
& perms
);
1091 int64_t drop_caches();
1094 int lazyio_propogate(int fd
, loff_t offset
, size_t count
);
1095 int lazyio_synchronize(int fd
, loff_t offset
, size_t count
);
1097 // expose file layout
1098 int describe_layout(const char *path
, file_layout_t
* layout
,
1099 const UserPerm
& perms
);
1100 int fdescribe_layout(int fd
, file_layout_t
* layout
);
1101 int get_file_stripe_address(int fd
, loff_t offset
, vector
<entity_addr_t
>& address
);
1102 int get_file_extent_osds(int fd
, loff_t off
, loff_t
*len
, vector
<int>& osds
);
1103 int get_osd_addr(int osd
, entity_addr_t
& addr
);
1106 int get_local_osd();
1107 int get_pool_replication(int64_t pool
);
1108 int64_t get_pool_id(const char *pool_name
);
1109 string
get_pool_name(int64_t pool
);
1110 int get_osd_crush_location(int id
, vector
<pair
<string
, string
> >& path
);
1112 int enumerate_layout(int fd
, vector
<ObjectExtent
>& result
,
1113 loff_t length
, loff_t offset
);
1115 int mksnap(const char *path
, const char *name
, const UserPerm
& perm
);
1116 int rmsnap(const char *path
, const char *name
, const UserPerm
& perm
);
1119 int get_caps_issued(int fd
);
1120 int get_caps_issued(const char *path
, const UserPerm
& perms
);
1122 // low-level interface v2
1123 inodeno_t
ll_get_inodeno(Inode
*in
) {
1124 Mutex::Locker
lock(client_lock
);
1125 return _get_inodeno(in
);
1127 snapid_t
ll_get_snapid(Inode
*in
);
1128 vinodeno_t
ll_get_vino(Inode
*in
) {
1129 Mutex::Locker
lock(client_lock
);
1130 return _get_vino(in
);
1132 // get inode from faked ino
1133 Inode
*ll_get_inode(ino_t ino
);
1134 Inode
*ll_get_inode(vinodeno_t vino
);
1135 int ll_lookup(Inode
*parent
, const char *name
, struct stat
*attr
,
1136 Inode
**out
, const UserPerm
& perms
);
1137 int ll_lookupx(Inode
*parent
, const char *name
, Inode
**out
,
1138 struct ceph_statx
*stx
, unsigned want
, unsigned flags
,
1139 const UserPerm
& perms
);
1140 bool ll_forget(Inode
*in
, int count
);
1141 bool ll_put(Inode
*in
);
1142 int ll_getattr(Inode
*in
, struct stat
*st
, const UserPerm
& perms
);
1143 int ll_getattrx(Inode
*in
, struct ceph_statx
*stx
, unsigned int want
,
1144 unsigned int flags
, const UserPerm
& perms
);
1145 int ll_setattrx(Inode
*in
, struct ceph_statx
*stx
, int mask
,
1146 const UserPerm
& perms
);
1147 int ll_setattr(Inode
*in
, struct stat
*st
, int mask
,
1148 const UserPerm
& perms
);
1149 int ll_getxattr(Inode
*in
, const char *name
, void *value
, size_t size
,
1150 const UserPerm
& perms
);
1151 int ll_setxattr(Inode
*in
, const char *name
, const void *value
, size_t size
,
1152 int flags
, const UserPerm
& perms
);
1153 int ll_removexattr(Inode
*in
, const char *name
, const UserPerm
& perms
);
1154 int ll_listxattr(Inode
*in
, char *list
, size_t size
, const UserPerm
& perms
);
1155 int ll_opendir(Inode
*in
, int flags
, dir_result_t
**dirpp
,
1156 const UserPerm
& perms
);
1157 int ll_releasedir(dir_result_t
* dirp
);
1158 int ll_fsyncdir(dir_result_t
* dirp
);
1159 int ll_readlink(Inode
*in
, char *buf
, size_t bufsize
, const UserPerm
& perms
);
1160 int ll_mknod(Inode
*in
, const char *name
, mode_t mode
, dev_t rdev
,
1161 struct stat
*attr
, Inode
**out
, const UserPerm
& perms
);
1162 int ll_mknodx(Inode
*parent
, const char *name
, mode_t mode
, dev_t rdev
,
1163 Inode
**out
, struct ceph_statx
*stx
, unsigned want
,
1164 unsigned flags
, const UserPerm
& perms
);
1165 int ll_mkdir(Inode
*in
, const char *name
, mode_t mode
, struct stat
*attr
,
1166 Inode
**out
, const UserPerm
& perm
);
1167 int ll_mkdirx(Inode
*parent
, const char *name
, mode_t mode
, Inode
**out
,
1168 struct ceph_statx
*stx
, unsigned want
, unsigned flags
,
1169 const UserPerm
& perms
);
1170 int ll_symlink(Inode
*in
, const char *name
, const char *value
,
1171 struct stat
*attr
, Inode
**out
, const UserPerm
& perms
);
1172 int ll_symlinkx(Inode
*parent
, const char *name
, const char *value
,
1173 Inode
**out
, struct ceph_statx
*stx
, unsigned want
,
1174 unsigned flags
, const UserPerm
& perms
);
1175 int ll_unlink(Inode
*in
, const char *name
, const UserPerm
& perm
);
1176 int ll_rmdir(Inode
*in
, const char *name
, const UserPerm
& perms
);
1177 int ll_rename(Inode
*parent
, const char *name
, Inode
*newparent
,
1178 const char *newname
, const UserPerm
& perm
);
1179 int ll_link(Inode
*in
, Inode
*newparent
, const char *newname
,
1180 const UserPerm
& perm
);
1181 int ll_open(Inode
*in
, int flags
, Fh
**fh
, const UserPerm
& perms
);
1182 int _ll_create(Inode
*parent
, const char *name
, mode_t mode
,
1183 int flags
, InodeRef
*in
, int caps
, Fh
**fhp
,
1184 const UserPerm
& perms
);
1185 int ll_create(Inode
*parent
, const char *name
, mode_t mode
, int flags
,
1186 struct stat
*attr
, Inode
**out
, Fh
**fhp
,
1187 const UserPerm
& perms
);
1188 int ll_createx(Inode
*parent
, const char *name
, mode_t mode
,
1189 int oflags
, Inode
**outp
, Fh
**fhp
,
1190 struct ceph_statx
*stx
, unsigned want
, unsigned lflags
,
1191 const UserPerm
& perms
);
1192 int ll_read_block(Inode
*in
, uint64_t blockid
, char *buf
, uint64_t offset
,
1193 uint64_t length
, file_layout_t
* layout
);
1195 int ll_write_block(Inode
*in
, uint64_t blockid
,
1196 char* buf
, uint64_t offset
,
1197 uint64_t length
, file_layout_t
* layout
,
1198 uint64_t snapseq
, uint32_t sync
);
1199 int ll_commit_blocks(Inode
*in
, uint64_t offset
, uint64_t length
);
1201 int ll_statfs(Inode
*in
, struct statvfs
*stbuf
, const UserPerm
& perms
);
1202 int ll_walk(const char* name
, Inode
**i
, struct ceph_statx
*stx
,
1203 unsigned int want
, unsigned int flags
, const UserPerm
& perms
);
1204 uint32_t ll_stripe_unit(Inode
*in
);
1205 int ll_file_layout(Inode
*in
, file_layout_t
*layout
);
1206 uint64_t ll_snap_seq(Inode
*in
);
1208 int ll_read(Fh
*fh
, loff_t off
, loff_t len
, bufferlist
*bl
);
1209 int ll_write(Fh
*fh
, loff_t off
, loff_t len
, const char *data
);
1210 loff_t
ll_lseek(Fh
*fh
, loff_t offset
, int whence
);
1211 int ll_flush(Fh
*fh
);
1212 int ll_fsync(Fh
*fh
, bool syncdataonly
);
1213 int ll_fallocate(Fh
*fh
, int mode
, loff_t offset
, loff_t length
);
1214 int ll_release(Fh
*fh
);
1215 int ll_getlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
);
1216 int ll_setlk(Fh
*fh
, struct flock
*fl
, uint64_t owner
, int sleep
);
1217 int ll_flock(Fh
*fh
, int cmd
, uint64_t owner
);
1218 int ll_file_layout(Fh
*fh
, file_layout_t
*layout
);
1219 void ll_interrupt(void *d
);
1220 bool ll_handle_umask() {
1221 return acl_type
!= NO_ACL
;
1224 int ll_get_stripe_osd(struct Inode
*in
, uint64_t blockno
,
1225 file_layout_t
* layout
);
1226 uint64_t ll_get_internal_offset(struct Inode
*in
, uint64_t blockno
);
1228 int ll_num_osds(void);
1229 int ll_osdaddr(int osd
, uint32_t *addr
);
1230 int ll_osdaddr(int osd
, char* buf
, size_t size
);
1232 void ll_register_callbacks(struct client_callback_args
*args
);
1233 int test_dentry_handling(bool can_invalidate
);
1235 const char** get_tracked_conf_keys() const override
;
1236 void handle_conf_change(const struct md_config_t
*conf
,
1237 const std::set
<std::string
> &changed
) override
;
1241 * Specialization of Client that manages its own Objecter instance
1242 * and handles init/shutdown of messenger/monclient
1244 class StandaloneClient
: public Client
1247 StandaloneClient(Messenger
*m
, MonClient
*mc
);
1249 ~StandaloneClient() override
;
1251 int init() override
;
1252 void shutdown() override
;