Skip to content

Commit

Permalink
xmeta (tool) to correctly show lom (metadata)
Browse files Browse the repository at this point in the history
* in presence of copies (fix)

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Jan 4, 2025
1 parent 6740803 commit 257daaf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions cmd/xmeta/xmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func extractLOM() (err error) {
if err != nil {
return
}

lmi := lomInfo{Attrs: lom.ObjAttrs()}
if lom.HasCopies() {
lmi.Copies = make([]string, 0, lom.NumCopies())
Expand Down
6 changes: 3 additions & 3 deletions core/lom_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//nolint:dupl // copy-paste benign and can wait
// Package core_test provides tests for cluster package
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package core_test

Expand Down Expand Up @@ -301,7 +301,7 @@ var _ = Describe("LOM", func() {
lom := &core.LOM{}
err := lom.InitFQN(localFQN, nil)
Expect(err).NotTo(HaveOccurred())
lom.AcquireAtimefs()
lom.TestAtime()
Expect(lom.Persist()).NotTo(HaveOccurred())
err = lom.Load(false, false)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -316,7 +316,7 @@ var _ = Describe("LOM", func() {
lom := &core.LOM{}
err := lom.InitFQN(localFQN, nil)
Expect(err).NotTo(HaveOccurred())
lom.AcquireAtimefs()
lom.TestAtime()
Expect(lom.Persist()).NotTo(HaveOccurred())
err = lom.Load(false, false)
Expect(err).NotTo(HaveOccurred())
Expand Down
12 changes: 8 additions & 4 deletions core/lom_xattr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package core provides core metadata and in-cluster API
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package core

Expand Down Expand Up @@ -91,8 +91,8 @@ const prefLen = 10 // 10B prefix [ version = 1 | checksum-type | 64-bit xxhash ]

const getxattr = "getxattr" // syscall

// used in tests
func (lom *LOM) AcquireAtimefs() error {
// usage: unit tests only
func (lom *LOM) TestAtime() error {
_, atimefs, _, err := lom.Fstat(true /*get-atime*/)
if err != nil {
return err
Expand All @@ -102,7 +102,7 @@ func (lom *LOM) AcquireAtimefs() error {
return nil
}

// NOTE: used in tests, ignores `dirty`
// NOTE usage: tests and `xmeta` only; ignores `dirty`
func (lom *LOM) LoadMetaFromFS() error {
_, atimefs, _, err := lom.Fstat(true /*get-atime*/)
if err != nil {
Expand All @@ -113,6 +113,10 @@ func (lom *LOM) LoadMetaFromFS() error {
}
lom.md.Atime = atimefs
lom.md.atimefs = uint64(atimefs)

uname := lom.bck.MakeUname(lom.ObjName)
lom.md.uname = cos.UnsafeSptr(uname)

return nil
}

Expand Down

0 comments on commit 257daaf

Please sign in to comment.