From 2b2694a7951957546c6c6c17b6f8f5c21c90456f Mon Sep 17 00:00:00 2001 From: Alex Aizman Date: Sun, 5 Jan 2025 15:55:25 -0500 Subject: [PATCH] core: BID and object flags (metadata) * amend core/lombid; remove meta/bid; clarify and refactor Signed-off-by: Alex Aizman --- core/lombid.go | 29 ++++++++++++++++++++++------- core/lombid_internal_test.go | 20 ++++++++++++-------- core/meta/bid.go | 26 -------------------------- transport/obj_test.go | 20 ++++++++++---------- 4 files changed, 44 insertions(+), 51 deletions(-) delete mode 100644 core/meta/bid.go diff --git a/core/lombid.go b/core/lombid.go index 4d98ebc8b6..00c6188f01 100644 --- a/core/lombid.go +++ b/core/lombid.go @@ -1,19 +1,25 @@ // Package core provides core metadata and in-cluster API /* - * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. All rights reserved. */ package core import ( + "math" + "github.com/NVIDIA/aistore/cmn/debug" - "github.com/NVIDIA/aistore/core/meta" ) const ( + AisBID = uint64(1 << 63) + bitshift = 52 - flagsBID = uint64(0xfff<> bitshift // 0xfff + flagsBID = (flagmask << bitshift) & ^AisBID // 0x7ff0000000000000 ) +type lomBID uint64 + // lomBID is a 64-bit field in the LOM - specifically, `lmeta` structure. // As the name implies, lomBID is a union of two values: // - bucket ID @@ -26,22 +32,31 @@ const ( // * next 11 bits: bit flags // * remaining (64 - 12) = bitshift bits contain the bucket's serial number. -type lomBID meta.BID +func NewBID(serial uint64, isAis bool) uint64 { + // not adding runtime check given the time reasonably + // required to create (1 << 52) buckets + debug.Assert(serial&(flagmask<> bitshift) } func (lid lomBID) setbid(bid uint64) lomBID { - debug.Assert(bid&flagsBID == 0) + debug.Assert(bid&flagsBID == 0, bid) return lomBID((uint64(lid) & flagsBID) | bid) } func (lid lomBID) setflags(fl uint16) lomBID { - debug.Assert(fl <= 0x7ff) + debug.Assert(fl <= uint16(flagsBID>>bitshift), fl) return lomBID(uint64(lid) | (uint64(fl) << bitshift)) } func (lid lomBID) clrflags(fl uint16) lomBID { - debug.Assert(fl <= 0x7ff) + debug.Assert(fl <= uint16(flagsBID>>bitshift)) return lomBID(uint64(lid) & ^(uint64(fl) << bitshift)) } diff --git a/core/lombid_internal_test.go b/core/lombid_internal_test.go index 509f29dafe..ab2a8c6257 100644 --- a/core/lombid_internal_test.go +++ b/core/lombid_internal_test.go @@ -7,7 +7,6 @@ package core import ( "testing" - "github.com/NVIDIA/aistore/core/meta" "github.com/NVIDIA/aistore/tools/tassert" ) @@ -16,18 +15,23 @@ func TestLomBid(t *testing.T) { bid1, bid2 uint64 flags uint16 }{ - {1, 1 | meta.AisBID, 1}, - {2 | meta.AisBID, 1<= cos.GiB*100 { prevsize = size - tlog.Logf("[dry]: %d GiB\n", size/cos.GiB) + fmt.Printf("[dry]: %d GiB\n", size/cos.GiB) } } } @@ -703,7 +703,7 @@ func streamWriteUntil(t *testing.T, ii int, wg *sync.WaitGroup, ts *httptest.Ser if netstats == nil { reason, termErr := stream.TermInfo() tassert.Errorf(t, reason != "", "expecting reason for termination") - tlog.Logf("send$ %s[%d]: offset=%d, num=%d(%d), term(%q, %v)\n", + fmt.Printf("send$ %s[%d]: offset=%d, num=%d(%d), term(%q, %v)\n", trname, sessID, stats.Offset.Load(), stats.Num.Load(), num, reason, termErr) } else { lock.Lock()