Experiment about SG_FLAG_DIRECT_IO

This commit is contained in:
Thomas Schmitt 2009-11-20 13:48:44 +00:00
parent c8e0472637
commit f39ff2c2f6
4 changed files with 38 additions and 2 deletions

View File

@ -1 +1 @@
#define Cdrskin_timestamP "2009.11.18.185733" #define Cdrskin_timestamP "2009.11.20.134952"

View File

@ -2831,4 +2831,11 @@ int burn_drive_probe_cd_write_modes(struct burn_drive_info *drive_info)
#endif /* Libburn_pioneer_dvr_216d_dummy_probe_wM */ #endif /* Libburn_pioneer_dvr_216d_dummy_probe_wM */
/* ts A91120 */
/* Allocate write buffer via mmap() rather than calloc() and use flag
SG_FLAG_DIRECT_IO when running ioctl(SG_IO).
#define Libburn_mmap_write_buffeR 1
*/
#endif /*LIBBURN_H*/ #endif /*LIBBURN_H*/

View File

@ -2,8 +2,10 @@
/* <<< ts A91112 : experiments to get better speed with USB /* <<< ts A91112 : experiments to get better speed with USB
#define Libburn_sgio_as_growisofS 1
*/ */
#ifdef Libburn_mmap_write_buffeR
#define Libburn_sgio_as_growisofS 1
#endif
/* /*

View File

@ -50,6 +50,12 @@
extern struct libdax_msgs *libdax_messenger; extern struct libdax_msgs *libdax_messenger;
/* ts A91120 : <<< experimental */
#ifdef Libburn_mmap_write_buffeR
#include <sys/mman.h>
#endif
/* The maximum output size to be used with CD media. This is also curbed /* The maximum output size to be used with CD media. This is also curbed
by BURN_OS_TRANSPORT_BUFFER_SIZE. The smaller number gets into effect. by BURN_OS_TRANSPORT_BUFFER_SIZE. The smaller number gets into effect.
*/ */
@ -2307,6 +2313,11 @@ void burn_disc_write_sync(struct burn_write_opts *o, struct burn_disc *disc)
off_t default_size; off_t default_size;
char msg[80]; char msg[80];
#ifdef Libburn_mmap_write_buffeR
size_t buffer_size;
#endif
/* ts A60924 : libburn/message.c gets obsoleted /* ts A60924 : libburn/message.c gets obsoleted
burn_message_clear_queue(); burn_message_clear_queue();
*/ */
@ -2321,9 +2332,21 @@ void burn_disc_write_sync(struct burn_write_opts *o, struct burn_disc *disc)
else else
d->stream_recording_start = 0; d->stream_recording_start = 0;
#ifdef Libburn_mmap_write_buffeR
fprintf(stderr,
"libburn_EXPERIMENTAL: allocating write buffer via mmap()\n");
buffer_size = sizeof(struct buffer);
if (buffer_size % (64 * 1024))
buffer_size += 64 * 1024 - (buffer_size % (64 * 1024));
d->buffer = mmap(NULL, buffer_size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANONYMOUS, -1, (off_t) 0);
if(d->buffer == MAP_FAILED)
goto fail_wo_sync;
#else
d->buffer = calloc(sizeof(struct buffer), 1); d->buffer = calloc(sizeof(struct buffer), 1);
if (d->buffer == NULL) if (d->buffer == NULL)
goto fail_wo_sync; goto fail_wo_sync;
#endif /* ! Libburn_mmap_write_buffeR */
/* >>> ts A90321 /* >>> ts A90321
@ -2546,7 +2569,11 @@ fail_wo_sync:;
ex:; ex:;
d->do_stream_recording = 0; d->do_stream_recording = 0;
if (d->buffer != NULL) if (d->buffer != NULL)
#ifdef Libburn_mmap_write_buffeR
munmap(d->buffer, buffer_size);
#else
free((char *) d->buffer); free((char *) d->buffer);
#endif
d->buffer = buffer_mem; d->buffer = buffer_mem;
return; return;
} }