search for: rlen

Displaying 20 results from an estimated 98 matches for "rlen".

Did you mean: len
2019 Jun 09
0
[PATCH libnbd] states: In recv_into_rbuf and send_from_wbuf loop until EAGAIN.
...+++++++------------------------ 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/generator/states.c b/generator/states.c index 145e8c1..cde934a 100644 --- a/generator/states.c +++ b/generator/states.c @@ -46,43 +46,40 @@ recv_into_rbuf (struct nbd_handle *h) void *rbuf; size_t rlen; - if (h->rlen == 0) - return 0; /* move to next state */ + while (h->rlen > 0) { + /* As a special case h->rbuf is allowed to be NULL, meaning + * throw away the data. + */ + if (h->rbuf) { + rbuf = h->rbuf; + rlen = h->rlen; +...
2019 Jun 09
2
[PATCH libnbd] states: In recv_into_rbuf and send_from_wbuf loop until EAGAIN.
I thought this should produce a fairly dramatic performance gain. In fact I couldn't measure any performance difference at all. I think what's happening is we're actually paying an extra syscall (to discover the socket would block) and then doing the poll anyway. So I don't know if it's worth having this patch. It could be argued that it makes the code shorter (therefore
2019 Jun 03
0
[PATCH libnbd discussion only 3/5] lib: Pass handle to socket recv and send calls.
...socket.c | 5 +++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/generator/states-reply.c b/generator/states-reply.c index 5be3431..f0ef47c 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -36,7 +36,7 @@ h->rbuf = &h->sbuf; h->rlen = sizeof h->sbuf.simple_reply; - r = h->sock->ops->recv (h->sock, h->rbuf, h->rlen); + r = h->sock->ops->recv (h, h->sock, h->rbuf, h->rlen); if (r == -1) { /* This should never happen because when we enter this state we * should have notific...
2007 Apr 18
1
[patch 5/9] Guest page hinting: mlocked pages.
...c 2006-09-01 12:50:24.000000000 +0200 @@ -2523,6 +2523,31 @@ int make_pages_present(unsigned long add BUG_ON(addr >= end); BUG_ON(end > vma->vm_end); len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE; + + if (page_host_discards() && (vma->vm_flags & VM_LOCKED)) { + int rlen = len; + ret = 0; + while (rlen > 0) { + struct page *page_refs[32]; + int chunk, cret, i; + + chunk = rlen < 32 ? rlen : 32; + cret = get_user_pages(current, current->mm, addr, + chunk, write, 0, + page_refs, NULL); + if (cret > 0) { + for (i = 0; i &...
2007 Apr 18
1
[patch 5/9] Guest page hinting: mlocked pages.
...c 2006-09-01 12:50:24.000000000 +0200 @@ -2523,6 +2523,31 @@ int make_pages_present(unsigned long add BUG_ON(addr >= end); BUG_ON(end > vma->vm_end); len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE; + + if (page_host_discards() && (vma->vm_flags & VM_LOCKED)) { + int rlen = len; + ret = 0; + while (rlen > 0) { + struct page *page_refs[32]; + int chunk, cret, i; + + chunk = rlen < 32 ? rlen : 32; + cret = get_user_pages(current, current->mm, addr, + chunk, write, 0, + page_refs, NULL); + if (cret > 0) { + for (i = 0; i &...
2023 Jun 20
1
[libnbd PATCH v4 4/4] internal: Refactor layout of replies in sbuf
...; + _cookie_aliasing_simple); > + STATIC_ASSERT (offsetof (union reply_header, structured.cookie) == > + offsetof (union reply_header, cookie), > + _cookie_aliasing_structured); > assert (h->reply_cmd == NULL); > assert (h->rlen == 0); > > - h->rbuf = &h->sbuf; > - h->rlen = sizeof h->sbuf.simple_reply; > + h->rbuf = &h->sbuf.reply.hdr; > + h->rlen = sizeof h->sbuf.reply.hdr.simple; > > r = h->sock->ops->recv (h, h->sock, h->rbuf, h->rlen); &gt...
2019 Jun 03
1
Re: [PATCH libnbd discussion only 3/5] lib: Pass handle to socket recv and send calls.
...changed, 13 insertions(+), 9 deletions(-) > > diff --git a/generator/states-reply.c b/generator/states-reply.c > index 5be3431..f0ef47c 100644 > --- a/generator/states-reply.c > +++ b/generator/states-reply.c > @@ -36,7 +36,7 @@ > h->rbuf = &h->sbuf; > h->rlen = sizeof h->sbuf.simple_reply; > > - r = h->sock->ops->recv (h->sock, h->rbuf, h->rlen); > + r = h->sock->ops->recv (h, h->sock, h->rbuf, h->rlen); Do we need to pass both h and h->sock, or can the caller access h->sock through h? (Maybe I...
2023 Jun 09
4
[libnbd PATCH v4 0/4] Saner reply header layout
This was v3 patch 2/22, reworked to address the confusion about how a structured reply header is read in two pieces before getting to the payload portion. I'm still working on rebasing the rest of my v3 series (patches 1, 3-22) from other comments given, but this seemed independent enough that it's worth posting now rather than holding it up for the rest of the series. Eric Blake (4):
2019 Dec 20
3
[common/libguestfs PATCH 0/2] Fix OCaml/Python linking
Make sure they can build also in no as-neede setups. Pino Toscano (1): utils: split string list functions in own file build: use split stringlist functions from common/utils utils/Makefile.am | 2 + utils/guestfs-stringlists-utils.h | 30 +++++ utils/guestfs-utils.h | 7 +- utils/stringlists-utils.c | 197 ++++++++++++++++++++++++++++++ utils/utils.c
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must
2017 Mar 03
5
[PATCH WIP 0/5] Fix virt-rescue.
This set of patches fixes virt-rescue rather cleanly. In particular the problems with handling ^C are completely fixed. Work still to be done before this can go upstream: - Shutdown doesn't work properly if you exit the shell. At the moment to exit you must do 'reboot -f'. Future improvements: - An escape sequence and escape commands that could be handled by virt-rescue,
2017 Mar 03
5
[PATCH 0/5] Fix virt-rescue.
This fixes the main issues in virt-rescue and is usable. There are some enhancements which could be made (in follow up work): - An escape sequence and escape commands that could be handled by virt-rescue, eg. to shut down the appliance, mount or unmount filesystems. - `virt-rescue -i' could be implemented cleanly by performing the right API calls before handing control to the
2019 Sep 16
1
[libnbd PATCH] api: Add set_handshake_flags for integration
...it a/generator/states-newstyle-opt-export-name.c b/generator/states-newstyle-opt-export-name.c index ec73136..a46d851 100644 --- a/generator/states-newstyle-opt-export-name.c +++ b/generator/states-newstyle-opt-export-name.c @@ -45,7 +45,7 @@ case 0: h->rbuf = &h->sbuf; h->rlen = sizeof h->sbuf.export_name_reply; - if ((h->gflags & NBD_FLAG_NO_ZEROES) != 0) + if ((h->gflags & LIBNBD_HANDSHAKE_FLAG_NO_ZEROES) != 0) h->rlen -= sizeof h->sbuf.export_name_reply.zeroes; SET_NEXT_STATE (%RECV_REPLY); } diff --git a/generator/states-ne...
2010 Apr 27
4
Patch sensible callback framework
...#include <fcntl.h> #include <sys/stat.h> +#include <syslinux/callback.h> #include <syslinux/loadfile.h> #define INCREMENTAL_CHUNK 1024*1024 @@ -48,13 +49,13 @@ int floadfile(FILE * f, void **ptr, size struct stat st; void *data, *dp; size_t alen, clen, rlen, xlen; + callback_record *cb = NULL; clen = alen = 0; data = NULL; if (fstat(fileno(f), &st)) goto err; - if (!S_ISREG(st.st_mode)) { /* Not a regular file, we can't assume we know the file size */ if (prefix_len) { @@ -75,6 +76,11 @@ int floadfile(FILE * f,...
2010 Apr 06
2
help output figures in R
somfunc<- function (file) { aa_som<-scale(file) final.som<-som(data=aa_som, rlen=10000, grid=somgrid(5,4, "hexagonal")) pdf(file="/home/cdu/changbin/file.pdf") #output graphic file. plot(final.som, main="Unsupervised SOM") dev.off() } I have many different files, if I want output pdf file with the same name as for each dataset I feed to the f...
2017 Jun 19
0
[PATCH v7 13/13] daemon: Link guestfsd with libutils.
..._device_names (char **argv, size_t len) qsort (argv, len, sizeof (char *), compare_device_names_vp); } -char * -concat_strings (char *const *argv) -{ - return join_strings ("", argv); -} - -char * -join_strings (const char *separator, char *const *argv) -{ - size_t i, len, seplen, rlen; - char *r; - - seplen = strlen (separator); - - len = 0; - for (i = 0; argv[i] != NULL; ++i) { - if (i > 0) - len += seplen; - len += strlen (argv[i]); - } - len++; /* for final \0 */ - - r = malloc (len); - if (r == NULL) - return NULL; - - rlen = 0; - for (i = 0; argv[...
2019 Jun 19
4
[libnbd PATCH] states: Never block state machine inside REPLY
...is sub-group. If there is + * insufficient data to finish parsing a reply, requiring us to block + * until POLLIN, we instead track where in the state machine we left + * off, then return to READY to actually block. Then, on entry to + * REPLY.START, we can tell if this is the start of a new reply (rlen + * is 0, stay put), a continuation of the preamble (reply_cmd is NULL, + * resume with RECV_REPLY), or a continuation from any other location + * (reply_cmd contains the state to jump to). + */ + +static void +save_reply_state (struct nbd_handle *h) +{ + assert (h->reply_cmd); + assert (h-&gt...
2019 Jun 14
1
[libnbd PATCH] states: Validate error message size
...ad.error.len); + if (msglen > length - sizeof h->sbuf.sr.payload.error) { + SET_NEXT_STATE (%.DEAD); + set_error (0, "error message length too large"); + return -1; + } + /* We skip the human readable error for now. XXX */ h->rbuf = NULL; - h->rlen = be16toh (h->sbuf.sr.payload.error.len); + h->rlen = msglen; SET_NEXT_STATE (%RECV_ERROR_MESSAGE); } return 0; REPLY.STRUCTURED_REPLY.RECV_ERROR_MESSAGE: + uint32_t length, msglen; + uint16_t type; + + switch (recv_into_rbuf (h)) { + case -1: SET_NEXT_STATE (%.DEAD); ret...
2019 Jun 14
0
[libnbd PATCH 5/7] states: Factor out NBD_REP payload prep
...llowing payload if it is short enough to fit in the - * static buffer. If it's too long, skip it. - */ - len = be32toh (h->sbuf.or.option_reply.replylen); - if (len <= maxpayload) - h->rbuf = &h->sbuf.or.payload; - else - h->rbuf = NULL; - h->rlen = len; + if (prepare_for_reply_payload (h, NBD_OPT_GO) == -1) { + SET_NEXT_STATE (%.DEAD); + return -1; + } SET_NEXT_STATE (%RECV_REPLY_PAYLOAD); } return 0; @@ -104,8 +96,6 @@ return 0; NEWSTYLE.OPT_GO.CHECK_REPLY: - uint64_t magic; - uint32_t option; uint32_t...
2002 Apr 26
0
PAM keyboard-interactive
...set(SSH2_MSG_USERAUTH_INFO_RESPONSE, NULL); + if (recv(ctxt->pam_sock, &ch, 1, MSG_PEEK) < 1) + return (-1); + return (ch); +} - return retval; +/* + * Receive a message from parent or child. + */ +static char * +pam_receive(struct pam_ctxt *ctxt) +{ + char *buf; + size_t len; + ssize_t rlen; + + len = 64; + buf = NULL; + do { + len *= 2; + buf = xrealloc(buf, len); + rlen = recv(ctxt->pam_sock, buf, len, MSG_PEEK); + if (rlen < 1) { + xfree(buf); + return (NULL); + } + } while (rlen == len); + if (recv(ctxt->pam_sock, buf, len, 0) != rlen) { + xfree(buf); + return...