Introduce vfs_bio_set_valid() and use it from ffs_realloccg(). This
eliminates the misuse of vfs_bio_clrbuf() by ffs_realloccg(). In collaboration with: tegge
This commit is contained in:
parent
5f2df6ce18
commit
dc942dabcf
@ -3624,6 +3624,44 @@ vfs_clean_pages(struct buf *bp)
|
|||||||
VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object);
|
VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* vfs_bio_set_valid:
|
||||||
|
*
|
||||||
|
* Set the range within the buffer to valid. The range is
|
||||||
|
* relative to the beginning of the buffer, b_offset. Note that
|
||||||
|
* b_offset itself may be offset from the beginning of the first
|
||||||
|
* page.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
vfs_bio_set_valid(struct buf *bp, int base, int size)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
vm_page_t m;
|
||||||
|
|
||||||
|
if (!(bp->b_flags & B_VMIO))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fixup base to be relative to beginning of first page.
|
||||||
|
* Set initial n to be the maximum number of bytes in the
|
||||||
|
* first page that can be validated.
|
||||||
|
*/
|
||||||
|
base += (bp->b_offset & PAGE_MASK);
|
||||||
|
n = PAGE_SIZE - (base & PAGE_MASK);
|
||||||
|
|
||||||
|
VM_OBJECT_LOCK(bp->b_bufobj->bo_object);
|
||||||
|
for (i = base / PAGE_SIZE; size > 0 && i < bp->b_npages; ++i) {
|
||||||
|
m = bp->b_pages[i];
|
||||||
|
if (n > size)
|
||||||
|
n = size;
|
||||||
|
vm_page_set_valid(m, base & PAGE_MASK, n);
|
||||||
|
base += n;
|
||||||
|
size -= n;
|
||||||
|
n = PAGE_SIZE;
|
||||||
|
}
|
||||||
|
VM_OBJECT_UNLOCK(bp->b_bufobj->bo_object);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vfs_bio_set_validclean:
|
* vfs_bio_set_validclean:
|
||||||
*
|
*
|
||||||
|
@ -498,6 +498,7 @@ int cluster_read(struct vnode *, u_quad_t, daddr_t, long,
|
|||||||
struct ucred *, long, int, struct buf **);
|
struct ucred *, long, int, struct buf **);
|
||||||
int cluster_wbuild(struct vnode *, long, daddr_t, int);
|
int cluster_wbuild(struct vnode *, long, daddr_t, int);
|
||||||
void cluster_write(struct vnode *, struct buf *, u_quad_t, int);
|
void cluster_write(struct vnode *, struct buf *, u_quad_t, int);
|
||||||
|
void vfs_bio_set_valid(struct buf *, int base, int size);
|
||||||
void vfs_bio_set_validclean(struct buf *, int base, int size);
|
void vfs_bio_set_validclean(struct buf *, int base, int size);
|
||||||
void vfs_bio_clrbuf(struct buf *);
|
void vfs_bio_clrbuf(struct buf *);
|
||||||
void vfs_busy_pages(struct buf *, int clear_modify);
|
void vfs_busy_pages(struct buf *, int clear_modify);
|
||||||
|
@ -326,10 +326,9 @@ retry:
|
|||||||
ip->i_flag |= IN_CHANGE | IN_UPDATE;
|
ip->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||||
allocbuf(bp, nsize);
|
allocbuf(bp, nsize);
|
||||||
bp->b_flags |= B_DONE;
|
bp->b_flags |= B_DONE;
|
||||||
if ((bp->b_flags & (B_MALLOC | B_VMIO)) != B_VMIO)
|
bzero(bp->b_data + osize, nsize - osize);
|
||||||
bzero((char *)bp->b_data + osize, nsize - osize);
|
if ((bp->b_flags & (B_MALLOC | B_VMIO)) == B_VMIO)
|
||||||
else
|
vfs_bio_set_valid(bp, osize, nsize - osize);
|
||||||
vfs_bio_clrbuf(bp);
|
|
||||||
*bpp = bp;
|
*bpp = bp;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -404,10 +403,9 @@ retry:
|
|||||||
ip->i_flag |= IN_CHANGE | IN_UPDATE;
|
ip->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||||
allocbuf(bp, nsize);
|
allocbuf(bp, nsize);
|
||||||
bp->b_flags |= B_DONE;
|
bp->b_flags |= B_DONE;
|
||||||
if ((bp->b_flags & (B_MALLOC | B_VMIO)) != B_VMIO)
|
bzero(bp->b_data + osize, nsize - osize);
|
||||||
bzero((char *)bp->b_data + osize, nsize - osize);
|
if ((bp->b_flags & (B_MALLOC | B_VMIO)) == B_VMIO)
|
||||||
else
|
vfs_bio_set_valid(bp, osize, nsize - osize);
|
||||||
vfs_bio_clrbuf(bp);
|
|
||||||
*bpp = bp;
|
*bpp = bp;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user