Skip to content

Commit 43d0d95

Browse files
Donny9xiaoxiang781216
authored andcommitted
fs/inode: using inode reference to indicate unlink and simply code
Signed-off-by: dongjiuzhu1 <[email protected]>
1 parent c6815bb commit 43d0d95

File tree

12 files changed

+14
-20
lines changed

12 files changed

+14
-20
lines changed

fs/inode/fs_inoderelease.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void inode_release(FAR struct inode *inode)
7676
* now.
7777
*/
7878

79-
if (inode->i_crefs <= 0 && (inode->i_flags & FSNODEFLAG_DELETED) != 0)
79+
if (inode->i_crefs <= 0)
8080
{
8181
/* If the inode has been properly unlinked, then the peer pointer
8282
* should be NULL.

fs/inode/fs_inoderemove.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static FAR struct inode *inode_unlink(FAR const char *path)
9696

9797
node->i_peer = NULL;
9898
node->i_parent = NULL;
99+
node->i_crefs--;
99100
}
100101

101102
RELEASE_SEARCH(&desc);
@@ -135,11 +136,6 @@ int inode_remove(FAR const char *path)
135136

136137
if (node->i_crefs)
137138
{
138-
/* In that case, we will mark it deleted, when the filesystem
139-
* releases the inode, we will then, finally delete the subtree
140-
*/
141-
142-
node->i_flags |= FSNODEFLAG_DELETED;
143139
return -EBUSY;
144140
}
145141
else

fs/inode/fs_inodereserve.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static FAR struct inode *inode_alloc(FAR const char *name, mode_t mode)
8585
if (node)
8686
{
8787
node->i_ino = g_ino++;
88+
node->i_crefs = 1;
8889
#ifdef CONFIG_PSEUDOFS_ATTRIBUTES
8990
node->i_mode = mode;
9091
clock_gettime(CLOCK_REALTIME, &node->i_atime);

fs/mount/fs_mount.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,7 @@ int nx_mount(FAR const char *source, FAR const char *target,
507507
/* A lot of goto's! But they make the error handling much simpler */
508508

509509
errout_with_mountpt:
510-
inode_release(mountpt_inode);
511510
inode_remove(target);
512-
513511
errout_with_lock:
514512
inode_unlock();
515513
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS

fs/mqueue/mq_open.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int nxmq_file_close(FAR struct file *filep)
7474
{
7575
FAR struct inode *inode = filep->f_inode;
7676

77-
if (inode->i_crefs <= 1 && (inode->i_flags & FSNODEFLAG_DELETED))
77+
if (inode->i_crefs <= 0)
7878
{
7979
FAR struct mqueue_inode_s *msgq = inode->i_private;
8080

@@ -322,7 +322,7 @@ static int file_mq_vopen(FAR struct file *mq, FAR const char *mq_name,
322322

323323
/* Set the initial reference count on this inode to one */
324324

325-
inode->i_crefs = 1;
325+
inode->i_crefs++;
326326

327327
if (created)
328328
{

fs/mqueue/mq_unlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ int file_mq_unlink(FAR const char *mq_name)
150150
}
151151

152152
/* Remove the old inode from the tree. Because we hold a reference count
153-
* on the inode, it will not be deleted now. This will set the
154-
* FSNODEFLAG_DELETED bit in the inode flags.
153+
* on the inode, it will not be deleted now. This will put reference of
154+
* inode.
155155
*/
156156

157157
ret = inode_remove(fullpath);

fs/semaphore/sem_close.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int nxsem_close(FAR sem_t *sem)
105105
* now.
106106
*/
107107

108-
if (inode->i_crefs <= 0 && (inode->i_flags & FSNODEFLAG_DELETED) != 0)
108+
if (inode->i_crefs <= 0)
109109
{
110110
/* Destroy the semaphore and free the container */
111111

fs/semaphore/sem_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ int nxsem_open(FAR sem_t **sem, FAR const char *name, int oflags, ...)
211211
/* Initialize the inode */
212212

213213
INODE_SET_NAMEDSEM(inode);
214-
inode->i_crefs = 1;
214+
inode->i_crefs++;
215215

216216
/* Initialize the semaphore */
217217

fs/semaphore/sem_unlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ int nxsem_unlink(FAR const char *name)
115115
}
116116

117117
/* Remove the old inode from the tree. Because we hold a reference count
118-
* on the inode, it will not be deleted now. This will set the
119-
* FSNODEFLAG_DELETED bit in the inode flags.
118+
* on the inode, it will not be deleted now. This will put reference of
119+
* inode.
120120
*/
121121

122122
ret = inode_remove(fullpath);

fs/shm/shm_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int file_shm_open(FAR struct file *shm, FAR const char *name,
137137
INODE_SET_SHM(inode);
138138
inode->u.i_ops = &g_shmfs_operations;
139139
inode->i_private = NULL;
140-
inode->i_crefs = 1;
140+
inode->i_crefs++;
141141
}
142142

143143
/* Associate the inode with a file structure */

0 commit comments

Comments
 (0)