The Comprehensive Ceph Guide
فارسیGet started

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
20rank 08rank 114rank 2
Directories of the example tree on each rank; the number next to each path has that rank's colour. Orange means the path changed rank after the last edit.
  • 0/ root
  • 0/home distributed 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/projects explicit pin
  • 1/projects/alpha inherited pin
  • 1/projects/beta inherited pin
  • 1/projects/gamma inherited pin
  • 0/scratch with parent
  • 0/scratch/job001 with parent
  • 0/scratch/job002 with parent
  • 0/scratch/job003 with parent
  • 0/scratch/job004 with parent
  • 0/scratch/job005 with parent
  • 0/scratch/job006 with parent
  • 0/scratch/job007 with parent
  • 0/scratch/job008 with parent
  • 0/scratch/job009 with parent
  • 0/scratch/job010 with parent
  • 0/scratch/job011 with parent
  • 0/scratch/job012 with 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/scratch
frag 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 :: rjhash64 rjhash64 and a jump consistent hash for the rank
  • src/mds/CInode.cc :: CInode::get_export_pin, get_ephemeral_rand, maybe_ephemeral_rand the closest pin policy and the random probability
  • src/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 pins
  • src/include/ceph_frag.h :: ceph_frag_make, ceph_frag_contains_value; src/mds/CInode.cc :: hash_dentry_name dentry name to its parent dirfrag
  • src/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
A fixed snapshot of the simulator; the interactive version is in the web edition's lab. Interactive lab: CephFS subtrees and MDS pinning