Changeset ade135d4 in rtems


Ignore:
Timestamp:
Dec 19, 2016, 9:19:44 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ab834d65
Parents:
07c833f
git-author:
Sebastian Huber <sebastian.huber@…> (12/19/16 09:19:44)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/20/16 07:26:25)
Message:

JFFS2: Add RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION

Add IO control to force a garbage collection.

Update #2844.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/jffs2/include/rtems/jffs2.h

    r07c833f rade135d4  
    556556#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info)
    557557
     558/**
     559 * @brief IO control to force a garbage collection in a JFFS2 filesystem
     560 * instance.
     561 *
     562 * Use this operation with care since it may wear out your flash.
     563 */
     564#define RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION _IO('F', 3)
     565
    558566/** @} */
    559567
  • cpukit/libfs/src/jffs2/src/fs-rtems.c

    r07c833f rade135d4  
    569569                        eno = 0;
    570570                        break;
     571                case RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION:
     572                        eno = -jffs2_garbage_collect_pass(&inode->i_sb->jffs2_sb);
     573                        break;
    571574                default:
    572575                        eno = EINVAL;
  • testsuites/fstests/fsjffs2gc01/init.c

    r07c833f rade135d4  
    110110};
    111111
     112static const rtems_jffs2_info info_after_first_gc = {
     113  .flash_size = 131072,
     114  .flash_blocks = 8,
     115  .flash_block_size = 16384,
     116  .used_size = 23540,
     117  .dirty_size = 30988,
     118  .wasted_size = 7368,
     119  .free_size = 69176,
     120  .bad_size = 0,
     121  .clean_blocks = 0,
     122  .dirty_blocks = 3,
     123  .erasable_blocks = 0,
     124  .free_blocks = 5,
     125  .bad_blocks = 0
     126};
     127
     128static const rtems_jffs2_info info_after_excessive_gc = {
     129  .flash_size = 131072,
     130  .flash_blocks = 8,
     131  .flash_block_size = 16384,
     132  .used_size = 7224,
     133  .dirty_size = 0,
     134  .wasted_size = 12,
     135  .free_size = 123836,
     136  .bad_size = 0,
     137  .clean_blocks = 0,
     138  .dirty_blocks = 0,
     139  .erasable_blocks = 0,
     140  .free_blocks = 8,
     141  .bad_blocks = 0
     142};
     143
    112144static char big[] = "big";
    113145
     
    226258  int fd;
    227259  int rv;
     260  int counter;
    228261  rtems_jffs2_info info;
    229262
     
    247280  ASSERT_INFO(&info, &info_some_files_removed);
    248281
     282  rv = ioctl(fd, RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION);
     283  rtems_test_assert(rv == 0);
     284  ASSERT_INFO(&info, &info_after_first_gc);
     285
     286  counter = 0;
     287
     288  while (true) {
     289    errno = ENXIO;
     290    rv = ioctl(fd, RTEMS_JFFS2_FORCE_GARBAGE_COLLECTION);
     291    if (rv == -1) {
     292      rtems_test_assert(errno == EIO);
     293      break;
     294    }
     295
     296    ++counter;
     297    rtems_test_assert(rv == 0);
     298  }
     299
     300  rtems_test_assert(counter == 19);
     301
     302  rv = ioctl(fd, RTEMS_JFFS2_GET_INFO, &info);
     303  rtems_test_assert(rv == 0);
     304  ASSERT_INFO(&info, &info_after_excessive_gc);
     305
    249306  rv = close(fd);
    250307  rtems_test_assert(rv == 0);
Note: See TracChangeset for help on using the changeset viewer.