From f55093cdd66336ccc8145d32859b42be7f98e6e2 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Thu, 7 Jul 2016 21:36:35 +0530 Subject: [PATCH] multipart: During multipart list the listing go-routine should be saved to the List-pool. (#2130) --- fs-v1-multipart.go | 11 ++++++++++- xl-v1-multipart.go | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/fs-v1-multipart.go b/fs-v1-multipart.go index c676f7252..4341b2ec9 100644 --- a/fs-v1-multipart.go +++ b/fs-v1-multipart.go @@ -66,8 +66,10 @@ func (fs fsObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark } maxUploads = maxUploads - len(uploads) } + var walkResultCh chan treeWalkResult + var endWalkCh chan struct{} if maxUploads > 0 { - walkResultCh, endWalkCh := fs.listPool.Release(listParams{minioMetaBucket, recursive, multipartMarkerPath, multipartPrefixPath}) + walkResultCh, endWalkCh = fs.listPool.Release(listParams{minioMetaBucket, recursive, multipartMarkerPath, multipartPrefixPath}) if walkResultCh == nil { endWalkCh = make(chan struct{}) listDir := listDirFactory(fs.isMultipartUpload, fs.storage) @@ -137,6 +139,13 @@ func (fs fsObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark result.NextKeyMarker = objectName result.NextUploadIDMarker = uploadID } + + if !eof { + // Save the go-routine state in the pool so that it can continue from where it left off on + // the next request. + fs.listPool.Set(listParams{bucket, recursive, result.NextKeyMarker, prefix}, walkResultCh, endWalkCh) + } + result.IsTruncated = !eof if !result.IsTruncated { result.NextKeyMarker = "" diff --git a/xl-v1-multipart.go b/xl-v1-multipart.go index 7037a3797..512287d1d 100644 --- a/xl-v1-multipart.go +++ b/xl-v1-multipart.go @@ -79,9 +79,11 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark } maxUploads = maxUploads - len(uploads) } + var walkerCh chan treeWalkResult + var walkerDoneCh chan struct{} // Validate if we need to list further depending on maxUploads. if maxUploads > 0 { - walkerCh, walkerDoneCh := xl.listPool.Release(listParams{minioMetaBucket, recursive, multipartMarkerPath, multipartPrefixPath}) + walkerCh, walkerDoneCh = xl.listPool.Release(listParams{minioMetaBucket, recursive, multipartMarkerPath, multipartPrefixPath}) if walkerCh == nil { walkerDoneCh = make(chan struct{}) listDir := listDirFactory(xl.isMultipartUpload, xl.getLoadBalancedQuorumDisks()...) @@ -165,6 +167,13 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark result.NextKeyMarker = objectName result.NextUploadIDMarker = uploadID } + + if !eof { + // Save the go-routine state in the pool so that it can continue from where it left off on + // the next request. + xl.listPool.Set(listParams{bucket, recursive, result.NextKeyMarker, prefix}, walkerCh, walkerDoneCh) + } + result.IsTruncated = !eof // Result is not truncated, reset the markers. if !result.IsTruncated {