This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/18515] New: posix_fallocate disastrous fallback behavior is no longer mandated by POSIX and should be fixed


https://sourceware.org/bugzilla/show_bug.cgi?id=18515

            Bug ID: 18515
           Summary: posix_fallocate disastrous fallback behavior is no
                    longer mandated by POSIX and should be fixed
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: lopresti at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

The fallback behavior of posix_fallocate() is a disaster. The entire point of
this function is to improve system performance by allowing applications to
preallocate large extents, helping the O/S to minimize on-disk fragmentation.

But the behavior of this call on file systems lacking unwritten extents
ultimately results in two writes to every "preallocated" block: Once to
"preallocate", and once to populate with actual data. This is the exact
opposite of a performance improvement.

Since there is no portable way to tell when glibc will fall back to the
performance-killing mode, there is no way to use this function without risking
making the performance worse precisely when you were trying to make it better.
Conventional wisdom is thus to avoid this call altogether and use a mishmash of
platform-specific #ifdef-selected variants instead (see e.g.
http://stackoverflow.com/q/14063046/).

Earlier versions of POSIX did not provide any way for this call to fail due to
lack of file system support, so glibc's unfortunate fallback behavior was
effectively mandated by the spec.

However, the current version of POSIX
(http://pubs.opengroup.org/stage7tc1/functions/posix_fallocate.html#tag_16_366_05)
has extended the meaning of EINVAL to include "...or the underlying file system
does not support this operation". So it is now possible for glibc to do the
sane thing and simply return EINVAL when the fallocate() system call returns
ENOTSUPPORTED.

Best of all, this improvement can be made in the best possible way: By deleting
a bunch of code.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]