[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: |
Fam Zheng |
Subject: |
Re: [Qemu-devel] [PATCH 4/8] block/raw-posix: create translate_err helper to merge errno values |
Date: |
Mon, 5 Jan 2015 14:46:43 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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
> }
> #endif
>
> @@ -939,10 +948,9 @@ static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData
> *aiocb)
> #endif
> }
>
> - if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP ||
> - ret == -ENOTTY) {
> + ret = translate_err(ret);
> + if (ret == -ENOTSUP) {
> s->has_write_zeroes = false;
> - ret = -ENOTSUP;
> }
> return ret;
> }
> @@ -980,10 +988,9 @@ static ssize_t handle_aiocb_discard(RawPosixAIOData
> *aiocb)
> #endif
> }
>
> - if (ret == -ENODEV || ret == -ENOSYS || ret == -EOPNOTSUPP ||
> - ret == -ENOTTY) {
> + ret = translate_err(ret);
> + if (ret == -ENOTSUP) {
> s->has_discard = false;
> - ret = -ENOTSUP;
> }
> return ret;
> }
> --
> 1.9.1
>
>
- Re: [Qemu-devel] [PATCH 4/8] block/raw-posix: create translate_err helper to merge errno values,
Fam Zheng <=