Skip to content

Commit ee2a2d9

Browse files
markjdbbehlendorf
authored andcommitted
Revert "FreeBSD: zfs_putpages: don't undirty pages until after write completes"
This causes async putpages to leave the pages sbusied for a long time, which hurts concurrency. Revert for now until we have a better approach. This reverts commit 238eab7. Reported by: Ihor Antonov <[email protected]> Discussed with: Rob Norris <[email protected]> References: freebsd/freebsd-src@738a9a7 Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Mark Johnston <[email protected]> Ported-by: Rob Norris <[email protected]> Signed-off-by: Rob Norris <[email protected]> Closes #17533
1 parent 1b84bd1 commit ee2a2d9

File tree

3 files changed

+15
-47
lines changed

3 files changed

+15
-47
lines changed

include/os/freebsd/spl/sys/vm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
extern const int zfs_vm_pagerret_bad;
3636
extern const int zfs_vm_pagerret_error;
3737
extern const int zfs_vm_pagerret_ok;
38-
extern const int zfs_vm_pagerret_pend;
3938
extern const int zfs_vm_pagerput_sync;
4039
extern const int zfs_vm_pagerput_inval;
4140

module/os/freebsd/spl/spl_vm.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
const int zfs_vm_pagerret_bad = VM_PAGER_BAD;
4444
const int zfs_vm_pagerret_error = VM_PAGER_ERROR;
4545
const int zfs_vm_pagerret_ok = VM_PAGER_OK;
46-
const int zfs_vm_pagerret_pend = VM_PAGER_PEND;
4746
const int zfs_vm_pagerput_sync = VM_PAGER_PUT_SYNC;
4847
const int zfs_vm_pagerput_inval = VM_PAGER_PUT_INVAL;
4948

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
2626
* Copyright (c) 2014 Integros [integros.com]
2727
* Copyright 2017 Nexenta Systems, Inc.
28-
* Copyright (c) 2025, Klara, Inc.
2928
*/
3029

3130
/* Portions Copyright 2007 Jeremy Teo */
@@ -4300,33 +4299,6 @@ zfs_freebsd_getpages(struct vop_getpages_args *ap)
43004299
ap->a_rahead));
43014300
}
43024301

4303-
typedef struct {
4304-
uint_t pca_npages;
4305-
vm_page_t pca_pages[];
4306-
} putpage_commit_arg_t;
4307-
4308-
static void
4309-
zfs_putpage_commit_cb(void *arg)
4310-
{
4311-
putpage_commit_arg_t *pca = arg;
4312-
vm_object_t object = pca->pca_pages[0]->object;
4313-
4314-
zfs_vmobject_wlock(object);
4315-
4316-
for (uint_t i = 0; i < pca->pca_npages; i++) {
4317-
vm_page_t pp = pca->pca_pages[i];
4318-
vm_page_undirty(pp);
4319-
vm_page_sunbusy(pp);
4320-
}
4321-
4322-
vm_object_pip_wakeupn(object, pca->pca_npages);
4323-
4324-
zfs_vmobject_wunlock(object);
4325-
4326-
kmem_free(pca,
4327-
offsetof(putpage_commit_arg_t, pca_pages[pca->pca_npages]));
4328-
}
4329-
43304302
static int
43314303
zfs_putpages(struct vnode *vp, vm_page_t *ma, size_t len, int flags,
43324304
int *rtvals)
@@ -4428,12 +4400,10 @@ zfs_putpages(struct vnode *vp, vm_page_t *ma, size_t len, int flags,
44284400
}
44294401

44304402
if (zp->z_blksz < PAGE_SIZE) {
4431-
vm_ooffset_t woff = off;
4432-
size_t wlen = len;
4433-
for (i = 0; wlen > 0; woff += tocopy, wlen -= tocopy, i++) {
4434-
tocopy = MIN(PAGE_SIZE, wlen);
4403+
for (i = 0; len > 0; off += tocopy, len -= tocopy, i++) {
4404+
tocopy = len > PAGE_SIZE ? PAGE_SIZE : len;
44354405
va = zfs_map_page(ma[i], &sf);
4436-
dmu_write(zfsvfs->z_os, zp->z_id, woff, tocopy, va, tx);
4406+
dmu_write(zfsvfs->z_os, zp->z_id, off, tocopy, va, tx);
44374407
zfs_unmap_page(sf);
44384408
}
44394409
} else {
@@ -4454,19 +4424,19 @@ zfs_putpages(struct vnode *vp, vm_page_t *ma, size_t len, int flags,
44544424
zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime);
44554425
err = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
44564426
ASSERT0(err);
4427+
/*
4428+
* XXX we should be passing a callback to undirty
4429+
* but that would make the locking messier
4430+
*/
4431+
zfs_log_write(zfsvfs->z_log, tx, TX_WRITE, zp, off,
4432+
len, commit, B_FALSE, NULL, NULL);
44574433

4458-
putpage_commit_arg_t *pca = kmem_alloc(
4459-
offsetof(putpage_commit_arg_t, pca_pages[ncount]),
4460-
KM_SLEEP);
4461-
pca->pca_npages = ncount;
4462-
memcpy(pca->pca_pages, ma, sizeof (vm_page_t) * ncount);
4463-
4464-
zfs_log_write(zfsvfs->z_log, tx, TX_WRITE, zp,
4465-
off, len, commit, B_FALSE, zfs_putpage_commit_cb, pca);
4466-
4467-
for (i = 0; i < ncount; i++)
4468-
rtvals[i] = zfs_vm_pagerret_pend;
4469-
4434+
zfs_vmobject_wlock(object);
4435+
for (i = 0; i < ncount; i++) {
4436+
rtvals[i] = zfs_vm_pagerret_ok;
4437+
vm_page_undirty(ma[i]);
4438+
}
4439+
zfs_vmobject_wunlock(object);
44704440
VM_CNT_INC(v_vnodeout);
44714441
VM_CNT_ADD(v_vnodepgsout, ncount);
44724442
}

0 commit comments

Comments
 (0)