From owner-freebsd-fs Tue May 25 1:58:40 1999 Delivered-To: freebsd-fs@freebsd.org Received: from peik.bol.sharif.ac.ir (unknown [194.225.42.33]) by hub.freebsd.org (Postfix) with ESMTP id 6C7D014C93 for ; Tue, 25 May 1999 01:58:07 -0700 (PDT) (envelope-from farshid@peik.bol.sharif.ac.ir) Received: from localhost (farshid@localhost) by peik.bol.sharif.ac.ir (8.8.7/8.8.7) with SMTP id NAA00849; Tue, 25 May 1999 13:29:27 +0430 Date: Tue, 25 May 1999 13:29:27 +0430 (IRST) From: Farshid Eslami To: Alfred Perlstein Cc: fs@FreeBSD.ORG Subject: Re: how are partial writes handled in FFS? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, 24 May 1999, Alfred Perlstein wrote: I've not read the FFS code in detail, but as far as I know, if write is not block-aligned, the block should be read from disk and then the write syscall updates the necessary data in block. Otherwise, if the write is block-aligned, there is no need to read the block from disk because all of the block is going to be overwitten. So why should the data that will be overwirtten be read from disk? In this case, there is no need to pay the cost of a read from disk. A block should be assigned from buffer cache to write and write copies the data to the buffer. Again in this case, the content of the buffer is not needed to be zero or any thing else, because all the buffer is overwirtten by write syscall. These are for cached write. For uncached write, it's done through raw device. I don't know exactly how it handles this, but the policy is straight forward. One more point is that if the write in uncached, there is no need to copy data, which size is a multiple of block size, into a separate buffer. There write syscall can send out data directly from user space to device. --Farshid : : considering a (dumb) process that writes to a file calling write() : several times. The writes are done to a buffer, but let's say the : buffer is uncached, what exactly happens? : : does: : A) it fetch the block off disk the write the data into it? : b) a block is allocated for the data and the partial write : is done to it maintaining the offset of the write, the buffer : is marked so that before it : is sync'd back to disk (or any reading from a location not : within the partial write) that a buffer must be allocated, and : the on disk data must be read into the buffer, then merged into : the partially written buffer. : : If it is B, or if sometimes B is a possiblity, can someone show me : where the code that does this is located? : : thanks, : -Alfred : : : : To Unsubscribe: send mail to majordomo@FreeBSD.org : with "unsubscribe freebsd-fs" in the body of the message : Farshid Eslami farshidoo@yahoo.com ----------------------------------------------------------- Without passion man is a mere latent force and possibility, like the flint which awaits the shock of the iron before it can give forth its spark. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message