Skip to content

Commit

Permalink
namespace: add nlink as an attribute
Browse files Browse the repository at this point in the history
Motivation:

It is occationally useful to know when deleting a file will trigger
garbage collection of the underlying data storage.  For files, this
happens when the file has an nlink count of 1.

Modification:

Add nlink as a file attribute.

Result:

The nlink count of a file is available when querying a file.

Target: master
Requires-notes: no
Requires-book: no
Patch: https://rb.dcache.org/r/9693/
Acked-by: Gerd Behrmann
  • Loading branch information
paulmillar committed Aug 31, 2016
1 parent f4e5691 commit 249cb99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Expand Up @@ -873,6 +873,10 @@ private FileAttributes getFileAttributes(ExtendedInode inode, Set<FileAttribute>
attributes.setHsm(storageInfo.getHsm());
}
break;
case NLINK:
stat = inode.statCache();
attributes.setNlink(stat.getNlink());
break;
default:
throw new UnsupportedOperationException("Attribute " + attribute + " not supported yet.");
}
Expand Down
Expand Up @@ -28,5 +28,10 @@ public enum FileAttribute {
STORAGEINFO,
TYPE,
SIMPLE_TYPE,
PNFSID
PNFSID,

/**
* @since 2.17
*/
NLINK // Be careful not to send this to pools before next golden release
}
Expand Up @@ -111,6 +111,11 @@ public class FileAttributes implements Serializable {
*/
private int _mode;

/**
* @since 2.17
*/
private int _nlink;

/**
* file's access latency ( e.g. ONLINE/NEARLINE )
*/
Expand Down Expand Up @@ -473,6 +478,18 @@ public String getHsm()
return _hsm;
}

public void setNlink(int nlink)
{
define(NLINK);
_nlink = nlink;
}

public int getNlink()
{
guard(NLINK);
return _nlink;
}

@Override
public String toString()
{
Expand Down

0 comments on commit 249cb99

Please sign in to comment.