From 01383dc17ce48af0d07a01af8700f569bfb5e071 Mon Sep 17 00:00:00 2001 From: Far Date: Thu, 8 Jul 2021 15:40:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0mount=E7=9A=84MS=5FRD?= =?UTF-8?q?ONLY=E6=A0=87=E5=BF=97=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改jffs2_mount和jffs2_umount的逻辑,使其在只读的形式挂载时不再启动gc线程 Close #I3Z1W6 Signed-off-by: Far --- fs/jffs2/jffs2_fs_sb.h | 2 +- fs/jffs2/os-linux.h | 2 +- fs/jffs2/super.c | 53 +++++++++++++++++++++--------------------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h index 4093420..8efda0d 100755 --- a/fs/jffs2/jffs2_fs_sb.h +++ b/fs/jffs2/jffs2_fs_sb.h @@ -171,12 +171,12 @@ struct super_block { LIST_HEAD s_node_hash[JFFS2_NODE_HASH_BUCKETS]; LosMux s_node_hash_lock; struct jffs2_inode *s_root; - unsigned long s_mount_count; void *s_dev; UINT32 s_lock; /* Lock the inode cache */ EVENT_CB_S s_gc_thread_flags; /* Communication with the gcthread */ unsigned int s_gc_thread; + unsigned long s_mount_flags; }; #define JFFS2_SB_INFO(sb) (&(sb)->jffs2_sb) diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index b45f83b..62c1c6b 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h @@ -189,7 +189,7 @@ int jffs2_flash_direct_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, /* super.c */ int jffs2_fill_super(struct super_block *sb); -int jffs2_mount(int part_no, struct jffs2_inode **root_node); +int jffs2_mount(int part_no, struct jffs2_inode **root_node, unsigned long mountflags); int jffs2_umount(struct jffs2_inode *root_node); #endif /* __JFFS2_OS_LINUX_H__ */ diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index 676e8f1..6f2e5f8 100755 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c @@ -68,7 +68,7 @@ int jffs2_fill_super(struct super_block *sb) return 0; } -int jffs2_mount(int part_no, struct jffs2_inode **root_node) +int jffs2_mount(int part_no, struct jffs2_inode **root_node, unsigned long mountflags) { struct super_block *sb = NULL; struct jffs2_sb_info *c = NULL; @@ -143,9 +143,11 @@ int jffs2_mount(int part_no, struct jffs2_inode **root_node) return ret; } - jffs2_start_garbage_collect_thread(c); + if (!(mountflags & MS_RDONLY)) { + jffs2_start_garbage_collect_thread(c); + } - sb->s_mount_count++; + sb->s_mount_flags = mountflags; *root_node = sb->s_root; return 0; } @@ -159,34 +161,33 @@ int jffs2_umount(struct jffs2_inode *root_node) D2(PRINTK("Jffs2Umount\n")); // Only really umount if this is the only mount - if (sb->s_mount_count == 1) { + if (!(sb->s_mount_flags & MS_RDONLY)) { jffs2_stop_garbage_collect_thread(c); + } - // free directory entries - for (fd = root_node->jffs2_i.dents; fd; fd = next) { - next = fd->next; - jffs2_free_full_dirent(fd); - } + // free directory entries + for (fd = root_node->jffs2_i.dents; fd; fd = next) { + next = fd->next; + jffs2_free_full_dirent(fd); + } - free(root_node); + free(root_node); - // Clean up the super block and root_node inode - jffs2_free_ino_caches(c); - jffs2_free_raw_node_refs(c); - free(c->blocks); - c->blocks = NULL; - free(c->inocache_list); - c->inocache_list = NULL; - (void)Jffs2HashDeinit(&sb->s_node_hash_lock); + // Clean up the super block and root_node inode + jffs2_free_ino_caches(c); + jffs2_free_raw_node_refs(c); + free(c->blocks); + c->blocks = NULL; + free(c->inocache_list); + c->inocache_list = NULL; + (void)Jffs2HashDeinit(&sb->s_node_hash_lock); + + (void)mutex_destroy(&c->alloc_sem); + (void)mutex_destroy(&c->erase_free_sem); + free(sb); + // That's all folks. + D2(PRINTK("Jffs2Umount No current mounts\n")); - (void)mutex_destroy(&c->alloc_sem); - (void)mutex_destroy(&c->erase_free_sem); - free(sb); - // That's all folks. - D2(PRINTK("Jffs2Umount No current mounts\n")); - } else { - sb->s_mount_count--; - } if (--jffs2_mounted_number == 0) { jffs2_destroy_slab_caches(); (void)jffs2_compressors_exit(); -- Gitee