AM·PER·SAN

Mapping CephFS directories to other pools

Mapping diffrent Cephfs directories to diffrent pools

So far my experience with cephfs has been really great. Comparing it to other systems I use like gluster, Cephfs is really coming out on top for me. And the flexibility of cephfs is one I wanted to hit on today.

Imagine if you will the topology of a standard cephfs data pool named cephfs_pool.

1
2
3
4
5
6
cephfs_pool
├── production
├── staging
├── development
├── backups
└── misc

Inside there are 5 directories created for all sorts of varying purposes. In the production directory, performance is of the utmost importance to us, as opposed to backups where we really just need a dumping ground for data.

Instead of everyone using the same pool (cephfs_pool), we can actually map these different directories to other pools where our specific needs can be met.

Lets pretend these are the pools we are working with.

1
2
3
$ ceph osd lspools
0 rbd, 1 cephfs_pool, 2 slow_nearline_pool,
3 high_performance_pool, 4 cephfs_metadata

Lets map /production to the high_performace_pool. We’ll do this by using the setattr command.

First mount the root cephfs directory

1
$ mount -t ceph 20.20.20.20:/ /mnt/cephfs/ -o name=admin,secret=keyhere

Then go into that new mount point and change each subdirectory to the pool you want its data to reside on.

1
2
3
$ cd /mnt/cephfs/
$ setfattr -n ceph.dir.layout.pool -v 3 production # Setting pool by ID
$ setfattr -n ceph.dir.layout.pool -v slow_nearline_pool backups # Setting pool by name

Now to verify it worked.

1
2
3
4
5
6
7
getfattr -n ceph.dir.layout.pool backups
# file: slow_nearline_pool
ceph.dir.layout.pool="slow_nearline_pool"
getfattr -n ceph.dir.layout.pool production
# file: high_performance_pool
ceph.dir.layout.pool="high_performance_pool"

And thats it! Your data will now reside on what ever pool you have changed this to.

Note - Files inherit the layout of their parent directory at creation time. However, subsequent changes to the parent directory’s layout do not affect children.