mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
o replace {stack; return 0;}'s with a macro (just for this file).
This commit is contained in:
parent
9d3f8b7144
commit
06985de900
@ -8,6 +8,7 @@
|
|||||||
#include "disk-rep.h"
|
#include "disk-rep.h"
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
|
|
||||||
|
#define fail do {stack; return 0;} while(0)
|
||||||
#define xx16(v) disk->v = xlate16(disk->v)
|
#define xx16(v) disk->v = xlate16(disk->v)
|
||||||
#define xx32(v) disk->v = xlate32(disk->v)
|
#define xx32(v) disk->v = xlate32(disk->v)
|
||||||
#define xx64(v) disk->v = xlate64(disk->v)
|
#define xx64(v) disk->v = xlate64(disk->v)
|
||||||
@ -96,10 +97,8 @@ static void _xlate_extents(struct pe_disk *extents, int count)
|
|||||||
static int _read_pv(struct data_list *data)
|
static int _read_pv(struct data_list *data)
|
||||||
{
|
{
|
||||||
struct pv_disk *pvd = &data->pv;
|
struct pv_disk *pvd = &data->pv;
|
||||||
if (dev_read(data->dev, 0, sizeof(*pvd), pvd) != sizeof(*pvd)) {
|
if (dev_read(data->dev, 0, sizeof(*pvd), pvd) != sizeof(*pvd))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_xlate_pv(pvd);
|
_xlate_pv(pvd);
|
||||||
memset(pvd->pv_name, 0, sizeof (pvd->pv_name));
|
memset(pvd->pv_name, 0, sizeof (pvd->pv_name));
|
||||||
@ -110,10 +109,9 @@ static int _read_pv(struct data_list *data)
|
|||||||
|
|
||||||
static int _read_lv(struct device *dev, ulong pos, struct lv_disk *disk)
|
static int _read_lv(struct device *dev, ulong pos, struct lv_disk *disk)
|
||||||
{
|
{
|
||||||
if (dev_read(dev, pos, sizeof(*disk), disk) != sizeof(*disk)) {
|
if (dev_read(dev, pos, sizeof(*disk), disk) != sizeof(*disk))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_lv(disk);
|
_xlate_lv(disk);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -123,10 +121,9 @@ static int _read_vg(struct disk_list *data)
|
|||||||
{
|
{
|
||||||
struct vg_disk *vgd = &data->vg;
|
struct vg_disk *vgd = &data->vg;
|
||||||
unsigned long pos = data->pv.vg_on_disk.base;
|
unsigned long pos = data->pv.vg_on_disk.base;
|
||||||
if (dev_read(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd)) {
|
if (dev_read(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_vg(vgd);
|
_xlate_vg(vgd);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -142,15 +139,11 @@ static int _read_uuids(struct disk_list *data)
|
|||||||
|
|
||||||
while(pos < end && num_read < MAX_PV) {
|
while(pos < end && num_read < MAX_PV) {
|
||||||
if (dev_read(data->dev, pos, sizeof(buffer), buffer) !=
|
if (dev_read(data->dev, pos, sizeof(buffer), buffer) !=
|
||||||
sizeof(buffer)) {
|
sizeof(buffer))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(ul = pool_alloc(data->mem, sizeof(*ul)))) {
|
if (!(ul = pool_alloc(data->mem, sizeof(*ul))))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(ul->uuid, buffer, NAME_LEN);
|
memcpy(ul->uuid, buffer, NAME_LEN);
|
||||||
ul->uuid[NAME_LEN] = '\0';
|
ul->uuid[NAME_LEN] = '\0';
|
||||||
@ -173,15 +166,11 @@ static int _read_lvs(struct disk_list *data)
|
|||||||
pos = data->pv.lv_on_disk.base + (i * sizeof(struct lv_disk));
|
pos = data->pv.lv_on_disk.base + (i * sizeof(struct lv_disk));
|
||||||
struct lv_list *ll = pool_alloc(sizeof(*ll));
|
struct lv_list *ll = pool_alloc(sizeof(*ll));
|
||||||
|
|
||||||
if (!ll) {
|
if (!ll)
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_read_lv(data->dev, pos, &ll->lv)) {
|
if (!_read_lv(data->dev, pos, &ll->lv))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
list_add(&ll->list, &data->lvs);
|
list_add(&ll->list, &data->lvs);
|
||||||
}
|
}
|
||||||
@ -195,15 +184,12 @@ static int _read_extents(struct disk_list *data)
|
|||||||
struct pe_disk *extents = pool_alloc(data->mem, len);
|
struct pe_disk *extents = pool_alloc(data->mem, len);
|
||||||
unsigned long pos = data->pv.pe_on_disk.base;
|
unsigned long pos = data->pv.pe_on_disk.base;
|
||||||
|
|
||||||
if (!extents) {
|
if (!extents)
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
if (dev_read(data->dev, pos, len, extents) != len)
|
||||||
|
fail;
|
||||||
|
|
||||||
if (dev_read(data->dev, pos, len, extents) != len) {
|
|
||||||
stack;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_extents(extents, data->pv.pe_total);
|
_xlate_extents(extents, data->pv.pe_total);
|
||||||
data->extents = extents;
|
data->extents = extents;
|
||||||
|
|
||||||
@ -290,10 +276,9 @@ static int _write_vg(struct disk_list *data)
|
|||||||
unsigned long pos = data->pv.vg_on_disk.base;
|
unsigned long pos = data->pv.vg_on_disk.base;
|
||||||
|
|
||||||
_xlate_vg(vgd);
|
_xlate_vg(vgd);
|
||||||
if (dev_write(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd)) {
|
if (dev_write(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_vg(vgd);
|
_xlate_vg(vgd);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -315,11 +300,10 @@ static int _write_uuids(struct disk_list *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ul = list_entry(tmp, struct uuid_list, list);
|
ul = list_entry(tmp, struct uuid_list, list);
|
||||||
if (dev_write(data->dev, pos, sizeof(NAME_LEN), NAME_LEN) !=
|
if (dev_write(data->dev, pos,
|
||||||
NAME_LEN) {
|
sizeof(NAME_LEN), NAME_LEN) != NAME_LEN)
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
pos += NAME_LEN;
|
pos += NAME_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,10 +313,9 @@ static int _write_uuids(struct disk_list *data)
|
|||||||
static int _write_lv(struct device *dev, ulong pos, struct lv_disk *disk)
|
static int _write_lv(struct device *dev, ulong pos, struct lv_disk *disk)
|
||||||
{
|
{
|
||||||
_xlate_lv(disk);
|
_xlate_lv(disk);
|
||||||
if (dev_write(dev, pos, sizeof(*disk), disk) != sizeof(*disk)) {
|
if (dev_write(dev, pos, sizeof(*disk), disk) != sizeof(*disk))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_lv(disk);
|
_xlate_lv(disk);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -345,10 +328,8 @@ static int _write_lvs(struct disk_list *data)
|
|||||||
list_for_each(tmp, &data->lvs) {
|
list_for_each(tmp, &data->lvs) {
|
||||||
struct lv_list *ll = list_entry(tmp, struct lv_list, list);
|
struct lv_list *ll = list_entry(tmp, struct lv_list, list);
|
||||||
|
|
||||||
if (!_write_lv(data->dev, pos, &ll->lv)) {
|
if (!_write_lv(data->dev, pos, &ll->lv))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pos += sizeof(struct lv_disk);
|
pos += sizeof(struct lv_disk);
|
||||||
}
|
}
|
||||||
@ -363,10 +344,9 @@ static int _write_extents(struct disk_list *data)
|
|||||||
unsigned long pos = data->pv.pe_on_disk.base;
|
unsigned long pos = data->pv.pe_on_disk.base;
|
||||||
|
|
||||||
_xlate_extents(extents, data->pv.pe_total);
|
_xlate_extents(extents, data->pv.pe_total);
|
||||||
if (dev_write(data->dev, 0, len, extents) != len) {
|
if (dev_write(data->dev, 0, len, extents) != len)
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_extents(extents, data->pv.pe_total);
|
_xlate_extents(extents, data->pv.pe_total);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -377,10 +357,9 @@ static int _write_pv(struct disk_list *data)
|
|||||||
struct pv_disk *disk = &data->pv;
|
struct pv_disk *disk = &data->pv;
|
||||||
|
|
||||||
_xlate_pv(disk);
|
_xlate_pv(disk);
|
||||||
if (dev_write(data->dev, 0, sizeof(*disk), disk) != sizeof(&disk)) {
|
if (dev_write(data->dev, 0, sizeof(*disk), disk) != sizeof(&disk))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_xlate_pv(disk);
|
_xlate_pv(disk);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -421,7 +400,8 @@ static int _write_all_pv(struct disk_list *data)
|
|||||||
/*
|
/*
|
||||||
* Writes all the given pv's to disk. Does very
|
* Writes all the given pv's to disk. Does very
|
||||||
* little sanity checking, so make sure correct
|
* little sanity checking, so make sure correct
|
||||||
* data is passed to here. */
|
* data is passed to here.
|
||||||
|
*/
|
||||||
int write_pvs(struct list_head *pvs)
|
int write_pvs(struct list_head *pvs)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
@ -429,10 +409,9 @@ int write_pvs(struct list_head *pvs)
|
|||||||
|
|
||||||
list_for_each(tmp, pvs) {
|
list_for_each(tmp, pvs) {
|
||||||
dl = list_entry(tmp, struct disk_list, list);
|
dl = list_entry(tmp, struct disk_list, list);
|
||||||
if (!(_write_all_pv(dl))) {
|
if (!(_write_all_pv(dl)))
|
||||||
stack;
|
fail;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
log_debug("successfully wrote data to %s\n", dl->dev->name);
|
log_debug("successfully wrote data to %s\n", dl->dev->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user