Skip to content

Commit

Permalink
An experiment
Browse files Browse the repository at this point in the history
Signed-off-by: Rich Ercolani <[email protected]>
  • Loading branch information
rincebrain committed Mar 15, 2024
1 parent 8f2f6cd commit e55d3b0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
uint_t inblksz;
uint64_t clear_setid_bits_txg = 0;
uint64_t last_synced_txg = 0;
int busy = 0;

inoff = *inoffp;
outoff = *outoffp;
Expand Down Expand Up @@ -1187,6 +1188,12 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
}
}


if (zn_has_cached_data(inzp, inoff, inoff + size - 1)) {
redo:
zn_flush_cached_data(inzp, B_TRUE);
}

/*
* Maintain predictable lock order.
*/
Expand All @@ -1202,6 +1209,35 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
RL_READER);
}

if (zn_has_cached_data(inzp, inoff, inoff + size - 1)) {
if (busy == 0) {
/*
* We somehow dirtied between flushing and taking the lock, try again

Check failure on line 1215 in module/zfs/zfs_vnops.c

View workflow job for this annotation

GitHub Actions / checkstyle

line > 80 characters
*/
busy = 1;

Check failure on line 1217 in module/zfs/zfs_vnops.c

View workflow job for this annotation

GitHub Actions / checkstyle

spaces instead of tabs

Check failure on line 1217 in module/zfs/zfs_vnops.c

View workflow job for this annotation

GitHub Actions / checkstyle

non-continuation indented 4 spaces
/*

Check failure on line 1218 in module/zfs/zfs_vnops.c

View workflow job for this annotation

GitHub Actions / checkstyle

block comment not indented by tabs
* If we have wait_dirty set, we might as well try a forced flush

Check failure on line 1219 in module/zfs/zfs_vnops.c

View workflow job for this annotation

GitHub Actions / checkstyle

line > 80 characters
* here too.
*/
if (zfs_bclone_wait_dirty) {
last_synced_txg = spa_last_synced_txg(dmu_objset_spa(inos));

Check failure on line 1223 in module/zfs/zfs_vnops.c

View workflow job for this annotation

GitHub Actions / checkstyle

line > 80 characters
txg_wait_synced(dmu_objset_pool(inos),
last_synced_txg + 1);
}

zfs_rangelock_exit(outlr);
zfs_rangelock_exit(inlr);
goto redo;
}
else {
/*
* We tried once, it's churning too much, give up.
*/
error = EAGAIN;
goto unlock;
}
}

inblksz = inzp->z_blksz;

/*
Expand Down Expand Up @@ -1306,6 +1342,8 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
}

nbps = maxblocks;


last_synced_txg = spa_last_synced_txg(dmu_objset_spa(inos));
error = dmu_read_l0_bps(inos, inzp->z_id, inoff, size, bps,
&nbps);
Expand Down

0 comments on commit e55d3b0

Please sign in to comment.