ivandika3 commented on code in PR #6268:
URL: https://github.com/apache/ozone/pull/6268#discussion_r1510893463


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/PrefixManagerImpl.java:
##########
@@ -322,23 +331,53 @@ public OMPrefixAclOpResult setAcl(OzoneObj ozoneObj, 
List<OzoneAcl> ozoneAcls,
         prefixInfoBuilder.setUpdateID(transactionLogIndex);
       }
       prefixInfo = prefixInfoBuilder.build();
+      newPrefix = true;
     }
 
     boolean changed = prefixInfo.setAcls(ozoneAcls);
-    inheritParentAcl(ozoneObj, prefixInfo);
+    if (newPrefix) {
+      inheritParentAcl(ozoneObj, prefixInfo);
+    }
     prefixTree.insert(ozoneObj.getPath(), prefixInfo);
     if (!isRatisEnabled) {
       metadataManager.getPrefixTable().put(ozoneObj.getPath(), prefixInfo);
     }
     return new OMPrefixAclOpResult(prefixInfo, changed);
   }
 
+  /**
+   * Get the resolved prefix object to handle prefix that is under a link 
bucket.
+   * @param obj prefix object
+   * @return the resolved prefix object if the object belongs under a link 
bucket.
+   * Otherwise, return the same prefix object.
+   * @throws IOException Exception thrown when resolving the bucket link.
+   */
+  private OzoneObj getResolvedPrefixObj(OzoneObj obj) throws IOException {
+    if (StringUtils.isEmpty(obj.getVolumeName()) || 
StringUtils.isEmpty(obj.getBucketName())) {
+      return obj;
+    }
+
+    ResolvedBucket resolvedBucket = ozoneManager.resolveBucketLink(
+        Pair.of(obj.getVolumeName(), obj.getBucketName()));
+    String realVolume = resolvedBucket.realVolume();
+    String realBucket = resolvedBucket.realBucket();
+    // If the bucket is not a link bucket, just return the Ozone object
+    if (realVolume.equals(obj.getVolumeName()) && 
realBucket.equals(obj.getBucketName())) {
+      return obj;
+    }
+    // If the bucket is a link bucket, return a new OzoneObj with resolved 
volume and bucket name
+    return OzoneObjInfo.Builder.fromOzoneObj(obj)
+        .setVolumeName(realVolume).setBucketName(realBucket).build();
+  }

Review Comment:
   Thank you for the suggestion. Updated. PTAL.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to