From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCQMO-0001EO-7V for qemu-devel@nongnu.org; Thu, 22 Aug 2013 04:35:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VCQMI-0004el-3G for qemu-devel@nongnu.org; Thu, 22 Aug 2013 04:35:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VCQMH-0004eB-RW for qemu-devel@nongnu.org; Thu, 22 Aug 2013 04:35:09 -0400 From: Stefan Hajnoczi Date: Thu, 22 Aug 2013 10:34:57 +0200 Message-Id: <1377160499-11323-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [RFC 0/2] osdep: warn if opening a file O_DIRECT on tmpfs fails List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , Stefan Hajnoczi , Deepak C Shetty This is an implementation of Dan and Eric's idea for probing a failed O_DIRECT open(2) call to see if the file system does not support O_DIRECT. I wanted to see what the implementation looks like but I don't like it: 1. We still need to guess if O_DIRECT is supported in the O_CREAT EINVAL case because we can't probe if O_CREAT | O_DIRECT | O_EXCL returned EINVAL. 2. There is a race condition between open(O_CREAT | O_EXCL | O_DIRECT) and opening again without O_CREAT. If the file is deleted we'll get ENOENT which would have been impossible before. 3. It's way complicated. Issue #1 gives me an idea: why play games when we can simply warn the user? if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) { error_report("file system may not support O_DIRECT"); errno = EINVAL; /* in case it was clobbered */ } I think this simple, portable approach beats statfs tmpfs and open probing. Will send a patch for that and plan to merge it. Stefan Hajnoczi (2): libcacard: link against qemu-error.o for error_report() osdep: warn if opening a file O_DIRECT on tmpfs fails libcacard/Makefile | 3 ++- util/osdep.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 8 deletions(-) -- 1.8.3.1