Author: kib
Date: Sat Nov 14 05:19:59 2020
New Revision: 367671
URL: https://svnweb.freebsd.org/changeset/base/367671

Log:
  Add ffs_inode_bwrite() helper.
  
  In collaboration with:        pho
  Reviewed by:  mckusick (previous version), markj
  Tested by:    markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:        https://reviews.freebsd.org/D26136

Modified:
  head/sys/ufs/ffs/ffs_inode.c

Modified: head/sys/ufs/ffs/ffs_inode.c
==============================================================================
--- head/sys/ufs/ffs/ffs_inode.c        Sat Nov 14 05:19:44 2020        
(r367670)
+++ head/sys/ufs/ffs/ffs_inode.c        Sat Nov 14 05:19:59 2020        
(r367671)
@@ -67,6 +67,17 @@ __FBSDID("$FreeBSD$");
 static int ffs_indirtrunc(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
            ufs2_daddr_t, int, ufs2_daddr_t *);
 
+static void
+ffs_inode_bwrite(struct vnode *vp, struct buf *bp, int flags)
+{
+       if ((flags & IO_SYNC) != 0)
+               bwrite(bp);
+       else if (DOINGASYNC(vp))
+               bdwrite(bp);
+       else
+               bawrite(bp);
+}
+
 /*
  * Update the access, modified, and inode change times as specified by the
  * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively.  Write the inode
@@ -357,12 +368,7 @@ ffs_truncate(vp, length, flags, cred)
                DIP_SET(ip, i_size, length);
                if (bp->b_bufsize == fs->fs_bsize)
                        bp->b_flags |= B_CLUSTEROK;
-               if (flags & IO_SYNC)
-                       bwrite(bp);
-               else if (DOINGASYNC(vp))
-                       bdwrite(bp);
-               else
-                       bawrite(bp);
+               ffs_inode_bwrite(vp, bp, flags);
                UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
                return (ffs_update(vp, waitforupdate));
        }
@@ -478,12 +484,7 @@ ffs_truncate(vp, length, flags, cred)
                allocbuf(bp, size);
                if (bp->b_bufsize == fs->fs_bsize)
                        bp->b_flags |= B_CLUSTEROK;
-               if (flags & IO_SYNC)
-                       bwrite(bp);
-               else if (DOINGASYNC(vp))
-                       bdwrite(bp);
-               else
-                       bawrite(bp);
+               ffs_inode_bwrite(vp, bp, flags);
                UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
        }
        /*
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to