mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Replace alloca with dm_malloc in _aligned_io.
(This section of code dates from 2.4 and could be written more efficiently nowadays.)
This commit is contained in:
parent
980d2d8683
commit
0cb07b65f3
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.74 -
|
Version 2.02.74 -
|
||||||
=====================================
|
=====================================
|
||||||
|
Replace alloca with dm_malloc in _aligned_io.
|
||||||
Fix partial mode operations for lvm1 metadata format.
|
Fix partial mode operations for lvm1 metadata format.
|
||||||
Track recursive filter iteration to avoid refreshing while in use. (2.02.56)
|
Track recursive filter iteration to avoid refreshing while in use. (2.02.56)
|
||||||
Revert to old glibc vsnprintf behaviour in emit_to_buffer() to catch overflow.
|
Revert to old glibc vsnprintf behaviour in emit_to_buffer() to catch overflow.
|
||||||
|
@ -164,10 +164,11 @@ static void _widen_region(unsigned int block_size, struct device_area *region,
|
|||||||
static int _aligned_io(struct device_area *where, void *buffer,
|
static int _aligned_io(struct device_area *where, void *buffer,
|
||||||
int should_write)
|
int should_write)
|
||||||
{
|
{
|
||||||
void *bounce;
|
void *bounce, *bounce_buf;
|
||||||
unsigned int block_size = 0;
|
unsigned int block_size = 0;
|
||||||
uintptr_t mask;
|
uintptr_t mask;
|
||||||
struct device_area widened;
|
struct device_area widened;
|
||||||
|
int r = 0;
|
||||||
|
|
||||||
if (!(where->dev->flags & DEV_REGULAR) &&
|
if (!(where->dev->flags & DEV_REGULAR) &&
|
||||||
!_get_block_size(where->dev, &block_size))
|
!_get_block_size(where->dev, &block_size))
|
||||||
@ -185,8 +186,8 @@ static int _aligned_io(struct device_area *where, void *buffer,
|
|||||||
return _io(where, buffer, should_write);
|
return _io(where, buffer, should_write);
|
||||||
|
|
||||||
/* Allocate a bounce buffer with an extra block */
|
/* Allocate a bounce buffer with an extra block */
|
||||||
if (!(bounce = alloca((size_t) widened.size + block_size))) {
|
if (!(bounce_buf = bounce = dm_malloc((size_t) widened.size + block_size))) {
|
||||||
log_error("Bounce buffer alloca failed");
|
log_error("Bounce buffer malloc failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ static int _aligned_io(struct device_area *where, void *buffer,
|
|||||||
/* channel the io through the bounce buffer */
|
/* channel the io through the bounce buffer */
|
||||||
if (!_io(&widened, bounce, 0)) {
|
if (!_io(&widened, bounce, 0)) {
|
||||||
if (!should_write)
|
if (!should_write)
|
||||||
return_0;
|
goto_out;
|
||||||
/* FIXME pre-extend the file */
|
/* FIXME pre-extend the file */
|
||||||
memset(bounce, '\n', widened.size);
|
memset(bounce, '\n', widened.size);
|
||||||
}
|
}
|
||||||
@ -209,13 +210,18 @@ static int _aligned_io(struct device_area *where, void *buffer,
|
|||||||
(size_t) where->size);
|
(size_t) where->size);
|
||||||
|
|
||||||
/* ... then we write */
|
/* ... then we write */
|
||||||
return _io(&widened, bounce, 1);
|
r = _io(&widened, bounce, 1);
|
||||||
|
goto_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(buffer, bounce + (where->start - widened.start),
|
memcpy(buffer, bounce + (where->start - widened.start),
|
||||||
(size_t) where->size);
|
(size_t) where->size);
|
||||||
|
|
||||||
return 1;
|
r = 1;
|
||||||
|
|
||||||
|
out:
|
||||||
|
dm_free(bounce_buf);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _dev_get_size_file(const struct device *dev, uint64_t *size)
|
static int _dev_get_size_file(const struct device *dev, uint64_t *size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user