source: gpfs_3.1_ker2.6.20/lpp/mmfs/bin/mmfsfuncs.Linux @ 214

Last change on this file since 214 was 16, checked in by rock, 17 years ago
  • Property svn:executable set to *
File size: 23.9 KB
RevLine 
[16]1#!/bin/ksh
2# IBM_PROLOG_BEGIN_TAG
3# This is an automatically generated prolog.
4
5
6
7# Licensed Materials - Property of IBM
8
9# (C) COPYRIGHT International Business Machines Corp. 2000,2006
10# All Rights Reserved
11
12# US Government Users Restricted Rights - Use, duplication or
13# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
14
15# IBM_PROLOG_END_TAG
16# @(#)12 1.18.6.4 src/avs/fs/mmfs/ts/admin/mmfsfuncs.Linux.sh, mmfs, avs_rgpfs24, rgpfs24s007a 10/24/06 10:23:08
17######################################################################
18#
19#  This file contains declarations and functions that are unique
20#  to the Linux operating system environment.
21#
22######################################################################
23
24
25###################################################################
26#
27# Function:  wrapper function for invoking insmod
28#
29# Input:     $1 module to load
30#            $@ -d generate load map in /var/mmfs/tmp/<module>.map
31#               or options to be given to insmod
32#
33# Returns:   0 success
34#            1 failure
35#
36###################################################################
37function InsModWrapper  #  <moduleName> <insmod_options> ..
38{
39  typeset sourceFile="mmfsfuncs.Linux.sh"
40  [[ -n $DEBUG || -n $DEBUGInsModWrapper ]] && set -x
41  $mmTRACE_ENTER "$*"
42
43  # First argument is module name and insmod parameters.
44  # The remaining arguments are insmod options.
45  typeset module="$1"
46  shift
47  typeset opts="$@"
48
49  typeset name iopts opt debug loadcmd
50
51
52  # Strip off insmod parameters to get module name.
53  name="${module%% *}"
54  name="${name%%[0-9][0-9]}"
55
56  # Check whether the module is loaded already.
57  $lsmod | $grep -qwe ^${name##*/}
58  if [[ $? = 0 ]]
59  then
60    # Informational:  The module is already loaded.
61    printErrorMsg 140 $mmcmd ${name##*/}
62    return 0
63  fi
64
65  # The "-d" option means that we should generate a load map in /var/mmfs/tmp.
66  iopts=""
67  for opt in $opts
68  do
69    # Linux 2.5 and later do not have /proc/ksyms and insmod -m/-f.
70    [[ -z $version24 && ($opt = "-d" || $opt = "-f") ]] &&  \
71      continue
72
73    if [[ "$opt" = "-d" ]]
74    then
75      # The -m options tells insmod to generate a map.
76      # Currently "insmod -m" is broken on x86_64 w/ RHEL, so skip x86_64 here.
77      if [[ $($uname -m) != 'x86_64' ]]
78      then
79        iopts="$iopts -m"
80
81        # Write load map to /var/mmfs/tmp/<module>.map
82        module="$module > /var/mmfs/tmp/${name##*/}.map"
83        debug=1
84      fi
85    else
86      iopts="$iopts $opt"
87    fi
88  done
89
90  # Load the module.
91  loadcmd="$insmod $iopts $module"
92  eval $loadcmd
93  return $?
94
95}  #---------- end of function InsModWrapper ---------------
96
97
98###########################################################
99#
100# Function:  wrapper function for invoking rmmod
101#
102# Input:     $1 module to unload
103#
104# Returns:   return code from rmmod
105#
106###########################################################
107function RmModWrapper  # <moduleName>
108{
109  typeset sourceFile="mmfsfuncs.Linux.sh"
110  [[ -n $DEBUG || -n $DEBUGRmModWrapper ]] && set -x
111  $mmTRACE_ENTER "$*"
112  typeset module="$1"
113
114  # Check whether the module is loaded.
115  $lsmod | $grep -qwe ^${module##*/}
116  [[ $? = 1 ]] && return 0
117
118  # Unload the module.
119  print -- "Unloading module $module"
120  $rmmod $module
121  return $?
122
123}  #---------- end of function RmModWrapper ---------------
124
125
126#####################################################################
127#
128# Function:  Determine kernel configuration and perform
129#            some verification of the mmfslinux module.
130#
131# Inout:     none
132#
133# Output:    'mmfslinux' or '' (empty string when module is missing)
134#
135# Returns:   0 - success
136#            1 - failure
137#
138#####################################################################
139function verifyModule
140{
141  typeset sourceFile="mmfsfuncs.Linux.sh"
142  [[ -n $DEBUG || -n $DEBUGverifyModule ]] && set -x
143  $mmTRACE_ENTER "$*"
144
145  typeset kMODULE
146
147  # If mmfslinux exists, use it.  Otherwise, return an error.
148  if [[ -s $mmcmdDir/mmfslinux ]]
149  then
150    kMODULE="mmfslinux"
151  else
152    kMODULE=""
153    # Error:  The mmfslinux kernel extension does not exist.
154    printErrorMsg 135 $mmcmd $mmcmdDir/mmfslinux
155    return 1
156  fi
157
158  # kMODULE is valid and ready to be loaded.
159  print -- "$kMODULE"
160  return 0
161
162}  #---------- end of function verifyModule ---------------
163
164
165###################################################################
166#
167# Function:  Unmount the specified file system(s).
168#
169# Input:     $1 - list of device names or all
170#            $2 - (optional) force unmount option (-f)
171#
172# Output:    None
173#
174# Returns:   Always zero.
175#
176###################################################################
177function unmountFileSystems  #  <fsList> [-f]
178{
179  typeset sourceFile="mmfsfuncs.Linux.sh"
180  [[ -n $DEBUG || -n $DEBUGunmountFileSystems ]] && set -x
181  $mmTRACE_ENTER "$*"
182  typeset fsList=$1
183  typeset forceOption=$2
184
185  typeset mountPoint deviceName
186
187
188  # Verify the force option.
189  [[ $forceOption != "-f" ]] && forceOption=""
190
191  # Unmount the requested file system(s).
192  #   Important! Do not try to capture, pipe or redirect
193  #   in any way stderr from the umount command on Linux.
194  #   See Defect 439182 for details.
195  if [[ $fsList = all ]]
196  then
197    # The request is to unmount all GPFS file systems.
198    $umount $forceOption -a -t gpfs
199
200    # Make sure we do not have any stale mounts.
201    $awk '$3 == "gpfs" { print $2 }' /proc/mounts |  \
202    while read mountPoint
203    do
204      $umount $forceOption $mountPoint
205    done
206
207  else
208    # The request is to unmount one or more GPFS file systems.
209    IFS=','
210    for deviceName in $fsList
211    do
212      IFS="$IFS_sv"
213
214      # Find out the mount point where the file system is mounted.
215      mountPoint=$(findMountpoint $deviceName)
216
217      # If the file system is mounted, unmount it.
218      [[ -n $mountPoint ]] &&   \
219        $umount $forceOption $mountPoint
220
221      # Move to the next file system.
222      IFS=','
223    done  # end of for deviceName in $fsList
224    IFS="$IFS_sv"
225  fi  # end of if [[ $deviceName = all ]]
226
227  return 0
228
229}  #------ end of function unmountFileSystems ------------------
230
231
232###################################################################
233#
234# Function:  Unmount the GPFS file system currently mounted
235#            at the specified mount point.
236#
237# Input:     $1 - mount point
238#            $2 - (optional) force unmount option (-f)
239#
240# Output:    None
241#
242# Returns:   Always zero.
243#
244###################################################################
245function unmountMountpoint  #  <mountPoint> [-f]
246{
247  typeset sourceFile="mmfsfuncs.Linux.sh"
248  [[ -n $DEBUG || -n $DEBUGunmountMountpoint ]] && set -x
249  $mmTRACE_ENTER "$*"
250  typeset mountPoint=$1
251  typeset forceOption=$2
252
253  typeset fqDeviceName
254
255
256  # Verify the force option.
257  [[ $forceOption != "-f" ]] && forceOption=""
258
259  # See if there is a GPFS file system currently mounted
260  # at the specidfied mount point.
261  fqDeviceName=$($awk '                                 \
262    $2 == "'$mountPoint'" && $3 == "gpfs" { print $1 }  \
263  ' /proc/mounts)
264
265  # If the file system is mounted, unmount it.
266  #   Important! Do not try to capture, pipe or redirect
267  #   in any way stderr from the umount command on Linux.
268  #   See Defect 439182 for details.
269  [[ -n $fqDeviceName ]] &&   \
270    $umount $forceOption $mountPoint
271
272  return 0
273
274}  #------ end of function unmountMountpoint ------------------
275
276
277#####################################################################
278#
279# Function:  Unload GPFS kernel extensions.
280#            Always try to unload all extensions,
281#            even if there is an intermediate failure.
282#
283# Returns:   0 - success
284#            1 - failure:  at least one extension cannot be unloaded
285#
286#####################################################################
287function unloadKernelExt
288{
289  typeset sourceFile="mmfsfuncs.Linux.sh"
290  [[ -n $DEBUG || -n $DEBUGunloadKernelExt ]] && set -x
291  $mmTRACE_ENTER "$*"
292
293  typeset rc=0
294  typeset force="-f"
295  typeset kMODULE gpl_module ibm_module trc_module
296  typeset trc_device ss_device pid usecount kdump_device expected_mod_count
297
298  [[ $@ = "-r" ]] && force=""
299
300  print -- "Unloading modules from $mmcmdDir"
301
302  # Determine the kernel configuration so the appropriately
303  # configured mmfslinux module may be unloaded.
304  kMODULE=$(verifyModule)
305  if [[ $? -ne 0 || -z $kMODULE ]]
306  then
307    # Error:  Unable to verify kernel/module configuration.
308    printErrorMsg 136 $mmcmd
309    return 1
310  fi
311
312  # Initialize module names and insmod parameters.
313  gpl_module="$kMODULE"
314  trc_module="tracedev"
315  ibm_module="mmfs"
316
317  if [[ -n $version24 ]]
318  then
319    ibm_module="mmfs24"
320  fi
321
322  if [[ -n $version24 ]]
323  then
324    expected_mod_count=0
325  else
326    expected_mod_count=1
327  fi
328
329  # Initialize device names.
330  trc_device="trace"
331  ss_device="ss"
332  kdump_device="kdump"
333
334  # Make sure the daemon isn't running anymore.
335  cmdout=$($ps -eo "pid args" | $awk '$2 ~ /mmfsd/ && !/this process/ {print $1}')
336  if [[ -n $cmdout ]]
337  then
338    # Error:  The GPFS daemon is still running.
339    printErrorMsg 137 $mmcmd
340    return 1
341  fi
342
343  # Make sure we don't have any mounts just laying around.
344  unmountFileSystems all $force
345
346  # Before unloading the $ibm_module,
347  # make sure the $gpl_module can be unloaded as well.
348  usecount=$($lsmod | $grep -w -e ^$gpl_module | $awk '{print $3}')
349  if [[ -n $usecount && $usecount -ne $expected_mod_count && $usecount -ne 0 ]]
350  then
351    # Error:  Module $gpl_module is still in use.
352    printErrorMsg 138 $mmcmd $gpl_module
353    rc=1
354  fi
355
356  # Invoke rmmod with all arguments we got.
357  RmModWrapper $ibm_module "$@"
358  if [[ $? -ne 0 ]]
359  then
360    # Error unloading module $ibm_module.
361    printErrorMsg 139 $mmcmd $ibm_module
362    rc=1
363  fi
364
365  RmModWrapper $gpl_module "$@"
366  if [[ $? -ne 0 ]]
367  then
368    # Error unloading module $gpl_module.
369    printErrorMsg 139 $mmcmd $gpl_module
370    rc=1
371  else
372    $rm -f /dev/${ss_device}0 /dev/${ss_device}
373  fi
374
375  RmModWrapper $trc_module "$@"
376  if [[ $? -ne 0 ]]
377  then
378    # Error unloading module $trc_module.
379    printErrorMsg 139 $mmcmd $trc_module
380    rc=1
381  else
382    # ${trc_module} is the device name also
383    $rm -f /dev/${trc_device}0 /dev/${trc_module} /dev/${kdump_device}0
384  fi
385
386  return $rc
387
388}  #---------- end of function unloadKernelExt ---------------
389
390
391###########################################################
392#
393# Function:  load GPFS kernel extensions
394#
395# Input:     -d - generate load map in /var/mmfs/tmp
396#            $@ - options to give to insmod
397#
398# Returns:   0 - success
399#            1 - failure
400#
401###########################################################
402function loadKernelExt
403{
404  typeset sourceFile="mmfsfuncs.Linux.sh"
405  [[ -n $DEBUG || -n $DEBUGloadKernelExt ]] && set -x
406  $mmTRACE_ENTER "$*"
407
408  typeset opts="$@"
409
410  typeset opt kMODULE gpl_module ibm_module trc_module trc_device ss_device kdump_device
411  typeset debug sysmap major gdbfile module name mapfile textaddr
412
413  debug=0
414  for opt in $opts
415  do
416    [[ $opt = "-d" ]] && debug=1
417  done
418
419  # Specifically turn on debugging.
420  # We need everything we can get for debugging on linux.
421  if [[ $debug = 0 ]]
422  then
423    debug=1
424    opts="$opts -d"
425  fi
426
427  print -- "Loading modules from $mmcmdDir"
428
429  # Determine the kernel configuration so the appropriately-configured
430  # mmfslinux module may be loaded.
431
432  kMODULE=$(verifyModule)
433  if [[ $? -ne 0 || -z $kMODULE ]]
434  then
435    # Error:  Unable to verify kernel/module configuration.
436    printErrorMsg 136 $mmcmd
437    return 1
438  fi
439
440  # Initialize module names and insmod parameters.
441  gpl_module="$kMODULE prog_path=$mmcmdDir"
442  trc_module="tracedev"
443  if [[ -n $version24 ]]
444  then
445    ibm_module="mmfs24"
446  else
447    ibm_module="mmfs26"
448  fi
449
450  # Initialize device names.
451  trc_device="trace"
452  ss_device="ss"
453  kdump_device="kdump"
454
455  # Invoke insmod with all arguments we got.
456  InsModWrapper "$mmcmdDir/$trc_module" "$opts"
457  if [[ $? -ne 0 ]]
458  then
459    unloadKernelExt
460    return 1
461  fi
462
463  # Load gpl module without forcing insmod.
464  InsModWrapper "$mmcmdDir/$gpl_module" "$opts"
465  if [[ $? -ne 0 ]]
466  then
467    unloadKernelExt
468    return 1
469  fi
470
471  InsModWrapper "$mmcmdDir/$ibm_module" "$opts"
472  if [[ $? -ne 0 ]]
473  then
474    unloadKernelExt
475    return 1
476  fi
477
478  # Show what we loaded.
479  $lsmod | $grep -w -e ^Module -e ^${trc_module%% *} \
480                    -e ^${gpl_module%% *} -e ^${ibm_module%% *}
481
482  MAPDIR=/var/mmfs/tmp
483  if [[ $debug = 1 ]] && [[ -r $MAPDIR ]]
484  then
485    # Build one symbol map for kernel and modules and sort it.
486    MMFSLINUX_MAP=$MAPDIR/$kMODULE.map
487    COMPLETE_MAP=$MAPDIR/complete.map
488    TRCDEV_MAP=$MAPDIR/$trc_module.map
489    MMFS_MAP=$MAPDIR/$ibm_module.map
490    SORT_MAP=$MAPDIR/sort.map
491    KSYMS_MAP=$MAPDIR/ksyms.map
492    if [[ -n $version24 ]]
493    then
494      KALLSYMS_MAP=""
495    else
496      KALLSYMS_MAP=/proc/kallsyms
497    fi
498
499    #------------------------------------------------------
500    # Clean out tmp files not accessed in the last 3 days.
501    #------------------------------------------------------
502    SAVEPWD="$PWD"
503    print -- "Removing old $MAPDIR files:"
504    if cd "$MAPDIR"
505    then
506       $find . -type f -atime +3 -exec $rm {} \; -print
507    fi
508    cd "$SAVEPWD"
509
510    #------------------------------
511    # Find or create a system map.
512    #------------------------------
513    SYSTEM_MAP=""
514    activeKernel=$($uname -r 2>/dev/null)
515    if [[ -r /boot/System.map ]]
516    then
517      SYSTEM_MAP="/boot/System.map"
518    elif [[ -r /usr/src/linux/System.map ]]
519    then
520      SYSTEM_MAP="/usr/src/linux/System.map"
521    elif [[ -r /boot/System.map-$activeKernel ]]
522    then
523      SYSTEM_MAP="/boot/System.map-$activeKernel"
524    else
525      # Not the same thing but perhaps useful
526      print -- "Couldn't find System.map.  Using /proc/ksyms."
527      SYSTEM_MAP=$KSYMS_MAP
528      $cat /proc/ksyms | $awk '{print $1" ? "$2}' > $SYSTEM_MAP
529    fi
530
531    #----------------------------------------------------
532    # Strip and sort other maps into appropriate format.
533    #----------------------------------------------------
534    $cat $MMFSLINUX_MAP $TRCDEV_MAP $MMFS_MAP 2>/dev/null | \
535      $awk '/ [TtDdRr] / {print $0}' | $sort -o $SORT_MAP
536
537    #-----------------------------------------------------
538    # Create a complete.map and latest/previous symlinks.
539    #-----------------------------------------------------
540    SUFFIX="$($date +%Y.%m.%d.%H.%M.%S).$($hostname -s)"
541    $cat $KALLSYMS_MAP $SYSTEM_MAP $SORT_MAP > "${COMPLETE_MAP}.${SUFFIX}"
542
543    if [[ -L "${COMPLETE_MAP}.previous" ]]
544    then
545      previous=$($ls -l "${COMPLETE_MAP}.previous")
546      previous=${previous##*-\> }
547      $rm -f $previous
548    fi
549
550    [[ -r "${COMPLETE_MAP}.previous" ]] && $rm -f "${COMPLETE_MAP}.previous"
551
552    if [[ -L "${COMPLETE_MAP}.latest" ]]
553    then
554        $mv -f "${COMPLETE_MAP}.latest" "${COMPLETE_MAP}.previous"
555    fi
556
557    [[ -r "${COMPLETE_MAP}.latest" ]] && $rm -f "${COMPLETE_MAP}.latest"
558
559    $ln -sf $(basename "${COMPLETE_MAP}.${SUFFIX}") "${COMPLETE_MAP}.latest"
560
561    # Re-initialize syslogd so it can load GPFS module symbols.
562    [[ -s /var/run/syslogd.pid ]] && \
563      $kill -s SIGHUP $($cat /var/run/syslogd.pid)
564
565    #-----------------------------------------------------------------------
566    # Generate a gdb script in /var/mmfs/tmp that will load module symbols.
567    #-----------------------------------------------------------------------
568    GDBFILE="$MAPDIR/loadsyms"
569    $rm -f $GDBFILE
570
571    for module in "$mmcmdDir/$trc_module" "$mmcmdDir/$gpl_module" \
572                  "$mmcmdDir/$ibm_module"
573    do
574      name="${module%% *}"
575      mapfile="$MAPDIR/${name##*/}.map"
576      if [[ -s $mapfile ]]
577      then
578        textaddr=$($awk '/^.text / { print $3 }' $mapfile)
579        $awk 'BEGIN { printf "add-symbol-file '"$name 0x$textaddr"'" }
580             /^Sections:/,/^$/ \
581             {
582               if (substr($1,1,1) == "." &&
583                   $1 != ".this" &&
584                   $1 != ".text" &&
585                   $1 != ".kmodtab" &&
586                   $1 != ".kstrtab" &&
587                   $1 !~ "^.gnu.linkonce.")
588               {
589                 sect = $1
590                 addr = $3
591
592                 # If section name is too long, it gets concatenated
593                 # with the address field, so fix that.
594                 if (NF == 3 && length(sect) > 15)
595                 {
596                   sect = substr(sect, 1, length(sect) - 8)
597                   addr = $2
598                 }
599                 printf " -s %s 0x%s", sect, addr
600               }
601             }
602           END { print "" }' $mapfile >> $GDBFILE
603      fi
604    done
605
606    $rm -f $SORT_MAP $MMFSLINUX_MAP $MMFS_MAP $TRCDEV_MAP $KSYMS_MAP
607  fi
608
609  # Get the major number of the ss_device from /proc/devices.
610  # Remove stale ss_device node and replace it.
611  major=$($awk ' $2=="'$ss_device'" {print $1} ' /proc/devices)
612  if [[ -n "$major" ]]
613  then
614    $rm -f /dev/${ss_device}0
615
616    # Normal user must be able to open device in read
617    # mode so ioctl() will work.
618    umask 013
619    $mknod /dev/${ss_device}0 c $major 0
620    umask $UMASK_sv
621  fi
622
623  # Get the major number of the trc_device from /proc/devices.
624  # Remove stale trc_device node and replace it.
625  major=$($awk ' $2=="'$trc_device'" {print $1} ' /proc/devices)
626  if [[ -n "$major" ]]
627  then
628    $rm -f /dev/${trc_device}0
629
630    umask 077
631    $mknod /dev/${trc_device}0 c $major 0
632    umask $UMASK_sv
633  fi
634
635  # Get the major number of the kdump_device from /proc/devices.
636  # Remove stale kdump_device node and replace it.
637  major=$($awk ' $2=="'$kdump_device'" {print $1} ' /proc/devices)
638  if [[ -n "$major" ]]
639  then
640    $rm -f /dev/${kdump_device}0
641
642    umask 077
643    $mknod /dev/${kdump_device}0 c $major 0
644    umask $UMASK_sv
645  fi
646
647  return 0
648
649}  #---------- end of function loadKernelExt ---------------
650
651
652###################################################################
653#
654# Function:  Determine the mount point at which a file system
655#            is currently mounted.
656#
657# Input:     $1 - file system device name
658#
659# Output:    Mount point or null (if not mounted).
660#
661# Returns:   Always zero.
662#
663###################################################################
664function findMountpoint  # <deviceName>
665{
666  typeset sourceFile="mmfsfuncs.Linux.sh"
667  [[ -n $DEBUG || -n $DEBUGfindMountpoint ]] && set -x
668  $mmTRACE_ENTER "$*"
669  typeset device=$1
670
671  typeset deviceName fqDeviceName
672
673  # Verify the device name.
674  deviceName=${device##+(/)dev+(/)}  # name stripped of /dev/ prefix
675  fqDeviceName="/dev/$deviceName"    # fully-qualified name with /dev/ prefix
676
677  # See if the file system is mounted.
678  mountPoint=$($awk '                                     \
679    $1 == "'$fqDeviceName'" && $3 == "gpfs" { print $2 }  \
680  ' /proc/mounts)
681
682  # Print the output and return.
683  print -- "$mountPoint"
684  return 0
685
686}  # ---- end of function findMountpoint --------------------
687
688
689###################################################################
690#
691# Function:  Given a path name, find the GPFS file system to which
692#            the object (file, directory, etc.) belongs.
693#
694# Input:     $1 - fully-qualified path name
695#
696# Output:    GPFS file system device name or null.
697#
698# Returns:   0            - device name determined
699#            19 (ENODEV)  - device not found
700#            22 (EINVAL)  - input path name is not valid
701#            other unexpected errors
702#
703###################################################################
704function findDeviceName  # <pathName>
705{
706  typeset sourceFile="mmfsfuncs.Linux.sh"
707  [[ -n $DEBUG || -n $DEBUGfindDeviceName ]] && set -x
708  $mmTRACE_ENTER "$*"
709  typeset pathName=$1
710
711  typeset deviceID objectDeviceID fqDeviceName mountInfo vfsType
712
713  # Find the device ID of the specified directory.
714  objectDeviceID=$($perl -e '($dev) = stat "'$pathName'"; printf "%u", $dev;')
715  if [[ -z $objectDeviceID ]]
716  then
717    # Failed to stat the directory.
718    printErrorMsg 454 $mmcmd $pathName
719    return $MM_InvalidName
720  fi
721
722  # Go down the list of monted file systems.  If the vfs type is gpfs,
723  # find the device ID and see if it matches the device ID of our object.
724  exec 5<&-
725  exec 5< /proc/mounts
726  while read -u5 mountInfo
727  do
728    # Parse the line.
729    set -f ; set -- $mountInfo ; set +f
730    fqDeviceName=$1
731    mountPoint=$2
732    vfsType=$3
733
734    # Skip the line if this is not a GPFS file system.
735    [[ $vfsType != "gpfs" ]] && continue
736
737    # Find the device ID for the mount point.
738    deviceID=$($perl -e '($dev) = stat "'$mountPoint'"; printf "%u", $dev;')
739
740    # If this is the file system that we are looking for,
741    # print the device name and return.
742    if [[ $deviceID = $objectDeviceID ]]
743    then
744      print -- "$fqDeviceName"
745      return 0
746    fi
747
748  done  # end while read -u3 mountInfo
749
750  # If we get here, the object does not belong to a GPFS file system.
751  printErrorMsg 455 $mmcmd $pathName
752  return $MM_DeviceNotFound
753
754}  # ---- end of function findDeviceName --------------------
755
756
757#####################################################################
758#
759# Function:  Unfence the specified disks on the local node.
760#            Clear any PR registrations.
761#
762# Input:     $1 - file with disks to unfence
763#
764# Output:    A line with the following ':' separated fields:
765#            - magic word 'unfenceDisks'
766#            - function return code
767#            - status
768#
769# Returns:   Zero if successful, non-zero otherwise.
770#
771#####################################################################
772function unfenceDisks  # <diskName>
773{
774  typeset sourceFile="mmfsfuncs.Linux.sh"
775  [[ -n $DEBUG || -n $DEBUGunfenceDisks ]] && set -x
776  $mmTRACE_ENTER "$*"
777  typeset disksToUnfence=$1
778
779  # This function is a no-op in Linux.
780  print -- "unfenceDisks:0:success:"
781  return 0
782
783}  #---- end of function unfenceDisks ----------------
784
785
786#####################################################################
787#
788# Function:  Unfence the specified disk on the local node.
789#
790# Input:     $1 - name of the disk to unfence.
791#
792# Output:    None.
793#
794# Returns:   Zero if successful, non-zero otherwise.
795#
796#####################################################################
797function unfenceVSDdisk  # <diskName>
798{
799  typeset sourceFile="mmfsfuncs.Linux.sh"
800  [[ -n $DEBUG || -n $DEBUGunfenceVSDdisk ]] && set -x
801  $mmTRACE_ENTER "$*"
802  typeset diskName=$1
803
804  # This function is a no-op in Linux.
805  return 0
806
807}  #---- end of function unfenceVSDdisk ----------------
808
809
810####################################################################
811#
812# Function:  Determine the NSD subtype, i.e., the type of the disk
813#            used to create the NSD.
814#
815# Input:     name of the disk whose NSD subtype must be determined
816#
817# Output:    the NSD subtype for the disk;  possible values are:
818#              vpath, powerdisk, generic or file.
819#
820# Returns:   0 - success
821#            1 - error detected
822#
823####################################################################
824function determineNsdSubtype  # <diskName>
825{
826  typeset sourceFile="mmfsfuncs.Linux.sh"
827  [[ -n $DEBUG || -n $DEBUGdetermineNsdSubtype ]] && set -x
828  $mmTRACE_ENTER "$*"
829  typeset diskName=$1
830
831  typeset nsdSubtype
832  typeset rc=0
833
834  # Invoke the nsddevices user exit if it was activated.
835  # If that script is not activated, or if it does not find
836  # the disk, proceed with the normal GPFS disk discovery.
837  if [[ -x $nsddevices ]]
838  then
839    nsdSubtype=$($nsddevices | $awk ' $1 == "'$diskName'" { print $2 } ')
840    if [[ -n $nsdSubtype ]]
841    then
842      # Return the device type from the nsdddevices function.
843      print $nsdSubtype
844      return 0
845    fi
846  fi
847
848  # We come here if we could not obtain the device type
849  # from nsddevices.  Determine how the disk should be
850  # reported (vpath, EMC powerpath, generic, or file).
851  if [[ $diskName = vpath* ]]
852  then
853    nsdSubtype="vpath"
854  elif [[ $diskName = emcpower* ]]
855  then
856    nsdSubtype="powerdisk"
857  elif [[ $diskName = /* ]]
858  then
859    nsdSubtype="file"
860  else
861    nsdSubtype="generic"
862  fi
863
864  # Verify that the device exists.
865  if [[ $nsdSubtype = file ]]
866  then
867    if [[ ! -f $diskName ]]
868    then
869      # Error:  disk not found.
870      printErrorMsg 524 $mmcmd $diskName
871      return 1
872    fi
873  else
874    $grep -w $diskName /proc/partitions > /dev/null 2>&1
875    if [[ $? -ne 0 ]]
876    then
877      # Error:  disk not found in /proc/partitions.
878      printErrorMsg 141 $mmcmd $diskName
879      return 1
880    fi
881  fi
882
883  # Output the NSD subtype and return.
884  print $nsdSubtype
885  return $rc
886
887}  #---- end of function determineNsdSubtype -------------
888
Note: See TracBrowser for help on using the repository browser.