lkml.org 
[lkml]   [1999]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[patch] EXT2 inode.i_generation patch
Date
From
This patch modifies the ext2 filesystem so that it uses the new
inode.i_generation field. No data structures where hurt in the
making of this patch. Some names where changed to protect
future maintainers.

BUGS: There is a 1/(2^32) chance of not getting a new generation
number on for a new inode.

diff -ru linux-2.2.3/include/linux/ext2_fs.h linux/include/linux/ext2_fs.h
--- linux-2.2.3/include/linux/ext2_fs.h Mon Mar 15 15:16:35 1999
+++ linux/include/linux/ext2_fs.h Mon Mar 15 15:22:34 1999
@@ -238,7 +238,7 @@
} masix1;
} osd1; /* OS dependent 1 */
__u32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
- __u32 i_version; /* File version (for NFS) */
+ __u32 i_generation; /* inode generation (for NFS) */
__u32 i_file_acl; /* File ACL */
__u32 i_dir_acl; /* Directory ACL */
__u32 i_faddr; /* Fragment address */
diff -ru linux-2.2.3/include/linux/ext2_fs_i.h linux/include/linux/ext2_fs_i.h
--- linux-2.2.3/include/linux/ext2_fs_i.h Mon Mar 15 15:16:35 1999
+++ linux/include/linux/ext2_fs_i.h Mon Mar 15 15:22:34 1999
@@ -29,7 +29,7 @@
__u32 i_file_acl;
__u32 i_dir_acl;
__u32 i_dtime;
- __u32 i_version;
+ __u32 _i_unused; /* XXX was i_version; see inode.i_generation */
__u32 i_block_group;
__u32 i_next_alloc_block;
__u32 i_next_alloc_goal;
diff -ru linux-2.2.3/fs/ext2/ialloc.c linux/fs/ext2/ialloc.c
--- linux-2.2.3/fs/ext2/ialloc.c Tue Oct 20 14:08:14 1998
+++ linux/fs/ext2/ialloc.c Mon Mar 15 15:28:21 1999
@@ -34,6 +34,7 @@
#include <linux/string.h>
#include <linux/locks.h>
#include <linux/quotaops.h>
+#include <linux/random.h>

#include <asm/bitops.h>
#include <asm/byteorder.h>
@@ -268,21 +269,6 @@
}

/*
- * This function increments the inode version number
- *
- * This may be used one day by the NFS server
- */
-static void inc_inode_version (struct inode * inode,
- struct ext2_group_desc *gdp,
- int mode)
-{
- inode->u.ext2_i.i_version++;
- mark_inode_dirty(inode);
-
- return;
-}
-
-/*
* There are two policies for allocating an inode. If the new inode is
* a directory, then a forward search is made for a block group with both
* free space and a low directory-to-inode ratio; if that fails, then of
@@ -493,8 +479,11 @@
if (inode->u.ext2_i.i_flags & EXT2_SYNC_FL)
inode->i_flags |= MS_SYNCHRONOUS;
insert_inode_hash(inode);
+
+ get_random_bytes(&inode->i_generation,
+ sizeof(inode->i_generation));
+
mark_inode_dirty(inode);
- inc_inode_version (inode, gdp, mode);

unlock_super (sb);
if(DQUOT_ALLOC_INODE(sb, inode)) {
diff -ru linux-2.2.3/fs/ext2/inode.c linux/fs/ext2/inode.c
--- linux-2.2.3/fs/ext2/inode.c Wed May 6 10:56:05 1998
+++ linux/fs/ext2/inode.c Mon Mar 15 15:22:34 1999
@@ -552,7 +552,7 @@
<< 32;
#endif
}
- inode->u.ext2_i.i_version = le32_to_cpu(raw_inode->i_version);
+ inode->i_generation = le32_to_cpu(raw_inode->i_generation);
inode->u.ext2_i.i_block_group = block_group;
inode->u.ext2_i.i_next_alloc_block = 0;
inode->u.ext2_i.i_next_alloc_goal = 0;
@@ -682,7 +682,7 @@
raw_inode->i_size_high = cpu_to_le32(inode->i_size >> 32);
#endif
}
- raw_inode->i_version = cpu_to_le32(inode->u.ext2_i.i_version);
+ raw_inode->i_generation = cpu_to_le32(inode->i_generation);
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
raw_inode->i_block[0] = cpu_to_le32(kdev_t_to_nr(inode->i_rdev));
else if (S_ISLNK(inode->i_mode) && !inode->i_blocks)
diff -ru linux-2.2.3/fs/ext2/ioctl.c linux/fs/ext2/ioctl.c
--- linux-2.2.3/fs/ext2/ioctl.c Wed May 6 10:56:05 1998
+++ linux/fs/ext2/ioctl.c Mon Mar 15 15:22:34 1999
@@ -69,13 +69,13 @@
mark_inode_dirty(inode);
return 0;
case EXT2_IOC_GETVERSION:
- return put_user(inode->u.ext2_i.i_version, (int *) arg);
+ return put_user(inode->i_generation, (int *) arg);
case EXT2_IOC_SETVERSION:
if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
return -EPERM;
if (IS_RDONLY(inode))
return -EROFS;
- if (get_user(inode->u.ext2_i.i_version, (int *) arg))
+ if (get_user(inode->i_generation, (int *) arg))
return -EFAULT;
inode->i_ctime = CURRENT_TIME;
mark_inode_dirty(inode);
--
Allen Morris <gam3@acm.org>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:1.667 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site