Changeset b17bcb3 in rtems


Ignore:
Timestamp:
Dec 13, 2017, 5:18:28 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
3b77417
Parents:
16fc3f9a
git-author:
Sebastian Huber <sebastian.huber@…> (12/13/17 05:18:28)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/02/18 14:01:22)
Message:

JFFS2: Use self-contained recursive mutex

Update #2843.

Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/confdefs.h

    r16fc3f9a rb17bcb3  
    450450    defined(CONFIGURE_FILESYSTEM_JFFS2)
    451451  #include <rtems/jffs2.h>
    452   #if !defined(CONFIGURE_MAXIMUM_JFFS2_MOUNTS)
    453     #define CONFIGURE_MAXIMUM_JFFS2_MOUNTS 1
    454   #endif
    455452  #define CONFIGURE_FILESYSTEM_ENTRY_JFFS2 \
    456453    { RTEMS_FILESYSTEM_TYPE_JFFS2, rtems_jffs2_initialize }
    457   #define _CONFIGURE_SEMAPHORES_FOR_JFFS2 CONFIGURE_MAXIMUM_JFFS2_MOUNTS
    458 #else
    459   #define _CONFIGURE_SEMAPHORES_FOR_JFFS2 0
    460454#endif
    461455
     
    468462     _CONFIGURE_SEMAPHORES_FOR_NFS + \
    469463     _CONFIGURE_SEMAPHORES_FOR_DOSFS + \
    470      _CONFIGURE_SEMAPHORES_FOR_RFS + \
    471      _CONFIGURE_SEMAPHORES_FOR_JFFS2)
     464     _CONFIGURE_SEMAPHORES_FOR_RFS)
    472465
    473466#ifdef CONFIGURE_INIT
  • cpukit/libfs/src/jffs2/src/fs-rtems.c

    r16fc3f9a rb17bcb3  
    316316} rtems_jffs2_fs_info;
    317317
    318 static void rtems_jffs2_do_lock(const struct super_block *sb)
    319 {
    320         rtems_status_code sc = rtems_semaphore_obtain(sb->s_mutex, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
    321         assert(sc == RTEMS_SUCCESSFUL);
    322         (void) sc; /* avoid unused variable warning */
    323 }
    324 
    325 static void rtems_jffs2_do_unlock(const struct super_block *sb)
    326 {
    327         rtems_status_code sc = rtems_semaphore_release(sb->s_mutex);
    328         assert(sc == RTEMS_SUCCESSFUL);
    329         (void) sc; /* avoid unused variable warning */
     318static void rtems_jffs2_do_lock(struct super_block *sb)
     319{
     320        rtems_recursive_mutex_lock(&sb->s_mutex);
     321}
     322
     323static void rtems_jffs2_do_unlock(struct super_block *sb)
     324{
     325        rtems_recursive_mutex_unlock(&sb->s_mutex);
    330326}
    331327
     
    367363        }
    368364
    369         if (sb->s_mutex != 0) {
    370                 rtems_status_code sc = rtems_semaphore_delete(sb->s_mutex);
    371                 assert(sc == RTEMS_SUCCESSFUL);
    372                 (void) sc; /* avoid unused variable warning */
    373         }
    374 
    375365        rtems_jffs2_flash_control_destroy(fs_info->sb.s_flash_control);
    376366        rtems_jffs2_compressor_control_destroy(fs_info->sb.s_compressor_control);
    377 
     367        rtems_recursive_mutex_destroy(&sb->s_mutex);
    378368        free(fs_info);
    379369}
     
    884874static void rtems_jffs2_lock(const rtems_filesystem_mount_table_entry_t *mt_entry)
    885875{
    886         const rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
    887         const struct super_block *sb = &fs_info->sb;
     876        rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
     877        struct super_block *sb = &fs_info->sb;
    888878
    889879        rtems_jffs2_do_lock(sb);
     
    892882static void rtems_jffs2_unlock(const rtems_filesystem_mount_table_entry_t *mt_entry)
    893883{
    894         const rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
    895         const struct super_block *sb = &fs_info->sb;
     884        rtems_jffs2_fs_info *fs_info = mt_entry->fs_info;
     885        struct super_block *sb = &fs_info->sb;
    896886
    897887        rtems_jffs2_do_unlock(sb);
     
    12461236
    12471237        if (err == 0) {
     1238                rtems_recursive_mutex_init(&sb->s_mutex, RTEMS_FILESYSTEM_TYPE_JFFS2);
     1239        }
     1240
     1241        if (err == 0) {
    12481242                uint32_t blocks = fc->flash_size / fc->block_size;
    12491243
     
    12591253                        err = -EINVAL;
    12601254                }
    1261         }
    1262 
    1263         if (err == 0) {
    1264                 rtems_status_code sc = rtems_semaphore_create(
    1265                         rtems_build_name('J', 'F', 'F', 'S'),
    1266                         1,
    1267                         RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY | RTEMS_BINARY_SEMAPHORE,
    1268                         0,
    1269                         &sb->s_mutex
    1270                 );
    1271 
    1272                 err = sc == RTEMS_SUCCESSFUL ? 0 : -ENOMEM;
    12731255        }
    12741256
  • cpukit/libfs/src/jffs2/src/os-rtems.h

    r16fc3f9a rb17bcb3  
    3333
    3434#include <rtems/jffs2.h>
     35#include <rtems/thread.h>
    3536
    3637#define CONFIG_JFFS2_RTIME
     
    105106        bool                    s_is_readonly;
    106107        unsigned char           s_gc_buffer[PAGE_CACHE_SIZE]; // Avoids malloc when user may be under memory pressure
    107         rtems_id                s_mutex;
     108        rtems_recursive_mutex   s_mutex;
    108109        char                    s_name_buf[JFFS2_MAX_NAME_LEN];
    109110};
Note: See TracChangeset for help on using the changeset viewer.