Changeset 9f527308 in rtems


Ignore:
Timestamp:
Jun 12, 2012, 7:46:09 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
51c85da2, 65d8263
Parents:
7d4a859
git-author:
Sebastian Huber <sebastian.huber@…> (06/12/12 07:46:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/12/12 08:12:40)
Message:

libblock: Add block device statistics

Files:
7 added
10 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/Makefile.am

    r7d4a859 r9f527308  
    88    src/blkdev-ioctl.c \
    99    src/blkdev-ops.c \
     10    src/blkdev-print-stats.c \
     11    src/blkdev-blkstats.c \
    1012    src/diskdevs.c \
    1113    src/diskdevs-init.c \
  • cpukit/libblock/include/rtems/bdbuf.h

    r7d4a859 r9f527308  
    663663rtems_bdbuf_set_block_size (rtems_disk_device *dd, uint32_t block_size);
    664664
     665/**
     666 * @brief Returns the block device statistics.
     667 */
     668void
     669rtems_bdbuf_get_device_stats (const rtems_disk_device *dd,
     670                              rtems_blkdev_stats      *stats);
     671
     672/**
     673 * @brief Resets the block device statistics.
     674 */
     675void
     676rtems_bdbuf_reset_device_stats (rtems_disk_device *dd);
     677
    665678/** @} */
    666679
  • cpukit/libblock/include/rtems/blkdev.h

    r7d4a859 r9f527308  
    1717#include <rtems.h>
    1818#include <rtems/diskdevs.h>
     19#include <rtems/bspIo.h>
    1920#include <sys/ioctl.h>
     21#include <stdio.h>
    2022
    2123#ifdef __cplusplus
     
    162164#define RTEMS_BLKIO_GETDISKDEV      _IOR('B', 9, rtems_disk_device *)
    163165#define RTEMS_BLKIO_PURGEDEV        _IO('B', 10)
     166#define RTEMS_BLKIO_GETDEVSTATS     _IOR('B', 11, rtems_blkdev_stats *)
     167#define RTEMS_BLKIO_RESETDEVSTATS   _IO('B', 12)
    164168
    165169/** @} */
     
    207211{
    208212  return ioctl(fd, RTEMS_BLKIO_PURGEDEV);
     213}
     214
     215static inline int rtems_disk_fd_get_device_stats(
     216  int fd,
     217  rtems_blkdev_stats *stats
     218)
     219{
     220  return ioctl(fd, RTEMS_BLKIO_GETDEVSTATS, stats);
     221}
     222
     223static inline int rtems_disk_fd_reset_device_stats(int fd)
     224{
     225  return ioctl(fd, RTEMS_BLKIO_RESETDEVSTATS);
    209226}
    210227
     
    362379);
    363380
     381/**
     382 * @brief Prints the block device statistics.
     383 */
     384void rtems_blkdev_print_stats(
     385  const rtems_blkdev_stats *stats,
     386  rtems_printk_plugin_t print,
     387  void *print_arg
     388);
     389
     390/**
     391 * @brief Block device statistics command.
     392 */
     393void rtems_blkstats(
     394  FILE *output,
     395  const char *device,
     396  bool reset
     397);
     398
    364399/** @} */
    365400
  • cpukit/libblock/include/rtems/diskdevs.h

    r7d4a859 r9f527308  
    8888
    8989/**
     90 * @brief Block device statistics.
     91 *
     92 * Integer overflows in the statistic counters may happen.
     93 */
     94typedef struct {
     95  /**
     96   * @brief Read hit count.
     97   *
     98   * A read hit occurs in the rtems_bdbuf_read() function in case the block is
     99   * in the cached or modified state.
     100   */
     101  uint32_t read_hits;
     102
     103  /**
     104   * @brief Read miss count.
     105   *
     106   * A read miss occurs in the rtems_bdbuf_read() function in case the block is
     107   * in the empty state and a read transfer must be initiated to read the data
     108   * from the device.
     109   */
     110  uint32_t read_misses;
     111
     112  /**
     113   * @brief Read-ahead transfer count.
     114   *
     115   * Each read-ahead transfer may read multiple blocks.
     116   */
     117  uint32_t read_ahead_transfers;
     118
     119  /**
     120   * @brief Count of blocks transfered from the device.
     121   */
     122  uint32_t read_blocks;
     123
     124  /**
     125   * @brief Read error count.
     126   *
     127   * Error count of transfers issued by the read or read-ahead requests.
     128   */
     129  uint32_t read_errors;
     130
     131  /**
     132   * @brief Write transfer count.
     133   *
     134   * Each write transfer may write multiple blocks.
     135   */
     136  uint32_t write_transfers;
     137
     138  /**
     139   * @brief Count of blocks transfered to the device.
     140   */
     141  uint32_t write_blocks;
     142
     143  /**
     144   * @brief Write error count.
     145   *
     146   * Error count of transfers issued by write requests.
     147   */
     148  uint32_t write_errors;
     149} rtems_blkdev_stats;
     150
     151/**
    90152 * @brief Description of a disk device (logical and physical disks).
    91153 *
     
    201263   */
    202264  bool deleted;
     265
     266  /**
     267   * @brief Device statistics for this disk.
     268   */
     269  rtems_blkdev_stats stats;
    203270
    204271  /**
  • cpukit/libblock/src/bdbuf.c

    r7d4a859 r9f527308  
    19001900  rtems_bdbuf_lock_cache ();
    19011901
     1902  /* Statistics */
     1903  if (req->req == RTEMS_BLKDEV_REQ_READ)
     1904  {
     1905    dd->stats.read_blocks += req->bufnum;
     1906    if (sc != RTEMS_SUCCESSFUL)
     1907      ++dd->stats.read_errors;
     1908  }
     1909  else
     1910  {
     1911    dd->stats.write_blocks += req->bufnum;
     1912    ++dd->stats.write_transfers;
     1913    if (sc != RTEMS_SUCCESSFUL)
     1914      ++dd->stats.write_errors;
     1915  }
     1916
    19021917  for (transfer_index = 0; transfer_index < req->bufnum; ++transfer_index)
    19031918  {
     
    20752090    {
    20762091      case RTEMS_BDBUF_STATE_CACHED:
     2092        ++dd->stats.read_hits;
    20772093        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_CACHED);
    20782094        break;
    20792095      case RTEMS_BDBUF_STATE_MODIFIED:
     2096        ++dd->stats.read_hits;
    20802097        rtems_bdbuf_set_state (bd, RTEMS_BDBUF_STATE_ACCESS_MODIFIED);
    20812098        break;
    20822099      case RTEMS_BDBUF_STATE_EMPTY:
     2100        ++dd->stats.read_misses;
    20832101        rtems_bdbuf_set_read_ahead_trigger (dd, block);
    20842102        sc = rtems_bdbuf_execute_read_request (dd, bd, 1);
     
    30263044          }
    30273045
     3046          ++dd->stats.read_ahead_transfers;
    30283047          rtems_bdbuf_execute_read_request (dd, bd, transfer_count);
    30293048        }
     
    30403059  rtems_task_delete (RTEMS_SELF);
    30413060}
     3061
     3062void rtems_bdbuf_get_device_stats (const rtems_disk_device *dd,
     3063                                   rtems_blkdev_stats      *stats)
     3064{
     3065  rtems_bdbuf_lock_cache ();
     3066  *stats = dd->stats;
     3067  rtems_bdbuf_unlock_cache ();
     3068}
     3069
     3070void rtems_bdbuf_reset_device_stats (rtems_disk_device *dd)
     3071{
     3072  rtems_bdbuf_lock_cache ();
     3073  memset (&dd->stats, 0, sizeof(dd->stats));
     3074  rtems_bdbuf_unlock_cache ();
     3075}
  • cpukit/libblock/src/blkdev-ioctl.c

    r7d4a859 r9f527308  
    6565            break;
    6666
     67        case RTEMS_BLKIO_GETDEVSTATS:
     68            rtems_bdbuf_get_device_stats(dd, (rtems_blkdev_stats *) argp);
     69            break;
     70
     71        case RTEMS_BLKIO_RESETDEVSTATS:
     72            rtems_bdbuf_reset_device_stats(dd);
     73            break;
     74
    6775        default:
    6876            errno = EINVAL;
  • cpukit/libmisc/Makefile.am

    r7d4a859 r9f527308  
    105105    shell/main_mkrfs.c shell/main_debugrfs.c \
    106106    shell/main_lsof.c \
     107    shell/main_blkstats.c \
    107108    shell/shell-wait-for-input.c
    108109
  • cpukit/libmisc/shell/shellconfig.h

    r7d4a859 r9f527308  
    6666extern rtems_shell_cmd_t rtems_shell_UNMOUNT_Command;
    6767extern rtems_shell_cmd_t rtems_shell_BLKSYNC_Command;
     68extern rtems_shell_cmd_t rtems_shell_BLKSTATS_Command;
    6869extern rtems_shell_cmd_t rtems_shell_FDISK_Command;
    6970extern rtems_shell_cmd_t rtems_shell_DD_Command;
     
    351352    #endif
    352353    #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
     354         !defined(CONFIGURE_SHELL_NO_COMMAND_BLKSTATS)) || \
     355        defined(CONFIGURE_SHELL_COMMAND_BLKSTATS)
     356      &rtems_shell_BLKSTATS_Command,
     357    #endif
     358    #if (defined(CONFIGURE_SHELL_COMMANDS_ALL) && \
    353359         !defined(CONFIGURE_SHELL_NO_COMMAND_FDISK)) || \
    354360        defined(CONFIGURE_SHELL_COMMAND_FDISK)
  • testsuites/libtests/Makefile.am

    r7d4a859 r9f527308  
    22
    33SUBDIRS = POSIX
     4SUBDIRS += block14
    45SUBDIRS += block13
    56SUBDIRS += rbheap01
  • testsuites/libtests/configure.ac

    r7d4a859 r9f527308  
    4242# Explicitly list all Makefiles here
    4343AC_CONFIG_FILES([Makefile
     44block14/Makefile
    4445block13/Makefile
    4546rbheap01/Makefile
Note: See TracChangeset for help on using the changeset viewer.