Re: [PATCH] Update to libaio?

2008-01-09 Thread Rusty Russell
On Wednesday 09 January 2008 08:51:28 Jeff Moyer wrote:
> I did, thank you.  The remaining failures were in the ENOSPC test.
> For some reason, the filler filled 1024 bytes too much of the file
> system.  Did this test succeed for you?

Sorry, just got around to checking.

I assume you're talking about 10.t?  It works for me:

mount -o loop -t ext2 ext2-enospc.img testdir.enospc
./runtests.sh cases/10.p; ret=$?; umount testdir.enospc; exit $ret
Test run starting at Wed Jan 9 22:50:59 EST 2008
Starting cases/10.p
expect 65536: (w), res = 65536 [Success]
expect 65536: (r), res = 65536 [Success]
expect   -28: (w), res =   -28 [No space left on device]
expect 0: (r), res = 0 [Success]
expect 65535: (w), res = 65535 [Success]
expect 65535: (r), res = 65535 [Success]
expect 0: (r), res = 0 [Success]
expect   -28: (w), res =   -28 [No space left on device]
expect 0: (r), res = 0 [Success]
expect 0: (w), res = 0 [Success]
test cases/10.t completed PASSED.
Completed cases/10.p with 0.
Pass: 1  Fail: 0
Test run complete at Wed Jan 9 22:50:59 EST 2008

I've attached my ext2-enospc.img (bzips down to a tiny amount).  It was 
shipped with the Ubuntu source package I downloaded.

Cheers,
Rusty.


ext2-enospc.img.bz2
Description: BZip2 compressed data
-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Sarah Sharp
I think the Debian package maintainer should also be involved in this.

I would love to see preadv and pwritev go into libaio, as they will be useful
for userspace USB driver developers to interface with usbfs2
(http://wiki.cs.pdx.edu/usb/usbfs2.html).  I do have a few more issues with the
libaio-dev package.

Currently, the Debian libaio-dev package includes man pages like aio_read and
aio_write, which are for POSIX aio.  The io_submit pages refer to the kernel
API, not the libaio wrappers, so the variable types are incorrect.

Also, the libaio example in the io manpage doesn't compile against current
libaio.  Jamey Sharp wrote a very small example program that could replace the
example.  It can be found at:
http://minilop.net/svn/jamey/trunk/test/aio/
(Although it doesn't have a license header currently, Jamey told me it's BSD
licensed.)

I'll submit a patch for these corrections as soon as Jamey gives his permission
to use his example and adds a license header.

Sarah Sharp

On Tue, Jan 08, 2008 at 05:02:14PM +1100, Rusty Russell wrote:
> I recently tried to use libaio (0.3.106), and discovered it didn't have
> eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
> compile.  Or work.
> 
> Anyway, it's shipped by the distros, so I figure it's worth patching.
> I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
> find a home somewhere for it.
> 
> (Thanks for Jeff's feedback on the first version of this patch).
> 
> Cheers,
> Rusty.
> 
> diff -r 3a023dc4e63a ChangeLog
> --- a/ChangeLog   Tue Jan 08 14:38:53 2008 +1100
> +++ b/ChangeLog   Tue Jan 08 17:00:53 2008 +1100
> @@ -1,3 +1,14 @@ 0.4.0
> +rusty-v1
> + - Make tests compile again on modern systems (warnings + -Werror)
> + - Add 'make partcheck' and don't require manual setup for testing.
> + - Change test harness to compile against this dir, not global install
> + - Fix 5.t for archs where PROT_WRITE mappings are readable.
> + - Allow sending of SIGXFSZ on aio over limits
> + - Explicitly specify bash for runtests.sh
> + - Put deprecating comments on never-merged io_prep_poll
> + - Add io_prep_preadv and io_prep_pwritev
> + - Add eventfd support (io_set_eventfd).
> +
>  0.4.0
>   - remove libredhat-kernel
>   - add rough outline for man pages
> diff -r 3a023dc4e63a Makefile
> --- a/MakefileTue Jan 08 14:38:53 2008 +1100
> +++ b/MakefileTue Jan 08 17:00:53 2008 +1100
> @@ -17,6 +17,11 @@ install:
>  install:
>   @$(MAKE) -C src install prefix=$(prefix) includedir=$(includedir) 
> libdir=$(libdir)
>  
> +check:
> + @$(MAKE) -C harness check
> +
> +partcheck: all
> + @$(MAKE) -C harness partcheck
>  
>  clean:
>   @$(MAKE) -C src clean
> diff -r 3a023dc4e63a harness/Makefile
> --- a/harness/MakefileTue Jan 08 14:38:53 2008 +1100
> +++ b/harness/MakefileTue Jan 08 17:00:53 2008 +1100
> @@ -1,37 +1,56 @@
>  # foo.
>  TEST_SRCS:=$(shell find cases/ -name \*.t | sort -n -t/ -k2)
> -PROGS:=$(patsubst %.t,%.p,$(TEST_SRCS))
> +EXTRAPROGS:=cases/8.p cases/10.p
> +PARTPROGS:=$(filter-out $(EXTRAPROGS), $(patsubst %.t,%.p,$(TEST_SRCS)))
> +PROGS:=$(PARTPROGS) $(EXTRAPROGS)
>  HARNESS_SRCS:=main.c
>  # io_queue.c
>  
> -CFLAGS=-Wall -Werror -g -O -laio
> +CFLAGS=-Wall -Werror -I../src -g -O
>  #-lpthread -lrt
>  
>  all: $(PROGS)
>  
>  $(PROGS): %.p: %.t $(HARNESS_SRCS)
> - $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c
> + $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c ../src/libaio.a
>  
>  clean:
>   rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
>  
>  .PHONY:
>  
> -testdir/rofile: .PHONY
> +testdir/rofile: testdir .PHONY
>   rm -f $@
>   echo "test" >$@
>   chmod 400 $@
>  
> -testdir/wofile: .PHONY
> +testdir/wofile: testdir .PHONY
>   rm -f $@
>   echo "test" >$@
>   chmod 200 $@
>  
> -testdir/rwfile: .PHONY
> +testdir/rwfile: testdir .PHONY
>   rm -f $@
>   echo "test" >$@
>   chmod 600 $@
>  
> -check: $(PROGS) testdir/rofile testdir/rwfile testdir/wofile
> - ./runtests.sh $(PROGS)
> +testdir testdir.enospc testdir.ext2:
> + mkdir $@
>  
> +root: .PHONY
> + @if [ `id -u` -ne 0 ]; then echo Need root for check, try partcheck 
> >&2; exit 1; fi
> +
> +partcheck: $(PARTPROGS) testdir/rofile testdir/rwfile testdir/wofile
> + ./runtests.sh $(PARTPROGS)
> +
> +ext2.img:
> + dd if=/dev/zero bs=1M count=10 of=$@
> + mke2fs -F -b 4096 $@
> +
> +extracheck: $(EXTRAPROGS) root testdir.ext2 testdir.enospc ext2.img
> + mount -o loop -t ext2 ext2-enospc.img testdir.enospc
> + ./runtests.sh cases/10.p; ret=$$?; umount testdir.enospc; exit $$ret
> + mount -o loop -t ext2 ext2.img testdir.ext2
> + ./runtests.sh cases/8.p; ret=$$?; umount testdir.ext2; exit $$ret
> +
> +check: partcheck extracheck 
> diff -r 3a023dc4e63a harness/cases/12.t
> --- a/harness/cases/12.t  Tue Jan 08 14:38:53 2008 +1100
> +++ b/harness/cases/12.t  Tue

Re: [PATCH] Update to libaio?

2008-01-08 Thread Zach Brown
Sarah Sharp wrote:
> I think the Debian package maintainer should also be involved in this.
> 
> I would love to see preadv and pwritev go into libaio, as they will be useful
> for userspace USB driver developers to interface with usbfs2
> (http://wiki.cs.pdx.edu/usb/usbfs2.html).  I do have a few more issues with 
> the
> libaio-dev package.

*I* would love for people to stop using libaio. It's not a library, in
that it doesn't isolate applications from the system ABI.  It's no more
than a bunch of inline functions.  It was a mistake, in my opinion, but
here we are.

I happen to hate it because it's silly assertion on the ring cookie is
literally the *only* use of the mmaped ring that I know if.  If it
weren't for that, we might stand a chance of getting rid of the ring.

- z

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Benjamin LaHaise
On Tue, Jan 08, 2008 at 02:19:55PM -0800, Zach Brown wrote:
> 
> > What's the driving need to rip out functionality?
> 
> Well, in this case of the ring it's an irritation to have to massage the
> tracking of events into the ring format when you, say, back the aio
> implementation with syslets.  If it were just queueing up results for
> io_getevents(), which can lock in the kernel, we'd have more freedom.
> 
> It's a nit, don't get me wrong.

Then why not massage the ring into what you need from a ring buffer?  Come up 
with some real design criteria that are to be satisfied so some real 
direction can be had in discussions.

> > Why not actually submit 
> > some more in kernel implementations of aio and then evaluate if the api 
> > really needs to be ripped out or not (and use syslets or whatever to 
> > implement 
> > them)?
> 
> Don't ask me, ask the subsystem maintainers who have not chosen to do
> this over the last N years.

Want a patch that spews "->read() is not async" for every device in the 
kernel?  That would get attention.  As it stands today, nobody cares for 
functionality that they aren't directly involved with and which does not 
block development.  Patches have been bounced around doing aio via threads 
but almost always got dropped for some reason or other, I just don't have 
the time to carry them around indefinately.

-ben
-- 
"Time is of no importance, Mr. President, only life is important."
Don't Email: <[EMAIL PROTECTED]>.

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Benjamin LaHaise
On Tue, Jan 08, 2008 at 11:23:22AM -0800, Zach Brown wrote:
> I happen to hate it because it's silly assertion on the ring cookie is
> literally the *only* use of the mmaped ring that I know if.  If it
> weren't for that, we might stand a chance of getting rid of the ring.

What's the driving need to rip out functionality?  Why not actually submit 
some more in kernel implementations of aio and then evaluate if the api 
really needs to be ripped out or not (and use syslets or whatever to implement 
them)?  The api has room for changing how the rings are implemented -- that's 
what compat and incompat bits are for.

-ben
-- 
"Time is of no importance, Mr. President, only life is important."
Don't Email: <[EMAIL PROTECTED]>.

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Jeff Moyer
Rusty Russell <[EMAIL PROTECTED]> writes:

> On Wednesday 09 January 2008 06:07:51 Jeff Moyer wrote:
>> I've been keeping a copy on rhlinux.redhat.com.  You can access it
>> via:
>>
>>   cvs -d :pserver:[EMAIL PROTECTED]:/usr/local/CVS login  # no
>> password cvs -d :pserver:[EMAIL PROTECTED]:/usr/local/CVS co
>> libaio
>
> Excellent!  I'll feed you patches from now on then, should I find anything 
> else.
>
>> When I'm happy with the regression tests (they
>> don't all pass for me on 2.6.24-rc7), I'll roll a new version and
>> build it for Fedora.
>
> Did you see my two kernel patches to fix them?  Attached for your 
> convenience...

I did, thank you.  The remaining failures were in the ENOSPC test.
For some reason, the filler filled 1024 bytes too much of the file
system.  Did this test succeed for you?

Cheers,

Jeff

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


[PATCH] Update to libaio?

2008-01-08 Thread Rusty Russell
I recently tried to use libaio (0.3.106), and discovered it didn't have
eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
compile.  Or work.

Anyway, it's shipped by the distros, so I figure it's worth patching.
I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
find a home somewhere for it.

(Thanks for Jeff's feedback on the first version of this patch).

Cheers,
Rusty.

diff -r 3a023dc4e63a ChangeLog
--- a/ChangeLog Tue Jan 08 14:38:53 2008 +1100
+++ b/ChangeLog Tue Jan 08 17:00:53 2008 +1100
@@ -1,3 +1,14 @@ 0.4.0
+rusty-v1
+   - Make tests compile again on modern systems (warnings + -Werror)
+   - Add 'make partcheck' and don't require manual setup for testing.
+   - Change test harness to compile against this dir, not global install
+   - Fix 5.t for archs where PROT_WRITE mappings are readable.
+   - Allow sending of SIGXFSZ on aio over limits
+   - Explicitly specify bash for runtests.sh
+   - Put deprecating comments on never-merged io_prep_poll
+   - Add io_prep_preadv and io_prep_pwritev
+   - Add eventfd support (io_set_eventfd).
+
 0.4.0
- remove libredhat-kernel
- add rough outline for man pages
diff -r 3a023dc4e63a Makefile
--- a/Makefile  Tue Jan 08 14:38:53 2008 +1100
+++ b/Makefile  Tue Jan 08 17:00:53 2008 +1100
@@ -17,6 +17,11 @@ install:
 install:
@$(MAKE) -C src install prefix=$(prefix) includedir=$(includedir) 
libdir=$(libdir)
 
+check:
+   @$(MAKE) -C harness check
+
+partcheck: all
+   @$(MAKE) -C harness partcheck
 
 clean:
@$(MAKE) -C src clean
diff -r 3a023dc4e63a harness/Makefile
--- a/harness/Makefile  Tue Jan 08 14:38:53 2008 +1100
+++ b/harness/Makefile  Tue Jan 08 17:00:53 2008 +1100
@@ -1,37 +1,56 @@
 # foo.
 TEST_SRCS:=$(shell find cases/ -name \*.t | sort -n -t/ -k2)
-PROGS:=$(patsubst %.t,%.p,$(TEST_SRCS))
+EXTRAPROGS:=cases/8.p cases/10.p
+PARTPROGS:=$(filter-out $(EXTRAPROGS), $(patsubst %.t,%.p,$(TEST_SRCS)))
+PROGS:=$(PARTPROGS) $(EXTRAPROGS)
 HARNESS_SRCS:=main.c
 # io_queue.c
 
-CFLAGS=-Wall -Werror -g -O -laio
+CFLAGS=-Wall -Werror -I../src -g -O
 #-lpthread -lrt
 
 all: $(PROGS)
 
 $(PROGS): %.p: %.t $(HARNESS_SRCS)
-   $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c
+   $(CC) $(CFLAGS) -DTEST_NAME=\"$<\" -o $@ main.c ../src/libaio.a
 
 clean:
rm -f $(PROGS) *.o runtests.out rofile wofile rwfile
 
 .PHONY:
 
-testdir/rofile: .PHONY
+testdir/rofile: testdir .PHONY
rm -f $@
echo "test" >$@
chmod 400 $@
 
-testdir/wofile: .PHONY
+testdir/wofile: testdir .PHONY
rm -f $@
echo "test" >$@
chmod 200 $@
 
-testdir/rwfile: .PHONY
+testdir/rwfile: testdir .PHONY
rm -f $@
echo "test" >$@
chmod 600 $@
 
-check: $(PROGS) testdir/rofile testdir/rwfile testdir/wofile
-   ./runtests.sh $(PROGS)
+testdir testdir.enospc testdir.ext2:
+   mkdir $@
 
+root: .PHONY
+   @if [ `id -u` -ne 0 ]; then echo Need root for check, try partcheck 
>&2; exit 1; fi
+
+partcheck: $(PARTPROGS) testdir/rofile testdir/rwfile testdir/wofile
+   ./runtests.sh $(PARTPROGS)
+
+ext2.img:
+   dd if=/dev/zero bs=1M count=10 of=$@
+   mke2fs -F -b 4096 $@
+
+extracheck: $(EXTRAPROGS) root testdir.ext2 testdir.enospc ext2.img
+   mount -o loop -t ext2 ext2-enospc.img testdir.enospc
+   ./runtests.sh cases/10.p; ret=$$?; umount testdir.enospc; exit $$ret
+   mount -o loop -t ext2 ext2.img testdir.ext2
+   ./runtests.sh cases/8.p; ret=$$?; umount testdir.ext2; exit $$ret
+
+check: partcheck extracheck 
diff -r 3a023dc4e63a harness/cases/12.t
--- a/harness/cases/12.tTue Jan 08 14:38:53 2008 +1100
+++ b/harness/cases/12.tTue Jan 08 17:00:53 2008 +1100
@@ -20,11 +20,15 @@ int test_main(void)
 {
int res, status;
pid_t pid;
+   sigset_t set;
 
if (attempt_io_submit(io_ctx, 0, NULL, 0))
return 1;
 
-   sigblock(sigmask(SIGCHLD) | siggetmask());
+   sigemptyset(&set);
+   sigaddset(&set, SIGCHLD);
+   sigprocmask(SIG_BLOCK, &set, NULL);
+
fflush(NULL);
pid = fork();   assert(pid != -1);
 
diff -r 3a023dc4e63a harness/cases/14.t
--- a/harness/cases/14.tTue Jan 08 14:38:53 2008 +1100
+++ b/harness/cases/14.tTue Jan 08 17:00:53 2008 +1100
@@ -61,11 +61,14 @@ int test_main(void)
 {
int res, status;
pid_t pid;
+   sigset_t set;
 
if (attempt_io_submit(io_ctx, 0, NULL, 0))
return 1;
 
-   sigblock(sigmask(SIGCHLD) | siggetmask());
+   sigemptyset(&set);
+   sigaddset(&set, SIGCHLD);
+   sigprocmask(SIG_BLOCK, &set, NULL);
fflush(NULL);
pid = fork();   assert(pid != -1);
 
diff -r 3a023dc4e63a harness/cases/15.t
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/harness/cases/15.tTue Jan 08 17:00:53 2008 +1100
@@ -0,0 +1,94 @@
+/* 15.t
+- pwritev and

Re: [PATCH] Update to libaio?

2008-01-08 Thread Davide Libenzi
On Tue, 8 Jan 2008, Rusty Russell wrote:

> I recently tried to use libaio (0.3.106), and discovered it didn't have
> eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
> compile.  Or work.
> 
> Anyway, it's shipped by the distros, so I figure it's worth patching.
> I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
> find a home somewhere for it.
> 
> (Thanks for Jeff's feedback on the first version of this patch).

I've had a few asking me how to use AIO with the new eventfd thing with 
libaio, but not knowing libaio status I told them to either contact libaio 
developers or use the direct KAIO syscall interface (what I used in my 
example code).
But all ppl that asked, were libaio users, so a library update would be 
welcome from them IMO.



- Davide



-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Zach Brown

> Come up 
> with some real design criteria that are to be satisfied so some real 
> direction can be had in discussions.

If you're so inclined, you can check out the ring that is being kicked
around in the syslets patches.  The main criteria there is that there
isn't a syscall to build up and initialize kernel state for the ring.
It means we have to play some games to serialize the two blocking stores
that make up event insertion, but there are some things we could do there.

- z

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Jeff Moyer
Rusty Russell <[EMAIL PROTECTED]> writes:

> I recently tried to use libaio (0.3.106), and discovered it didn't have
> eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
> compile.  Or work.

> Anyway, it's shipped by the distros, so I figure it's worth patching.
> I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
> find a home somewhere for it.

Thanks for doing this, Rusty.  I have a few comments below.

> diff -ur libaio-0.3.106/ChangeLog libaio-0.3.106-aio_abi/ChangeLog
> --- libaio-0.3.106/ChangeLog  2002-10-01 08:09:56.0 +1000
> +++ libaio-0.3.106-aio_abi/ChangeLog  2008-01-03 17:48:48.0 +1100
> @@ -1,3 +1,14 @@
> +rusty-v1
> + - Make tests compile again on modern systems (warnings + -Werror)
> + - Add 'make partcheck' and don't require manual setup for testing.
> + - Change test harness to compile against this dir, not global install
> + - Fix 5.t for archs where PROT_WRITE mappings are readable.
> + - Allow sending of SIGXFSZ on aio over limits
> + - Explicitly specify bash for runtests.sh
> + - Remove (never-merged?) io_prep_poll

Well, I believe this was supported in Red Hat AS2.1 and RHEL 3.

> + - Add io_prep_preadv and io_prep_pwritev
> + - Add eventfd support (io_set_eventfd).
> +
>  0.4.0
>   - remove libredhat-kernel
>   - add rough outline for man pages
> diff -ur libaio-0.3.106/harness/cases/5.t 
> libaio-0.3.106-aio_abi/harness/cases/5.t
> --- libaio-0.3.106/harness/cases/5.t  2002-04-20 10:26:22.0 +1000
> +++ libaio-0.3.106-aio_abi/harness/cases/5.t  2008-01-03 16:29:37.0 
> +1100
> @@ -3,6 +3,7 @@
>  */
>  #include "aio_setup.h"
>  #include 
> +#include 
>  
>  int test_main(void)
>  {
> @@ -40,7 +41,13 @@
>   assert(buf != (char *)-1);
>  
>   status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, SIZE);
> - status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, -EFAULT);
> +
> + /* Whether PROT_WRITE is readable is arch-dependent.  So compare
> +  * against pread result. */
> + res = write(rwfd, buf, SIZE);
> + if (res < 0)
> + res = -errno;
> + status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, res);

Am I missing something, or does the code change do the opposite of
what your comment suggests?

> diff -ur libaio-0.3.106/harness/cases/8.t 
> libaio-0.3.106-aio_abi/harness/cases/8.t
> --- libaio-0.3.106/harness/cases/8.t  2008-01-03 15:13:05.0 +1100
> +++ libaio-0.3.106-aio_abi/harness/cases/8.t  2008-01-03 18:47:23.0 
> +1100
> @@ -2,44 +2,23 @@
>  - Ditto for the above three tests at the offset maximum (largest
>possible ext2/3 file size.) (8.t)
>   */
> -#include 
> -
> -#define EXT2_OLD_SUPER_MAGIC 0xEF51
> -#define EXT2_SUPER_MAGIC 0xEF53
> +#include 
> +#include 
>  
>  long long get_fs_limit(int fd)
>  {
> - struct statfs s;
> - int res;
> - long long lim = 0;
> -
> - res = fstatfs(fd, &s);  assert(res == 0);
> + long long min = 0, max = 100ULL;
> + char c = 0;

How did you choose this upper bound?

Thanks,

Jeff

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Rusty Russell
On Tuesday 08 January 2008 08:25:07 Jeff Moyer wrote:
> Rusty Russell <[EMAIL PROTECTED]> writes:
> > I recently tried to use libaio (0.3.106), and discovered it didn't have
> > eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
> > compile.  Or work.
> >
> > Anyway, it's shipped by the distros, so I figure it's worth patching.
> > I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
> > find a home somewhere for it.
>
> Thanks for doing this, Rusty.  I have a few comments below.

Thanks Jeff, I was wondering if I'd sent it into the void...

> > diff -ur libaio-0.3.106/ChangeLog libaio-0.3.106-aio_abi/ChangeLog
> > --- libaio-0.3.106/ChangeLog2002-10-01 08:09:56.0 +1000
> > +++ libaio-0.3.106-aio_abi/ChangeLog2008-01-03 17:48:48.0 
> > +1100
> > @@ -1,3 +1,14 @@
> > +rusty-v1
> > +   - Make tests compile again on modern systems (warnings + -Werror)
> > +   - Add 'make partcheck' and don't require manual setup for testing.
> > +   - Change test harness to compile against this dir, not global install
> > +   - Fix 5.t for archs where PROT_WRITE mappings are readable.
> > +   - Allow sending of SIGXFSZ on aio over limits
> > +   - Explicitly specify bash for runtests.sh
> > +   - Remove (never-merged?) io_prep_poll
>
> Well, I believe this was supported in Red Hat AS2.1 and RHEL 3.

Ah, OK.  It's not in mainline (only checked back to 2.6.12-rc2 tho).  I'll put 
them back with a comment to that effect...

> > assert(buf != (char *)-1);
> >
> > status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, SIZE);
> > -   status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, -EFAULT);
> > +
> > +   /* Whether PROT_WRITE is readable is arch-dependent.  So compare
> > +* against pread result. */
> > +   res = write(rwfd, buf, SIZE);
> > +   if (res < 0)
> > +   res = -errno;
> > +   status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, res);
>
> Am I missing something, or does the code change do the opposite of
> what your comment suggests?

Err, yeah.  Works on x86 of course, but it's wrong.

> >  long long get_fs_limit(int fd)
> >  {
> > -   struct statfs s;
> > -   int res;
> > -   long long lim = 0;
> > -
> > -   res = fstatfs(fd, &s);  assert(res == 0);
> > +   long long min = 0, max = 100ULL;
> > +   char c = 0;
>
> How did you choose this upper bound?

Added a few zeroes to the previous one 8).  It's so fast I might as well 
choose 18446744073709551615LL.

Will update and re-send, this time cc'ing the linux-aio list.

Thanks,
Rusty.

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Rusty Russell
On Wednesday 09 January 2008 06:23:22 Zach Brown wrote:
> Sarah Sharp wrote:
> > I think the Debian package maintainer should also be involved in this.
> >
> > I would love to see preadv and pwritev go into libaio, as they will be
> > useful for userspace USB driver developers to interface with usbfs2
> > (http://wiki.cs.pdx.edu/usb/usbfs2.html).  I do have a few more issues
> > with the libaio-dev package.
>
> *I* would love for people to stop using libaio.

Then you will have to provide an alternative.

Since AIO now hooks up with eventfd, making it poll()able and not just a 
novelty, I'd say now is the time for such a thing.  Otherwise it'll be libaio 
everywhere.

> It's not a library, in 
> that it doesn't isolate applications from the system ABI.  It's no more
> than a bunch of inline functions.  It was a mistake, in my opinion, but
> here we are.

For some reason it implements the arch-specific syscalls manually, too.

Cheers,
Rusty.

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Zach Brown

> What's the driving need to rip out functionality?

Well, in this case of the ring it's an irritation to have to massage the
tracking of events into the ring format when you, say, back the aio
implementation with syslets.  If it were just queueing up results for
io_getevents(), which can lock in the kernel, we'd have more freedom.

It's a nit, don't get me wrong.

> Why not actually submit 
> some more in kernel implementations of aio and then evaluate if the api 
> really needs to be ripped out or not (and use syslets or whatever to 
> implement 
> them)?

Don't ask me, ask the subsystem maintainers who have not chosen to do
this over the last N years.

- z

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Rusty Russell
On Wednesday 09 January 2008 06:07:51 Jeff Moyer wrote:
> I've been keeping a copy on rhlinux.redhat.com.  You can access it
> via:
>
>   cvs -d :pserver:[EMAIL PROTECTED]:/usr/local/CVS login  # no
> password cvs -d :pserver:[EMAIL PROTECTED]:/usr/local/CVS co
> libaio

Excellent!  I'll feed you patches from now on then, should I find anything 
else.

> When I'm happy with the regression tests (they
> don't all pass for me on 2.6.24-rc7), I'll roll a new version and
> build it for Fedora.

Did you see my two kernel patches to fix them?  Attached for your 
convenience...

Rusty.
An AIO read or write should return -EINVAL if the offset is negative.
This check matches the one in pread and pwrite.

This was found by the libaio test suite.

Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
---
 fs/aio.c |4 
 1 file changed, 4 insertions(+)

diff -r 18802689361a fs/aio.c
--- a/fs/aio.c	Thu Jan 03 15:22:24 2008 +1100
+++ b/fs/aio.c	Thu Jan 03 18:05:25 2008 +1100
@@ -1330,6 +1330,10 @@ static ssize_t aio_rw_vect_retry(struct 
 		opcode = IOCB_CMD_PWRITEV;
 	}
 
+	/* This matches the pread()/pwrite() logic */
+	if (iocb->ki_pos < 0)
+		return -EINVAL;
+
 	do {
 		ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],
 			iocb->ki_nr_segs - iocb->ki_cur_seg,
When an AIO write gets a non-retry error after writing some data
(eg. ENOSPC), it should return the amount written already, not the
error.  Just like write() is supposed to.

This was found by the libaio test suite.

Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>
Acked-By: Zach Brown <[EMAIL PROTECTED]>
---
 fs/aio.c |7 +++
 1 file changed, 7 insertions(+)

diff -r 18802689361a fs/aio.c
--- a/fs/aio.c	Thu Jan 03 15:22:24 2008 +1100
+++ b/fs/aio.c	Thu Jan 03 18:05:25 2008 +1100
@@ -1346,6 +1350,13 @@ static ssize_t aio_rw_vect_retry(struct 
 	/* This means we must have transferred all that we could */
 	/* No need to retry anymore */
 	if ((ret == 0) || (iocb->ki_left == 0))
+		ret = iocb->ki_nbytes - iocb->ki_left;
+
+	/* If we managed to write some out we return that, rather than
+	 * the eventual error. */
+	if (opcode == IOCB_CMD_PWRITEV
+	&& ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY
+	&& iocb->ki_nbytes - iocb->ki_left)
 		ret = iocb->ki_nbytes - iocb->ki_left;
 
 	return ret;
-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Zach Brown

> Then you will have to provide an alternative.

If it were up to me, we'd freeze AIO at it's current level of support
and migrate people towards syslets, possibly via posix aio in glibc
depending on their needs.  Yes, this won't happen immediately ;).

> Since AIO now hooks up with eventfd, making it poll()able and not just a 
> novelty, I'd say now is the time for such a thing.  Otherwise it'll be libaio 
> everywhere.

Well, if Jeff is maintaining libaio, I don't see that we have a pressing
problem.

- z

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


Re: [PATCH] Update to libaio?

2008-01-08 Thread Jeff Moyer
Rusty Russell <[EMAIL PROTECTED]> writes:

> I recently tried to use libaio (0.3.106), and discovered it didn't have
> eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
> compile.  Or work.
>
> Anyway, it's shipped by the distros, so I figure it's worth patching.
> I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
> find a home somewhere for it.

I've been keeping a copy on rhlinux.redhat.com.  You can access it
via:

  cvs -d :pserver:[EMAIL PROTECTED]:/usr/local/CVS login  # no password
  cvs -d :pserver:[EMAIL PROTECTED]:/usr/local/CVS co libaio

> (Thanks for Jeff's feedback on the first version of this patch).

I think we also need to update the test cases to use O_DIRECT, since
buffered AIO isn't really supported.  I'll work on that.  In the mean
time, I've incorporated your changes into a work branch
(jmoyer-work-branch).  When I'm happy with the regression tests (they
don't all pass for me on 2.6.24-rc7), I'll roll a new version and
build it for Fedora.

Thanks again!

Jeff

-- 
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss


[PATCH] Update to libaio?

2008-01-03 Thread Rusty Russell
I recently tried to use libaio (0.3.106), and discovered it didn't have
eventfd support.  Or preadv/pwritev support.  And the testsuite didn't
compile.  Or work.

Anyway, it's shipped by the distros, so I figure it's worth patching.
I'm cc'ing Ben in the hope he's still maintaining it.  If not I'll
find a home somewhere for it.

Cheers,
Rusty.

diff -ur libaio-0.3.106/ChangeLog libaio-0.3.106-aio_abi/ChangeLog
--- libaio-0.3.106/ChangeLog2002-10-01 08:09:56.0 +1000
+++ libaio-0.3.106-aio_abi/ChangeLog2008-01-03 17:48:48.0 +1100
@@ -1,3 +1,14 @@
+rusty-v1
+   - Make tests compile again on modern systems (warnings + -Werror)
+   - Add 'make partcheck' and don't require manual setup for testing.
+   - Change test harness to compile against this dir, not global install
+   - Fix 5.t for archs where PROT_WRITE mappings are readable.
+   - Allow sending of SIGXFSZ on aio over limits
+   - Explicitly specify bash for runtests.sh
+   - Remove (never-merged?) io_prep_poll
+   - Add io_prep_preadv and io_prep_pwritev
+   - Add eventfd support (io_set_eventfd).
+
 0.4.0
- remove libredhat-kernel
- add rough outline for man pages
diff -ur libaio-0.3.106/harness/cases/5.t 
libaio-0.3.106-aio_abi/harness/cases/5.t
--- libaio-0.3.106/harness/cases/5.t2002-04-20 10:26:22.0 +1000
+++ libaio-0.3.106-aio_abi/harness/cases/5.t2008-01-03 16:29:37.0 
+1100
@@ -3,6 +3,7 @@
 */
 #include "aio_setup.h"
 #include 
+#include 
 
 int test_main(void)
 {
@@ -40,7 +41,13 @@
assert(buf != (char *)-1);
 
status |= attempt_rw(rwfd, buf, SIZE,  0,  READ, SIZE);
-   status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, -EFAULT);
+
+   /* Whether PROT_WRITE is readable is arch-dependent.  So compare
+* against pread result. */
+   res = write(rwfd, buf, SIZE);
+   if (res < 0)
+   res = -errno;
+   status |= attempt_rw(rwfd, buf, SIZE,  0, WRITE, res);
 
return status;
 }
diff -ur libaio-0.3.106/harness/cases/7.t 
libaio-0.3.106-aio_abi/harness/cases/7.t
--- libaio-0.3.106/harness/cases/7.t2002-04-20 10:26:22.0 +1000
+++ libaio-0.3.106-aio_abi/harness/cases/7.t2008-01-03 17:46:11.0 
+1100
@@ -9,12 +9,15 @@
 */
 
 #include 
+#include 
 
 void SET_RLIMIT(long long limit)
 {
struct rlimit rlim;
int res;
 
+   /* Seems that we do send SIGXFSZ, but hard to fix... */
+   signal(SIGXFSZ, SIG_IGN);
rlim.rlim_cur = limit;  assert(rlim.rlim_cur == limit);
rlim.rlim_max = limit;  assert(rlim.rlim_max == limit);
 
diff -ur libaio-0.3.106/harness/cases/8.t 
libaio-0.3.106-aio_abi/harness/cases/8.t
--- libaio-0.3.106/harness/cases/8.t2008-01-03 15:13:05.0 +1100
+++ libaio-0.3.106-aio_abi/harness/cases/8.t2008-01-03 18:47:23.0 
+1100
@@ -2,44 +2,23 @@
 - Ditto for the above three tests at the offset maximum (largest
   possible ext2/3 file size.) (8.t)
  */
-#include 
-
-#define EXT2_OLD_SUPER_MAGIC   0xEF51
-#define EXT2_SUPER_MAGIC   0xEF53
+#include 
+#include 
 
 long long get_fs_limit(int fd)
 {
-   struct statfs s;
-   int res;
-   long long lim = 0;
-
-   res = fstatfs(fd, &s);  assert(res == 0);
+   long long min = 0, max = 100ULL;
+   char c = 0;
 
-   switch(s.f_type) {
-   case EXT2_OLD_SUPER_MAGIC:
-   case EXT2_SUPER_MAGIC:
-#if 0
-   {
-   long long tmp;
-   tmp = s.f_bsize / 4;
-   /* 12 direct + indirect block + dind + tind */
-   lim = 12 + tmp + tmp * tmp + tmp * tmp * tmp;
-   lim *= s.f_bsize;
-   printf("limit(%ld) = %Ld\n", (long)s.f_bsize, lim);
-   }
-#endif
-   switch(s.f_bsize) {
-   case 4096: lim = 2199023251456ULL; break;
-   default:
-   printf("unknown ext2 blocksize %ld\n", (long)s.f_bsize);
-   exit(3);
+   while (max - min > 1) {
+   if (pwrite64(fd, &c, 1, (min + max) / 2) == -1)
+   max = (min + max) / 2;
+   else {
+   ftruncate(fd, 0);
+   min = (min + max) / 2;
}
-   break;
-   default:
-   printf("unknown filesystem 0x%08lx\n", (long)s.f_type);
-   exit(3);
}
-   return lim;
+   return max;
 }
 
 #define SET_RLIMIT(x)  do ; while (0)
diff -ur libaio-0.3.106/harness/cases/common-7-8.h 
libaio-0.3.106-aio_abi/harness/cases/common-7-8.h
--- libaio-0.3.106/harness/cases/common-7-8.h   2002-04-20 10:26:22.0 
+1000
+++ libaio-0.3.106-aio_abi/harness/cases/common-7-8.h   2008-01-03 
18:36:02.0 +1100
@@ -2,6 +2,8 @@
 */
 #include "aio_setup.h"
 
+#define _XOPEN_SOURCE 500
+#include 
 #include 
 
 #define SIZE   512
@@ -13,7 +15,7 @@
int status = 0, res;