From b85f319dc3751317773c906884305526b18e7244 Mon Sep 17 00:00:00 2001 From: Junjie Qian Date: Fri, 17 Mar 2017 09:19:19 -0700 Subject: [PATCH] Increase the maximum file handler from 1K to 1M (#16) The default file handler limitation on Linux for each process is 1K, which could be too few. Increase this number to 1M for hdfs-mount process only. This option requires sudo privilege, or no change happens with an error msg. --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index f3a7a32..570fd18 100644 --- a/main.go +++ b/main.go @@ -81,6 +81,15 @@ func main() { } log.Print("Mounted successfully") + // Increase the maximum number of file descriptor from 1K to 1M in Linux + rLimit := syscall.Rlimit { + Cur: 1024*1024, + Max: 1024*1024} + err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) + if err != nil { + Error.Printf("Failed to update the maximum number of file descriptors from 1K to 1M, %v", err) + } + defer func() { fileSystem.Unmount() log.Print("Closing...")