[prev in list] [next in list] [prev in thread] [next in thread] 

List:       user-mode-linux-devel
Subject:    [uml-devel] Some changes while looking at  AIO
From:       "McMechan, James" <McMechanJW () navair ! navy ! mil>
Date:       2002-02-08 21:33:18
[Download RAW message or body]

The AIO interface appears to be the same between the SGI KAIO patch and the
glibc versions
what should happen is a include of either <aio.h> (glibc) or <linux/aio.h>
(patch)
and linking with librt (glibc) or libdba (patch).

Benjamin LaHaise's patch appears to also patch rt/glibc and so should be
completely transparent.

On adding void * to io_thread_req the user side does not have the struct
request definitions 
from blk.h available and kernel side does not have struct aiocb from aio.h
but both need 
to be kept track of when handling async completions so:

When the aio signal handler writes to the fd and starts the ubd_handler it
then disposes of aiocb & io_req
The ubd_handler can take the request (not CURRENT) and send it on to a local
end_request.

On fork problems with the stack, are threads a problem? or since the aio
stuff can be started from 
the io_thread would it be possible to have that one thread appear to glibc
as a normal COW stack frame?
It does not need to share with the other frames since it uses read/write
pipe to communicate.

Yes it is a bit ugly but it would prevent requiring one of the patches to
avoid the stack mess.
I don't know of a easy way to test for either patch and a expert config
option can still be wrong.



I noticed that setup_common when it detects =sync sets a local variable and
returns?
what was it supposed to do?

I would think the global sync should be set, and the local renamed.
But did you want to be able to have sync (no thread) I/O without having the
file opened O_SYNC?
Would sync (no thread) I/O use AIO?
Would a ubd opened sync use AIO?
Should AIO have its own options?
AIO for the whole system?
AIO for each ubd? 
Whole system enables then each ubd could be enabled?

This patch is slightly fuzzed as I found it after looking at AIO. 

--- uml-2.4.17-10/arch/um/drivers/ubd.c  Fri Feb  8 11:02:44 2002
+++ work-2.4.17-10/arch/um/drivers/ubd.c         Fri Feb  8 12:04:40 2002
@@ -139,6 +139,7 @@
 static int fake_ide = 0;
 static struct proc_dir_entry *proc_ide_root = NULL;
 static struct proc_dir_entry *proc_ide = NULL;
+static int sync = 0;
 
 static void make_proc_ide(void)
 {
@@ -357,7 +356,6 @@
 
 __uml_exitcall(kill_io_thread);
 
-int sync = 0;
 
 devfs_handle_t ubd_dir_handle;
 devfs_handle_t ubd_fake_dir_handle;
@@ -197,7 +198,7 @@
 static int ubd_setup_common(char *str, int *index_out)
 {
         char *backing_file;
-        int n, sync, perm = O_RDWR;
+        int n, local_sync, perm = O_RDWR;
 
         if(index_out) *index_out = -1;
         n = *str++;
@@ -206,7 +207,7 @@
                 int major;
 
                 if(!strcmp(str, "sync")){
-                        sync = 1;
+                        sync = O_SYNC;
                         return(0);
                 }
                 major = simple_strtoul(str, &end, 0);
@@ -231,13 +232,13 @@
                 return(1);
         }
         if(index_out) *index_out = n;
-        sync = ubd_dev[n].boot_openflags & 
O_SYNC;
+        local_sync = ubd_dev[n].boot_openflags & O_SYNC | sync;
         if (*str == 'r') {
                 perm = O_RDONLY;
                 str++;
         }
         if (*str == 's') {
-                sync = O_SYNC;
+                local_sync = O_SYNC;
                 str++;
         }
         if(*str++ != '='){
@@ -251,7 +252,7 @@
         }
         ubd_dev[n].file = str;
         ubd_dev[n].cow.file = backing_file;
-        ubd_dev[n].boot_openflags = perm | sync;
+        ubd_dev[n].boot_openflags = perm | local_sync;
          return(0);
 }
 
these later patches want the include "ubd_user.h" after the types.h (I
think) include in ubd[_user].c
so __u32/64 work nicely

--- uml-2.4.17-10/arch/um/drivers/ubd.c  Fri Feb  8 11:02:44 2002
+++ work-2.4.17-10/arch/um/drivers/ubd.c         Fri Feb  8 12:04:40 2002
@@ -3,7 +3,6 @@
  * Licensed under the GPL
  */
 
-#include "ubd_user.h"
 #define MAJOR_NR UBD_MAJOR
 #include "linux/config.h"
 #include "linux/blk.h"
@@ -30,6 +29,7 @@
 #include "init.h"
 #include "irq_user.h"
 #include "2_5compat.h"
+#include "ubd_user.h"
 
 extern __u64 file_size(char *file);
 


Here are some changes to the ubd_user.h header for the non endian bit tests

--- uml-2.4.17-10/arch/um/include/ubd_user.h     Fri Feb  8 11:02:44 2002
+++ work-2.4.17-10/arch/um/include/ubd_user.h    Fri Feb  8 08:26:12 2002
@@ -37,23 +39,21 @@
 extern void do_io(struct io_thread_req *req);
 extern int ubd_is_dir(char *file);
 
-static inline int ubd_test_bit(int bit, unsigned long *data)
+static inline int ubd_test_bit(__u64 bit, unsigned char *data)
 {
-        int bits, n, off;
+        __u64 n, off;
 
-        bits = sizeof(data[0]) * 8;
-        n = bit / bits;
-        off = bit % bits;
+        n = bit >> 3;    /* get byte index */
+        off = bit & 0x07;        /* get bit within that byte */
         return((data[n] & (1 << off)) != 0);
 }
 
-static inline void ubd_set_bit(int bit, unsigned long *data)
+static inline void ubd_set_bit(__u64 bit, unsigned char *data)
 {
-        int bits, n, off;
+        __u64 n, off;
 
-        bits = sizeof(data[0]) * 8;
-        n = bit / bits;
-        off = bit % bits;
+        n = bit >> 3;    /* get byte index */
+        off = bit &
 0x07;        /* get bit within that byte */
         data[n] |= (1 << off);
 }
 
Here is a shuffle to io_thread_req items first pointers then 64, then 32
then enum
I also added the aio and CURRENT pointers, and I changed to __u64/32 instead
of the long/+long
eventually it would be nice to drop the bitmaps and only pass a run of
blocks.
It looks almost like that now. And then it is only one fd and 2 offsets can
be pushed up too.

--- uml-2.4.17-10/arch/um/include/ubd_user.h     Fri Feb  8 11:02:44 2002
+++ work-2.4.17-10/arch/um/include/ubd_user.h    Fri Feb  8 08:26:12 2002
@@ -10,17 +10,19 @@
 enum ubd_req { UBD_READ, UBD_WRITE };
 
 struct io_thread_req {
-        enum ubd_req op;
-        int fds[2];
-        unsigned long offsets[2];
-        unsigned long long offset;
-        unsigned long length;
         char *buffer;
+        void *current_request;
+        void *aio_info;
+        __u64 offset;
+        __u32 offsets[2];
+        __u32 length;
+        __u32 sector_mask;
+        __u32 cow_offset;
+        __u32 bitmap_words[2];
+        int fds[2];
         int sectorsize;
-        unsigned long sector_mask;
-        unsigned long cow_offset;
-        unsigned long bitmap_words[2];
         int error;
+        enum ubd_req op;
 };
 
 extern int open_ubd_file(char *file, int *openflags, char
**backing_file_out, 

_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic