qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 4/8] block/raw-posix: create translate_err helpe


From: Denis V. Lunev
Subject: Re: [Qemu-devel] [PATCH 4/8] block/raw-posix: create translate_err helper to merge errno values
Date: Mon, 5 Jan 2015 14:17:55 +0300
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 05/01/15 09:46, Fam Zheng wrote:
On Tue, 12/30 12:20, Denis V. Lunev wrote:
actually the code
     if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP ||
         ret == -ENOTTY) {
         ret = -ENOTSUP;
     }
is present twice and will be added a couple more times. Create helper
for this. Place it into do_fallocate() for further convinience.
s/convinience/convenience/

Signed-off-by: Denis V. Lunev <address@hidden>
CC: Kevin Wolf <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
CC: Peter Lieven <address@hidden>
---
  block/raw-posix.c | 21 ++++++++++++++-------
  1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index a7c8816..25a6947 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -894,6 +894,15 @@ static int xfs_discard(BDRVRawState *s, int64_t offset, 
uint64_t bytes)
  #endif
+static int translate_err(int err)
+{
+    if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP ||
+        err == -ENOTTY) {
+        err = -ENOTSUP;
+    }
+    return err;
+}
+
  #if defined(CONFIG_FALLOCATE_PUNCH_HOLE) || 
defined(CONFIG_FALLOCATE_ZERO_RANGE)
  static int do_fallocate(int fd, int mode, off_t offset, off_t len)
  {
@@ -902,7 +911,7 @@ static int do_fallocate(int fd, int mode, off_t offset, 
off_t len)
              return 0;
          }
      } while (errno == EINTR);
-    return -errno;
+    return translate_err(-errno);
This could be a separate patch. Maybe reorder the previous patches as:

1) Introduce translate_err.
2) Refactor out do_fallocate.
3) Introduce FALLOC_FL_ZERO_RANGE calling code.

Fam
ok, will try



reply via email to

[Prev in Thread] Current Thread [Next in Thread]