git: 6189672e6008 - main - Handle ERELOOKUP from VOP_FSYNC() in several other places
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Jan 2023 01:55:24 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6189672e600814fec4cc165d25ae050fb2f3a999 commit 6189672e600814fec4cc165d25ae050fb2f3a999 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-01-18 21:09:10 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-01-20 01:54:56 +0000 Handle ERELOOKUP from VOP_FSYNC() in several other places We need to repeat the operation if the vnode was relocked. Reported and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D38114 --- sys/dev/md/md.c | 12 +++++++----- sys/vm/vm_object.c | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 9b8773fc3c91..44358278a237 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -917,11 +917,13 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) */ if (bp->bio_cmd == BIO_FLUSH) { - (void) vn_start_write(vp, &mp, V_WAIT); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - error = VOP_FSYNC(vp, MNT_WAIT, td); - VOP_UNLOCK(vp); - vn_finished_write(mp); + do { + (void) vn_start_write(vp, &mp, V_WAIT); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + error = VOP_FSYNC(vp, MNT_WAIT, td); + VOP_UNLOCK(vp); + vn_finished_write(mp); + } while (error == ERELOOKUP); return (error); } else if (bp->bio_cmd == BIO_DELETE) { error = vn_deallocate(vp, &off, &len, 0, diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 8e146318f0dc..341c8aaec01a 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1233,8 +1233,23 @@ vm_object_sync(vm_object_t object, vm_ooffset_t offset, vm_size_t size, res = vm_object_page_clean(object, offset, offset + size, flags); VM_OBJECT_WUNLOCK(object); - if (fsync_after) - error = VOP_FSYNC(vp, MNT_WAIT, curthread); + if (fsync_after) { + for (;;) { + error = VOP_FSYNC(vp, MNT_WAIT, curthread); + if (error != ERELOOKUP) + break; + + /* + * Allow SU/bufdaemon to handle more + * dependencies in the meantime. + */ + VOP_UNLOCK(vp); + vn_finished_write(mp); + + (void)vn_start_write(vp, &mp, V_WAIT); + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + } + } VOP_UNLOCK(vp); vn_finished_write(mp); if (error != 0)