Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: add zpl_drop_inode #16612

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 7 additions & 39 deletions module/os/linux/zfs/zfs_znode_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,6 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)

*zpp = NULL;

again:
zh = zfs_znode_hold_enter(zfsvfs, obj_num);

err = sa_buf_hold(zfsvfs->z_os, obj_num, NULL, &db);
Expand All @@ -1076,55 +1075,24 @@ zfs_zget(zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
if (hdl != NULL) {
zp = sa_get_userdata(hdl);


/*
* Since "SA" does immediate eviction we
* should never find a sa handle that doesn't
* know about the znode.
*/

ASSERT3P(zp, !=, NULL);

mutex_enter(&zp->z_lock);
ASSERT3U(zp->z_id, ==, obj_num);
/*
* If zp->z_unlinked is set, the znode is already marked
* for deletion and should not be discovered. Check this
* after checking igrab() due to fsetxattr() & O_TMPFILE.
*
* If igrab() returns NULL the VFS has independently
* determined the inode should be evicted and has
* called iput_final() to start the eviction process.
* The SA handle is still valid but because the VFS
* requires that the eviction succeed we must drop
* our locks and references to allow the eviction to
* complete. The zfs_zget() may then be retried.
*
* This unlikely case could be optimized by registering
* a sops->drop_inode() callback. The callback would
* need to detect the active SA hold thereby informing
* the VFS that this inode should not be evicted.
*/
if (igrab(ZTOI(zp)) == NULL) {
if (zp->z_unlinked)
err = SET_ERROR(ENOENT);
else
err = SET_ERROR(EAGAIN);
} else {
*zpp = zp;
err = 0;
if (zp->z_unlinked) {
sa_buf_rele(db, NULL);
zfs_znode_hold_exit(zfsvfs, zh);
return (SET_ERROR(ENOENT));
}
VERIFY3P(igrab(ZTOI(zp)), !=, NULL);
*zpp = zp;

mutex_exit(&zp->z_lock);
sa_buf_rele(db, NULL);
zfs_znode_hold_exit(zfsvfs, zh);

if (err == EAGAIN) {
/* inode might need this to finish evict */
cond_resched();
goto again;
}
return (err);
return (0);
}

/*
Expand Down
21 changes: 21 additions & 0 deletions module/os/linux/zfs/zpl_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,26 @@ zpl_evict_inode(struct inode *ip)
spl_fstrans_unmark(cookie);
}

static int
zpl_drop_inode(struct inode *ip)
{
znode_t *zp = ITOZ(ip);
dmu_buf_t *db;
int error;

/*
* Don't allow the kernel to proceed to zpl_evict_inode if there's an
* active SA hold so that igrab() in zfs_zget doesn't race against
* eviction
*/
if ((zp->z_sa_hdl && (db = sa_get_db(zp->z_sa_hdl)) &&
dmu_buf_refcount(db)))
return (0);

error = generic_drop_inode(ip);
return (error);
}

static void
zpl_put_super(struct super_block *sb)
{
Expand Down Expand Up @@ -384,6 +404,7 @@ const struct super_operations zpl_super_operations = {
.dirty_inode = zpl_dirty_inode,
.write_inode = NULL,
.evict_inode = zpl_evict_inode,
.drop_inode = zpl_drop_inode,
.put_super = zpl_put_super,
.sync_fs = zpl_sync_fs,
.statfs = zpl_statfs,
Expand Down
6 changes: 6 additions & 0 deletions module/zfs/spa_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ spa_history_log_internal(spa_t *spa, const char *operation,
}
}

if (htx->tx_txg > spa_final_dirty_txg(spa)) {
if (tx == NULL)
dmu_tx_abort(htx);
return;
}

va_start(adx, fmt);
log_internal(fnvlist_alloc(), operation, spa, htx, fmt, adx);
va_end(adx);
Expand Down
Loading