Date: Sun, 26 Apr 2009 16:03:43 -0500 From: "Rick C. Petty" <rick-freebsd2008@kiwi-computer.com> To: Rick Macklem <rmacklem@uoguelph.ca> Cc: freebsd-fs@freebsd.org Subject: Re: Why do some ufs i-node fields have 2 copies? Message-ID: <20090426210343.GA51829@keira.kiwi-computer.com> In-Reply-To: <Pine.GSO.4.63.0904261651460.4478@muncher.cs.uoguelph.ca>
index | next in thread | previous in thread | raw e-mail
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
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090426210343.GA51829>
