MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cluster_collectbufs

Function cluster_collectbufs

freebsd/kern/vfs_cluster.c:1049–1085  ·  view source on GitHub ↗

* Collect together all the buffers in a cluster. * Plus add one additional buffer. */

Source from the content-addressed store, hash-verified

1047 * Plus add one additional buffer.
1048 */
1049static struct cluster_save *
1050cluster_collectbufs(struct vnode *vp, struct buf *last_bp, int gbflags)
1051{
1052 struct cluster_save *buflist;
1053 struct buf *bp;
1054 daddr_t lbn;
1055 int i, j, len, error;
1056
1057 len = vp->v_lastw - vp->v_cstart + 1;
1058 buflist = malloc(sizeof(struct buf *) * (len + 1) + sizeof(*buflist),
1059 M_SEGMENT, M_WAITOK);
1060 buflist->bs_nchildren = 0;
1061 buflist->bs_children = (struct buf **) (buflist + 1);
1062 for (lbn = vp->v_cstart, i = 0; i < len; lbn++, i++) {
1063 error = bread_gb(vp, lbn, last_bp->b_bcount, NOCRED,
1064 gbflags, &bp);
1065 if (error != 0) {
1066 /*
1067 * If read fails, release collected buffers
1068 * and return failure.
1069 */
1070 for (j = 0; j < i; j++)
1071 brelse(buflist->bs_children[j]);
1072 free(buflist, M_SEGMENT);
1073 return (NULL);
1074 }
1075 buflist->bs_children[i] = bp;
1076 if (bp->b_blkno == bp->b_lblkno)
1077 VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno,
1078 NULL, NULL);
1079 }
1080 buflist->bs_children[i] = bp = last_bp;
1081 if (bp->b_blkno == bp->b_lblkno)
1082 VOP_BMAP(vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL);
1083 buflist->bs_nchildren = i + 1;
1084 return (buflist);
1085}

Callers 1

cluster_writeFunction · 0.85

Calls 3

mallocFunction · 0.85
brelseFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected