* [PATCH v2] multipath: make devt2devname use lstat to check sysfs links
@ 2013-01-10 20:06 Benjamin Marzinski
2013-01-11 7:01 ` Hannes Reinecke
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Marzinski @ 2013-01-10 20:06 UTC (permalink / raw)
To: device-mapper development; +Cc: Christophe Varoqui
dm_reassign wasn't working correctly for me because devt2devname used stat()
to check if /sys/dev/block/major:minor was a symlink. But stat() never returns
a symlink, if follows it. It needs to use lstat() instead. Also, I made
multipath log a message when a dm device gets reassigned to use multipath.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
libmultipath/devmapper.c | 4 +++-
libmultipath/sysfs.c | 6 ++++--
libmultipath/util.c | 3 ++-
3 files changed, 9 insertions(+), 4 deletions(-)
Index: multipath-tools-130109/libmultipath/devmapper.c
===================================================================
--- multipath-tools-130109.orig/libmultipath/devmapper.c
+++ multipath-tools-130109/libmultipath/devmapper.c
@@ -1394,8 +1394,10 @@ int dm_reassign(const char *mapname)
return 1;
}
- if (!(dmt = dm_task_create(DM_DEVICE_DEPS)))
+ if (!(dmt = dm_task_create(DM_DEVICE_DEPS))) {
+ condlog(3, "%s: couldn't make dm task", mapname);
return 0;
+ }
if (!dm_task_set_name(dmt, mapname))
goto out;
Index: multipath-tools-130109/libmultipath/sysfs.c
===================================================================
--- multipath-tools-130109.orig/libmultipath/sysfs.c
+++ multipath-tools-130109/libmultipath/sysfs.c
@@ -125,8 +125,10 @@ int sysfs_check_holders(char * check_dev
return 0;
}
- if (devt2devname(check_dev, PATH_SIZE, check_devt))
+ if (devt2devname(check_dev, PATH_SIZE, check_devt)) {
+ condlog(1, "can't get devname for %s", check_devt);
return 0;
+ }
condlog(3, "%s: checking holder", check_dev);
@@ -153,7 +155,7 @@ int sysfs_check_holders(char * check_dev
}
table_name = dm_mapname(major, table_minor);
- condlog(3, "%s: reassign table %s old %s new %s", check_dev,
+ condlog(0, "%s: reassign table %s old %s new %s", check_dev,
table_name, check_devt, new_devt);
dm_reassign_table(table_name, check_devt, new_devt);
Index: multipath-tools-130109/libmultipath/util.c
===================================================================
--- multipath-tools-130109.orig/libmultipath/util.c
+++ multipath-tools-130109/libmultipath/util.c
@@ -161,6 +161,7 @@ devt2devname (char *devname, int devname
struct stat statbuf;
memset(block_path, 0, sizeof(block_path));
+ memset(dev, 0, sizeof(dev));
if (sscanf(devt, "%u:%u", &major, &minor) != 2) {
condlog(0, "Invalid device number %s", devt);
return 1;
@@ -172,7 +173,7 @@ devt2devname (char *devname, int devname
if (stat("/sys/dev/block", &statbuf) == 0) {
/* Newer kernels have /sys/dev/block */
sprintf(block_path,"/sys/dev/block/%u:%u", major, minor);
- if (stat(block_path, &statbuf) == 0) {
+ if (lstat(block_path, &statbuf) == 0) {
if (S_ISLNK(statbuf.st_mode) &&
readlink(block_path, dev, FILE_NAME_SIZE) > 0) {
char *p = strrchr(dev, '/');
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] multipath: make devt2devname use lstat to check sysfs links
2013-01-10 20:06 [PATCH v2] multipath: make devt2devname use lstat to check sysfs links Benjamin Marzinski
@ 2013-01-11 7:01 ` Hannes Reinecke
0 siblings, 0 replies; 2+ messages in thread
From: Hannes Reinecke @ 2013-01-11 7:01 UTC (permalink / raw)
To: dm-devel
On 01/10/2013 09:06 PM, Benjamin Marzinski wrote:
> dm_reassign wasn't working correctly for me because devt2devname used stat()
> to check if /sys/dev/block/major:minor was a symlink. But stat() never returns
> a symlink, if follows it. It needs to use lstat() instead. Also, I made
> multipath log a message when a dm device gets reassigned to use multipath.
>
> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Acked-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke zSeries & Storage
hare@suse.de +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-11 7:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-10 20:06 [PATCH v2] multipath: make devt2devname use lstat to check sysfs links Benjamin Marzinski
2013-01-11 7:01 ` Hannes Reinecke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.