Chapter 7. File and directory layouts As a storage administrator, you can control how file or directory data is mapped to objects. This section describes how to: Understand file and directory layouts Set file and directory layouts View file and directory layout fields View individual layout fields Remove the directory layouts Prerequisites A running, and healthy Red Hat Ceph Storage cluster. Deployment of a Ceph File System. The installation of the attr package. 7.1. Overview of file and directory layouts This section explains what file and directory layouts are in the context for the Ceph File System. A layout of a file or directory controls how its content is mapped to Ceph RADOS objects. The directory layouts serve primarily for setting an inherited layout for new files in that directory. To view and set a file or directory layout, use virtual extended attributes or extended file attributes ( xattrs ). The name of the layout attributes depends on whether a file is a regular file or a directory: Regular files layout attributes are called ceph.file.layout . Directories layout attributes are called ceph.dir.layout . Layouts Inheritance Files inherit the layout of their parent directory when you create them. However, subsequent changes to the parent directory layout do not affect children. If a directory does not have any layouts set, files inherit the layout from the closest directory to the layout in the directory structure. 7.2. Setting file and directory layout fields Use the setfattr command to set layout fields on a file or directory. Important When you modify the layout fields of a file, the file must be empty, otherwise an error occurs. Prerequisites Root-level access to the node. Procedure To modify layout fields on a file or directory: Syntax Replace: TYPE with file or dir . FIELD with the name of the field. VALUE with the new value of the field. PATH with the path to the file or directory. Example Additional Resources See the table in the Overview of file and directory layouts section of the Red Hat Ceph Storage File System Guide for more details. See the setfattr(1) manual page. 7.3. Viewing file and directory layout fields To use the getfattr command to view layout fields on a file or directory. Prerequisites A running Red Hat Ceph Storage cluster. Root-level access to all nodes in the storage cluster. Procedure To view layout fields on a file or directory as a single string: Syntax Replace PATH with the path to the file or directory. TYPE with file or dir . Example Note A directory does not have an explicit layout until you set it. Consequently, attempting to view the layout without first setting it fails because there are no changes to display. Additional Resources The getfattr(1) manual page. For more information, see Setting file and directory layout fields section in the Red Hat Ceph Storage File System Guide . 7.4. Viewing individual layout fields Use the getfattr command to view individual layout fields for a file or directory. Prerequisites A running Red Hat Ceph Storage cluster. Root-level access to all nodes in the storage cluster. Procedure To view individual layout fields on a file or directory: Syntax Replace TYPE with file or dir . FIELD with the name of the field. PATH with the path to the file or directory. Example Note Pools in the pool field are indicated by name. However, newly created pools can be indicated by ID. Additional Resources The getfattr(1) manual page. 7.5. Removing directory layouts Use the setfattr command to remove layouts from a directory. Note When you set a file layout, you cannot change or remove it. Prerequisites A directory with a layout. Procedure To remove a layout from a directory: Syntax Example To remove the pool_namespace field: Syntax Example Note The pool_namespace field is the only field you can remove separately. Additional Resources The setfattr(1) manual page Additional Resources See the Deployment of the Ceph File System section in the Red Hat Ceph Storage File System Guide . See the getfattr(1) manual page for more information. See the setfattr(1) manual page for more information.

Commands:
setfattr -n ceph. TYPE .layout. FIELD -v VALUE PATH
setfattr -n ceph.file.layout.stripe_unit -v 1048576 test
getfattr -n ceph. TYPE .layout PATH
getfattr -n ceph.dir.layout /home/test ceph.dir.layout="stripe_unit=4194304 stripe_count=2 object_size=4194304 pool=cephfs_data"
getfattr -n ceph. TYPE .layout. FIELD _PATH
getfattr -n ceph.file.layout.pool test ceph.file.layout.pool="cephfs_data"
setfattr -x ceph.dir.layout DIRECTORY_PATH
[user@client ~]USD setfattr -x ceph.dir.layout /home/cephfs
setfattr -x ceph.dir.layout.pool_namespace DIRECTORY_PATH
[user@client ~]USD setfattr -x ceph.dir.layout.pool_namespace /home/cephfs