Skip to content

Commit

Permalink
dcache: reject access to files with nearline QoS
Browse files Browse the repository at this point in the history
Motivation:
If file has QoS policy "HSM-only" then dCache should reject the access
to the file, even if file is still available on disk (as transition
might take some time).

Modification:
- Update QoS policy engine to reflect policy in the namespace attributes
- Update Transfer to request policy state (as an indicate of applied
  policy) and reject read transfers if access latency is nearline.

Result:
dCache behavior compliant with selected QoS policy.

Acked-by: Lea Morschel
Acked-by: Dmitry Litvintsev
Target: master
Require-book: no
Require-notes: yes
(cherry picked from commit 1a3c12e)
Signed-off-by: Tigran Mkrtchyan <[email protected]>
  • Loading branch information
kofemann authored and lemora committed Oct 9, 2024
1 parent 2423686 commit 1e916a9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,14 @@ public void handleModifiedRequirements(FileQoSRequirements newRequirements, Subj

FileAttributes modifiedAttributes = new FileAttributes();

if (currentAttributes.isDefined(FileAttribute.QOS_POLICY)
&& !newRequirements.hasRequiredQoSPolicy()) {
modifiedAttributes.setQosPolicy(null); // remove the policy from the stored state
modifyRequirements(pnfsId, currentAttributes, modifiedAttributes, newRequirements,
subject);
return;
}

if (newRequirements.hasRequiredQoSPolicy()) {
modifiedAttributes.setQosPolicy(newRequirements.getRequiredQoSPolicy());
modifiedAttributes.setQosState(newRequirements.getRequiredQoSStateIndex());
}

if (canModifyQos(subject, isEnableRoles(), currentAttributes)) {
pnfsHandler().setFileAttributes(pnfsId, modifiedAttributes);
} else {
throw new PermissionDeniedCacheException("User does not have permissions to set "
+ "attributes for " + newRequirements.getPnfsId());
modifiedAttributes.setQosPolicy(null); // remove the policy from the stored state
}

modifyRequirements(pnfsId, currentAttributes, modifiedAttributes, newRequirements, subject);
}

@Required
Expand Down
16 changes: 13 additions & 3 deletions modules/dcache/src/main/java/org/dcache/util/Transfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import diskCacheV111.poolManager.RequestContainerV5.RequestState;
import diskCacheV111.util.AccessLatency;
import diskCacheV111.util.CacheException;
import diskCacheV111.util.CheckStagePermission;
import diskCacheV111.util.FileExistsCacheException;
Expand Down Expand Up @@ -750,7 +751,7 @@ public ListenableFuture<Void> readNameSpaceEntryAsync(boolean allowWrite) {
}

private ListenableFuture<Void> readNameSpaceEntryAsync(boolean allowWrite, long timeout) {
Set<FileAttribute> attr = EnumSet.of(PNFSID, TYPE, STORAGEINFO, SIZE, CREATION_TIME);
Set<FileAttribute> attr = EnumSet.of(PNFSID, TYPE, STORAGEINFO, SIZE, CREATION_TIME, QOS_STATE);
attr.addAll(_additionalAttributes);
attr.addAll(PoolMgrSelectReadPoolMsg.getRequiredAttributes());
Set<AccessMask> mask;
Expand Down Expand Up @@ -925,13 +926,22 @@ protected synchronized void setReadPoolSelectionContext(
*/
public ListenableFuture<Void> selectPoolAsync(long timeout) {

FileAttributes fileAttributes = getFileAttributes();

// if this is a read, and the file has QoS policy nearline,
// then read is forbidden independent of is there cached copy or not.
if (!isWrite() && fileAttributes.isDefined(QOS_STATE) &&
fileAttributes.getAccessLatency().equals(AccessLatency.NEARLINE)) {
return immediateFailedFuture(
new PermissionDeniedCacheException(
"Read is forbidden for file with QoS policy nearline"));
}

if (getPool() != null) {
// we have a valid preselected pool. Let use it as long as clearPoolSelection is not called.
return immediateFuture(null);
}

FileAttributes fileAttributes = getFileAttributes();

ProtocolInfo protocolInfo = getProtocolInfoForPoolManager();
ListenableFuture<? extends PoolMgrSelectPoolMsg> reply;
if (isWrite()) {
Expand Down

0 comments on commit 1e916a9

Please sign in to comment.