El lun, 20-05-2013 a las 14:16 +0200, Juan Antonio Martinez escribió:
[...]
> So my question:
> Is there any way to get nbd kernel module waiting for server client
> execute finnish_sock() routine to tell the new socket to talk to,
> instead of inmediate return of ioerror ?
>
> Perhaps a new ioctl() or nbd_flag option to say kernel that client
> is in "persist mode" and wait instead of return?

Not sure if this is a good aproach:

--- nbd.h.orig  2013-05-21 08:59:57.203829317 +0200
+++ nbd.h       2013-05-21 09:18:06.867850220 +0200
@@ -47,6 +47,7 @@
 #define NBD_FLAG_SEND_FUA (1 << 3) /* Send FUA (Force Unit Access) */
 #define NBD_FLAG_ROTATIONAL (1 << 4) /* Use elevator algorithm -
rotational media */
 #define NBD_FLAG_SEND_TRIM (1 << 5) /* Send TRIM (discard) */
+#define NBD_FLAG_PERSIST (1 << 6) /* Wait for reconnection */
 
 #define nbd_cmd(req) ((req)->cmd[0])

--- nbd-client.c.orig   2013-05-21 09:02:01.303831698 +0200
+++ nbd-client.c 2013-05-21 09:20:17.655852729 +0200
@@ -567,6 +567,7 @@
    if (nbd < 0)
        err("Cannot open NBD: %m\nPlease ensure the 'nbd' module is
loaded.");
 
+    if (cont) flags |= NBD_FLAG_PERSIST;
     setsizes(nbd, size64, blocksize, flags);
     set_timeout(nbd, timeout);
     finish_sock(sock, nbd, swap);
@@ -642,6 +643,7 @@
                if (size64 != new_size) {
                    err("Size of the device changed. Bye");
                }
+               new_flags |= NBD_FLAG_PERSIST;
                setsizes(nbd, size64, blocksize, new_flags);
 
--- kernel/nbd.c.orig   2013-05-21 09:31:06.167865169 +0200
+++ kernel/nbd.c 2013-05-21 10:55:23.071962172 +0200
@@ -531,6 +531,10 @@
             if (list_empty(&nbd->waiting_queue))
                     continue;

+            /* if persist mode and closed socket loop again */
+            if (nbd->flags & NBD_FLAG_PERSIST ) 
+               if (!nbd->file) continue;
+
             spin_lock_irq(&nbd->queue_lock);
             req = list_entry(nbd->waiting_queue.next, struct request,
                                  queuelist);
--------------------------------------------

with this preliminary patch things goes better, but still far of
correctnes: on DO_IT ioctl, still some work with pending queues are
required. Sorry: I'm not sure about how to properly handle new (3.6)
block driver interface. 

My idea is keep pendind request in queue until reconnection gets
complete, instead of returning "Attemped send on closed socket" error.

Is this a right approach? ¿any ideas?
Thanks in advance

Juan Antonio



------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Nbd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nbd-general

Reply via email to