@@ -18,13 +18,10 @@ type (
1818 Name string `json:"name,omitempty"` // inventory name (optional; must be unique for a given bucket)
1919 LsoMsg
2020
21- // PagesPerChunk overrides the default number of pages to pack into a single inventory chunk.
22- // If zero, the default is used.
23- PagesPerChunk int64 `json:"pages_per_chunk,omitempty"`
24-
25- // MaxEntriesPerChunk puts a hard cap on the number of entries in a single inventory chunk.
26- // If zero, the cap is disabled.
27- MaxEntriesPerChunk int64 `json:"max_entries_per_chunk,omitempty"`
21+ // Number of object names to store in each inventory chunk.
22+ // Requested properties are stored alongside each name.
23+ // Advanced usage only - non-zero overrides system default.
24+ NamesPerChunk int64 `json:"names_per_chunk,omitempty"`
2825
2926 // Remove all existing inventories, if any, and proceed to create the new one
3027 // (only one inventory per bucket is supported).
@@ -48,11 +45,11 @@ type (
4845//
4946
5047func (m * LsoMsg ) ValidateNBI () error {
51- const etag = "invalid list via native bucket inventory"
48+ const epref = "invalid list via native bucket inventory"
5249
5350 // inventory snapshot is flat; StartAfter currently unsupported
5451 if m .StartAfter != "" {
55- return errors .New (etag + ": start_after is not supported" )
52+ return errors .New (epref + ": start_after is not supported" )
5653 }
5754
5855 // flags that do not make sense for inventory listing
@@ -64,7 +61,7 @@ func (m *LsoMsg) ValidateNBI() error {
6461 sb .Grow (96 )
6562 sb .WriteString ("flags:" )
6663 m .appendFlags (& sb )
67- return fmt .Errorf ("%s: %s" , etag , sb .String ())
64+ return fmt .Errorf ("%s: %s" , epref , sb .String ())
6865 }
6966
7067 return nil
@@ -75,21 +72,21 @@ func (m *LsoMsg) ValidateNBI() error {
7572//////////////////
7673
7774const (
78- DefaultInvPagesPerChunk = 50
79- MaxInvPagesPerChunk = 256
80- MaxInvEntriesPerChunk = MaxInvPagesPerChunk * MaxPageSizeGlobal
75+ DfltInvNamesPerChunk = 2 * MaxPageSizeAIS // 20K
76+ MaxInvNamesPerChunk = 64 * MaxPageSizeAIS // 640K
77+ MinInvNamesPerChunk = 2
8178)
8279
8380// validate; set defaults
8481func (m * CreateNBIMsg ) SetValidate () error {
85- const etag = "invalid '" + ActCreateNBI + "'"
82+ const epref = "invalid '" + ActCreateNBI + "'"
8683
8784 // 1) disallow
8885 if m .ContinuationToken != "" {
89- return errors .New (etag + ": continuation_token must be empty" )
86+ return errors .New (epref + ": continuation_token must be empty" )
9087 }
9188 if m .StartAfter != "" {
92- return errors .New (etag + ": start_after is not supported" )
89+ return errors .New (epref + ": start_after is not supported" )
9390 }
9491 // flags that don't make sense for inventory generation
9592 const badFlags = LsCached | LsNotCached | LsMissing | LsDeleted | LsArchDir |
@@ -100,23 +97,19 @@ func (m *CreateNBIMsg) SetValidate() error {
10097 sb .Grow (96 )
10198 sb .WriteString ("flags:" )
10299 m .appendFlags (& sb )
103- return fmt .Errorf ("%s: %s" , etag , sb .String ())
100+ return fmt .Errorf ("%s: %s" , epref , sb .String ())
104101 }
105102
106103 // 2) advanced tunables
107104 switch {
108- case m .PagesPerChunk == 0 :
109- m .PagesPerChunk = DefaultInvPagesPerChunk
110- case m .PagesPerChunk < 0 :
111- return fmt .Errorf ("%s: pages_per_chunk=%d" , etag , m .PagesPerChunk )
112- case m .PagesPerChunk > MaxInvPagesPerChunk :
113- return fmt .Errorf ("%s: pages_per_chunk too large: %d" , etag , m .PagesPerChunk )
114- }
115- if m .MaxEntriesPerChunk < 0 {
116- return fmt .Errorf ("%s: negative max_entries_per_chunk=%d" , etag , m .MaxEntriesPerChunk )
117- }
118- if m .MaxEntriesPerChunk > MaxInvEntriesPerChunk {
119- return fmt .Errorf ("%s: too large max_entries_per_chunk=%d" , etag , m .MaxEntriesPerChunk )
105+ case m .NamesPerChunk == 0 :
106+ m .NamesPerChunk = DfltInvNamesPerChunk
107+ case m .NamesPerChunk < 0 :
108+ return fmt .Errorf ("%s: negative names_per_chunk=%d" , epref , m .NamesPerChunk )
109+ case m .NamesPerChunk < MinInvNamesPerChunk :
110+ return fmt .Errorf ("%s: names_per_chunk=%d too small (min=%d)" , epref , m .NamesPerChunk , MinInvNamesPerChunk )
111+ case m .NamesPerChunk > MaxInvNamesPerChunk :
112+ return fmt .Errorf ("%s: names_per_chunk=%d too large (max=%d)" , epref , m .NamesPerChunk , MaxInvNamesPerChunk )
120113 }
121114
122115 // 3) NOTE: otherwise, backend _may_ append extra (virt-dir) entries (in re: pre-allocation+reuse)
@@ -158,9 +151,9 @@ func (m NBIInfoMap) Names() []string {
158151 return names
159152}
160153
161- func (m NBIInfoMap ) SingleName () ( name string ) {
162- for name = range m {
163- break
154+ func (m NBIInfoMap ) SingleName () string {
155+ for _ , info : = range m {
156+ return info . Name
164157 }
165- return
158+ return ""
166159}
0 commit comments