On Thursday 25 October 2007 19:11:40 Jens Axboe wrote:Well currently sg_chain() only joins "incomplete" (ie. unterminated) sg chains. That works great for you, but it feels more like a special purpose to me. It was suggested by analogy earlier in this thread, to use a two-level structure. In this case I would have first renamed struct scatterlist to struct scatterelem. Then struct scatterlist looks like: struct scatterlist { unsigned int num; struct scatterelem elems[0]; }; We'd want a nice macro to declare them for the stack case: #define DEFINE_SCATTERLIST(name, elems) \ struct { \ struct scatterlist sg; \ struct scatterelem elems[num]; \ } name Now we've tied the number and array together, we can introduce: struct sg_multilist { unsigned int num_scatterlists; struct scatterlist *sg_array[0]; }; And, of course, a common way to represent a one-sglist array: #define DEFINE_SG_MULTI(name, num) \ struct { \ struct sg_multilist ml; \ struct scatterlist *sg_array; \ struct scatterlist sg; \ struct scatterelem elems[num]; \ } name = { .ml = { 1 }, .sg_array = &name.sg } Now simply replace all the places which expect a "struct scatterlist" with "struct sg_multilist" and we're done. Using dangling structures is not as neat as using pointers, but it's very efficient. I changed the sg_chain() function not to take one off the argument. It made more sense when I wrote the virtblk code (here it's natural, since the num elements used + 1 == size of array). Agreed, and it was the use of "prv_nents - 2" in that code which made me think the arg should be "num used" not "one past the num used". Cheers, Rusty. -
| Arjan van de Ven | [patch] Add basic sanity checks to the syscall execution patch |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Karl Meyer | PROBLEM: 2.6.23-rc "NETDEV WATCHDOG: eth0: transmit timed out" |
| Greg Kroah-Hartman | [PATCH 022/196] adb: Convert from class_device to device |
git: | |
| Jakub Narebski | Re: VCS comparison table |
| Mark Levedahl | Re: [PATCH] Teach remote machinery about remotes.default config variable |
| Matthieu Moy | git push to a non-bare repository |
| Jon Smirl | Re: Calculating tree nodes |
| Marco Peereboom | Re: Real men don't attack straw men |
| Richard Stallman | Real men don't attack straw men |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Tony Abernethy | Re: What is our ultimate goal?? |
| Felix Radensky | RE: e1000e "Detected Tx Unit Hang" |
| Jeff Garzik | Re: [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Andy Grover | [PATCH] RDS: Add AF and PF defines for RDS sockets |
| David Miller | Re: [PATCH] inet6: Fix paramater issue of inet6_csk_xmit |
