CephFS subtrees and MDS pinning
In the book: Chapter 6
Lab
CephFS subtrees and MDS pinning
Split /home, /projects and /scratch over MDS ranks: change explicit pins and their inheritance, distributed ephemeral pins and random pins, and see which subtrees max_mds moves.
3active ranks
8dirfrags in /home
20 / 8most / fewest directories
–paths moved by the last edit
- 0
/root - 0
/homedistributed parent
user01101*user02000*user03010*user04011*user05100*user06101*user07010*user08111*user09100*user10011*user11111*user12111*user13101*user14110*user15000*user16111*user17101*user18011*user19000*user20011*user21101*user22001*user23000*user24000*
- 1
/projectsexplicit pin - 1
/projects/alphainherited pin - 1
/projects/betainherited pin - 1
/projects/gammainherited pin
- 0
/scratchwith parent - 0
/scratch/job001with parent - 0
/scratch/job002with parent - 0
/scratch/job003with parent - 0
/scratch/job004with parent - 0
/scratch/job005with parent - 0
/scratch/job006with parent - 0
/scratch/job007with parent - 0
/scratch/job008with parent - 0
/scratch/job009with parent - 0
/scratch/job010with parent - 0
/scratch/job011with parent - 0
/scratch/job012with parent
ceph fs set cephfs max_mds 3
setfattr -n ceph.dir.pin.distributed -v 1 /mnt/cephfs/home
setfattr -n ceph.dir.pin -v 1 /mnt/cephfs/projects
setfattr -n ceph.dir.pin.random -v 0.5 /mnt/cephfs/scratchfrag bits = ⌈log2(factor × max_mds)⌉ = 3 · child → frag by ceph_str_hash_rjenkins(name) · rank = hash_into_rank_bucket(ino(/home), frag) = jump_hash(rjhash64(rjhash64(ino) + rjhash64(frag)), max_mds)
mds_export_ephemeral_random_max defaults to only 0.01; even ceph.dir.pin.random=0.5 selects no more than 1% of directories unless you change that cap. A closer explicit pin overrides an inherited pin. More max_mds needs enough standbys for the new ranks, and splitting dirfrags can cause more movement than the jump hash alone (chapter 6).
Follows:
src/mds/MDCache.cc :: MDCache::hash_into_rank_bucket; src/include/hash.h :: rjhash64rjhash64 and a jump consistent hash for the ranksrc/mds/CInode.cc :: CInode::get_export_pin, get_ephemeral_rand, maybe_ephemeral_randthe closest pin policy and the random probabilitysrc/mds/MDBalancer.cc :: handle_export_pins; src/mds/MDCache.cc :: handle_mdsmap (export_ephemeral_dist_frag_bits)exporting and the dirfrag split floor for distributed pinssrc/include/ceph_frag.h :: ceph_frag_make, ceph_frag_contains_value; src/mds/CInode.cc :: hash_dentry_namedentry name to its parent dirfragsrc/common/options/mds.yaml.in :: mds_export_ephemeral_distributed (true), mds_export_ephemeral_distributed_factor (2), mds_export_ephemeral_random (true), mds_export_ephemeral_random_max (0.01)the ephemeral pin defaults