eina_file: Ensure populate is safe to call 17/151517/2 accepted/tizen/unified/20170929.081243 submit/tizen/20170928.042726
authorjiin.moon <jiin.moon@samsung.com>
Wed, 20 Sep 2017 10:41:48 +0000 (19:41 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 28 Sep 2017 00:00:44 +0000 (00:00 +0000)
commit60a9f8f733de9d0f9c70986745a15be4e36c69b7
tree87a2549e04e40e3470afb9ca936889c28e52c5cc
parentbcaecddb9966d498d9ef36687c3605abad7b8000
eina_file: Ensure populate is safe to call
Fix map_populate on the global map

This patch includes two commits

1) [PATCH] eina file: Ensure populate is safe to call
   (commit 05c051405e89ef595f117f637dbbb0104262c218)
 This makes sure that the call to madvise is safe. On Linux it's not too
 much of an issue as checks are made inside madvise, and the worst that
 can happen is an error is returned (EINVAL). Not great.

 But if MAP_POPULATE is not present, as is the case on *BSD, then the
 internal function _eina_file_map_populate() is used for the populate
 rule. In that case actual data is read and we should make sure not to
 trigger a segfault or bus error.

 Also, this makes sure that in case of HugeTLB we actually populate all
 pages, rather than one page out of 8 (we were jumping by 16Mb instead of
 2Mb).

 Note: Can we get the size of a HugeTLB at runtime? We're assuming 2Mb
 which might very well not be the case!
 See: https://wiki.debian.org/Hugepages

 Tested by disabling MAP_POPULATE and observing crashes :)

 @fix

2) [PATCH] eina file: Fix map_populate on the global map
   (commit b2ea60691e45674a4e283e0535634bdd699544ea)
 If eina_file_map_all() is called, the map isn't added to the internal
 hash "rmap" and so _eina_file_map_rule_apply() would never be called.

 @fix

Change-Id: Ib074aff31e3498fb7fca7c5ca792d5bdf8e8bd17
src/lib/eina/eina_file.c
src/lib/eina/eina_file_common.h
src/tests/eina/eina_test_file.c