]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/fs.c
Update bcachefs sources to ed6b7f81a7 six locks: Disable percpu read lock mode in...
[bcachefs-tools-debian] / libbcachefs / fs.c
index 56091ce8407fee7a9fbb3fccf486ceff4fcffdbe..05f1bdee7260d21e34f4c7eec7fdfbef44e205b0 100644 (file)
@@ -105,7 +105,7 @@ retry:
        if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
                goto retry;
 
-       bch2_fs_fatal_err_on(ret == -ENOENT, c,
+       bch2_fs_fatal_err_on(bch2_err_matches(ret, ENOENT), c,
                             "inode %u:%llu not found when updating",
                             inode_inum(inode).subvol,
                             inode_inum(inode).inum);
@@ -1261,14 +1261,14 @@ retry:
                        goto err;
 
                if (k.k->type != KEY_TYPE_dirent) {
-                       ret = -ENOENT;
+                       ret = -BCH_ERR_ENOENT_dirent_doesnt_match_inode;
                        goto err;
                }
 
                d = bkey_s_c_to_dirent(k);
                ret = bch2_dirent_read_target(&trans, inode_inum(dir), d, &target);
                if (ret > 0)
-                       ret = -ENOENT;
+                       ret = -BCH_ERR_ENOENT_dirent_doesnt_match_inode;
                if (ret)
                        goto err;
 
@@ -1481,22 +1481,14 @@ again:
                        continue;
 
                if (!(inode->v.i_state & I_DONTCACHE) &&
-                   !(inode->v.i_state & I_FREEING)) {
+                   !(inode->v.i_state & I_FREEING) &&
+                   igrab(&inode->v)) {
                        this_pass_clean = false;
 
-                       d_mark_dontcache(&inode->v);
-                       d_prune_aliases(&inode->v);
-
-                       /*
-                        * If i_count was zero, we have to take and release a
-                        * ref in order for I_DONTCACHE to be noticed and the
-                        * inode to be dropped;
-                        */
-
-                       if (!atomic_read(&inode->v.i_count) &&
-                           igrab(&inode->v) &&
-                           darray_push_gfp(&grabbed, inode, GFP_ATOMIC|__GFP_NOWARN))
+                       if (darray_push_gfp(&grabbed, inode, GFP_ATOMIC|__GFP_NOWARN)) {
+                               iput(&inode->v);
                                break;
+                       }
                } else if (clean_pass && this_pass_clean) {
                        wait_queue_head_t *wq = bit_waitqueue(&inode->v.i_state, __I_NEW);
                        DEFINE_WAIT_BIT(wait, &inode->v.i_state, __I_NEW);
@@ -1511,8 +1503,12 @@ again:
        }
        mutex_unlock(&c->vfs_inodes_lock);
 
-       darray_for_each(grabbed, i)
-               iput(&(*i)->v);
+       darray_for_each(grabbed, i) {
+               inode = *i;
+               d_mark_dontcache(&inode->v);
+               d_prune_aliases(&inode->v);
+               iput(&inode->v);
+       }
        grabbed.nr = 0;
 
        if (!clean_pass || !this_pass_clean) {