From: Matthew Wilcox Subject: Re: Files, Inodes, and Blocks Date: Sat, 4 Oct 2003 20:39:41 +0100 Sender: linux-fsdevel-owner@vger.kernel.org Message-ID: <20031004193941.GK24824@parcelfarce.linux.theplanet.co.uk> References: <200310041410.03395.theman@josephdwagner.info> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from parcelfarce.linux.theplanet.co.uk ([195.92.249.252]:3713 "EHLO www.linux.org.uk") by vger.kernel.org with ESMTP id S262719AbTJDTjm (ORCPT ); Sat, 4 Oct 2003 15:39:42 -0400 To: "Joseph D. Wagner" Content-Disposition: inline In-Reply-To: <200310041410.03395.theman@josephdwagner.info> List-Id: linux-fsdevel.vger.kernel.org On Sat, Oct 04, 2003 at 02:10:03PM +0600, Joseph D. Wagner wrote: > There is a 1:1 relationship between the number of files and the number of > used inodes. In other words, each file has only one corresponding inode. > > There is a 1:many relationship between the number of used inodes (1) and the > number of used blocks (many). In other words, one inode can refer to many > blocks. Assuming you're talking about a "classic" Unix filesystem like ext2, yes. I think you probably need to read some of the classic texts on Unix filesystems. Many libraries have this available: Leffler, Samuel J., Marshall Kirk McKusick, Michael J. Karels, and John S. Quarterman, The Design and Implementation of the 4.3BSD UNIX Operating System, Addison-Wesley, Reading, MA, 1989. $40 ISBN 0-201-06196-1. which was how I learned about how Unix filesystems work. I'm sure there are other good books. FWIW, in BSD's FFS and several other filesystems (not ext2 though), there are ways for multiple files to share the same block (fragments or tail-packing), so blocks <-> files can be many-to-many. The other thing that tends to confuse people new to Unix filesystems is that an inode is a file, but files can have 0-or-more names. That is, a file will continue to exist as long as there is a reference to it, where a reference can be an open file handle or a directory entry. And multiple directory entries can refer to the same file (see ln(1)). -- "It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk