Subject: Re: VOP_BMAP question
To: Juergen Hannken-Illjes <email@example.com>
From: Zhihui Zhang <firstname.lastname@example.org>
Date: 12/23/2003 13:30:42
On Tue, 23 Dec 2003, Juergen Hannken-Illjes wrote:
> On Tue, Dec 23, 2003 at 09:55:37AM -0800, Bill Studenmund wrote:
> > On Fri, Dec 19, 2003 at 10:13:22PM +0100, Juergen Hannken-Illjes wrote:
> > > How does VOP_BMAP() handle fragments?
> > >
> > > Given a file with holes obtained from ftruncate(), what does VOP_BMAP()
> > > return in its argument "bnp" if it finds a fragment?
> > >
> > > Is it the block number of the fragment or will it return (daddr_t)-1?
> > >
> > > Is it always ok to write a full block to "bnp"?
> > I think you've been bitten by an ffs ambiguity (since only ffs has
> > "fragments").
> > What ffs calls a fragment in its documentation (the 1k in an 8k/1k file
> > system) is what the kernel internally calls a block. Since VOP_BMAP()
> > deals with kernel things, a "fragment" is a block, so there is no problem.
> So ufs_bmaparray() first sets "maxrun = MAXPHYS / mp->mnt_stat.f_iosize - 1"
> which is "64k / 8k - 1 == 7" from example above. Then it computes "*runp" as
> the number of 1k blocks (fragments) that are contiguous.
> From sys/dev/vnd.c:
> bsize = vnd->sc_vp->v_mount->mnt_stat.f_iosize;
> error = VOP_BMAP(vnd->sc_vp, bn / bsize, &vp, &nbn, &nra);
> sz = (1 + nra) * bsize;
> This looks like it would run on "blocks" instead of "fragments".
> Still confused,
This IS confusing. The address is measured in units of fragments. A
block's address is actually a fragment address. If a block has 8
fragments, then that fragment address must be a multiple of 8. They should
say a full block or a partial block to clarify things.