Project

General

Profile

Notes on libmultipath » History » Version 1

Version 1/2 - Next ยป - Current version
Gerhard Gonter (uni), 2012-10-02 06:29


Wiki

File source:libmultipath/print.c:

static int
snprint_hcil (char * buff, size_t len, struct path * pp)
{
        if (pp->sg_id.host_no < 0)
                return snprintf(buff, len, "#:#:#:#");

        return snprintf(buff, len, "%i:%i:%i:%i",
                        pp->sg_id.host_no,
                        pp->sg_id.channel,
                        pp->sg_id.scsi_id,
                        pp->sg_id.lun);
}

hcil == host channel ID LUN
definiert inf struct path pp, siehe
file source:libmultipath/structs.h:

struct sg_id {
        int host_no;
        int channel;
        int scsi_id;
        int lun;
        short h_cmd_per_lun;
        short d_queue_depth;
        int unused1;
        int unused2;
};

struct path {
        char dev[FILE_NAME_SIZE];
        char dev_t[BLK_DEV_SIZE];
        struct scsi_idlun scsi_id;
        struct sg_id sg_id;
        char wwid[WWID_SIZE];
        char vendor_id[SCSI_VENDOR_SIZE];
        char product_id[SCSI_PRODUCT_SIZE];
        char rev[SCSI_REV_SIZE];
        char serial[SERIAL_SIZE];
        char tgt_node_name[NODE_NAME_SIZE];
        unsigned long long size;
        unsigned int checkint;
        unsigned int tick;
        int bus;
        int state;
        int dmstate;
        int failcount;
        int priority;
        int pgindex;
        char * getuid;
        char * getprio;
        int getprio_selected;
        struct checker checker;
        struct multipath * mpp;
        int fd;

        /* configlet pointers */
        struct hwentry * hwe;
};

Befuellt wird sg_id in file source:libmultipath/discovery.c:

static int
scsi_sysfs_pathinfo (struct path * pp)
{
...
        /*
         * host / bus / target / lun
         */
        if(safe_sprintf(attr_path, "%s/block/%s/device",
                        sysfs_path, pp->dev)) {
                condlog(0, "attr_path too small");
                return 1;
        }
        if (0 > sysfs_get_link(attr_path, attr_buff, sizeof(attr_buff)))
                return 1;

        basename(attr_buff, attr_path);

        sscanf(attr_path, "%i:%i:%i:%i",
                        &pp->sg_id.host_no,
                        &pp->sg_id.channel,
                        &pp->sg_id.scsi_id,
                        &pp->sg_id.lun);
...
        /*
         * target node name
         */
        if(safe_sprintf(attr_path,
                        "%s/class/fc_transport/target%i:%i:%i/node_name",
                        sysfs_path,
                        pp->sg_id.host_no,
                        pp->sg_id.channel,
                        pp->sg_id.scsi_id)) { ... }
...
}

basename() ist keine libc Funktion, sie ist in util.c definiert und kopiert string1 ab dem letzten Slash auf string2 um.

Interessant auch das File source:libmultipath/hwtable.c:


        /*
         * NETAPP controller family
         *
         * Maintainer : Dave Wysochanski
         * Mail : davidw@netapp.com
         */
        {
                .vendor        = "NETAPP",
                .product       = "LUN.*",
                .getuid        = DEFAULT_GETUID,
                .getprio       = "/sbin/mpath_prio_netapp /dev/%n",
                .features      = "1 queue_if_no_path",
                .hwhandler     = DEFAULT_HWHANDLER,
                .selector      = DEFAULT_SELECTOR,
                .pgpolicy      = GROUP_BY_PRIO,
                .pgfailback    = -FAILBACK_IMMEDIATE,
                .rr_weight     = RR_WEIGHT_NONE,
                .no_path_retry = NO_PATH_RETRY_UNDEF,
                .minio         = 128,
                .checker_name  = READSECTOR0,
        },