linux/fs/ceph/mds_client.h
<<
>>
Prefs
   1#ifndef _FS_CEPH_MDS_CLIENT_H
   2#define _FS_CEPH_MDS_CLIENT_H
   3
   4#include <linux/completion.h>
   5#include <linux/kref.h>
   6#include <linux/list.h>
   7#include <linux/mutex.h>
   8#include <linux/rbtree.h>
   9#include <linux/spinlock.h>
  10
  11#include <linux/ceph/types.h>
  12#include <linux/ceph/messenger.h>
  13#include <linux/ceph/mdsmap.h>
  14#include <linux/ceph/auth.h>
  15
  16/*
  17 * Some lock dependencies:
  18 *
  19 * session->s_mutex
  20 *         mdsc->mutex
  21 *
  22 *         mdsc->snap_rwsem
  23 *
  24 *         ci->i_ceph_lock
  25 *                 mdsc->snap_flush_lock
  26 *                 mdsc->cap_delay_lock
  27 *
  28 */
  29
  30struct ceph_fs_client;
  31struct ceph_cap;
  32
  33/*
  34 * parsed info about a single inode.  pointers are into the encoded
  35 * on-wire structures within the mds reply message payload.
  36 */
  37struct ceph_mds_reply_info_in {
  38        struct ceph_mds_reply_inode *in;
  39        struct ceph_dir_layout dir_layout;
  40        u32 symlink_len;
  41        char *symlink;
  42        u32 xattr_len;
  43        char *xattr_data;
  44};
  45
  46/*
  47 * parsed info about an mds reply, including information about
  48 * either: 1) the target inode and/or its parent directory and dentry,
  49 * and directory contents (for readdir results), or
  50 * 2) the file range lock info (for fcntl F_GETLK results).
  51 */
  52struct ceph_mds_reply_info_parsed {
  53        struct ceph_mds_reply_head    *head;
  54
  55        /* trace */
  56        struct ceph_mds_reply_info_in diri, targeti;
  57        struct ceph_mds_reply_dirfrag *dirfrag;
  58        char                          *dname;
  59        u32                           dname_len;
  60        struct ceph_mds_reply_lease   *dlease;
  61
  62        /* extra */
  63        union {
  64                /* for fcntl F_GETLK results */
  65                struct ceph_filelock *filelock_reply;
  66
  67                /* for readdir results */
  68                struct {
  69                        struct ceph_mds_reply_dirfrag *dir_dir;
  70                        int                           dir_nr;
  71                        char                          **dir_dname;
  72                        u32                           *dir_dname_len;
  73                        struct ceph_mds_reply_lease   **dir_dlease;
  74                        struct ceph_mds_reply_info_in *dir_in;
  75                        u8                            dir_complete, dir_end;
  76                };
  77        };
  78
  79        /* encoded blob describing snapshot contexts for certain
  80           operations (e.g., open) */
  81        void *snapblob;
  82        int snapblob_len;
  83};
  84
  85
  86/*
  87 * cap releases are batched and sent to the MDS en masse.
  88 */
  89#define CEPH_CAPS_PER_RELEASE ((PAGE_CACHE_SIZE -                       \
  90                                sizeof(struct ceph_mds_cap_release)) /  \
  91                               sizeof(struct ceph_mds_cap_item))
  92
  93
  94/*
  95 * state associated with each MDS<->client session
  96 */
  97enum {
  98        CEPH_MDS_SESSION_NEW = 1,
  99        CEPH_MDS_SESSION_OPENING = 2,
 100        CEPH_MDS_SESSION_OPEN = 3,
 101        CEPH_MDS_SESSION_HUNG = 4,
 102        CEPH_MDS_SESSION_CLOSING = 5,
 103        CEPH_MDS_SESSION_RESTARTING = 6,
 104        CEPH_MDS_SESSION_RECONNECTING = 7,
 105};
 106
 107struct ceph_mds_session {
 108        struct ceph_mds_client *s_mdsc;
 109        int               s_mds;
 110        int               s_state;
 111        unsigned long     s_ttl;      /* time until mds kills us */
 112        u64               s_seq;      /* incoming msg seq # */
 113        struct mutex      s_mutex;    /* serialize session messages */
 114
 115        struct ceph_connection s_con;
 116
 117        struct ceph_auth_handshake s_auth;
 118
 119        /* protected by s_gen_ttl_lock */
 120        spinlock_t        s_gen_ttl_lock;
 121        u32               s_cap_gen;  /* inc each time we get mds stale msg */
 122        unsigned long     s_cap_ttl;  /* when session caps expire */
 123
 124        /* protected by s_cap_lock */
 125        spinlock_t        s_cap_lock;
 126        struct list_head  s_caps;     /* all caps issued by this session */
 127        int               s_nr_caps, s_trim_caps;
 128        int               s_num_cap_releases;
 129        struct list_head  s_cap_releases; /* waiting cap_release messages */
 130        struct list_head  s_cap_releases_done; /* ready to send */
 131        struct ceph_cap  *s_cap_iterator;
 132
 133        /* protected by mutex */
 134        struct list_head  s_cap_flushing;     /* inodes w/ flushing caps */
 135        struct list_head  s_cap_snaps_flushing;
 136        unsigned long     s_renew_requested; /* last time we sent a renew req */
 137        u64               s_renew_seq;
 138
 139        atomic_t          s_ref;
 140        struct list_head  s_waiting;  /* waiting requests */
 141        struct list_head  s_unsafe;   /* unsafe requests */
 142};
 143
 144/*
 145 * modes of choosing which MDS to send a request to
 146 */
 147enum {
 148        USE_ANY_MDS,
 149        USE_RANDOM_MDS,
 150        USE_AUTH_MDS,   /* prefer authoritative mds for this metadata item */
 151};
 152
 153struct ceph_mds_request;
 154struct ceph_mds_client;
 155
 156/*
 157 * request completion callback
 158 */
 159typedef void (*ceph_mds_request_callback_t) (struct ceph_mds_client *mdsc,
 160                                             struct ceph_mds_request *req);
 161
 162/*
 163 * an in-flight mds request
 164 */
 165struct ceph_mds_request {
 166        u64 r_tid;                   /* transaction id */
 167        struct rb_node r_node;
 168        struct ceph_mds_client *r_mdsc;
 169
 170        int r_op;                    /* mds op code */
 171
 172        /* operation on what? */
 173        struct inode *r_inode;              /* arg1 */
 174        struct dentry *r_dentry;            /* arg1 */
 175        struct dentry *r_old_dentry;        /* arg2: rename from or link from */
 176        struct inode *r_old_dentry_dir;     /* arg2: old dentry's parent dir */
 177        char *r_path1, *r_path2;
 178        struct ceph_vino r_ino1, r_ino2;
 179
 180        struct inode *r_locked_dir; /* dir (if any) i_mutex locked by vfs */
 181        struct inode *tade=r_inode" class="sref">r_inodlTead" class="sref">list_head   171
s18e" name="L153"> 153struct s_mutex;    list_headfillserialize session mesadfillseriale" name="L179"> 179
  85
) (streasaiting cap_relealback_t) (streasa list_headeasaiting cap_relearreasa  179


 171
list_headument">/* transactioui" name="L76">  76                }1ent"> */<1/span>
list_headgment">/* transactiogi" name="L76">  76                }1eh/mds_cliH_CAPS_PER_RELEASE" clas1s="sr18e" name="L180"> 180        struct          1      sizeof(struct  171
  76                }1/mds_clie1nt.h#L93" id="L93" class1="lin19"+code=xattr_len" class="sref">xattr_len;

 171
CEPH_MDS_SESSION_RESboosession caps expbooshref="fs/ceph/mds_clres/ceph_is_has" id="L118" clasres/ceph_is_has"href="fs/ceph/mds_client.h#L141"f="e lieres/ceph_has"  idvalss="line" name="L167"> 167        struct ent">/*
  85
 * s1tate associated with eac1h MDS19"fs/ceph/mds_client.h#L56" id="L56" cl51" cass="li  idu>
 135        struct ent"> */<1/span>
  76                }1/ href="+cs_client.h#L98" id="L98"1 clas19="sref">s_nr_capsph/mds_client.h#L1umh#Lgwaiting cap_relea.h1umh#Lgwa name="L76">  76                }1/nt"> */<1H_MDS_SESSION_NEW" class1="sre19es" class="sref">"fs/ceph/mds_clres1" nt.h#L83" id="L83" res1" nt.h name="L76">  76                }1/nt"> * sesssion->s_mutex
="sr19e" name="L180"> 180        struct2="+code=C2PH_MDS_SESSION_OPEN" cla2s="sr20ode=ceph_mds_="fs/ceph/mds_client.h#L6clasclass=sh_cliwe/mrops="line" name="L173"> 173        struct2="+code=C2PH_MDS_SESSION_HUNG" cla2s="sr20de=ceph_mds_c     /* arg1 */
  76                }2="+code=C2PH_MDS_SESSION_CLOSING" 2lass=20pblob_len;
  76                }2=nt"> *CEPH_       76                }2=nt"> *   PH_MDS_SESSION_RECONNECT2NG" c20 *r_old_dentry_dir;       76                }2=5t"> *   Pate associated with eac2lass=205"sref">CEPH_     /* arg1 */  76                }2=nt"> *   ent.h#L107" id="L107" cl2ss="l2ne" name="L107"> 107struct ce20ss="sref">ceph_mds_reply_dirfrag *dirsef="fsir;      173        struct2=nt"> */"fs/ceph/mds_clrea>) (strspan>
<_offseient.h#L166" id=rass="linrspan>
<_offsei name="L76">  76                }2=mds_clien ceph_dir_layout dirsef="fsir;       66
ceph_mds_reply_lease   *;       66
 *
  66
u64 2     2         66
 * 144s_renew_req   130        struct2s_renew_req   173        struct2ph/mds_cl2ent.h#L117" id="L117" cl2ss="l21d" class="sref">s_renew_req"fs/ceph/mds_clrea>) (strstar>/* last time we srea>) (strstar>/*vfs */
  49 173        struct2pnt"> */ 119        /* protected by s_g2n_ttl2lock */
 173        struct2ent"> *          mdsc->mutex *r_locked_dir; < sir;       66
u32 2     22t_head  s_unsafe;   ;       66
 153struct ceph_mds_reply_head    *;       66
/* protected by s_c2p_loc22 name="L85">  85
s2inloc225"sref">CEPH_                  "fs/ceph/mds_clreat_clptaiting cap_relearret_clptak from *52" class="line" name="L152"="L14t_clpta""line" name="L173"> 173        struct2eh/mds_cl2code=list_head" class="s2ef">l22a> * 173        struct2ea href="2 s_nr_caps, "="L8" cvfs */
 173        struct2ent"> */,
s_cap_gen;  rlasnt_onirs id="L161" class="lasnt_onirs ivfs */
 173        struct2eass="com2code=list_head" class="s2ef">l22e" name="L180"> 180        struct2l2st_head    lass="comment">rlkr" id="L140" classrlkr" ne" e="L66">  66
ce2h_cap  *s_unsafe;   /rpan>
id="L140" classrlan>
ne" e="L66">  66
;       66
/* protected by mut2x */<23"sref">ceph_mds_reply_head    *;       66
l2st_head  ) (struct ceph_mdc;     cent.h#L108" id= c  66
l2st_head  s_cap_snaps_flushing;
< cid="L1ds_client.h#L92" id= cid="L1ds_cl nameetadata item */
sclass="line" name="L151"> 151};
rboosession caps expbooshref=/a>;  rlgot unsafe requests */  66
u64 2     2      ="L66">  66
 */;  rldid_prepopul111" id="L111" clarldid_prepopul111in" e="L66">  66
ato2ic_t<2a>          s_cap_gen;  rld="L68"_offseient.h#L166" id=rass"L68"_offseiin" e="L66">  66
l2st_hea="L66">  66
l2st_head  s_con;
;     s_con  66
;
 128        int   2ph/mds_cl2ent.h#L144" id="L144" cl2ss="l24e" name="L84">  84
/*2/span>
  85
 *2modes of choosing which 2DS to2send a request to
 163 *2
 163
 151};
2SE_AN2_MDS *r_mdsc;
 166        USE24f">ceph_dir_layout r_mdscf 169
  s_mutex;    ss="sref">s_mutex;    
 130        struct2ceph/mds_2lient.h#L152" id="L152" 2lass=25e" name="L172"> 172        s_cap_it;
;mds_client.h#L160" m class="sref">s_c;
 169
ce25"sref">ceph_mds_reply_head    *="L1dumountlan>
eraiting cap_releas"L1dumountlan>
erap_geame="L169"> 169
/*2h_mds_client" class="sre2">cep25t_head  
_claue_cap_ref="+code=ceph_man>
_claue_cap_repan cspan class="comment">= class hrose_w#L138" id="L138"  class hrose_w#p_geame="L169"> 169
 *2ent.h#L156" id="L156" cl2ss="l25t_head  s_cap_snaps_/a>  
ing_for_m class="sref">s_can>
ing_for_m cp_geame="L169"> 169
 *2/span>
 107struct  *2request completion callb2ckceph_mds_reply_dirfrag * 127        int   2mment"> *2
s_num_cap_relespan class="comment">sax_ass="liaiting cap_releasax_ass="lia nameetadata item */
 130        struct2c"+code=U2code=ceph_mds_request_ca2lback25ef">s_mds;
=toppting requests */ 127        int   2         2                    stru2t   66
 163/*2/span>
;
 163 163/*2
sc id=ainsess"lmsmds_clnline" name="L146"> 146ce26end a request to
 164u64 2a hre26ent.h#L147" id="L147" class=phspan c*enhould beeph/troyedne" name="L88">  88rb_26a href="fs/ceph/mds_client.hhhhhhhhh"line" name="L127"> 127        int   2 ment"> *2code=ceph_mds_client" cl2ss="s2ef">ceph_mds_client *ceph_mdlass="comment">=t.h_rwsemg requests */ 169
ceph_dir_layout =t.h_rs"lmsg requests */ 169
r_o2;27t_head  s_waiting;  =t.h_clptyg requests */ 169
s_cap_lock;
=t.h_clptyt.h#L126" id="L126" ct.h_clptyt.h#L nameetadata item */
 127        int   2lass="com2ent">/* operation on wha2? */<27e" name="L153"> 153struct CEPH_MDS_SESSION_RES_seq" class="sref">s_renew_seq;
/* transactclatomme screclas 4" class="l "line" name="L127"> 127        int   2lment">/*2code=dentry" class="sref2>dent2y *
 130        struct2 * eetadata item */
 130        struct2<"+code=u2code=inode" class="sref"2inode27d" class="sref">s_renew_requesMDS_SESSION_RESclatolass="" caiting cap_releaclatolass="" ca nameetadata item */
 135        struct2a href="+2ode=r_path1" class="sref2>r_pa27ss="sref">ceph_mds_reply_dirfrags_unsafe;   ;     ;ent.h#L108" id="/;k from *52" class="line" name="L1lass= s_clcllayed  id="L13"line" name="L135"> 135        struct2ament"> *2code=ceph_vino" class="s2ef">c27MDS,
s_cap_lock;
;     ;3"line" name="L135"> 135        struct2ah/mds_cl2ent.h#L180" id="L180" cl2ss="l27t_head  s_cap_releases=t.h_ass="_/a>;ent.h#L108" id==t.h_ass="_/a>; nameetadata item */
 135        struct2        s_gen_ttl_lock=t.h_ass="_/h#L126" id="L126" ct.h_ass="_/h#Lp_geame="L169"> 169
 172        s28      s_seq;      /* iing caps t.h#L138" id="L138"ing caps t.h#p_geame="L169"> 169
s_cap_snaps_flushing;
<"/ 135        struct2/mds_clie2nt.h#L85" id="L85" class2="lin28t_head  s_cap_flushing;     
 135        struct2/a href="2nt.h#L86" id="L86" class2="lin285"sref">CEPH_                  "fs/ceph/mds_clL129" cleph/mds_client.h#L136" L129" cleph/mds_vfs */
 135        struct2/"+code=u2span>
rs_cap_lock" class="sref">s_cap_lock;
 135        struct2/ href="+2ap releases are batched 2and s28      
_claue_cap_repan c="comment">/* iing caps ing_w#L138" id="L138"ing caps ing_w#p_geame="L169"> 169
 *2/span>
 119         135        struct2         2      sizeof(struct  135        struct2 a href="2     sizeof(struct  135        struct2 f="+code2nt.h#L93" id="L93" class2="lin29nt.h#L163" id="L163" class=ephspan c*eMaid=ain a global pool/cephss"l/h#aq *;
 163 163 163
 163
 163 163 *2H_MDS_SESSION_NEW" class2="sre29ent.h#L159" id="L159" class=phspan c*eRpservalass0 are " id=owned" id=e="La a>;
  88 * s2sssion->s_mutex 127        int   3="+code=C3PH_MDS_SESSION_OPEN" cla3s="sr30t        s_gen_ttl_lock/* iings_/a>;_/h#L126" id="L126" a/;_/h#Lp_geame="L169"> 169
s_unsafe;   ;     ;ent.h#L108" id="/; namee/ceph/mds_client.h#L142" idu>
 127        int   3=2+code=C3Pt.h#L93" id="L93" class3lass=30nt.h#L163" id="L163" class=ephspan ccccccccccccccccccccccccccccccccccccccccunspserv
<)h"line" name="L127"> 127        int   3=3+code=C3Pt.h#L94" id="L94" class3" cla3s="sref">CEPH_                ;      127        int   3=4+code=C3Ppan>
 *;     
_countent.h#L108" id="/
_count  135        struct3=5t"> *  3Pate associated with eac3lass=305"sref">CEPH_                ;      135        struct3=6t"> *  3Pspan>
 * 135        struct3=7t"> *  3P_client.h#L98" id="L98"3f">ce30="sref">s_nr_caps, ;      135        struct3=8t"> *  3P_MDS_SESSION_NEW" class3ss="s30ent.h#L159" id="L159" class=phspan cccccccccccccccccccccccccccccccccccccccc(unspserv
<)h"line" name="L127"> 127        int   3=9t"> *  3Pssion->s_mutex          s_cap_lock;
 169
ceph_mds_reply_lease   ushing" class="sref">s_cap_flushing;      169

/* arg2: renameL129ment">p_geame="L169"> 169
u64 3     31ine" name="L143"> 143
 * 144sc f="+code=r_path2" cl"L108" clop_115"ent.h#L108" id="L108" clop_115"/a> (;
 161
 156 * 156 *  3code=ceph_auth_handshake3 clas3r_mdsc;
 161
 *  3ent.h#L119" id="L119" cl3ss="l3ne" name="L119"> 119        /* protected by s_g3n_ttl3lock *="liicr_locked_dir" clastectedast time we sastect"fs/ch_mds_reply_dirfrag * 156 *  3       mdsc->mutex * * (lient *;      156u32 3     32t_heaame="L166"> 166         (&;     ;      161
ceph_mreturammds_request_calsg requests */ 161
/* protected by s_c3p_loc32 name}me="L161"> 161
s3inloc32e" name="L156"> 156l32d" cl"L8erse">cepa> * (lient *;      161
 *  3   66
 */<3  (lient *r_mdsc;
 160              3eass="com3code=list_head" class="s3ef">l32>           dirsef="fse href="fs/ceph/"s_dir" class="srersef="f,>;
 161
l33t_hea="L66">  66
ce3h_cap<"L8erse;

id="L140" class"L108"lin_in>
/a> (lient *r_mdscf 161
cepa> *r_mdsc;
 161
/* protected by mut3x */<33"sref"L8erse">cepa> * (lient *r_mdscf 161
l33 name="L85">  85
l3st_hea"L8erse">cepa> * (lient *r_mdsc;
 161
 107struct u64 3     3      "L8erse">cepa> *
<_ id="L1iting cap_releaode=r"lin_an>
<_ id="L1/a> (lient *r_mdsc;
 160              3 */<3ent.h#L139" id="L139" cl3ss="l33MDS,
 r_old_dentry_dir;     r_old_dentry_dame="L160"> 160              3ato3ic_t<33>           r_old_dentry;         161
l3st_hea="L66">  66
l341    "L8erse">cepa> * (lient *;         161
 153struct  *;   me="L153"> 153struct 
 (lient *r_mdsc;
;
r_oldmhre namname="L161"> 161
cepa> * (lient *r_mdsc;
 160              3mment"> *3
;         161
 (lient *r_mdsc;
 160              3mnt"> */<3E_ANY_MDS" class="sref">3SE_AN34MDS,
 r_old_dentry_dir;      160              3mass="com3E_RANDOM_MDS" class="sre3">USE34>           *;         161
cepa> * (lient *;         161
 166         (&;      161
ce35"sref}me="L161"> 161
/*3h_mds_client" class="sre3">cep354_hea"L8erse">cepa> *
<_mds_client.h#L166" id=ode=r_mdn_span>
<_mds_cli/a> (lient * 161
cepa> * (lient *;         161
 *3/span>
 166         (&;     
<_mds_client.h#L166" id=ode=r_mdn_span>
<_mds_cli/a> name="L161"> 161
 */<3
 161
 180        struct3         3                    stru3t 

 (lient *r_mdsc;
 160              3ph/mds_cl3ent.h#L162" id="L162" cl3ss="l36       *;      161
/*3/span>
cepa> *

 (lient *r_mdsc;
 160              3ph/mds_cl3an in-flight mds request3/span363      *;      161
/*3
  85
ce36t_hea"L8erse">cepa> * (lient *r_mdsc;
 161
u64 3a hre36e" name="L107"> 107struct rb_36     "L8erse f="+code=r_path2" cl"L108" cc_build_pathent.h#L166" id=ode=r_mdn_build_path/a> (lient *r_old_dentry;        r_old_dentry; ,>;
s_seq;          ame="L160"> 160              3pnt"> */<3code=ceph_mds_client" cl3ss="s36MDS,
 161
 180        struct3href="+co3e=r_op" class="sref">r_o3;370_hea"L8erse">cepa> *r_old_dentry;        r_old_dentry; name="L161"> 161
cepa> *
<_"="L8"sgiting cap_releaode=r"lin_an>
<_"="L8"sg/a> (lient *;      160              3lass="com3ent">/* operation on wha3? */<37ap_gen;   *r_old_dentry_dir;     r_old_dentry_dame="L160"> 160              3 r_old_dentry;        r_old_dentry; ,> f="+      160              3/*3code=dentry" class="sref3>dent3y *s_cap_gen;      161
 156cepa> *s_code=r"lin_handle_m c/a> (lient *r_mdsc;
 160              3a href="+3ode=r_path1" class="sref3>r_pa37ss="sref">cepaaaaaaaaaaaaaaaaaaaaaaaaaayout dirsef="fse href="fs/ceph/"s_dir" class="srersef="fname="L161"> 161
 */<3code=ceph_vino" class="s3ef">c37e" name="L119"> 119        cepa> *r_mdsc;
 160              3         hrefaaaaaaaaaaaaaaaaaaaaaaaaaaaaaayout ;      161
 172        s38     #end=fme="L172"> 172        
The original LXR software by ="L8e="L172">http://sourceforse.net/projd="s/lxr">LXR 59" unit/a>; ,>1" idexperi claal verlass=by e="L172">mailto:lxr@ idux.no">lxr@ idux.noa>; .
lxr. idux.no kindly hoeq *http://www.redpill- idpro.no">Redpill Lidpro ASa>; ,>provider/cepLiduxe id>ul="" cand ope81" id="servicss=since 1995.