linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Moyer <jmoyer@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: Avi Kivity <avi@scylladb.com>,
	xfs@oss.sgi.com, linux-aio@kvack.org,
	Steven Whitehouse <swhiteho@redhat.com>,
	linux-fsdevel@vger.kernel.org
Subject: Re: AIO read returns negative number for bytes read
Date: Thu, 19 Nov 2015 10:33:03 -0500	[thread overview]
Message-ID: <x49k2perols.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20151119153004.GB25804@quack.suse.cz> (Jan Kara's message of "Thu, 19 Nov 2015 16:30:04 +0100")

Jan Kara <jack@suse.cz> writes:

> Can you please post the reproduce here as well? I couldn't easily find it
> with google.

Here it is, Jan.

-Jeff

#define _GNU_SOURCE

#include <libaio.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int ac, char** av) {
  int fd;
  char* buf;
  io_context_t ioc = NULL;
  int r;
  struct iocb iocb;
  struct iocb *iocbp[1];
  struct io_event ioev;

  buf = aligned_alloc(4096, 4096*4);
  assert(buf);
  r = io_setup(1, &ioc);
  assert(r == 0);
  fd = open("tmp.tmp", O_RDWR | O_CREAT | O_DIRECT, 0600);
  assert(fd >= 0);
  io_prep_pwrite(&iocb, fd, buf, 4096*4, 0);
  iocbp[0] = &iocb;
  r = io_submit(ioc, 1, iocbp);
  assert(r == 1);
  r = io_getevents(ioc, 1, 1, &ioev, NULL);
  assert(r == 1);
  assert(ioev.res == 4*4096);
  ftruncate(fd, 13002);
  io_prep_pread(&iocb, fd, buf, 8192, 13312);
  r = io_submit(ioc, 1, iocbp);
  assert(r == 1);
  r = io_getevents(ioc, 1, 1, &ioev, NULL);
  assert(r == 1);
  printf("read result: %d\n", (int)ioev.res);
  return 0;
}

      parent reply	other threads:[~2015-11-19 15:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <564883BD.8070607@scylladb.com>
2015-11-16 19:27 ` AIO read returns negative number for bytes read Jeff Moyer
2015-11-17 12:52   ` Avi Kivity
2015-11-19 15:30     ` Jan Kara
2015-11-19 15:32       ` Avi Kivity
2015-11-19 15:33       ` Jeff Moyer [this message]

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=x49k2perols.fsf@segfault.boston.devel.redhat.com \
    --to=jmoyer@redhat.com \
    --cc=avi@scylladb.com \
    --cc=jack@suse.cz \
    --cc=linux-aio@kvack.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=swhiteho@redhat.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;
as well as URLs for NNTP newsgroup(s).