From owner-freebsd-fs@FreeBSD.ORG Tue Oct 3 06:26:49 2006 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F3C0B16A403 for ; Tue, 3 Oct 2006 06:26:48 +0000 (UTC) (envelope-from adamsch1@yahoo.com) Received: from web31810.mail.mud.yahoo.com (web31810.mail.mud.yahoo.com [68.142.207.73]) by mx1.FreeBSD.org (Postfix) with SMTP id 8F48743D46 for ; Tue, 3 Oct 2006 06:26:48 +0000 (GMT) (envelope-from adamsch1@yahoo.com) Received: (qmail 24346 invoked by uid 60001); 3 Oct 2006 06:26:48 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding; b=BIbO3J1LF5n2izD38teyX+Qm52H05fP+sFKT/lqOr6XquLund9o395YsBmBPGWmtZZO+FEYS5bc//4wQbQmVOXSSQSDcVyTKBd8BdCNYDAMIplrhcH6tr6i8koR7JEcq+2Yq9Rs9B0hBJILwoObSYviTLbToGwoYzZuX5mLmHoU= ; Message-ID: <20061003062648.24344.qmail@web31810.mail.mud.yahoo.com> Received: from [69.236.99.151] by web31810.mail.mud.yahoo.com via HTTP; Mon, 02 Oct 2006 23:26:48 PDT Date: Mon, 2 Oct 2006 23:26:48 -0700 (PDT) From: Shane Adams To: Scott Long MIME-Version: 1.0 Content-Type: text/plain; charset=ascii Content-Transfer-Encoding: quoted-printable Cc: freebsd-fs@freebsd.org Subject: Re: curiosity between bread and UFS_BALLOC on struct buf X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Oct 2006 06:26:49 -0000 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 =0ATo: Shane Adams =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