public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Felix Blyakher <felixb@sgi.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] xfstests: fix async io error handling in fsx
Date: Wed, 1 Apr 2009 03:21:17 -0400	[thread overview]
Message-ID: <20090401072117.GA25131@infradead.org> (raw)
In-Reply-To: <1238442101-24311-1-git-send-email-felixb@sgi.com>

On Mon, Mar 30, 2009 at 02:41:41PM -0500, Felix Blyakher wrote:
> The result of async io returned in the event.res in addition
> to the number of bytes read/written provides negated error
> number. The broken libaio defines event.res as unsigned
> while the same structure in the kernel defines it as signed.
> The kernel indeed treat it as signed, and returns the
> negated error number. Till libaio is fixed we provide
> the signed long temp var.
> Also set errno for each error condition in aio_rw, as the
> caller is not aio aware and expects ret(-1)+errno by the
> traditional libc convention.
> 
> Signed-off-by: Felix Blyakher <felixb@sgi.com>
> ---
>  ltp/fsx.c |   42 +++++++++++++++++++++++++++++++++++-------
>  1 files changed, 35 insertions(+), 7 deletions(-)

>  	if (len != event.res) {
> -		fprintf(stderr, "bad read length: %lu instead of %u\n",
> -				event.res, len);
> +		/*
> +		 * The b0rked libaio defines event.res as unsigned.
> +		 * However the kernel strucuture has it signed,
> +		 * and it's used to pass negated error value.
> +		 * Till the library is fixed use the temp var.
> +		 */
> +		res = (long)event.res;
> +		if (res >= 0)
> +			fprintf(stderr, "bad io length: %lu instead of %u\n",
> +					res, len);
> +		else {
> +			fprintf(stderr, "errcode=%d\n", -res);
> +			fprintf(stderr, "aio_rw: async io failed: %s\n",
> +					strerror(-res));
> +			goto out_error;
> +		}
> +
>  	}
>  	return event.res;
> +
> +out_error:
> +	/*
> +	 * The caller expects error return in traditional libc
> +	 * convention, i.e. -1 and the errno set to error.
> +	 */
> +	errno = ret <= 0 ? -ret : -res;
> +	return -1;

I wonder why this doesn't give a compiler warning.  res is only
initialized in that last branch above.  Wouldn't it be better to set
ret to res inside that branch and only use ret down here?

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2009-04-01  7:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-30 19:41 [PATCH] xfstests: fix async io error handling in fsx Felix Blyakher
2009-04-01  7:21 ` Christoph Hellwig [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-04-06 15:26 Felix Blyakher
2009-04-06 16:33 ` Christoph Hellwig
2009-04-13 13:58   ` Christoph Hellwig
2009-03-30  5:30 Felix Blyakher
2009-03-30 17:54 ` Christoph Hellwig
2009-03-30 18:53   ` Felix Blyakher
2009-03-30 18:56     ` Christoph Hellwig
2009-03-30 18:59       ` Felix Blyakher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090401072117.GA25131@infradead.org \
    --to=hch@infradead.org \
    --cc=felixb@sgi.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox