From c11cbfd9574434aaae957d478096d911036d4da3 Mon Sep 17 00:00:00 2001 From: Kirk McKusick Date: Mon, 11 Mar 2019 22:42:33 +0000 Subject: [PATCH] Update the main loop in the flushbuflist() routine to properly select buffers for flushing when requested to flush both normal and extended attributes buffers. Sponsored by: Netflix --- sys/kern/vfs_subr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index afc0e786aeef..a6ac7bec13b7 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1756,8 +1756,16 @@ flushbuflist(struct bufv *bufv, int flags, struct bufobj *bo, int slpflag, retval = 0; TAILQ_FOREACH_SAFE(bp, &bufv->bv_hd, b_bobufs, nbp) { - if (((flags & V_NORMAL) && (bp->b_xflags & BX_ALTDATA)) || - ((flags & V_ALT) && (bp->b_xflags & BX_ALTDATA) == 0)) { + /* + * If we are flushing both V_NORMAL and V_ALT buffers then + * do not skip any buffers. If we are flushing only V_NORMAL + * buffers then skip buffers marked as BX_ALTDATA. If we are + * flushing only V_ALT buffers then skip buffers not marked + * as BX_ALTDATA. + */ + if (((flags & (V_NORMAL | V_ALT)) != (V_NORMAL | V_ALT)) && + (((flags & V_NORMAL) && (bp->b_xflags & BX_ALTDATA) != 0) || + ((flags & V_ALT) && (bp->b_xflags & BX_ALTDATA) == 0))) { continue; } if (nbp != NULL) {