From owner-freebsd-fs@FreeBSD.ORG Sun Apr 26 21:30:24 2009 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 82BB6106564A for ; Sun, 26 Apr 2009 21:30:24 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: from kiwi-computer.com (keira.kiwi-computer.com [63.224.10.3]) by mx1.freebsd.org (Postfix) with SMTP id 16CBA8FC0C for ; Sun, 26 Apr 2009 21:30:23 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: (qmail 51951 invoked by uid 2001); 26 Apr 2009 21:03:43 -0000 Date: Sun, 26 Apr 2009 16:03:43 -0500 From: "Rick C. Petty" To: Rick Macklem Message-ID: <20090426210343.GA51829@keira.kiwi-computer.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: freebsd-fs@freebsd.org Subject: Re: Why do some ufs i-node fields have 2 copies? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rick-freebsd2008@kiwi-computer.com List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Apr 2009 21:30:24 -0000 On Sun, Apr 26, 2009 at 04:56:03PM -0400, Rick Macklem wrote: > > I was just wondering if anyone conversant with ufs/ffs could tell me why > the following fields of the i-node have off-disk and on-disk copies? > (One thought I had was that these fields are sometimes set to values > that shouldn't get saved on-disk, but it was just a hunch.) > /* > * Copies from the on-disk dinode itself. > */ > u_int16_t i_mode; /* IFMT, permissions; see below. */ > int16_t i_nlink; /* File link count. */ > u_int64_t i_size; /* File byte count. */ > u_int32_t i_flags; /* Status flags (chflags). */ > int64_t i_gen; /* Generation number. */ > u_int32_t i_uid; /* File owner. */ > u_int32_t i_gid; /* File group. */ > /* > * The real copy of the on-disk inode. You missed a few lines: union { struct ufs1_dinode *din1; /* UFS1 on-disk dinode. */ struct ufs2_dinode *din2; /* UFS2 on-disk dinode. */ } dinode_u; The reason is that the first set (the "copies") are what are referenced by the ffs/ufs code. The real copies are what came from the disk (hence the "on-disk"). Because UFS1 & UFS2 have such different dinode structures, the copies are moved to/from the dinode structures when the inode is read to or written from the disk. At all other times, the "copies" are used. -- Rick C. Petty