Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 308994 Details for
Bug 450948
nash 'dm create' command requires major:minor numbers when establishing multipath
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
This is a patch for mkinitrd-6.0.19 that creates a new nash command.
mpdiff.patch (text/plain), 6.28 KB, created by
Glenn Watkins
on 2008-06-11 20:53:14 UTC
(
hide
)
Description:
This is a patch for mkinitrd-6.0.19 that creates a new nash command.
Filename:
MIME Type:
Creator:
Glenn Watkins
Created:
2008-06-11 20:53:14 UTC
Size:
6.28 KB
patch
obsolete
>diff -up ./nash/nash.c.orig ./nash/nash.c >--- ./nash/nash.c.orig 2008-06-11 15:57:16.000000000 -0400 >+++ ./nash/nash.c 2008-06-11 15:55:42.000000000 -0400 >@@ -59,6 +59,9 @@ > > #include <nash.h> > >+#include <sysfs/libsysfs.h> >+#include <scsi/sg.h> >+ > #include "lib.h" > #include "util.h" > #include "block.h" >@@ -109,6 +112,12 @@ > #define MNT_DETACH 0x2 > #endif > >+#define UUID_PREFIX "mpath-" >+#define WWID_SIZE 128 >+#define SCSI_BUS "scsi" >+#define MULTIPATH_TYPE "multipath" >+static const char hex_str[]="0123456789abcdef"; >+ > #define PATH "/usr/bin:/bin:/sbin:/usr/sbin" > static char * env[] = { > "PATH=" PATH, >@@ -2333,6 +2342,176 @@ usage: > } > > static int >+multipathCommand(char *cmd, char *end) >+{ >+ int rc; >+ int sgfd, numPaths = 0; >+ int idLen, majminLen; >+ long long length = 0, devSize = 0; >+ long long start = 0; >+ char *name = NULL, *wwid = NULL; >+ char uuid[sizeof(UUID_PREFIX) + WWID_SIZE], sgwwid[WWID_SIZE], pathgrp[64], params[512], prefixparams[512]; >+ char devName[256], majmin[32]; >+ >+ int idType; >+ int i, j, k; >+ >+ struct sysfs_class *class; >+ struct sysfs_device *dev; >+ struct sysfs_class_device *classdev; >+ struct sysfs_attribute *attr; >+ struct dlist *classdevList; >+ >+ sg_io_hdr_t sghdr; >+ unsigned char sense_b[32]; >+ unsigned char sgcmd[6] = {0x12, 1, 0x83, 0, 254, 0}; >+ char buf[256]; >+ char *devId; >+ >+ memset(&sghdr, 0, sizeof(sg_io_hdr_t)); >+ >+ memset(pathgrp, 0, sizeof(pathgrp)); >+ memset(params, 0, sizeof(params)); >+ memset(prefixparams, 0, sizeof(prefixparams)); >+ >+ strncpy(devName, "/dev/", 5); >+ sgwwid[0] = '3'; //NAA Identifier >+ >+ //get name >+ cmd = getArg(cmd, end, &name); >+ if (!cmd) return 1; >+ >+ //get wwid >+ cmd = getArg(cmd, end, &wwid); >+ if (!cmd) return 1; >+ >+ //build uuid from wwid >+ strncpy(uuid, UUID_PREFIX, sizeof(UUID_PREFIX)); >+ strncat(uuid, wwid, WWID_SIZE); >+ >+ //open sysfs/block >+ class = sysfs_open_class(SYSFS_BLOCK_NAME); >+ if (class == NULL) { >+ printf("open class failed\n"); >+ return 1; >+ } >+ >+ //get the list of block devices >+ classdevList = sysfs_get_class_devices(class); >+ if (classdevList != NULL) { >+ >+ dlist_for_each_data(classdevList, classdev, struct sysfs_class_device) { >+ >+ //is it a scsi device? >+ dev = sysfs_get_classdev_device(classdev); >+ if ((dev != NULL) && (!strncmp(dev->bus, SCSI_BUS, sizeof(SCSI_BUS)))) { >+ >+ //open device >+ devName[5] = '\0'; >+ strncat(devName, classdev->name, SYSFS_NAME_LEN); >+ >+ if ((sgfd = open(devName, O_RDONLY | O_NONBLOCK)) >= 0) { >+ >+ //get wwid of device >+ sghdr.interface_id = 'S'; >+ sghdr.cmd_len = sizeof(sgcmd); >+ sghdr.mx_sb_len = sizeof(sense_b); >+ sghdr.dxfer_direction = SG_DXFER_FROM_DEV; >+ sghdr.dxfer_len = sizeof(buf); >+ sghdr.dxferp = buf; >+ sghdr.cmdp = sgcmd; >+ sghdr.sbp = sense_b; >+ sghdr.timeout = 30000; //30 second timeout >+ >+ if (ioctl(sgfd, SG_IO, &sghdr) >= 0) { >+ >+ for (i = 4; i <=(unsigned int)buf[3] + 3; i += buf[i+3] + 4) { >+ //printf("id type: %X\n", buf[j+1] & 0xF); >+ idType = buf[i+1] & 0xF; >+ if (idType == 3) { >+ //printf("code set: %x\n", buf[i] & 0xF); >+ //printf("association: %x\n", (buf[i+1] >> 4) & 0x3); >+ >+ idLen = buf[i+3]; >+ >+ devId = &buf[i+4]; >+ //printf("NAA field: %x\n", (devId[0] & 0xF0) >> 4); >+ >+ k = 1; >+ for (j = 0; j < idLen; j++) { >+ sgwwid[k++] = hex_str[(devId[j] & 0xF0) >> 4]; >+ sgwwid[k++] = hex_str[devId[j] & 0x0F]; >+ } >+ sgwwid[k] = '\0'; >+ >+ //printf("%s\n", sgwwid); >+ } >+ } >+ } >+ >+ //if wwid we're looking for >+ if (!strncmp(wwid, sgwwid, WWID_SIZE)) { >+ >+ //this was being called in the init script before the 'dm create' >+ //do it here because we can >+ if (nashDisablePartitions(classdev->name) < 1) >+ eprintf("mp: could not disable partitions for %s\n", classdev->name); >+ >+ //get size >+ attr = sysfs_get_classdev_attr(classdev, "size"); >+ if (attr != NULL) { >+ errno = 0; >+ devSize = strtoll(attr->value, NULL, 0); >+ if (errno) { >+ eprintf("mp: error getting size\n"); >+ return 1; >+ } >+ } >+ if (!length && devSize) length = devSize; >+ >+ //get major:minor >+ attr = sysfs_get_classdev_attr(classdev, "dev"); >+ if (attr != NULL) { >+ strncpy(majmin, attr->value, sizeof(majmin)); >+ >+ //remove trailing newline >+ majminLen = strlen(majmin); >+ if (majmin[majminLen-1] == '\n') { >+ majmin[majminLen-1] = '\0'; >+ } >+ >+ //create path group (round-robin 0 1 1 major:minor 1000) >+ sprintf(pathgrp, "round-robin 0 1 1 %s 1000 ", majmin); >+ >+ //add path group to params >+ strncat(params, pathgrp, sizeof(pathgrp)); >+ >+ //increment number of path groups >+ numPaths++; >+ } >+ } >+ } >+ } >+ } >+ } >+ >+ sysfs_close_class(class); >+ >+ if (numPaths < 1) { >+ eprintf("mp: not enough paths found\n"); >+ return 1; >+ } >+ >+ //prefix params (0 0 #pathgroups 1) >+ sprintf(prefixparams, "0 0 %d 1 ", numPaths); >+ strncat(prefixparams, params, sizeof(prefixparams) - strlen(prefixparams)); >+ >+ rc = nashDmCreate(_nash_context, name, uuid, start, length, MULTIPATH_TYPE, prefixparams); >+ >+ return rc; >+} >+ >+static int > mkDMNodCommand(char * cmd, char * end) > { > int n = -1; >@@ -2671,6 +2850,7 @@ static const struct commandHandler handl > { "mknod", mknodCommand }, > { "mkrootdev", mkrootdevCommand }, > { "mount", mountCommand }, >+ { "mp", multipathCommand}, > { "network", networkCommand }, > { "hotplug", hotplugCommand }, > { "killplug", killplugCommand }, >diff -up ./nash/Makefile.orig ./nash/Makefile >--- ./nash/Makefile.orig 2008-06-11 15:57:31.000000000 -0400 >+++ ./nash/Makefile 2008-05-23 18:02:16.000000000 -0400 >@@ -18,7 +18,7 @@ CFLAGS += $(shell pkg-config --cflags li > LDFLAGS += -Wl,-rpath-link,$(TOPDIR)/bdevid:$(TOPDIR)/nash > > nash_LIBPATHS = -L$(TOPDIR)/nash -L$(TOPDIR)/bdevid -L/$(LIB) >-nash_LIBS += -ldevmapper -lparted -lblkid -lselinux -lsepol >+nash_LIBS += -ldevmapper -lparted -lblkid -lselinux -lsepol -lsysfs > nash_LIBS += -luuid -lpopt -lresolv -ldl > nash_LIBS += $(shell pkg-config --libs libdhcp glib-2.0) -lm > # We need to link against libgcc_s directly, or it'll /dlopen() it during
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 450948
: 308994