|
68 | 68 | skipEC bool // do not erasure-encode when finalizing |
69 | 69 | skipVC bool // skip loading existing Version and skip comparing Checksums (skip VC) |
70 | 70 | coldGET bool // (one implication: proceed to write) |
| 71 | + locked bool // true if the LOM is already locked by the caller |
71 | 72 | remoteErr bool // to exclude `putRemote` errors when counting soft IO errors |
72 | 73 | } |
73 | 74 |
|
@@ -180,6 +181,7 @@ func (poi *putOI) chunk(chunkSize int64) (ecode int, err error) { |
180 | 181 | lom = poi.lom |
181 | 182 | uploadID string |
182 | 183 | ) |
| 184 | + debug.Assertf(!poi.coldGET || poi.locked, "expecting locked LOM for cold-GET") |
183 | 185 |
|
184 | 186 | debug.Assertf(poi.size > 0, "poi.size is required in chunk, object name: %s", poi.lom.Cname()) |
185 | 187 | if uploadID, err = poi.t.ups.start(poi.oreq, lom, poi.coldGET); err != nil { |
@@ -239,12 +241,14 @@ func (poi *putOI) chunk(chunkSize int64) (ecode int, err error) { |
239 | 241 | parts: completedParts, |
240 | 242 | isS3: false, |
241 | 243 | coldGET: poi.coldGET, |
| 244 | + locked: poi.locked, |
242 | 245 | }) |
243 | 246 | return ecode, err |
244 | 247 | } |
245 | 248 |
|
246 | 249 | func (poi *putOI) putObject() (ecode int, err error) { |
247 | 250 | maxMonoSize := int64(poi.lom.Bprops().Chunks.MaxMonolithicSize) |
| 251 | + // protect the bucket: if the object size exceeds the max monolithic size, MUST chunk |
248 | 252 | // NOTE: if `poi.size` is not set, don't trigger chunking |
249 | 253 | if maxMonoSize > 0 && poi.size > maxMonoSize { |
250 | 254 | if cmn.Rom.V(5, cos.ModAIS) { |
@@ -453,8 +457,9 @@ func (poi *putOI) fini() (ecode int, err error) { |
453 | 457 | // locking strategies: optimistic and otherwise |
454 | 458 | // (see GetCold() implementation and cmn.OWT enum) |
455 | 459 | switch poi.owt { |
456 | | - case cmn.OwtGetTryLock, cmn.OwtGetLock, cmn.OwtGet: |
| 460 | + case cmn.OwtGetTryLock, cmn.OwtGetLock, cmn.OwtGet, cmn.OwtChunks: |
457 | 461 | // do nothing: lom is already wlocked |
| 462 | + debug.Assertf(lom.IsLocked() == apc.LockWrite, "lom %s is not write-locked", lom.Cname()) |
458 | 463 | case cmn.OwtGetPrefetchLock: |
459 | 464 | if !lom.TryLock(true) { |
460 | 465 | nlog.Warningln(poi.loghdr(), "is busy") |
@@ -879,6 +884,7 @@ func (goi *getOI) coldPut(res *core.GetReaderResult) (int, error) { |
879 | 884 | poi.owt = cmn.OwtGet |
880 | 885 | poi.cksumToUse = res.ExpCksum // expected checksum (to validate if the bucket's `validate_cold_get == true`) |
881 | 886 | poi.coldGET = true |
| 887 | + poi.locked = true |
882 | 888 | } |
883 | 889 | code, err := poi.putObject() |
884 | 890 | freePOI(poi) |
|
0 commit comments