Skip to contentSkip to conversation

f2fs: remove unnecessary judgment in f2fs_drop_inode

PATCH In review Liu Song via Linux-f2fs-devel 2 participants 3 messages Aug 6, 2020 – Aug 9, 2020 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: remove unnecessary judgment in f2fs_drop_inode

From: Liu Song <[email protected]>

Inode hash has been removed in "make_bad_inode". If inode_unhashed is false, it must not be a bad inode.

---
 fs/f2fs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/super.c +1 -1
index 20e56b0fa46a..ee01d15effe3 100644
@@ -1043,7 +1043,7 @@ static int f2fs_drop_inode(struct inode *inode)
 	 *       - inode_wait_for_writeback(inode)
 	 */
 	if ((!inode_unhashed(inode) && inode->i_state & I_SYNC)) {
-		if (!inode->i_nlink && !is_bad_inode(inode)) {
+		if (!inode->i_nlink) {
 			/* to avoid evict_inode call simultaneously */
 			atomic_inc(&inode->i_count);
 			spin_unlock(&inode->i_lock);
Signature · 8 lines
2.20.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 15 lines · On 2020/8/6 23:03, Liu Song via Linux-f2fs-devel wrote:

From: Liu Song <[email protected]>

Inode hash has been removed in "make_bad_inode". If inode_unhashed is false, it must not be a bad inode.

---
  fs/f2fs/super.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/super.c +0 -0
index 20e56b0fa46a..ee01d15effe3 100644

fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 1045

Quoted 3 lines
fs/f2fs/super.c +0 -0
@@ -1043,7 +1043,7 @@ static int f2fs_drop_inode(struct inode *inode)
  	 *       - inode_wait_for_writeback(inode)
  	 */
  	if ((!inode_unhashed(inode) && inode->i_state & I_SYNC)) {

Since logic of "bad inode should be removed from hash" is not controlled by f2fs, so let's add below condition to make sure the rule of vfs is as it is.

f2fs_bug_on(sbi, is_bad_inode(inode));

Quoted 6 lines
fs/f2fs/super.c +1 -1
-		if (!inode->i_nlink && !is_bad_inode(inode)) {
+		if (!inode->i_nlink) {
  			/* to avoid evict_inode call simultaneously */
  			atomic_inc(&inode->i_count);
  			spin_unlock(&inode->i_lock);
#2 lore raw
Quoted 10 lines
Quoted 10 lines

From: Liu Song <[email protected]>

Inode hash has been removed in "make_bad_inode". If inode_unhashed is false, it must not be a bad inode.

---
  fs/f2fs/super.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines

fs/f2fs/super.c static int f2fs_drop_inode(struct inode *inode) · line 1045

Quoted 8 lines
fs/f2fs/super.c +0 -0
index 20e56b0fa46a..ee01d15effe3 100644
@@ -1043,7 +1043,7 @@ static int f2fs_drop_inode(struct inode *inode)
    *       - inode_wait_for_writeback(inode)
    */
   if ((!inode_unhashed(inode) && inode->i_state & I_SYNC)) {

Since logic of "bad inode should be removed from hash" is not controlled by f2fs, so let's add below condition to make sure the rule of vfs is as it is.

Very reasonable, thank you for your reply :D

Thanks
Liu Song

Quoted 9 lines

f2fs_bug_on(sbi, is_bad_inode(inode));

Quoted 6 lines
fs/f2fs/super.c +1 -1
-  if (!inode->i_nlink && !is_bad_inode(inode)) {
+  if (!inode->i_nlink) {
     /* to avoid evict_inode call simultaneously */
     atomic_inc(&inode->i_count);
     spin_unlock(&inode->i_lock);

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel