25.1 Understanding Hard Links

Novell Storage Services supports zero to 65,535 hard links per file on NSS volumes. Hard link support for an NSS volume allows users to create multiple names for a single, existing file object in the same directory or in multiple directories in the same NSS volume.

IMPORTANT:Hard links to directories, data streams, and extended attributes are not allowed.

The alternate names for the file object link to the primary file inode in the NSS file system. One file can have different filenames in the same directory or multiple directories as long as all of the directories reside on the same volume. It is not possible to create hard links from different volumes and have them point to the same file.

This section describes the following:

25.1.1 Hard Links and the Primary Link

Every file has what is considered to be the primary link, which is originally the path and filename assigned at file creation time. The primary parent directory is originally the path and directory name where the file is created. When you create hard links for the file, the file’s primary link and all of its hard links share the file content by pointing to the file’s inode. All links share all of the file’s metadata except for name information; each link accesses only its own filename information.

When multiple hard links exist for a file, you can delete the file’s primary link or its hard links, but the file’s content and metadata are not deleted until the last remaining link is deleted. If you delete a hard link, the link name is deleted, not the file. If hard links exist, whenever you delete a primary link, the most recently created hard link automatically becomes the new primary link.

When the primary link is deleted and the status of primary is given to the next hard link, the following occurs:

  • The file owner does not change.

  • The explicitly assigned file system trustee assignments, trustee rights, and file attributes for the file do not change.

  • If the new primary link is in a different directory, the file’s inherited rights filter applies to the new parent directory, so effective rights for the file’s trustees can change. For information, see Section 25.1.4, Hard Links and File System Trustees.

    IMPORTANT:Make sure to check the consequences to effective rights before deleting the primary link.

  • For the directory space quota, the total disk space used by the file is reassigned from the old primary link’s parent directory to the new primary link’s parent directory. For information, see Section 25.1.5, Hard Links and Directory Space Quotas.

  • For the user space quota, the total disk space used by the file continues to be associated with the file’s assigned owner.

25.1.2 Hard Links and Linux Users

When hard links are used on NSS volumes, users must be Linux-enabled eDirectory users.

25.1.3 Hard Links and File Ownership

In the NSS file system, the user who creates a file is assigned as its owner at file creation time. File ownership is not affected by transferring the primary link, creating hard links, or deleting hard links. A file can have only one owner, even if has multiple hard links.

File ownership rarely, if ever, changes, but an administrator or administrator equivalent user can assign a new owner when necessary. Changing file ownership requires the Supervisor right for the primary parent directory and the file. Use whatever tools you normally use to modify the file’s ownership.

NSS uses the OES trustee model to secure access to the file, not file ownership. For information about how access control is affected by hard links, see Section 25.1.4, Hard Links and File System Trustees.

File ownership allows accounting of disk block usage per user and enables user space quotas to operate effectively. For information, see Section 25.1.6, Hard Links and User Space Quotas.

File ownership has no affect on the directory space quotas. For information, see Section 25.1.5, Hard Links and Directory Space Quotas.

25.1.4 Hard Links and File System Trustees

Explicit file system trustee assignments, trustee rights, and attributes for a file are stored in the file’s metadata where the information is shared equally by the primary link and all hard links. For users who match the trustee, the file is visible along any path of the file’s primary link and hard links. Explicit access security is enforced equally for any of these paths.

Inherited trustee assignments and trustee rights are inherited only through the primary link’s parent directory. When calculating effective rights to a file, rights are granted based on explicit rights and rights inherited from the primary link’s parent directory path.

If the primary link is deleted and reassigned, the inheritance changes to the settings of the newly assigned primary link’s parent directory.

IMPORTANT:Make sure you verify the effective rights on the new primary link whenever you delete a primary link.

25.1.5 Hard Links and Directory Space Quotas

If you set a directory space quota for a file’s primary parent directory, the file’s size is charged against the quota. All metadata increases associated with hard links are included in the file’s total disk space usage. For hard links in the primary parent directory, the file has an alternate name, but the charge for space usage is not duplicated. For hard links in other directories, quotas for their parent directories are not charged for space usage.

Whenever you delete a primary link, the most recently created hard link automatically becomes the new primary link. At that time, the file’s size is subtracted from the space usage reported on an old primary link’s parent directory and added to the space usage reported on the newly assigned primary link’s parent directory. The file’s space usage is no longer charged against the directory space quota on the old directory. If a quota is set on the new primary link’s parent directory, the file’s space usage is charged against it.

When you delete a primary link, the transfer of responsibility for space usage to the new primary parent directory is allowed even if the added file size overbooks its directory space quota. NSS allows the quota to be overbooked, and then enforces the directory quota restrictions.

IMPORTANT:Make sure you verify the directory quota on the new primary link’s parent directory whenever you delete a primary link.

25.1.6 Hard Links and User Space Quotas

User space restrictions are charged based on ownership of the file. Ownership is tracked with the user’s GUID, not the username. If the username ever becomes invalid, the file continues to be charged to the GUID. In a space usage report, the value of the GUID appears in place of where the a valid username would normally be.

If other users create hard links to the file, they are not charged a quota on that file. The file size is charged to the file owner’s user space quota, even if the owner no longer has the necessary rights to access the file. If hard links exist, deleting the primary link does not delete the file, and the owner continues to be responsible for the space used.

The file’s users can delete the primary link and hard links to the file only in directories where they have the necessary access rights. Hard links from directories the owner cannot access causes the file to be retained, and the owner continues to be charged for its quota. The file continues to be charged against the owner’s user space quota until the file itself is deleted or until the system administrator reassigns another user as the file owner.

When file ownership is changed, the new owner’s user space quota is checked before the change of ownership is allowed. If the file size will overbook the user space quota, the change is not allowed.

IMPORTANT:Make sure you verify the user space quota on the new owner whenever you change ownership of a file.

25.1.7 Hard Links and the Hard Links Attribute

Hard links support is available on OES 2 and later.

A media upgrade is required. For instructions, see Section 5.0, Upgrading the NSS Media Format.

The hard links attribute for the NSS volume must be enabled to allow hard links to be created. For information, see Section 25.3, Enabling or Disabling the Hard Links Attribute.

25.1.8 Hard Links and File Salvage and Purge

The interaction between hard links and the salvage system depends on how many links exist for a specified file. If a file has multiple links pointing to it, and one of the links is deleted, the hard link name is not added to the salvage system, and cannot be recovered later via a salvage operation. When the last and only remaining link to a file is deleted, that last name is a candidate for the salvage system. If the Salvage Files attribute is enabled on the volume, and an immediate purge is not in force, then the last link to be deleted is added into the salvage system. Under this final primary link and filename, the file can be salvaged or purged until the file is autopurged from the system.

25.1.9 Hard Links and DFS Move Volume

If you use the Novell Distributed File Services Volume Move operation to move a volume that has been upgraded to the new media format for hard links, consider the following guidelines:

  • Before you create the DFS Move Volume job, make sure that NSS is set so that the new target volume is automatically created with the upgraded media format for enhanced hard links.

  • If you moved the volume without enabling the new media format, you must upgrade the volume to the new media format after the move completes successfully.

  • In the initial release of OES 2, the Move Volume Wizard does not have an option to enable the Hard Links attribute for the new target volume. After the move is completed and the media format is upgraded for enhanced hard links support, you must manually enable the Hard Links attribute. For instructions, see Section 25.3, Enabling or Disabling the Hard Links Attribute.