~ubuntu-branches/debian/squeeze/multipath-tools/squeeze

« back to all changes in this revision

Viewing changes to libmultipath/dmparser.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2010-04-11 13:22:35 UTC
  • mfrom: (8.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100411132235-p0xdu9sy65mlx32z
Tags: 0.4.8+git0.761c66f-8
* [16268d8] Drop path from dmsetup_env call - thanks to Ferenc Wagner
* [2f3bdd5] Use $name in multipath.udev as well - thanks to Ferenc Wagner
  for testing
* [c978487] Don't pass -g on mips(el) to work around a binutils bug.  See
  http://sources.redhat.com/bugzilla/show_bug.cgi?id=10144 for details.
* [9daf438] Make sure we discover multipaths before checkfs/mountall runs
  This covers the cornercase where e.g. /home is on multipath (but not on
  LVM) and multipath-tols aren't started via initramfs. (Closes: #577172)
* [f7cc840] Bump standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#include <stdlib.h>
8
8
#include <string.h>
9
9
 
10
 
#include <checkers.h>
11
 
 
 
10
#include "checkers.h"
12
11
#include "vector.h"
13
12
#include "memory.h"
14
13
#include "structs.h"
60
59
        minio = mp->minio;
61
60
        p = mp->params;
62
61
        freechar = sizeof(mp->params);
63
 
        
 
62
 
64
63
        shift = snprintf(p, freechar, "%s %s %i %i",
65
64
                         mp->features, mp->hwhandler,
66
65
                         VECTOR_SIZE(mp->pg), mp->bestpg);
71
70
        }
72
71
        p += shift;
73
72
        freechar -= shift;
74
 
        
 
73
 
75
74
        vector_foreach_slot (mp->pg, pgp, i) {
76
75
                pgp = VECTOR_SLOT(mp->pg, i);
77
76
                shift = snprintf(p, freechar, " %s %i 1", mp->selector,
146
145
                        FREE(word);
147
146
                        return 1;
148
147
                }
 
148
                if ((mpp->no_path_retry == NO_PATH_RETRY_UNDEF) ||
 
149
                        (mpp->no_path_retry == NO_PATH_RETRY_FAIL) ||
 
150
                        (mpp->no_path_retry == NO_PATH_RETRY_QUEUE))
 
151
                        setup_feature(mpp, word);
 
152
 
149
153
                FREE(word);
150
154
        }
151
155
 
183
187
        num_pg = atoi(word);
184
188
        FREE(word);
185
189
 
186
 
        if (num_pg > 0 && !mpp->pg)
 
190
        if (num_pg > 0 && !mpp->pg) {
187
191
                mpp->pg = vector_alloc();
188
 
        
189
 
        if (!mpp->pg)
190
 
                return 1;
 
192
 
 
193
                if (!mpp->pg)
 
194
                        return 1;
 
195
        } else
 
196
                mpp->pg = NULL;
 
197
 
191
198
        /*
192
199
         * first pg to try
193
200
         */
219
226
                                goto out;
220
227
 
221
228
                        num_pg_args = atoi(word);
222
 
                        
 
229
 
223
230
                        if (merge_words(&mpp->selector, word, 1)) {
224
231
                                FREE(word);
225
232
                                goto out1;
237
244
                 * paths
238
245
                 */
239
246
                pgp = alloc_pathgroup();
240
 
                
 
247
 
241
248
                if (!pgp)
242
249
                        goto out;
243
250
 
278
285
 
279
286
                                strncpy(pp->dev_t, word, BLK_DEV_SIZE);
280
287
 
281
 
#ifndef DAEMON
282
 
                                if (store_path(pathvec, pp))
283
 
                                        goto out;
284
 
#endif
 
288
                                /* Only call this in multipath client mode */
 
289
                                if (!mpp->waiter && store_path(pathvec, pp))
 
290
                                        goto out1;
285
291
                        }
286
292
                        FREE(word);
287
293
 
306
312
                        pp->pgindex = i + 1;
307
313
 
308
314
                        for (k = 0; k < num_paths_args; k++)
309
 
                                if (k == 0 && !strncmp(mpp->selector,
310
 
                                                       "round-robin", 11)) {
311
 
                                        p += get_word(p, &word);
312
 
                                        def_minio = atoi(word);
313
 
 
314
 
                                        if (mpp->rr_weight == RR_WEIGHT_PRIO
315
 
                                            && pp->priority > 0)
316
 
                                                def_minio /= pp->priority;
317
 
 
318
 
                                        FREE(word);
 
315
                                if (k == 0) {
 
316
                                        if (!strncmp(mpp->selector,
 
317
                                                     "round-robin", 11)) {
 
318
                                                p += get_word(p, &word);
 
319
                                                def_minio = atoi(word);
 
320
 
 
321
                                                if (mpp->rr_weight == RR_WEIGHT_PRIO
 
322
                                                    && pp->priority > 0)
 
323
                                                        def_minio /= pp->priority;
 
324
 
 
325
                                                FREE(word);
 
326
                                        } else
 
327
                                                def_minio = 0;
 
328
 
319
329
                                        if (def_minio != mpp->minio)
320
330
                                                mpp->minio = def_minio;
321
331
                                }
329
339
        FREE(word);
330
340
out:
331
341
        free_pgvec(mpp->pg, KEEP_PATHS);
 
342
        mpp->pg = NULL;
332
343
        return 1;
333
344
}
334
345
 
343
354
        int num_pg;
344
355
        int num_pg_args;
345
356
        int num_paths;
 
357
        int def_minio = 0;
346
358
        struct path * pp;
347
359
        struct pathgroup * pgp;
348
360
 
398
410
        num_pg = atoi(word);
399
411
        FREE(word);
400
412
 
 
413
        if (num_pg == 0)
 
414
                return 0;
 
415
 
401
416
        /*
402
417
         * next pg to try
403
418
         */
433
448
                FREE(word);
434
449
 
435
450
                /*
436
 
                 * undef ?
 
451
                 * PG Status (discarded, would be '0' anyway)
437
452
                 */
438
453
                p += get_word(p, NULL);
439
454
 
496
511
                        /*
497
512
                         * selector args
498
513
                         */
499
 
                        for (k = 0; k < num_pg_args; k++)
500
 
                                p += get_word(p, NULL);
 
514
                        for (k = 0; k < num_pg_args; k++) {
 
515
                                if (!strncmp(mpp->selector,
 
516
                                             "least-pending", 13)) {
 
517
                                        p += get_word(p, &word);
 
518
                                        if (sscanf(word,"%d:*d",
 
519
                                                   &def_minio) == 1 &&
 
520
                                            def_minio != mpp->minio)
 
521
                                                        mpp->minio = def_minio;
 
522
                                } else
 
523
                                        p += get_word(p, NULL);
 
524
                        }
501
525
                }
502
526
        }
503
527
        return 0;