This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3bc3092e6a86469c7843e0ed1046271be5e038bc Author: dongjiuzhu1 <dongjiuz...@xiaomi.com> AuthorDate: Mon Jun 2 17:02:18 2025 +0800 fs/fs: remove unnecessary FS_REFCOUNT config Previously, this config was added to ensure that the size of the struct file remained unchanged, thereby preventing the Flash memory of resource-constrained MCUs from being unnecessarily increased. However, we have now refactored the relationship between struct fd and struct file, reducing their memory footprint in both Flash and RAM. Consequently, this config can be removed. Signed-off-by: dongjiuzhu1 <dongjiuz...@xiaomi.com> --- .../stm32/olimex-stm32-p407/configs/kmodule/defconfig | 1 - boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig | 1 - fs/Kconfig | 13 ------------- fs/inode/fs_files.c | 16 ---------------- fs/mmap/Kconfig | 1 - include/nuttx/fs/fs.h | 6 ------ 6 files changed, 38 deletions(-) diff --git a/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig b/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig index dabbb5d714..69c2d52b2d 100644 --- a/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig +++ b/boards/arm/stm32/olimex-stm32-p407/configs/kmodule/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_FS_REFCOUNT is not set CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="olimex-stm32-p407" CONFIG_ARCH_BOARD_OLIMEX_STM32P407=y diff --git a/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig b/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig index 1ca39a69d4..dc2de40c87 100644 --- a/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig +++ b/boards/arm/stm32/stm3240g-eval/configs/knxwm/defconfig @@ -6,7 +6,6 @@ # modifications. # # CONFIG_ARCH_FPU is not set -# CONFIG_FS_REFCOUNT is not set # CONFIG_NXFONTS_DISABLE_16BPP is not set # CONFIG_NXTK_DEFAULT_BORDERCOLORS is not set # CONFIG_NXWM_NXTERM is not set diff --git a/fs/Kconfig b/fs/Kconfig index 3b1af8b404..5aec56452e 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -127,19 +127,6 @@ config FS_HEAPBUF_SECTION Allocated fs heap from the specified section. If not specified, it will alloc from kernel heap. -config FS_REFCOUNT - bool "File reference count" - default !DISABLE_PTHREAD - ---help--- - Enable will Records the number of filep references. The file is - actually closed when the count reaches 0 - - Note that this option will ensure the safety of access to the file - system from multi-tasks (thread A blocking rw(fd), then thread B close(fd)), - the disadvantage is that it will increase the amount of code-size, - there is no need to enable this option if the application could ensure - he file operations are safe. - source "fs/vfs/Kconfig" source "fs/aio/Kconfig" source "fs/semaphore/Kconfig" diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c index d4ecadc91f..310baeff71 100644 --- a/fs/inode/fs_files.c +++ b/fs/inode/fs_files.c @@ -72,7 +72,6 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list, filep = &list->fl_files[l1][l2]; spin_unlock_irqrestore_notrace(&list->fl_lock, flags); -#ifdef CONFIG_FS_REFCOUNT if (filep->f_inode != NULL) { /* When the reference count is zero but the inode has not yet been @@ -100,13 +99,6 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list, *new = true; } -#else - if (filep->f_inode == NULL && new == NULL) - { - filep = NULL; - } -#endif - return filep; } @@ -586,9 +578,7 @@ int file_allocate_from_tcb(FAR struct tcb_s *tcb, FAR struct inode *inode, filep->f_pos = pos; filep->f_inode = inode; filep->f_priv = priv; -#ifdef CONFIG_FS_REFCOUNT atomic_set(&filep->f_refs, 1); -#endif #ifdef CONFIG_FDSAN filep->f_tag_fdsan = 0; #endif @@ -812,7 +802,6 @@ int fs_getfilep(int fd, FAR struct file **filep) * ****************************************************************************/ -#ifdef CONFIG_FS_REFCOUNT void fs_reffilep(FAR struct file *filep) { /* This interface is used to increase the reference count of filep */ @@ -852,7 +841,6 @@ int fs_putfilep(FAR struct file *filep) return ret; } -#endif /**************************************************************************** * Name: nx_dup2_from_tcb @@ -928,7 +916,6 @@ int nx_close_from_tcb(FAR struct tcb_s *tcb, int fd) return -EBADF; } -#ifdef CONFIG_FS_REFCOUNT /* files_fget will increase the reference count, there call fs_putfilep * reduce reference count. @@ -939,9 +926,6 @@ int nx_close_from_tcb(FAR struct tcb_s *tcb, int fd) /* Undo the last reference count from file_allocate_from_tcb */ return fs_putfilep(filep); -#else - return file_close(filep); -#endif } /**************************************************************************** diff --git a/fs/mmap/Kconfig b/fs/mmap/Kconfig index 4d0b2ff963..dbe87b5d3e 100644 --- a/fs/mmap/Kconfig +++ b/fs/mmap/Kconfig @@ -6,7 +6,6 @@ config FS_RAMMAP bool "File mapping emulation" default n - depends on FS_REFCOUNT ---help--- NuttX operates in a flat open address space and is focused on MCUs that do support Memory Management Units (MMUs). Therefore, NuttX generally does not diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h index d169aac287..3be9f34224 100644 --- a/include/nuttx/fs/fs.h +++ b/include/nuttx/fs/fs.h @@ -460,9 +460,7 @@ typedef struct cookie_io_functions_t struct file { int f_oflags; /* Open mode flags */ -#ifdef CONFIG_FS_REFCOUNT atomic_t f_refs; /* Reference count */ -#endif off_t f_pos; /* File position */ FAR struct inode *f_inode; /* Driver or file system interface */ FAR void *f_priv; /* Per file driver private data */ @@ -1221,11 +1219,7 @@ void fs_reffilep(FAR struct file *filep); * ****************************************************************************/ -#ifdef CONFIG_FS_REFCOUNT int fs_putfilep(FAR struct file *filep); -#else -# define fs_putfilep(f) -#endif /**************************************************************************** * Name: file_close