Skip to content

Commit

Permalink
meta/sql: fix nanosecond of link and readlink (#5496)
Browse files Browse the repository at this point in the history
  • Loading branch information
davies authored Jan 9, 2025
1 parent 3006738 commit 761aa83
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 140 deletions.
3 changes: 2 additions & 1 deletion pkg/meta/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,8 @@ func (m *baseMeta) ReadLink(ctx Context, inode Ino, path *[]byte) syscall.Errno
} else {
buf := target.([]byte)
// ctime and mtime are ignored since symlink can't be modified
attr := &Attr{Atime: int64(binary.BigEndian.Uint64(buf[:8]))}
atime := int64(binary.BigEndian.Uint64(buf[:8]))
attr := &Attr{Atime: atime / int64(time.Second), Atimensec: uint32(atime % int64(time.Second))}
if !m.atimeNeedsUpdate(attr, time.Now()) {
*path = buf[8:]
return 0
Expand Down
3 changes: 2 additions & 1 deletion pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -1263,17 +1263,18 @@ func (m *redisMeta) doReadlink(ctx Context, inode Ino, noatime bool) (atime int6
}
target = []byte(rs[1].(string))
if !m.atimeNeedsUpdate(attr, now) {
atime = attr.Atime*int64(time.Second) + int64(attr.Atimensec)
return nil
}
attr.Atime = now.Unix()
attr.Atimensec = uint32(now.Nanosecond())
atime = now.UnixNano()
_, e = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.Set(ctx, m.inodeKey(inode), m.marshal(attr), 0)
return nil
})
return e
}, m.inodeKey(inode))
atime = attr.Atime
return
}

Expand Down
Loading

0 comments on commit 761aa83

Please sign in to comment.