1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

device: Add reason to devbuf.

This commit is contained in:
Alasdair G Kergon 2018-01-15 19:38:18 +00:00
parent 1f01eaa612
commit c90582344d
2 changed files with 6 additions and 4 deletions

View File

@ -142,7 +142,7 @@ static int _io_sync(struct device_buffer *devbuf)
return (total == (size_t) where->size);
}
static int _io(struct device_buffer *devbuf, dev_io_reason_t reason)
static int _io(struct device_buffer *devbuf)
{
struct device_area *where = &devbuf->where;
int fd = dev_fd(where->dev);
@ -156,7 +156,7 @@ static int _io(struct device_buffer *devbuf, dev_io_reason_t reason)
log_debug_io("%s %s(fd %d):%8" PRIu64 " bytes (sync) at %" PRIu64 "%s (for %s)",
devbuf->write ? "Write" : "Read ", dev_name(where->dev), fd,
where->size, (uint64_t) where->start,
(devbuf->write && test_mode()) ? " (test mode - suppressed)" : "", _reason_text(reason));
(devbuf->write && test_mode()) ? " (test mode - suppressed)" : "", _reason_text(devbuf->reason));
/*
* Skip all writes in test mode.
@ -327,10 +327,11 @@ static int _aligned_io(struct device_area *where, char *buffer,
devbuf->where.start = widened.start;
devbuf->where.size = widened.size;
devbuf->write = 0;
devbuf->reason = reason;
/* Do we need to read into the bounce buffer? */
if ((!should_write || buffer_was_widened) &&
!_io(devbuf, reason)) {
!_io(devbuf)) {
if (!should_write)
goto_bad;
/* FIXME Handle errors properly! */
@ -348,7 +349,7 @@ static int _aligned_io(struct device_area *where, char *buffer,
/* ... then we write */
devbuf->write = 1;
if (!(r = _io(devbuf, reason)))
if (!(r = _io(devbuf)))
goto_bad;
_release_devbuf(devbuf);

View File

@ -90,6 +90,7 @@ struct device_buffer {
void *malloc_address; /* Start of allocated memory */
void *buf; /* Aligned buffer that contains data within it */
struct device_area where; /* Location of buf */
dev_io_reason_t reason;
unsigned write:1; /* 1 if write; 0 if read */
};