mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dev-type: dev_is_pmem reuses topology read code
This commit is contained in:
parent
2c597c73a8
commit
e429e69b65
@ -35,39 +35,6 @@
|
|||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* dev is pmem if /sys/dev/block/<major>:<minor>/queue/dax is 1
|
|
||||||
*/
|
|
||||||
|
|
||||||
int dev_is_pmem(struct device *dev)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
char path[PATH_MAX];
|
|
||||||
int is_pmem = 0;
|
|
||||||
|
|
||||||
if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/queue/dax",
|
|
||||||
dm_sysfs_dir(),
|
|
||||||
(int) MAJOR(dev->dev),
|
|
||||||
(int) MINOR(dev->dev)) < 0) {
|
|
||||||
log_warn("Sysfs path for %s dax is too long.", dev_name(dev));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(fp = fopen(path, "r")))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (fscanf(fp, "%d", &is_pmem) != 1)
|
|
||||||
log_warn("Failed to parse DAX %s.", path);
|
|
||||||
|
|
||||||
if (is_pmem)
|
|
||||||
log_debug("%s is pmem", dev_name(dev));
|
|
||||||
|
|
||||||
if (fclose(fp))
|
|
||||||
log_sys_debug("fclose", path);
|
|
||||||
|
|
||||||
return is_pmem ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An nvme device has major number 259 (BLKEXT), minor number <minor>,
|
* An nvme device has major number 259 (BLKEXT), minor number <minor>,
|
||||||
* and reading /sys/dev/block/259:<minor>/device/dev shows a character
|
* and reading /sys/dev/block/259:<minor>/device/dev shows a character
|
||||||
@ -1078,6 +1045,13 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev)
|
|||||||
{
|
{
|
||||||
return (int) _dev_topology_attribute(dt, "queue/rotational", dev, 1UL);
|
return (int) _dev_topology_attribute(dt, "queue/rotational", dev, 1UL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* dev is pmem if /sys/dev/block/<major>:<minor>/queue/dax is 1 */
|
||||||
|
int dev_is_pmem(struct dev_types *dt, struct device *dev)
|
||||||
|
{
|
||||||
|
return (int) _dev_topology_attribute(dt, "queue/dax", dev, 0UL);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
|
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
|
||||||
@ -1114,6 +1088,11 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev)
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_is_pmem(struct dev_types *dt, struct device *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef UDEV_SYNC_SUPPORT
|
#ifdef UDEV_SYNC_SUPPORT
|
||||||
|
@ -93,7 +93,7 @@ unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev);
|
|||||||
|
|
||||||
int dev_is_rotational(struct dev_types *dt, struct device *dev);
|
int dev_is_rotational(struct dev_types *dt, struct device *dev);
|
||||||
|
|
||||||
int dev_is_pmem(struct device *dev);
|
int dev_is_pmem(struct dev_types *dt, struct device *dev);
|
||||||
|
|
||||||
int dev_is_nvme(struct dev_types *dt, struct device *dev);
|
int dev_is_nvme(struct dev_types *dt, struct device *dev);
|
||||||
|
|
||||||
|
@ -4436,11 +4436,11 @@ int lv_on_pmem(struct logical_volume *lv)
|
|||||||
for (s = 0; s < seg->area_count; s++) {
|
for (s = 0; s < seg->area_count; s++) {
|
||||||
pv = seg_pv(seg, s);
|
pv = seg_pv(seg, s);
|
||||||
|
|
||||||
if (dev_is_pmem(pv->dev)) {
|
if (dev_is_pmem(lv->vg->cmd->dev_types, pv->dev)) {
|
||||||
log_debug("LV %s dev %s is pmem.", lv->name, dev_name(pv->dev));
|
log_debug("LV %s dev %s is pmem.", display_lvname(lv), dev_name(pv->dev));
|
||||||
pmem_devs++;
|
pmem_devs++;
|
||||||
} else {
|
} else {
|
||||||
log_debug("LV %s dev %s not pmem.", lv->name, dev_name(pv->dev));
|
log_debug("LV %s dev %s not pmem.", display_lvname(lv), dev_name(pv->dev));
|
||||||
other_devs++;
|
other_devs++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4452,7 +4452,7 @@ int lv_on_pmem(struct logical_volume *lv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pmem_devs) {
|
if (pmem_devs) {
|
||||||
log_debug("LV %s on pmem", lv->name);
|
log_debug("LV %s on pmem", display_lvname(lv));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user