Skip to content

Instantly share code, notes, and snippets.

@macdice
Created August 27, 2017 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macdice/873cda3af78b615f41647a161286ba8d to your computer and use it in GitHub Desktop.
Save macdice/873cda3af78b615f41647a161286ba8d to your computer and use it in GitHub Desktop.
diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index f5a45f1..50296f7 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -218,6 +218,29 @@ retry:
}
int
+ffs_sync_file_range(struct vnode *vp, off_t begin, size_t size)
+{
+ struct buf *bp, *nbp;
+ struct bufobj *bo = &vp->v_bufobj;
+ off_t past_end = begin + size;
+
+ /*
+ * Walk the dirty buffer list looking for buffers that overlap the given
+ * range, and request asynchronous write-back.
+ */
+ BO_LOCK(bo);
+ TAILQ_FOREACH_SAFE(bp, &bo->dirty.bv_hd, b_objufs, nbp) {
+ if (bp->b_offset + bp->bufsize > begin && bp->b_offset < past_end) {
+ bremfree(bp);
+ (void) bawrite(bp);
+ }
+ }
+ BO_UNLOCK(bo);
+
+ return (0);
+}
+
+int
ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
{
struct inode *ip;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment