Immutability and appendOnly features

To prevent files from being changed or deleted unexpectedly, GPFS™ provides immutability and appendOnly restrictions.

Applying immutability and appendOnly restrictions to individual files or to directories

You can apply immutability and appendOnly restrictions either to individual files within a fileset or to a directory.

An immutable file cannot be changed or renamed. An appendOnly file allows append operations, but not delete, modify, or rename operations.

An immutable directory cannot be deleted or renamed, and files cannot be added or deleted under such a directory. An appendOnly directory allows new files or subdirectories to be created with 0 byte length; all such new created files and subdirectories are marked as appendOnly automatically.

The immutable flag and the appendOnly flag can be set independently. If both immutability and appendOnly are set on a file, immutability restrictions will be in effect.

To set or unset these attributes, use the following command options:
mmchattr -i {yes | no}
Sets or unsets a file to or from an immutable state.
-i yes
Sets the immutable attribute of the file to yes.
-i no
Sets the immutable attribute of the file to no.
mmchattr -a {yes | no}
Sets or unsets a file to or from an appendOnly state.
-a yes
Sets the appendOnly attribute of the file to yes.
-a no
Sets the appendOnly attribute of the file to no.
Note: Before an immutable or appendOnly file can be deleted, you must change it to mutable or set appendOnly to no (by using the mmchattr command).

Storage pool assignment of an immutable or appendOnly file can be changed; an immutable or appendOnly file is allowed to transfer from one storage pool to another.

To display whether or not a file is immutable or appendOnly, issue this command:
mmlsattr -L myfile
The system displays information similar to the following:
file name:            myfile
metadata replication: 2 max 2
data replication:     1 max 2
immutable:            no
appendOnly:           no
flags:
storage pool name:    sp1
fileset name:         root
snapshot name:
creation Time:        Wed Feb 22 15:16:29 2012
Misc attributes:      ARCHIVE

The effects of file operations on immutable and appendOnly files

Once a file has been set as immutable or appendOnly, the following file operations and attributes work differently from the way they work on regular files:
delete
An immutable or appendOnly file cannot be deleted.
modify/append
An appendOnly file cannot be modified, but it can be appended. An immutable file cannot be modified or appended.
Note: The immutable and appendOnly flag check takes effect after the file is closed; therefore, the file can be modified if it is opened before the file is changed to immutable.
mode
An immutable or appendOnly file's mode cannot be changed.
ownership, acl
These attributes cannot be changed for an immutable or appendOnly file.
extended attributes
These attributes cannot be added, deleted, or modified for an immutable or appendOnly file.
timestamp
The timestamp of an immutable or appendOnly file can be changed.
directory
If a directory is marked as immutable, no files can be created, renamed, or deleted under that directory. However, a subdirectory under an immutable directory remains mutable unless it is explicitly changed by mmchattr.

If a directory is marked as appendOnly, no files can be renamed or deleted under that directory. However, 0 byte length files can be created.

The following table shows the effects of file operations on an immutable file or an appendOnly file:
Table 1. The effects of file operations on an immutable file or an appendOnly file
Operation immutable appendOnly
Add, delete, modify, or rename No No
Append No Yes
Change ownership, mode, or acl No No
Change atime, mtime, or ctime Yes Yes
Add, delete, or modify extended attributes Disallowed by external methods such as setfattr.

Allowed internally for dmapi, directio, and others.

Same as for immutable.
Create a file under an immutable or appendOnly directory No Yes, 0 byte length only
Rename or delete a file under an immutable or appendOnly directory No No
Modify a mutable file under an immutable directory Yes Not applicable
Set an immutable file back to mutable Yes Not applicable
Set an appendOnly file back to a non-appendOnly state Not applicable Yes

Fileset-level integrated archive manager (IAM) modes

You can modify the file-operation restrictions that apply to the immutable files in a fileset by setting an integrated archive manager (IAM) mode for the fileset. The following table shows the effects of each of the IAM modes.
Note: To set an IAM mode for a fileset, issue the mmchfileset command with the --iam-mode parameter. For more information, see mmchfileset command.
Table 2. IAM modes and their effects on file operations on immutable files
File operation Regular mode Advisory mode Noncompliant mode Compliant mode Compliant-plus mode
Modify No No No No No
Append No No No No No
Rename No No No No No
Change ownership, acl No No No No No
Change mode No No No No No
Change atime, mtime, ctime Yes mtime and ctime can be changed.

atime is overloaded by expiration time.

Expiration time can be changed by using the mmchattr --expiration-time command (alternatively mmchattr -E) or touch. You can see the expiration time by using stat as atime.

Same as advisory mode Same as advisory mode Same as advisory mode
Add, delete, or modify extended attributes. Not allowed for external methods such as setfattr. Allowed internally for dmapi, directio, and etc. Yes Yes Yes Yes
Create, rename, or delete under an immutable directory No No No No No
Modify mutable files under an immutable directory. Yes Yes Yes Yes Yes
Retention rule enforced No retention rule, cannot delete immutable files No Yes Yes Yes
Set ExpirationTime backwards Yes Yes Yes No No
Delete an immutable file No Yes, always Yes, only when expired Yes, only when expired Yes, only when expired
Set an immutable file back to mutable Yes No No No No
Allow hardlink No for immutable or appendOnly files.

Yes for other files.

No No No No
Rename or delete a non-empty directory Yes for rename.

No for delete only if the directory contains immutable files.

No for rename.

Yes for delete.

No for rename.

Yes for delete only if the immutable file has expired.

No for rename.

Yes for delete only if the immutable file has expired.

No for rename.

Yes for delete only if the immutable file has expired.

Rename an empty directory Yes Yes Yes Yes No
Remove user write permission to change a file to immutable No Yes Yes Yes Yes
Display expiration time instead of atime for stat call No Yes Yes Yes Yes
Set a directory to be immutable Yes No No No No