fuse_io.c (dff3a6b4109964418dd88e3aa0d931924b54d149) fuse_io.c (8eecd9ce05ee9744ebf9ecd0c2d1d2431b9fe06c)
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2007-2009 Google Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 551 unchanged lines hidden (view full) ---

560fuse_write_biobackend(struct vnode *vp, struct uio *uio,
561 struct ucred *cred, struct fuse_filehandle *fufh, int ioflag, pid_t pid)
562{
563 struct fuse_vnode_data *fvdat = VTOFUD(vp);
564 struct buf *bp;
565 daddr_t lbn;
566 off_t filesize;
567 int bcount;
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 2007-2009 Google Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 551 unchanged lines hidden (view full) ---

560fuse_write_biobackend(struct vnode *vp, struct uio *uio,
561 struct ucred *cred, struct fuse_filehandle *fufh, int ioflag, pid_t pid)
562{
563 struct fuse_vnode_data *fvdat = VTOFUD(vp);
564 struct buf *bp;
565 daddr_t lbn;
566 off_t filesize;
567 int bcount;
568 int n, on, err = 0;
568 int n, on, seqcount, err = 0;
569 bool last_page;
570
571 const int biosize = fuse_iosize(vp);
572
569 bool last_page;
570
571 const int biosize = fuse_iosize(vp);
572
573 seqcount = ioflag >> IO_SEQSHIFT;
574
573 KASSERT(uio->uio_rw == UIO_WRITE, ("fuse_write_biobackend mode"));
574 if (vp->v_type != VREG)
575 return (EIO);
576 if (uio->uio_offset < 0)
577 return (EINVAL);
578 if (uio->uio_resid == 0)
579 return (0);
580

--- 58 unchanged lines hidden (view full) ---

639 break;
640 }
641 if (extending) {
642 /*
643 * Extend file _after_ locking buffer so we won't race
644 * with other readers
645 */
646 err = fuse_vnode_setsize(vp, uio->uio_offset + n);
575 KASSERT(uio->uio_rw == UIO_WRITE, ("fuse_write_biobackend mode"));
576 if (vp->v_type != VREG)
577 return (EIO);
578 if (uio->uio_offset < 0)
579 return (EINVAL);
580 if (uio->uio_resid == 0)
581 return (0);
582

--- 58 unchanged lines hidden (view full) ---

641 break;
642 }
643 if (extending) {
644 /*
645 * Extend file _after_ locking buffer so we won't race
646 * with other readers
647 */
648 err = fuse_vnode_setsize(vp, uio->uio_offset + n);
649 filesize = uio->uio_offset + n;
647 fvdat->flag |= FN_SIZECHANGE;
648 if (err) {
649 brelse(bp);
650 break;
651 }
652 }
653
654 SDT_PROBE6(fusefs, , io, write_biobackend_start,

--- 127 unchanged lines hidden (view full) ---

782 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 1, bp);
783 err = bwrite(bp);
784 } else if (ioflag & IO_SYNC) {
785 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 2, bp);
786 err = bwrite(bp);
787 } else if (vm_page_count_severe() ||
788 buf_dirty_count_severe() ||
789 (ioflag & IO_ASYNC)) {
650 fvdat->flag |= FN_SIZECHANGE;
651 if (err) {
652 brelse(bp);
653 break;
654 }
655 }
656
657 SDT_PROBE6(fusefs, , io, write_biobackend_start,

--- 127 unchanged lines hidden (view full) ---

785 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 1, bp);
786 err = bwrite(bp);
787 } else if (ioflag & IO_SYNC) {
788 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 2, bp);
789 err = bwrite(bp);
790 } else if (vm_page_count_severe() ||
791 buf_dirty_count_severe() ||
792 (ioflag & IO_ASYNC)) {
790 /* TODO: enable write clustering later */
793 bp->b_flags |= B_CLUSTEROK;
791 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 3, bp);
792 bawrite(bp);
793 } else if (on == 0 && n == bcount) {
794 if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
794 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 3, bp);
795 bawrite(bp);
796 } else if (on == 0 && n == bcount) {
797 if ((vp->v_mount->mnt_flag & MNT_NOCLUSTERW) == 0) {
798 bp->b_flags |= B_CLUSTEROK;
795 SDT_PROBE2(fusefs, , io, write_biobackend_issue,
796 4, bp);
799 SDT_PROBE2(fusefs, , io, write_biobackend_issue,
800 4, bp);
797 bdwrite(bp);
801 cluster_write(vp, bp, filesize, seqcount, 0);
798 } else {
799 SDT_PROBE2(fusefs, , io, write_biobackend_issue,
800 5, bp);
801 bawrite(bp);
802 }
803 } else if (ioflag & IO_DIRECT) {
802 } else {
803 SDT_PROBE2(fusefs, , io, write_biobackend_issue,
804 5, bp);
805 bawrite(bp);
806 }
807 } else if (ioflag & IO_DIRECT) {
808 bp->b_flags |= B_CLUSTEROK;
804 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 6, bp);
805 bawrite(bp);
806 } else {
807 bp->b_flags &= ~B_CLUSTEROK;
808 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 7, bp);
809 bdwrite(bp);
810 }
811 if (err)

--- 208 unchanged lines hidden ---
809 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 6, bp);
810 bawrite(bp);
811 } else {
812 bp->b_flags &= ~B_CLUSTEROK;
813 SDT_PROBE2(fusefs, , io, write_biobackend_issue, 7, bp);
814 bdwrite(bp);
815 }
816 if (err)

--- 208 unchanged lines hidden ---