mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-20 23:16:28 -05:00
When logging device attributes, also provide the split information
This commit is contained in:
parent
bb3aae2f40
commit
efcdfb9118
8 changed files with 119 additions and 101 deletions
|
|
@ -21,6 +21,14 @@
|
|||
#include "state.h"
|
||||
#include "raid/raid.h"
|
||||
|
||||
void device_name_set(devinfo_t* dev, const char* name, int index)
|
||||
{
|
||||
if (index == 0)
|
||||
pathcpy(dev->name, sizeof(dev->name), name);
|
||||
else
|
||||
pathprint(dev->name, sizeof(dev->name), "%s/%d", name, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* The following are Failure Rate tables computed from the data that
|
||||
* BackBlaze made available at:
|
||||
|
|
@ -881,7 +889,7 @@ int devtest(tommy_list* high, tommy_list* low, int operation)
|
|||
pathprint(entry->serial, sizeof(entry->serial), "FAKE_%s", devinfo->serial);
|
||||
pathprint(entry->vendor, sizeof(entry->vendor), "FAKE_%s", devinfo->vendor);
|
||||
pathprint(entry->model, sizeof(entry->model), "FAKE_%s", devinfo->model);
|
||||
pathprint(entry->file, sizeof(entry->name), "FAKE_%s", devinfo->file);
|
||||
pathprint(entry->file, sizeof(entry->file), "FAKE_%s", devinfo->file);
|
||||
pathcpy(entry->name, sizeof(entry->name), devinfo->name);
|
||||
entry->info[INFO_SIZE] = count * TERA;
|
||||
entry->info[INFO_ROTATION_RATE] = 7200;
|
||||
|
|
@ -934,7 +942,7 @@ void state_device(struct snapraid_state* state, int operation, tommy_list* filte
|
|||
entry = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
entry->device = disk->device;
|
||||
pathcpy(entry->name, sizeof(entry->name), disk->name);
|
||||
device_name_set(entry, disk->name, 0);
|
||||
pathcpy(entry->mount, sizeof(entry->mount), disk->dir);
|
||||
pathcpy(entry->smartctl, sizeof(entry->smartctl), disk->smartctl);
|
||||
memcpy(entry->smartignore, disk->smartignore, sizeof(entry->smartignore));
|
||||
|
|
@ -954,7 +962,7 @@ void state_device(struct snapraid_state* state, int operation, tommy_list* filte
|
|||
entry = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
entry->device = state->parity[j].split_map[s].device;
|
||||
pathcpy(entry->name, sizeof(entry->name), lev_config_name(j));
|
||||
device_name_set(entry, lev_config_name(j), s);
|
||||
pathcpy(entry->mount, sizeof(entry->mount), state->parity[j].split_map[s].path);
|
||||
pathcpy(entry->smartctl, sizeof(entry->smartctl), state->parity[j].smartctl);
|
||||
memcpy(entry->smartignore, state->parity[j].smartignore, sizeof(entry->smartignore));
|
||||
|
|
|
|||
|
|
@ -2312,7 +2312,7 @@ static int devresolve(const char* mount, char* file, size_t file_size, char* wfi
|
|||
/**
|
||||
* Read a device tree filling the specified list of disk_t entries.
|
||||
*/
|
||||
static int devtree(const char* name, const char* smartctl, const int* smartignore, const char* wfile, devinfo_t* parent, tommy_list* list)
|
||||
static int devtree(devinfo_t* parent, tommy_list* list)
|
||||
{
|
||||
wchar_t conv_buf[CONV_MAX];
|
||||
HANDLE h;
|
||||
|
|
@ -2325,7 +2325,7 @@ static int devtree(const char* name, const char* smartctl, const int* smartignor
|
|||
DWORD i;
|
||||
|
||||
/* open the volume */
|
||||
h = CreateFileW(convert(conv_buf, wfile), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||
h = CreateFileW(convert(conv_buf, parent->wfile), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
windows_errno(GetLastError());
|
||||
return -1;
|
||||
|
|
@ -2360,9 +2360,9 @@ static int devtree(const char* name, const char* smartctl, const int* smartignor
|
|||
|
||||
devinfo = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
pathcpy(devinfo->name, sizeof(devinfo->name), name);
|
||||
pathcpy(devinfo->smartctl, sizeof(devinfo->smartctl), smartctl);
|
||||
memcpy(devinfo->smartignore, smartignore, sizeof(devinfo->smartignore));
|
||||
pathcpy(devinfo->name, sizeof(devinfo->name), parent->name);
|
||||
pathcpy(devinfo->smartctl, sizeof(devinfo->smartctl), parent->smartctl);
|
||||
memcpy(devinfo->smartignore, parent->smartignore, sizeof(devinfo->smartignore));
|
||||
devinfo->device = vde->Extents[i].DiskNumber;
|
||||
pathprint(devinfo->file, sizeof(devinfo->file), "/dev/pd%" PRIu64, devinfo->device);
|
||||
pathprint(devinfo->wfile, sizeof(devinfo->wfile), "\\\\.\\PhysicalDrive%" PRIu64, devinfo->device);
|
||||
|
|
@ -2992,7 +2992,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
}
|
||||
|
||||
/* expand the tree of devices */
|
||||
if (devtree(devinfo->name, devinfo->smartctl, devinfo->smartignore, devinfo->wfile, devinfo, low) != 0) {
|
||||
if (devtree(devinfo, low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to expand device '%s'.\n", devinfo->file);
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ int randomize(void* ptr, size_t size);
|
|||
*/
|
||||
struct devinfo_struct {
|
||||
uint64_t device; /**< Device ID. */
|
||||
char name[PATH_MAX]; /**< Name of the disk. */
|
||||
char name[PATH_MAX]; /**< Name of the disk combined with the split index if any */
|
||||
char mount[PATH_MAX]; /**< Mount point or other contained directory. */
|
||||
char smartctl[PATH_MAX]; /**< Options for smartctl. */
|
||||
int smartignore[SMART_IGNORE_MAX]; /**< Attribues to ignore */
|
||||
|
|
@ -526,6 +526,8 @@ struct devinfo_struct {
|
|||
};
|
||||
typedef struct devinfo_struct devinfo_t;
|
||||
|
||||
void device_name_set(devinfo_t* dev, const char* name, int index);
|
||||
|
||||
#define DEVICE_LIST 0
|
||||
#define DEVICE_DOWN 1
|
||||
#define DEVICE_UP 2
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
entry = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
entry->device = disk->device;
|
||||
pathcpy(entry->name, sizeof(entry->name), disk->name);
|
||||
device_name_set(entry, disk->name, 0);
|
||||
pathcpy(entry->mount, sizeof(entry->mount), disk->dir);
|
||||
pathcpy(entry->smartctl, sizeof(entry->smartctl), disk->smartctl);
|
||||
memcpy(entry->smartignore, disk->smartignore, sizeof(entry->smartignore));
|
||||
|
|
@ -176,7 +176,7 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
entry = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
entry->device = state->parity[j].split_map[s].device;
|
||||
pathcpy(entry->name, sizeof(entry->name), lev_config_name(j));
|
||||
device_name_set(entry, lev_config_name(j), s);
|
||||
pathcpy(entry->mount, sizeof(entry->mount), state->parity[j].split_map[s].path);
|
||||
pathcpy(entry->smartctl, sizeof(entry->smartctl), state->parity[j].smartctl);
|
||||
memcpy(entry->smartignore, state->parity[j].smartignore, sizeof(entry->smartignore));
|
||||
|
|
|
|||
|
|
@ -993,7 +993,7 @@ static dev_t devread(const char* path)
|
|||
* Read a device tree filling the specified list of disk_t entries.
|
||||
*/
|
||||
#if HAVE_LINUX_DEVICE
|
||||
static int devtree(const char* name, const char* smartctl, const int* smartignore, dev_t device, devinfo_t* parent, tommy_list* list)
|
||||
static int devtree(devinfo_t* parent, dev_t device, tommy_list* list)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
DIR* d;
|
||||
|
|
@ -1021,7 +1021,7 @@ static int devtree(const char* name, const char* smartctl, const int* smartignor
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (devtree(name, smartctl, smartignore, subdev, parent, list) != 0) {
|
||||
if (devtree(parent, subdev, list) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
closedir(d);
|
||||
return -1;
|
||||
|
|
@ -1065,9 +1065,9 @@ static int devtree(const char* name, const char* smartctl, const int* smartignor
|
|||
devinfo = calloc_nofail(1, sizeof(devinfo_t));
|
||||
|
||||
devinfo->device = device;
|
||||
pathcpy(devinfo->name, sizeof(devinfo->name), name);
|
||||
pathcpy(devinfo->smartctl, sizeof(devinfo->smartctl), smartctl);
|
||||
memcpy(devinfo->smartignore, smartignore, sizeof(devinfo->smartignore));
|
||||
pathcpy(devinfo->name, sizeof(devinfo->name), parent->name);
|
||||
pathcpy(devinfo->smartctl, sizeof(devinfo->smartctl), parent->smartctl);
|
||||
memcpy(devinfo->smartignore, parent->smartignore, sizeof(devinfo->smartignore));
|
||||
pathcpy(devinfo->file, sizeof(devinfo->file), path);
|
||||
devinfo->parent = parent;
|
||||
|
||||
|
|
@ -1713,7 +1713,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
}
|
||||
|
||||
/* expand the tree of devices */
|
||||
if (devtree(devinfo->name, devinfo->smartctl, devinfo->smartignore, device, devinfo, low) != 0) {
|
||||
if (devtree(devinfo, device, low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to expand device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue