if (size * (lbn + run + 1) > filesize)
if ((u_quad_t)size * (u_quad_t)(lbn + run + 1) > filesize)
cluster_rbuild(vp, filesize, bp, lbn, blkno, size, run, flags)	struct vnode *vp;	u_quad_t filesize;	struct buf *bp;	daddr_t lbn;	daddr_t blkno;	long size;	int run;	long flags;{	struct cluster_save *b_save;	struct buf *tbp;	daddr_t bn;	int i, inc;#ifdef DIAGNOSTIC	if (size != vp->v_mount->mnt_stat.f_iosize)		panic("cluster_rbuild: size %ld != filesize %ld\n",			size, vp->v_mount->mnt_stat.f_iosize);#endif	if (size * (lbn + run + 1) > filesize)		--run;	if (run == 0) {		if (!bp) {			bp = getblk(vp, lbn, size, 0, 0);			bp->b_blkno = blkno;			bp->b_flags |= flags;		}		return(bp);	}	bp = cluster_newbuf(vp, bp, flags, blkno, lbn, size, run + 1);	if (bp->b_flags & (B_DONE | B_DELWRI))		return (bp);	b_save = malloc(sizeof(struct buf *) * run +	    sizeof(struct cluster_save), M_SEGMENT, M_WAITOK);	b_save->bs_bufsize = b_save->bs_bcount = size;	b_save->bs_nchildren = 0;	b_save->bs_children = (struct buf **)(b_save + 1);	b_save->bs_saveaddr = bp->b_saveaddr;	bp->b_saveaddr = (caddr_t) b_save;	inc = btodb(size);	for (bn = blkno + inc, i = 1; i <= run; ++i, bn += inc) {		/*		 * A component of the cluster is already in core,		 * terminate the cluster early.		 */		if (incore(vp, lbn + i))			break;		tbp = getblk(vp, lbn + i, 0, 0, 0);		/*		 * getblk may return some memory in the buffer if there were		 * no empty buffers to shed it to.  If there is currently		 * memory in the buffer, we move it down size bytes to make		 * room for the valid pages that cluster_callback will insert.		 * We do this now so we don't have to do it at interrupt time		 * in the callback routine.		 */		if (tbp->b_bufsize != 0) {			caddr_t bdata = (char *)tbp->b_data;			/*			 * No room in the buffer to add another page,			 * terminate the cluster early.			 */			if (tbp->b_bufsize + size > MAXBSIZE) {#ifdef DIAGNOSTIC				if (tbp->b_bufsize > MAXBSIZE)					panic("cluster_rbuild: too much memory");#endif				/* This buffer is *not* valid.  */				tbp->b_flags |= B_INVAL;				brelse(tbp);				break;			}			pagemove(bdata, bdata + tbp->b_bufsize, size);		}		tbp->b_blkno = bn;		tbp->b_flags |= flags | B_READ | B_ASYNC;		b_save->bs_children[b_save->bs_nchildren++] = tbp;	}	/*	 * The cluster may have been terminated early, adjust the cluster	 * buffer size accordingly.  If no cluster could be formed,	 * deallocate the cluster save info.	 */	if (i <= run) {		if (i == 1) {			bp->b_saveaddr = b_save->bs_saveaddr;			bp->b_flags &= ~B_CALL;			bp->b_iodone = NULL;			free(b_save, M_SEGMENT);		}		allocbuf(bp, size * i);	}	return(bp);}