volume_id: abort early on read failures.

should help with probing missing fdd's
This commit is contained in:
Denis Vlasenko
2009-02-15 05:51:19 +00:00
parent 93b38208d1
commit 28ea4298e3
20 changed files with 99 additions and 70 deletions

View File

@@ -45,8 +45,8 @@
#define ENABLE_FEATURE_VOLUMEID_UFS 0
typedef int (*raid_probe_fptr)(struct volume_id *id, uint64_t off, uint64_t size);
typedef int (*probe_fptr)(struct volume_id *id, uint64_t off);
typedef int (*raid_probe_fptr)(struct volume_id *id, /*uint64_t off,*/ uint64_t size);
typedef int (*probe_fptr)(struct volume_id *id /*, uint64_t off*/);
static const raid_probe_fptr raid1[] = {
#if ENABLE_FEATURE_VOLUMEID_LINUXRAID
@@ -150,43 +150,49 @@ static const probe_fptr fs2[] = {
#endif
};
int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)
int volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64_t size)
{
unsigned i;
if (id == NULL)
return -EINVAL;
/* probe for raid first, cause fs probes may be successful on raid members */
if (size) {
for (i = 0; i < ARRAY_SIZE(raid1); i++)
if (raid1[i](id, off, size) == 0)
for (i = 0; i < ARRAY_SIZE(raid1); i++) {
if (raid1[i](id, /*off,*/ size) == 0)
goto ret;
if (id->error)
goto ret;
}
}
for (i = 0; i < ARRAY_SIZE(raid2); i++)
if (raid2[i](id, off) == 0)
for (i = 0; i < ARRAY_SIZE(raid2); i++) {
if (raid2[i](id /*,off*/) == 0)
goto ret;
if (id->error)
goto ret;
}
/* signature in the first block, only small buffer needed */
for (i = 0; i < ARRAY_SIZE(fs1); i++)
if (fs1[i](id, off) == 0)
for (i = 0; i < ARRAY_SIZE(fs1); i++) {
if (fs1[i](id /*,off*/) == 0)
goto ret;
if (id->error)
goto ret;
}
/* fill buffer with maximum */
volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
for (i = 0; i < ARRAY_SIZE(fs2); i++)
if (fs2[i](id, off) == 0)
for (i = 0; i < ARRAY_SIZE(fs2); i++) {
if (fs2[i](id /*,off*/) == 0)
goto ret;
return -1;
if (id->error)
goto ret;
}
ret:
/* If the filestystem in recognized, we free the allocated buffers,
otherwise they will stay in place for the possible next probe call */
volume_id_free_buffer(id);
return (- id->error); /* 0 or -1 */
return 0;
}
/* open volume by device node */