Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handled chown Scenario #1655

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Handled chown Scenario #1655

wants to merge 1 commit into from

Conversation

jainakanksha-msft
Copy link
Collaborator

@jainakanksha-msft jainakanksha-msft commented Mar 7, 2025

Type of Change

  • Bug fix
  • New feature
  • Code quality improvement
  • Other (describe):

Description

This pull request introduces changes to add chown handling handling for adls account, and includes corresponding tests.

How Has This Been Tested?

image
Tested locally and with unit testing.
Still have to cover file_cache handling

Checklist

  • The purpose of this PR is explained in this or a referenced issue.
  • Tests are included and/or updated for code changes.
  • Documentation update required.
  • Updates to module CHANGELOG.md are included.
  • License headers are included in each file.

@@ -666,6 +666,8 @@ func (bb *BlockBlob) getBlobAttr(blobInfo *container.BlobItem) (*internal.ObjAtt
Flags: internal.NewFileBitMap(),
MD5: blobInfo.Properties.ContentMD5,
ETag: sanitizeEtag(blobInfo.Properties.ETag),
GID: blobInfo.Metadata["gid"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shall not use random names, check what azcopy uses and we shall be using the same key name in metadata to cross tool compatibility.

@@ -81,6 +81,9 @@ type ObjAttr struct {
MD5 []byte // MD5 of the blob as per last GetAttr
ETag string // ETag of the blob as per last GetAttr
Metadata map[string]*string // extra information to preserve
// Even though GID and UID are part of Metadata Map, I am defining new attributes to solve case sensitivity issue.
GID *string // Group ID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for linux we can keep these values in integers so that we do not have to translate them later while giving it back to kernel

@@ -346,8 +346,17 @@ func libfuse_destroy(data unsafe.Pointer) {
}

func (lf *Libfuse) fillStat(attr *internal.ObjAttr, stbuf *C.stat_t) {
(*stbuf).st_uid = C.uint(lf.ownerUID)
(*stbuf).st_gid = C.uint(lf.ownerGID)
if attr.UID != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for this kind of check may be either *string or *int is better but we might be reading from storage less often and returning it back to kernel more often so storing as *int will be a better choice.

}

update := false
for key, value := range metadata {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are doing so much of processing. We can get the metadata and set uid/gid related keys irrespective of whether they are there or not and send the metadata back.

@@ -1629,3 +1631,67 @@ func (bb *BlockBlob) SetFilter(filter string) error {
bb.Config.filter = &blobfilter.BlobFilter{}
return bb.Config.filter.Configure(filter)
}

func (bb *BlockBlob) updateMetadata(name string, metadata map[string]*string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changeowner method anyways gets the uid and gid so there is no need to implement another method as this could have been done in that method itself,

// for operations like git clone where transaction fails if chown is not successful
// return success instead of ENOSYS
return nil
metadata := make(map[string]*string)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just pass the uid/gid as is to blockblob changeOwner method and it can take care of the rest. There is no need to implement this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants