mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	bfs commit
This commit is contained in:
		@@ -316,7 +316,8 @@ func (this *BlocksFile) Close() error {
 | 
				
			|||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_ = this.sync(true)
 | 
						// TODO 决定是否同步
 | 
				
			||||||
 | 
						//_ = this.sync(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.isClosed = true
 | 
						this.isClosed = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -256,6 +256,11 @@ func (this *FS) openBFileForHashWriting(hash string) (*BlocksFile, error) {
 | 
				
			|||||||
	if ok {
 | 
						if ok {
 | 
				
			||||||
		// 调整当前BFile所在位置
 | 
							// 调整当前BFile所在位置
 | 
				
			||||||
		this.mu.Lock()
 | 
							this.mu.Lock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if bFile.IsClosing() {
 | 
				
			||||||
 | 
								// TODO 需要重新等待打开
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		item, itemOk := this.bItemMap[bName]
 | 
							item, itemOk := this.bItemMap[bName]
 | 
				
			||||||
		if itemOk {
 | 
							if itemOk {
 | 
				
			||||||
			this.bList.Remove(item)
 | 
								this.bList.Remove(item)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,9 +18,9 @@ type FSOptions struct {
 | 
				
			|||||||
func (this *FSOptions) EnsureDefaults() {
 | 
					func (this *FSOptions) EnsureDefaults() {
 | 
				
			||||||
	if this.MaxOpenFiles <= 0 {
 | 
						if this.MaxOpenFiles <= 0 {
 | 
				
			||||||
		// 根据内存计算最大打开文件数
 | 
							// 根据内存计算最大打开文件数
 | 
				
			||||||
		var maxOpenFiles = memutils.SystemMemoryGB() * 64
 | 
							var maxOpenFiles = memutils.SystemMemoryGB() * 128
 | 
				
			||||||
		if maxOpenFiles > (4 << 10) {
 | 
							if maxOpenFiles > (8 << 10) {
 | 
				
			||||||
			maxOpenFiles = 4 << 10
 | 
								maxOpenFiles = 8 << 10
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		this.MaxOpenFiles = maxOpenFiles
 | 
							this.MaxOpenFiles = maxOpenFiles
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@ package bfs
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import "github.com/TeaOSLab/EdgeNode/internal/zero"
 | 
					import "github.com/TeaOSLab/EdgeNode/internal/zero"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO 使用atomic代替channel?需要使用基准测试对比性能
 | 
					 | 
				
			||||||
// TODO 线程数可以根据硬盘数量动态调整?
 | 
					// TODO 线程数可以根据硬盘数量动态调整?
 | 
				
			||||||
var readThreadsLimiter = make(chan zero.Zero, 8)
 | 
					var readThreadsLimiter = make(chan zero.Zero, 8)
 | 
				
			||||||
var writeThreadsLimiter = make(chan zero.Zero, 8)
 | 
					var writeThreadsLimiter = make(chan zero.Zero, 8)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user