Why do some ufs i-node fields have 2 copies?
Rick C. Petty
rick-freebsd2008 at kiwi-computer.com
Sun Apr 26 21:30:24 UTC 2009
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
More information about the freebsd-fs
mailing list