mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
Add dev_read_circular, read 2 regions on same device.
This commit is contained in:
parent
cc5a4e1d38
commit
662e0238f0
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.25 -
|
Version 2.02.25 -
|
||||||
=================================
|
=================================
|
||||||
|
Add dev_read_circular.
|
||||||
Add pvck command stub.
|
Add pvck command stub.
|
||||||
Update lists of attribute characters in man pages.
|
Update lists of attribute characters in man pages.
|
||||||
Change cling alloc policy attribute character from 'C' to l'.
|
Change cling alloc policy attribute character from 'C' to l'.
|
||||||
|
@ -210,18 +210,10 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
|
|||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!dev_read(dev, (uint64_t) offset, size, buf)) {
|
if (!dev_read_circular(dev, (uint64_t) offset, size,
|
||||||
log_error("Read from %s failed", dev_name(dev));
|
(uint64_t) offset2, size2, buf)) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (size2) {
|
|
||||||
if (!dev_read(dev, (uint64_t) offset2, size2,
|
|
||||||
buf + size)) {
|
|
||||||
log_error("Circular read from %s failed",
|
|
||||||
dev_name(dev));
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p->fb = buf;
|
p->fb = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,6 +564,35 @@ int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer)
|
|||||||
return _aligned_io(&where, buffer, 0);
|
return _aligned_io(&where, buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read from 'dev' into 'buf', possibly in 2 distinct regions, denoted
|
||||||
|
* by (offset,len) and (offset2,len2). Thus, the total size of
|
||||||
|
* 'buf' should be len+len2.
|
||||||
|
*/
|
||||||
|
int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
|
||||||
|
uint64_t offset2, size_t len2, void *buf)
|
||||||
|
{
|
||||||
|
if (!dev_read(dev, offset, len, buf)) {
|
||||||
|
log_error("Read from %s failed", dev_name(dev));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The second region is optional, and allows for
|
||||||
|
* a circular buffer on the device.
|
||||||
|
*/
|
||||||
|
if (!len2)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!dev_read(dev, offset2, len2, buf + len)) {
|
||||||
|
log_error("Circular read from %s failed",
|
||||||
|
dev_name(dev));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME If O_DIRECT can't extend file, dev_extend first; dev_truncate after.
|
/* FIXME If O_DIRECT can't extend file, dev_extend first; dev_truncate after.
|
||||||
* But fails if concurrent processes writing
|
* But fails if concurrent processes writing
|
||||||
*/
|
*/
|
||||||
|
@ -78,6 +78,8 @@ int dev_fd(struct device *dev);
|
|||||||
const char *dev_name(const struct device *dev);
|
const char *dev_name(const struct device *dev);
|
||||||
|
|
||||||
int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
||||||
|
int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
|
||||||
|
uint64_t offset2, size_t len2, void *buf);
|
||||||
int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
||||||
int dev_append(struct device *dev, size_t len, void *buffer);
|
int dev_append(struct device *dev, size_t len, void *buffer);
|
||||||
int dev_set(struct device *dev, uint64_t offset, size_t len, int value);
|
int dev_set(struct device *dev, uint64_t offset, size_t len, int value);
|
||||||
|
Loading…
Reference in New Issue
Block a user