Skip to content

Commit

Permalink
meta/redis: fix unlock on not-existed lock (#2325)
Browse files Browse the repository at this point in the history
  • Loading branch information
davies authored Jul 1, 2022
1 parent 6dbc25b commit 3ade892
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/meta/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ func testLocks(t *testing.T, m Meta) {
}

// POSIX locks
if st := m.Setlk(ctx, inode, o1, false, syscall.F_UNLCK, 0, 0xFFFF, 1); st != 0 {
t.Fatalf("plock unlock: %s", st)
}
if st := m.Setlk(ctx, inode, o1, false, syscall.F_RDLCK, 0, 0xFFFF, 1); st != 0 {
t.Fatalf("plock rlock: %s", st)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ func (m *redisMeta) cleanupZeroRef(key string) {
var ctx = Background
_ = m.txn(ctx, func(tx *redis.Tx) error {
v, err := tx.HGet(ctx, m.sliceRefs(), key).Int()
if err != nil {
if err != nil && err != redis.Nil {
return err
}
if v != 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/meta/redis_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (r *redisMeta) Setlk(ctx Context, inode Ino, owner uint64, block bool, ltyp
err = r.txn(ctx, func(tx *redis.Tx) error {
if ltype == F_UNLCK {
d, err := tx.HGet(ctx, ikey, lkey).Result()
if err != nil {
if err != nil && err != redis.Nil {
return err
}
ls := loadLocks([]byte(d))
Expand Down

0 comments on commit 3ade892

Please sign in to comment.