gen_fb_fstab

in cookbooks/fb_storage/libraries/storage.rb [1137:1219]


    def gen_fb_fstab(node)
      use_labels = node['fb_storage']['fstab_use_labels']
      fstab = {}
      fstab_fields =
        %w{type mount_point opts pass enable_remount allow_mount_failure}
      if node['fb_storage']['hybrid_xfs_use_helper']
        node.default['fb_fstab']['type_normalization_map']['rtxfs'] = 'xfs'
        node.default['fb_fstab']['ignorable_opts'] << /^rtdev=.*/
      end
      @config.each do |device, devconf|
        next if devconf['_skip']

        if devconf['whole_device']
          partconf = devconf['partitions'][0]
          if partconf['_swraid_array'] || partconf['_no_mount'] ||
             partconf['_swraid_array_journal']
            next
          end

          name = "storage_#{device}_whole"
          fstab[name] = {
            'device' => use_labels ? "LABEL=#{devconf['label']}" : device,
          }
          fstab_fields.each do |field|
            fstab[name][field] = devconf['partitions'][0][field]
          end
          next
        end
        
        devconf['partitions'].each_with_index do |partconf, index|
          
          
          
          if partconf['_no_mount'] ||
             partconf['_swraid_array'] || partconf['_swraid_array_journal'] ||
             partconf['_xfs_rt_data'] || partconf['_xfs_rt_rescue'] ||
             partconf['_xfs_rt_metadata']
            next
          end

          partnum = index + 1
          partition = FB::Storage.partition_device_name(
            device, partnum
          )
          name = "storage_#{partition}"
          fstab[name] = {
            'device' => use_labels ? "LABEL=#{partconf['label']}" : partition,
          }
          fstab_fields.each do |field|
            fstab[name][field] = partconf[field]
          end
        end
        
      end
      @arrays.each do |array, arrayconf|
        next if arrayconf['_skip'] || arrayconf['_no_mount']

        name = "storage_#{array}"
        if use_labels
          device = "LABEL=#{arrayconf['label']}"
        elsif arrayconf['raid_level'] == 'hybrid_xfs'
          device = arrayconf['journal']
        else
          device = array
        end
        fstab[name] = {
          'device' => device,
        }
        fstab_fields.each do |field|
          fstab[name][field] = arrayconf[field]
        end
        if arrayconf['raid_level'] == 'hybrid_xfs'
          if node['fb_storage']['hybrid_xfs_use_helper']
            fstab[name]['type'] = 'rtxfs'
          else
            
            fstab[name]['opts'] << ",rtdev=#{arrayconf['members'].first}"
          end
        end
      end
      fstab
    end