Esempio n. 1
0
    def decode_mpage(cls, bio):
        """
        Decodes a bio used for multipage i/o.

        This method decodes a bio generated by the mpage component of
        the file system subsystem.

        Args:
            bio(gdb.Value<struct bio>): The struct bio to be decoded, generated
                by the mpage component

        Returns:
            dict: Contains the following items:
                - description (str): Human-readable description of the bio
                - bio (gdb.Value<struct bio>): The struct bio being decoded
                - fstype (str): The name of the file system which submitted
                    this bio
                - inode (gdb.Value<struct inode>): The struct inode, if any,
                    that owns the file associated with this bio
        """
        inode = bio['bi_io_vec'][0]['bv_page']['mapping']['host']
        fstype = cls.super_fstype(inode['i_sb'])
        chain = {
            'description':
            "{:x} bio: Multipage I/O: inode {}, type {}, dev {}".format(
                long(bio), inode['i_ino'], fstype,
                block_device_name(bio['bi_bdev'])),
            'bio':
            bio,
            'fstype':
            fstype,
            'inode':
            inode,
        }
        return chain
Esempio n. 2
0
 def interpret(self) -> None:
     """Interprets a direct i/o bio to populate its attributes"""
     # pylint: disable=attribute-defined-outside-init
     self.dio = self.bio['bi_private'].cast(self._types.dio_p_type)
     self.fstype = super_fstype(self.dio['inode']['i_sb'])
     self.dev = block_device_name(self.dio['inode']['i_sb']['s_bdev'])
     self.offset = self.dio['block_in_file'] << self.dio['blkbits']
Esempio n. 3
0
 def interpret(self) -> None:
     """Interprets the ext3 buffer_head to populate its attributes"""
     # pylint: disable=attribute-defined-outside-init
     self.fstype = "journal on ext3"
     self.devname = block_device_name(self.bh['b_bdev'])
     self.offset = int(self.bh['b_blocknr']) * int(self.bh['b_size'])
     self.length = int(self.bh['b_size'])
Esempio n. 4
0
    def decode_buffer_head(cls, bh):
        """
        Decodes a struct buffer_head

        This method decodes a struct buffer_head, using an
        implementation-specific decoder, if available

        Args:
            bio(gdb.Value<struct buffer_head>): The struct buffer_head to be
                decoded.

        Returns:
            dict: Minimally contains the following items.
                - description (str): Human-readable description of the bio
                - bh (gdb.Value<struct buffer_head>): The struct buffer_head
                Additional items may be available based on the
                implmentation-specific decoder.
        """
        endio = bh['b_end_io']
        try:
            return cls.buffer_head_decoders[endio](bh)
        except KeyError:
            pass
        desc = "{:x} buffer_head: for dev {}, block {}, size {} (undecoded)".format(
            long(bh), block_device_name(bh['b_bdev']), bh['b_blocknr'],
            bh['b_size'])
        chain = {
            'description': desc,
            'bh': bh,
        }
        return chain
Esempio n. 5
0
 def decode_end_buffer_write_sync(cls, bh):
     desc = ("{:x} buffer_head: for dev {}, block {}, size {} (unassociated)"
             .format(block_device_name(bh['b_bdev']),
                     bh['b_blocknr'], bh['b_size']))
     chain = {
         'description' : desc,
         'bh' : bh,
     }
     return chain
Esempio n. 6
0
    def decode_clone_bio(cls, bio):
        tio = bio['bi_private'].cast(cls.dm_target_io_p_type)

        next_bio = tio['io']['bio']

        chain = {
            'description' : "{:x} bio: device mapper clone: {}[{}] -> {}[{}]".format(
                            long(bio),
                            block_device_name(bio['bi_bdev']),
                            long(bio['bi_sector']),
                            block_device_name(next_bio['bi_bdev']),
                            long(next_bio['bi_sector'])),
            'bio' : bio,
            'tio' : tio,
            'next' : tio['io']['bio'],
            'decoder' : block.decode_bio,
        }

        return chain
Esempio n. 7
0
    def decode_clone_bio(cls, bio):
        """
        Decodes a bio-based device mapper cloned bio

        This method decodes a cloned bio generated by request-based
        device mapper targets.

        Args:
            bio(gdb.Value<struct bio>): A struct bio generated by a
                bio-based device mapper target

        Returns:
            dict: Contains the following items:
                - description (str): Human-readable description of the bio
                - bio (gdb.Value<struct bio>): The provided bio
                - tio (gdb.Value<struct dm_target_io>): The struct
                    dm_target_tio for this bio
                - next (gdb.Value<struct bio>): The original bio that was
                    the source of this one
                - decoder (method(gdb.Value<struct bio>)): The decoder for the
                    original bio
        """
        tio = cls._get_clone_bio_tio(bio)

        next_bio = tio['io']['bio']

        chain = {
            'description':
            "{:x} bio: device mapper clone: {}[{}] -> {}[{}]".format(
                long(bio), block_device_name(bio['bi_bdev']),
                long(bio['bi_sector']), block_device_name(next_bio['bi_bdev']),
                long(next_bio['bi_sector'])),
            'bio':
            bio,
            'tio':
            tio,
            'next':
            next_bio,
            'decoder':
            block.decode_bio,
        }

        return chain
Esempio n. 8
0
 def decode_mpage(cls, bio):
     inode = bio['bi_io_vec'][0]['bv_page']['mapping']['host']
     fstype = cls.super_fstype(inode['i_sb'])
     chain = {
         'description' :
             "{:x} bio: Multipage I/O: inode {}, type {}, dev {}".format(
                     long(bio), inode['i_ino'], fstype,
                     block_device_name(bio['bi_bdev'])),
         'bio' : bio,
         'fstype' : fstype,
         'inode' : inode,
     }
     return chain
Esempio n. 9
0
 def decode_buffer_head(cls, bh):
     endio = bh['b_end_io']
     try:
         return cls.buffer_head_decoders[endio](bh)
     except KeyError:
         pass
     desc = "{:x} buffer_head: for dev {}, block {}, size {} (undecoded)".format(
                 long(bh), block_device_name(bh['b_bdev']),
                 bh['b_blocknr'], bh['b_size'])
     chain = {
         'description' : desc,
         'bh' : bh,
     }
     return chain
Esempio n. 10
0
    def decode_dio_bio(cls, bio):
        """
        Decodes a bio used for direct i/o.

        This method decodes a bio generated by the direct-io component of
        the file system subsystem.  The bio can either have been submitted
        directly or asynchronously.

        Args:
            bio(gdb.Value<struct bio>): The struct bio to be decoded, generated
                by the direct i/o component

        Returns:
            dict: Contains the following items:
                - description (str): Human-readable description of the bio
                - bio (gdb.Value<struct bio>): The struct bio being decoded
                - dio (gdb.Value<struct dio>): The direct i/o component of
                    the bio
                - fstype (str): The name of the file system which submitted
                    this bio
                - inode (gdb.Value<struct inode>): The struct inode, if any,
                    that owns the file associated with this bio
                - offset (long): The offset within the file, in bytes
                - devname (str): The device name associated with this bio
        """
        dio = bio['bi_private'].cast(cls.dio_p_type)
        fstype = cls.super_fstype(dio['inode']['i_sb'])
        dev = block_device_name(dio['inode']['i_sb']['s_bdev'])
        offset = dio['block_in_file'] << dio['blkbits']

        chain = {
            'description':
            "{:x} bio: Direct I/O for {} inode {} on {}".format(
                long(bio), fstype, dio['inode']['i_ino'], dev),
            'bio':
            bio,
            'dio':
            dio,
            'fstype':
            fstype,
            'inode':
            dio['inode'],
            'offset':
            offset,
            'devname':
            dev,
        }
        return chain
Esempio n. 11
0
    def decode_dio_bio(cls, bio):
        dio = bio['bi_private'].cast(cls.dio_p_type)
        fstype = cls.super_fstype(dio['inode']['i_sb'])
        dev = block_device_name(dio['inode']['i_sb']['s_bdev'])
        offset = dio['block_in_file'] << dio['blkbits']

        chain = {
            'description' : "{:x} bio: Direct I/O for {} inode {} on {}".format(
                            long(bio), fstype, dio['inode']['i_ino'], dev),
            'bio' : bio,
            'dio' : dio,
            'fstype' : fstype,
            'inode' : dio['inode'],
            'offset' : offset,
            'devname' : dev,
        }
        return chain
Esempio n. 12
0
    def decode_clone_bio_rq(cls, bio):
        """
        Decodes a request-based device mapper cloned bio

        This method decodes a cloned bio generated by request-based
        device mapper targets.

        Args:
            bio(gdb.Value<struct bio>): A struct bio generated by a
                request-based device mapper target

        Returns:
            dict: Contains the following items:
                - description (str):  Human-readable description of the bio
                - bio (gdb.Value<struct bio>): The provided bio
                - tio (gdb.Value(<struct dm_target_io>): The struct
                  dm_target_io for this bio
                - next (gdb.Value<struct bio>): The original bio that was
                  the source of this one
                - decoder (method(gdb.Value<struct bio>)): The decoder for
                  the original bio
        """

        info = cls._get_clone_bio_rq_info(bio)

        # We can pull the related bios together here if required
        # b = bio['bi_next']
        # while long(b) != 0:
        #    b = b['bi_next']

        chain = {
            'bio':
            bio,
            'tio':
            info['tio'],
            'next':
            info['orig'],
            'description':
            '{:x} bio: Request-based Device Mapper on {}'.format(
                long(bio), block_device_name(bio['bi_bdev'])),
            'decoder':
            block.decode_bio,
        }

        return chain
Esempio n. 13
0
    def decode_clone_bio_rq(cls, bio):
        info = bio['bi_private'].cast(cls.dm_rq_clone_bio_info_p_type)
        count = bio['bi_cnt']['counter']

        # We can pull the related bios together here if required
        # b = bio['bi_next']
        # while long(b) != 0:
        #    b = b['bi_next']

        bio = info['orig']

        chain = {
            'bio' : bio,
            'next' : info['orig'],
            'description' :
                '{:x} bio: Request-based Device Mapper on {}'.format(
                        long(bio), block_device_name(bio['bi_bdev'])),
            'decoder' : block.decode_bio,
        }

        return chain
Esempio n. 14
0
    def decode_end_buffer_write_sync(cls, bh):
        """
        Decodes a struct buffer_head submitted by file systems for routine
        synchronous writeback.

        Args:
            bio(gdb.Value<struct buffer_head>): The struct buffer_head to be
                decoded.

        Returns:
            dict: Minimally contains the following items.
                - description (str): Human-readable description of the bio
                - bh (gdb.Value<struct buffer_head>): The struct buffer_head
        """
        desc = (
            "{:x} buffer_head: for dev {}, block {}, size {} (unassociated)".
            format(block_device_name(bh['b_bdev']), bh['b_blocknr'],
                   bh['b_size']))
        chain = {
            'description': desc,
            'bh': bh,
        }
        return chain
Esempio n. 15
0
 def interpret(self) -> None:
     """Interpret the xfsbuf bio to populate its attributes"""
     # pylint: disable=attribute-defined-outside-init
     self.xfsbuf = self.bio['bi_private'].cast(self._types.xfs_buf_p_type)
     self.devname = block_device_name(self.bio['bi_bdev'])
Esempio n. 16
0
 def __str__(self) -> str:
     return self._description.format(int(self.bio),
                                     block_device_name(self.bio['bi_bdev']))
Esempio n. 17
0
 def interpret(self) -> None:
     # pylint: disable=attribute-defined-outside-init
     self.block_device = block_device_name(self.bh['b_bdev'])
Esempio n. 18
0
 def __str__(self) -> str:
     return self._description.format(block_device_name(self.bh['b_bdev']),
                                     self.bh['b_blocknr'], self.bh['b_size'])
Esempio n. 19
0
 def __str__(self) -> str:
     return self.description.format(int(self.bio), self.inode['i_ino'],
                                    self.fstype,
                                    block_device_name(self.bio['bi_bdev']))
Esempio n. 20
0
 def test_block_device_name(self):
     bdev = self.get_block_device()
     self.assertTrue(type(bdev) is gdb.Value)
     self.assertTrue(bdev.type == self.block_device_type)
     name = storage.block_device_name(bdev)
     self.assertTrue(type(name) is str)
Esempio n. 21
0
 def test_block_device_name_poisonptr(self):
     bdev = util.get_typed_pointer(self.poisonptr, self.block_device_type).dereference()
     self.assertTrue(type(bdev) is gdb.Value)
     self.assertTrue(bdev.type == self.block_device_type)
     with self.assertRaises(gdb.NotAvailableError):
         name = storage.block_device_name(bdev)