#4535 closed defect (invalid)

acess JFFS2 sb->s_root question

Reported by: chenjin_zhong Owned by:
Priority: normal Milestone: 5.1
Component: fs/jffs2 Version: 5
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

Hi, I have found when access global structure without mutex or spinlock about JFFS2. The code in RTEMS5.1 are listed as follows:

fs-rtems.c:

1) Add to the icache

for (cached_inode = sb->s_root; cached_inode != NULL;

cached_inode = cached_inode->i_cache_next) {

if (cached_inode->i_cache_next == NULL) {

cached_inode->i_cache_next = inode; Current last in cache points to newcomer
inode->i_cache_prev = cached_inode;
Newcomer points back to last
break;

}

}

2) Check for this inode in the cache

for (inode = sb->s_root; inode != NULL; inode = inode->i_cache_next) {

if (inode->i_ino == ino) {

inode->i_count++;
break;

}

}

when multi-tasks or threads access sb->s_root simultaneously, The behavior is unknown.

Change History (2)

comment:1 Changed on 10/28/21 at 05:19:18 by Sebastian Huber

Resolution: invalid
Status: newclosed

Thanks for your interest in the RTEMS port of JFFS2. If you have questions, then you could also ask them on the devel@… mailing list. The RTEMS port of JFFS2 does not use a file system internal locking. There is a global lock for each JFFS2 instance:

static void rtems_jffs2_do_lock(struct super_block *sb)
{
        rtems_recursive_mutex_lock(&sb->s_mutex);
}

static void rtems_jffs2_do_unlock(struct super_block *sb)
{
        rtems_recursive_mutex_unlock(&sb->s_mutex);
}

comment:2 Changed on 10/28/21 at 05:21:11 by Sebastian Huber

Component: adminfs/jaffs2
Note: See TracTickets for help on using tickets.