Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Oct 2006 23:26:48 -0700 (PDT)
From:      Shane Adams <adamsch1@yahoo.com>
To:        Scott Long <scottl@samsco.org>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: curiosity between bread and UFS_BALLOC on struct buf
Message-ID:  <20061003062648.24344.qmail@web31810.mail.mud.yahoo.com>

next in thread | raw e-mail | index | archive | help
Hey thanks for the response!  I should of mentioned that I am hacking on my=
 own filesystem, using UFS/FFS as a basis.  So I'm actually below VOP_*.   =
I did find in my digging throught the code that UFS_BALLOC ultimatly for my=
 code path gets the bufer from a call to getblk.=0A=0AFrom the documentatio=
n I've read I would think that I could then immediatly bwrite on that buffe=
r, which I attempt, but my change application specific changes to the buffe=
r do not persist.  I have a couple of anciallary functions that do the brea=
d/bwrite and those work perfectly.=0A=0A*shrug*=0A=0AHopefully I'll nail it=
!=0A=0ACheers,=0A  Shane=0A=0A=0A----- Original Message ----=0AFrom: Scott =
Long <scottl@samsco.org>=0ATo: Shane Adams <adamsch1@yahoo.com>=0ACc: freeb=
sd-fs@freebsd.org=0ASent: Monday, October 2, 2006 8:31:44 PM=0ASubject: Re:=
 curiosity between bread and UFS_BALLOC on struct buf=0A=0A=0A=0AOn Mon, 2 =
Oct 2006, Shane Adams wrote:=0A=0A> Hey all,=0A=0A> I've been puzzling with=
 a bit of code.  I'm creating a file from within=0A> a kernel module, that =
works fine, but I've got a question if perhaps I'm=0A> missing something:=
=0A>=0A> I use UFS_BALLOC to allocate some space.  That function has a stru=
ct buf=0A> thats returned.  What I would expect is that I could manipulate =
the=0A> bp->b_data field then do a bwrite and have my changes saved.  Doesn=
t =0A> workthat way.  Only way I can get it to work is=0A> =0A> 1 UFS_BALLO=
C( ... )=0A> =0A> 2 bwrite( .. )=0A> =0A> 3 bread( ... )=0A> =0A> 4 /* Make=
 changes to what I read */=0A> =0A> 5 bwrite()=0A> =0A> Seems like I could =
get rid of, 2 and 3.  I'm not sure why I have to =0A> bwrite the buffer ret=
urned from UFS_BALLOC.  I dug around and there are=0A> a few examples of wh=
ere ffs/ufs manipulate the buffer returned from=0A> UFS_BALLOC so I am gues=
sing I'm missing a flag or something.=0A> =0A> Hope the question is clear e=
nough!=0A=0AYou shouldn't be groping around in UFS internals like this.  Us=
ing =0AVOP_WRITE will probably serve you much better.  Look at something li=
ke=0Akern_ktrace.c to see how file writing in the kernel is done.=0A=0AScot=
t=0A=0A=0A=0A



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061003062648.24344.qmail>