Skip to content

Commit

Permalink
remove watch in getfacl
Browse files Browse the repository at this point in the history
Signed-off-by: jiefenghuang <[email protected]>
  • Loading branch information
jiefenghuang committed Jan 7, 2025
1 parent 9056870 commit b61702a
Showing 1 changed file with 25 additions and 29 deletions.
54 changes: 25 additions & 29 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -4549,29 +4549,27 @@ func (m *redisMeta) doSetFacl(ctx Context, ino Ino, aclType uint8, rule *aclAPI.
}

func (m *redisMeta) doGetFacl(ctx Context, ino Ino, aclType uint8, aclId uint32, rule *aclAPI.Rule) syscall.Errno {
return errno(m.rdb.Watch(ctx, func(tx *redis.Tx) error {
if aclId == aclAPI.None {
val, err := tx.Get(ctx, m.inodeKey(ino)).Bytes()
if err != nil {
return err
}
attr := &Attr{}
m.parseAttr(val, attr)
m.of.Update(ino, attr)

aclId = getAttrACLId(attr, aclType)
}

a, err := m.getACL(ctx, tx, aclId)
if aclId == aclAPI.None {
val, err := m.rdb.Get(ctx, m.inodeKey(ino)).Bytes()
if err != nil {
return err
}
if a == nil {
return ENOATTR
return errno(err)
}
*rule = *a
return nil
}, m.inodeKey(ino)))
attr := &Attr{}
m.parseAttr(val, attr)
m.of.Update(ino, attr)

aclId = getAttrACLId(attr, aclType)
}

a, err := m.getACL(ctx, nil, aclId)
if err != nil {
return errno(err)
}
if a == nil {
return ENOATTR
}
*rule = *a
return 0
}

func (m *redisMeta) getACL(ctx Context, tx *redis.Tx, id uint32) (*aclAPI.Rule, error) {
Expand All @@ -4582,15 +4580,13 @@ func (m *redisMeta) getACL(ctx Context, tx *redis.Tx, id uint32) (*aclAPI.Rule,
return cRule, nil
}

cmds, err := tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.HGet(ctx, m.aclKey(), strconv.FormatUint(uint64(id), 10))
return nil
})
if err != nil {
return nil, err
var val []byte
var err error
if tx != nil {
val, err = tx.HGet(ctx, m.aclKey(), strconv.FormatUint(uint64(id), 10)).Bytes()
} else {
val, err = m.rdb.HGet(ctx, m.aclKey(), strconv.FormatUint(uint64(id), 10)).Bytes()
}

val, err := cmds[0].(*redis.StringCmd).Bytes()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b61702a

Please sign in to comment.