summaryrefslogtreecommitdiff
path: root/sdcard
diff options
context:
space:
mode:
authorKen Sumrall <ksumrall@android.com>2013-02-08 16:50:55 -0800
committerKen Sumrall <ksumrall@android.com>2013-02-11 15:42:22 -0800
commit2fd72cc22171cc23e67206db795fc5025d4f7ac6 (patch)
tree3e8489c383d9fa1666920f1c3dcae148cd2e9a4b /sdcard
parent3d7790edf468a8b9669f30cca6863c4c0d31aa17 (diff)
Raise the max file open limit in sdcard
The default is 1024 files, and in some testing, the limit has been hit. This raises the limit to 8192. Going higher starts to cause performance issues (I started to notice that around 16K open files in my testing) as sdcard does linear searches. If a higher max is needed, then the sdcard daemon will need some optimizations. Bug: 7442187 Change-Id: I7aba7f4556ed70651f36244294a6756f3d6b8963
Diffstat (limited to 'sdcard')
-rw-r--r--sdcard/sdcard.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index 8d87ee92d..bff6e67d5 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -28,6 +28,8 @@
#include <limits.h>
#include <ctype.h>
#include <pthread.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <private/android_filesystem_config.h>
@@ -1305,6 +1307,7 @@ int main(int argc, char **argv)
gid_t gid = 0;
int num_threads = DEFAULT_NUM_THREADS;
int i;
+ struct rlimit rlim;
for (i = 1; i < argc; i++) {
char* arg = argv[i];
@@ -1353,6 +1356,12 @@ int main(int argc, char **argv)
return usage();
}
+ rlim.rlim_cur = 8192;
+ rlim.rlim_max = 8192;
+ if (setrlimit(RLIMIT_NOFILE, &rlim)) {
+ ERROR("Error setting RLIMIT_NOFILE, errno = %d\n", errno);
+ }
+
res = run(source_path, dest_path, uid, gid, num_threads);
return res < 0 ? 1 : 0;
}