multipart: During multipart list the listing go-routine should be saved to the List-pool. (#2130)

This commit is contained in:
Krishna Srinivas 2016-07-07 21:36:35 +05:30 committed by Harshavardhana
parent ddf3245677
commit f55093cdd6
2 changed files with 20 additions and 2 deletions

View File

@ -66,8 +66,10 @@ func (fs fsObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
} }
maxUploads = maxUploads - len(uploads) maxUploads = maxUploads - len(uploads)
} }
var walkResultCh chan treeWalkResult
var endWalkCh chan struct{}
if maxUploads > 0 { 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 { if walkResultCh == nil {
endWalkCh = make(chan struct{}) endWalkCh = make(chan struct{})
listDir := listDirFactory(fs.isMultipartUpload, fs.storage) listDir := listDirFactory(fs.isMultipartUpload, fs.storage)
@ -137,6 +139,13 @@ func (fs fsObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
result.NextKeyMarker = objectName result.NextKeyMarker = objectName
result.NextUploadIDMarker = uploadID 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 result.IsTruncated = !eof
if !result.IsTruncated { if !result.IsTruncated {
result.NextKeyMarker = "" result.NextKeyMarker = ""

View File

@ -79,9 +79,11 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
} }
maxUploads = maxUploads - len(uploads) maxUploads = maxUploads - len(uploads)
} }
var walkerCh chan treeWalkResult
var walkerDoneCh chan struct{}
// Validate if we need to list further depending on maxUploads. // Validate if we need to list further depending on maxUploads.
if maxUploads > 0 { 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 { if walkerCh == nil {
walkerDoneCh = make(chan struct{}) walkerDoneCh = make(chan struct{})
listDir := listDirFactory(xl.isMultipartUpload, xl.getLoadBalancedQuorumDisks()...) listDir := listDirFactory(xl.isMultipartUpload, xl.getLoadBalancedQuorumDisks()...)
@ -165,6 +167,13 @@ func (xl xlObjects) listMultipartUploads(bucket, prefix, keyMarker, uploadIDMark
result.NextKeyMarker = objectName result.NextKeyMarker = objectName
result.NextUploadIDMarker = uploadID 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.IsTruncated = !eof
// Result is not truncated, reset the markers. // Result is not truncated, reset the markers.
if !result.IsTruncated { if !result.IsTruncated {