Re: [uml-devel] [Patch] UML: Clean up arch/um/drivers/ubd_kern.c

2008-04-16 Thread Jeff Dike
On Wed, Apr 16, 2008 at 01:39:19PM +0800, WANG Cong wrote:
> From: Jeff Dike <[EMAIL PROTECTED]>
> Date: Tue, 15 Apr 2008 09:33:25 -0400
> > On Mon, Apr 14, 2008 at 11:42:37PM -0700, Andrew Morton wrote:
> > > omg, when checkpatch bit into this patch my CPU melted.

Here's a cleaned up version.

Jeff


From: WANG Cong <[EMAIL PROTECTED]>

Make some global functions and variables static.

And remove some useless declarations for local functions, since we just
need to move their definitions ahead.

Compile testing passed.

[ jdike - checkpatch cleanups ]

Signed-off-by: WANG Cong <[EMAIL PROTECTED]>
Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>

Index: linux-2.6.22/arch/um/drivers/ubd_kern.c
===
--- linux-2.6.22.orig/arch/um/drivers/ubd_kern.c2008-04-14 
10:44:36.0 -0400
+++ linux-2.6.22/arch/um/drivers/ubd_kern.c 2008-04-16 11:17:12.0 
-0400
@@ -72,18 +72,6 @@ struct io_thread_req {
int error;
 };
 
-extern int open_ubd_file(char *file, struct openflags *openflags, int shared,
-char **backing_file_out, int *bitmap_offset_out,
-unsigned long *bitmap_len_out, int *data_offset_out,
-int *create_cow_out);
-extern int create_cow_file(char *cow_file, char *backing_file,
-  struct openflags flags, int sectorsize,
-  int alignment, int *bitmap_offset_out,
-  unsigned long *bitmap_len_out,
-  int *data_offset_out);
-extern int read_cow_bitmap(int fd, void *buf, int offset, int len);
-extern void do_io(struct io_thread_req *req);
-
 static inline int ubd_test_bit(__u64 bit, unsigned char *data)
 {
__u64 n;
@@ -200,7 +188,7 @@ struct ubd {
 }
 
 /* Protected by ubd_lock */
-struct ubd ubd_devs[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
+static struct ubd ubd_devs[MAX_DEV] = { [0 ... MAX_DEV - 1] = DEFAULT_UBD };
 
 /* Only changed by fake_ide_setup which is a setup */
 static int fake_ide = 0;
@@ -463,7 +451,7 @@ __uml_help(udb_setup,
 static void do_ubd_request(struct request_queue * q);
 
 /* Only changed by ubd_init, which is an initcall. */
-int thread_fd = -1;
+static int thread_fd = -1;
 
 static void ubd_end_request(struct request *req, int bytes, int error)
 {
@@ -531,7 +519,7 @@ static irqreturn_t ubd_intr(int irq, voi
 /* Only changed by ubd_init, which is an initcall. */
 static int io_pid = -1;
 
-void kill_io_thread(void)
+static void kill_io_thread(void)
 {
if(io_pid != -1)
os_kill_process(io_pid, 1);
@@ -547,6 +535,192 @@ static inline int ubd_file_size(struct u
return os_file_size(file, size_out);
 }
 
+static int read_cow_bitmap(int fd, void *buf, int offset, int len)
+{
+   int err;
+
+   err = os_seek_file(fd, offset);
+   if (err < 0)
+   return err;
+
+   err = os_read_file(fd, buf, len);
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+
+static int backing_file_mismatch(char *file, __u64 size, time_t mtime)
+{
+   unsigned long modtime;
+   unsigned long long actual;
+   int err;
+
+   err = os_file_modtime(file, &modtime);
+   if (err < 0) {
+   printk(KERN_ERR "Failed to get modification time of backing "
+  "file \"%s\", err = %d\n", file, -err);
+   return err;
+   }
+
+   err = os_file_size(file, &actual);
+   if (err < 0) {
+   printk(KERN_ERR "Failed to get size of backing file \"%s\", "
+  "err = %d\n", file, -err);
+   return err;
+   }
+
+   if (actual != size) {
+   /*__u64 can be a long on AMD64 and with %lu GCC complains; so
+* the typecast.*/
+   printk(KERN_ERR "Size mismatch (%llu vs %llu) of COW header "
+  "vs backing file\n", (unsigned long long) size, actual);
+   return -EINVAL;
+   }
+   if (modtime != mtime) {
+   printk(KERN_ERR "mtime mismatch (%ld vs %ld) of COW header vs "
+  "backing file\n", mtime, modtime);
+   return -EINVAL;
+   }
+   return 0;
+}
+
+static int path_requires_switch(char *from_cmdline, char *from_cow, char *cow)
+{
+   struct uml_stat buf1, buf2;
+   int err;
+
+   if (from_cmdline == NULL)
+   return 0;
+   if (!strcmp(from_cmdline, from_cow))
+   return 0;
+
+   err = os_stat_file(from_cmdline, &buf1);
+   if (err < 0) {
+   printk(KERN_ERR "Couldn't stat '%s', err = %d\n", from_cmdline,
+  -err);
+   return 0;
+   }
+   err = os_stat_file(from_cow, &buf2);
+   if (err < 0) {
+   printk(KERN_ERR "Couldn't stat '%s', err = %d\n", from_cow,
+  -err);
+   return 1;
+   

Re: [uml-devel] Lockups with the fixed timer code :/

2008-04-16 Thread Nix
On 15 Apr 2008, [EMAIL PROTECTED] said:
> OK, trying that. (I'll extend the instrumentation patch to watch for
> zero cycle_interval as well, and see what happens. With luck nothing
> will happen except that the crashes will stop... except that they
> already *have* stopped for me. Annoying.)

Hard-spinning again, inside gettimeofday() inside os_nsecs(). (The stack
above that point is corrupt, or at least gdb 6.7.1 won't show
it. Nonetheless if it's not stuck inside idle_sleep() I'll eat my
hat. Note that I am *not* running CONFIG_NO_HZ because, hah, I thought
that as rather new code it might be unstable...)

This *is* a change in behaviour: the backtrace is different! Yay! :)

-- 
`The rest is a tale of post and counter-post.' --- Ian Rawlings
   describes USENET

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


Re: [uml-devel] [Patch] UML: Clean up arch/um/drivers/ubd_kern.c

2008-04-16 Thread WANG Cong
From: Jeff Dike <[EMAIL PROTECTED]>
Date: Wed, 16 Apr 2008 11:20:19 -0400
> On Wed, Apr 16, 2008 at 01:39:19PM +0800, WANG Cong wrote:
> > From: Jeff Dike <[EMAIL PROTECTED]>
> > Date: Tue, 15 Apr 2008 09:33:25 -0400
> > > On Mon, Apr 14, 2008 at 11:42:37PM -0700, Andrew Morton wrote:
> > > > omg, when checkpatch bit into this patch my CPU melted.
> 
> Here's a cleaned up version.
> 
>   Jeff

Looks OK for me. Thank you!

-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel