[xserver-xorg][PATCH 1/1] xwayland: ftruncate if posix_fallocate fails

Pekka Paalanen ppaalanen at gmail.com
Mon Apr 25 13:49:07 UTC 2016


On Mon, 25 Apr 2016 15:47:09 +0300
Ian Ray <ian.ray at ge.com> wrote:

> On a slow system that is configured with SMART_SCHEDULE_POSSIBLE, large
> posix_fallocate() requests may be interrupted by the SmartScheduleTimer
> (SIGALRM) continuously. Fallback to ftruncate if posix_fallocate fails.
> 
> Signed-off-by: Ian Ray <ian.ray at ge.com>
> ---
>  hw/xwayland/xwayland-shm.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/xwayland/xwayland-shm.c b/hw/xwayland/xwayland-shm.c
> index e8545b3..342b723 100644
> --- a/hw/xwayland/xwayland-shm.c
> +++ b/hw/xwayland/xwayland-shm.c
> @@ -142,9 +142,12 @@ os_create_anonymous_file(off_t size)
>  #ifdef HAVE_POSIX_FALLOCATE
>      ret = posix_fallocate(fd, 0, size);
>      if (ret != 0) {
> -        close(fd);
> -        errno = ret;
> -        return -1;
> +        /* Fallback to ftruncate in case of failure. */
> +        ret = ftruncate(fd, size);
> +        if (ret < 0) {
> +            close(fd);
> +            return -1;
> +        }
>      }
>  #else
>      ret = ftruncate(fd, size);

Hi Ian,

I indeed think this is a bit harsh. The first EINTR may happen on any
system, so the very least we should try twice before giving up.

I'd also like to see some comments on whether fallocate making no
progress when repeatedly restarted is normal or not. Maybe that should
be asked on a kernel list?


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <https://lists.x.org/archives/xorg-devel/attachments/20160425/96f10ba0/attachment.sig>


More information about the xorg-devel mailing list