xiaoxiang781216 commented on code in PR #11140:
URL: https://github.com/apache/nuttx/pull/11140#discussion_r1387461674


##########
fs/inode/fs_files.c:
##########
@@ -756,28 +714,18 @@ int nx_close_from_tcb(FAR struct tcb_s *tcb, int fd)
 
   /* Perform the protected close operation */
 
-  ret = nxmutex_lock(&list->fl_lock);
-  if (ret < 0)
-    {
-      return ret;
-    }
-
   /* If the file was properly opened, there should be an inode assigned */
 
   if (fd < 0 || fd >= list->fl_rows * CONFIG_NFILE_DESCRIPTORS_PER_BLOCK ||
-      !list->fl_files[fd / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK]
-                     [fd % CONFIG_NFILE_DESCRIPTORS_PER_BLOCK].f_inode)
+      files_fget(list, fd)->f_inode == NULL)

Review Comment:
   let's save to filep to remove the line 725.



##########
include/nuttx/fs/fs.h:
##########
@@ -850,6 +850,19 @@ void files_initlist(FAR struct filelist *list);
 
 void files_releaselist(FAR struct filelist *list);
 
+/****************************************************************************
+ * Name: files_get_filecount
+ *
+ * Description:
+ *   Get file count from file list
+ *
+ * Returned Value:
+ *   file count of file list
+ *
+ ****************************************************************************/
+
+int files_get_filecount(FAR struct filelist *list);

Review Comment:
   files_countlist, files_get_count or files_get_number



##########
fs/inode/fs_files.c:
##########
@@ -51,59 +51,118 @@
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: files_fget_index
+ ****************************************************************************/
+
+static FAR struct file *files_fget_index(FAR struct filelist *list,
+                                         int l1, int l2)
+{
+  FAR struct file *filep;
+  irqstate_t flags;
+
+  flags = enter_critical_section();

Review Comment:
   I think @raiden00pl suggest that spinlock can be faster in SMP case, so it's 
better to change mutex to spinlock_t



##########
fs/inode/fs_files.c:
##########
@@ -51,14 +51,47 @@
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: files_fget_index
+ ****************************************************************************/
+
+static FAR struct file *files_fget_index(FAR struct filelist *list,
+                                         int l1, int l2)
+{
+  FAR struct file *filep;
+  irqstate_t flags;
+
+  flags = enter_critical_section();
+
+  filep = &list->fl_files[l1][l2];
+
+  leave_critical_section(flags);
+
+  return filep;
+}
+
+/****************************************************************************
+ * Name: files_fget
+ ****************************************************************************/
+
+static FAR struct file *files_fget(FAR struct filelist *list, int fd)

Review Comment:
   files_fget->files_get



##########
fs/inode/fs_files.c:
##########
@@ -51,14 +51,47 @@
  * Private Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: files_fget_index
+ ****************************************************************************/
+
+static FAR struct file *files_fget_index(FAR struct filelist *list,

Review Comment:
   files_fget_index->files_get_by_index



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to