From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y85fo-000547-7Z for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:18:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y85fj-0006Ec-8h for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:18:12 -0500 Received: from mx2.parallels.com ([199.115.105.18]:43215) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y85fj-0006EY-3B for qemu-devel@nongnu.org; Mon, 05 Jan 2015 06:18:07 -0500 Message-ID: <54AA72E3.40200@openvz.org> Date: Mon, 5 Jan 2015 14:17:55 +0300 From: "Denis V. Lunev" MIME-Version: 1.0 References: <1419931250-19259-1-git-send-email-den@openvz.org> <1419931250-19259-5-git-send-email-den@openvz.org> <20150105064643.GA1800@ad.nay.redhat.com> In-Reply-To: <20150105064643.GA1800@ad.nay.redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/8] block/raw-posix: create translate_err helper to merge errno values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , Peter Lieven , qemu-devel@nongnu.org, Stefan Hajnoczi 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 >> CC: Kevin Wolf >> CC: Stefan Hajnoczi >> CC: Peter Lieven >> --- >> 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