- fs/ext3/inode.c | 3
- fs/ext3/iopen.c | 239 +++++++++++++++++++++++++++++++++++++
- fs/ext3/iopen.h | 15 ++
- fs/ext3/namei.c | 13 ++
- fs/ext3/super.c | 17 ++
- include/linux/ext3_fs.h | 2
- 7 files changed, 304 insertions(+), 1 deletion(-)
-
-Index: linux-stage/fs/ext3/Makefile
+Index: linux-2.6.5-7.311/fs/ext3/Makefile
===================================================================
---- linux-stage.orig/fs/ext3/Makefile 2004-05-07 16:00:16.000000000 -0400
-+++ linux-stage/fs/ext3/Makefile 2004-05-07 16:00:17.000000000 -0400
+--- linux-2.6.5-7.311.orig/fs/ext3/Makefile
++++ linux-2.6.5-7.311/fs/ext3/Makefile
@@ -4,7 +4,7 @@
obj-$(CONFIG_EXT3_FS) += ext3.o
ioctl.o namei.o super.o symlink.o hash.o
ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
-Index: linux-stage/fs/ext3/inode.c
+Index: linux-2.6.5-7.311/fs/ext3/inode.c
===================================================================
---- linux-stage.orig/fs/ext3/inode.c 2004-05-07 16:00:16.000000000 -0400
-+++ linux-stage/fs/ext3/inode.c 2004-05-07 17:21:59.000000000 -0400
+--- linux-2.6.5-7.311.orig/fs/ext3/inode.c
++++ linux-2.6.5-7.311/fs/ext3/inode.c
@@ -37,6 +37,7 @@
#include <linux/mpage.h>
#include <linux/uio.h>
#include "acl.h"
/*
-@@ -2472,6 +2473,9 @@
- ei->i_acl = EXT3_ACL_NOT_CACHED;
- ei->i_default_acl = EXT3_ACL_NOT_CACHED;
+@@ -2419,6 +2420,9 @@ void ext3_read_inode(struct inode * inod
#endif
+ ei->i_rsv_window.rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
+
+ if (ext3_iopen_get_inode(inode))
+ return;
+
if (ext3_get_inode_loc(inode, &iloc, 0))
goto bad_inode;
bh = iloc.bh;
-Index: linux-stage/fs/ext3/iopen.c
+Index: linux-2.6.5-7.311/fs/ext3/iopen.c
===================================================================
---- linux-stage.orig/fs/ext3/iopen.c 2004-05-07 16:00:17.000000000 -0400
-+++ linux-stage/fs/ext3/iopen.c 2004-05-07 17:22:37.000000000 -0400
-@@ -0,0 +1,272 @@
+--- /dev/null
++++ linux-2.6.5-7.311/fs/ext3/iopen.c
+@@ -0,0 +1,315 @@
+/*
+ * linux/fs/ext3/iopen.c
+ *
+ }
+
+ assert(list_empty(&dentry->d_alias)); /* d_instantiate */
-+ assert(d_unhashed(dentry)); /* d_rehash */
++ assert(d_unhashed(dentry)); /* d_rehash */
+
+ /* preferrably return a connected dentry */
+ spin_lock(&dcache_lock);
+ alternate = list_entry(inode->i_dentry.next,
+ struct dentry, d_alias);
+ dget_locked(alternate);
++ spin_lock(&alternate->d_lock);
+ alternate->d_vfs_flags |= DCACHE_REFERENCED;
++ spin_unlock(&alternate->d_lock);
+ iput(inode);
+ spin_unlock(&dcache_lock);
+ return alternate;
+ list_add(&dentry->d_alias, &inode->i_dentry); /* d_instantiate */
+ dentry->d_inode = inode;
+
-+ __d_rehash(dentry, 0); /* d_rehash */
++ d_rehash_cond(dentry, 0);
+ spin_unlock(&dcache_lock);
+
+ return NULL;
+ if (!inode)
+ goto do_rehash;
+
++ if (!test_opt(inode->i_sb, IOPEN))
++ goto do_instantiate;
++
+ /* preferrably return a connected dentry */
+ list_for_each(lp, &inode->i_dentry) {
+ tmp = list_entry(lp, struct dentry, d_alias);
+ goto do_instantiate;
+
+ /* Move the goal to the de hash queue */
-+ goal->d_flags &= ~ DCACHE_DISCONNECTED;
++ goal->d_flags &= ~DCACHE_DISCONNECTED;
+ security_d_instantiate(goal, inode);
-+ __d_rehash(dentry, 0);
-+ __d_move(goal, dentry);
++ __d_drop(dentry);
++ d_rehash_cond(dentry, 0);
++ d_move_locked(goal, dentry);
+ spin_unlock(&dcache_lock);
+ iput(inode);
+
+ dentry->d_inode = inode;
+do_rehash:
+ if (rehash)
-+ __d_rehash(dentry, 0); /* d_rehash */
++ d_rehash_cond(dentry, 0);
+ spin_unlock(&dcache_lock);
+
+ return NULL;
+}
+
+/*
++ * Similar as d_instantiate() except that it drops the disconnected
++ * dentry if any.
++ */
++void iopen_d_instantiate(struct dentry *dentry, struct inode * inode)
++{
++ struct dentry *dis_dentry;
++
++ /* verify this dentry is really new */
++ assert(dentry->d_inode == NULL);
++ assert(list_empty(&dentry->d_alias));
++
++ spin_lock(&dcache_lock);
++ if (!inode || !test_opt(inode->i_sb, IOPEN) ||
++ list_empty(&inode->i_dentry))
++ goto do_instantiate;
++
++ /* a disconnected dentry has been added in our back,
++ * we have to drop this dentry, see bug 16362/15713*/
++ dis_dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias);
++ spin_lock(&dis_dentry->d_lock);
++ assert(dis_dentry->d_alias.next == &inode->i_dentry);
++ assert(dis_dentry->d_alias.prev == &inode->i_dentry);
++ assert(dis_dentry->d_flags & DCACHE_DISCONNECTED);
++ __d_drop(dis_dentry);
++ list_del_init(&dis_dentry->d_alias);
++ spin_unlock(&dis_dentry->d_lock);
++
++do_instantiate:
++ if (inode)
++ list_add(&dentry->d_alias, &inode->i_dentry);
++ dentry->d_inode = inode;
++ spin_unlock(&dcache_lock);
++ security_d_instantiate(dentry, inode);
++}
++
++/*
+ * These are the special structures for the iopen pseudo directory.
+ */
+
+ inode->i_ctime = CURRENT_TIME;
+ inode->i_mtime = CURRENT_TIME;
+ EXT3_I(inode)->i_dtime = 0;
++ EXT3_I(inode)->i_file_acl = 0;
+ inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size
+ * (for stat), not the fs block
+ * size */
+
+ return 1;
+}
-Index: linux-stage/fs/ext3/iopen.h
+Index: linux-2.6.5-7.311/fs/ext3/iopen.h
===================================================================
---- linux-stage.orig/fs/ext3/iopen.h 2004-05-07 16:00:17.000000000 -0400
-+++ linux-stage/fs/ext3/iopen.h 2004-05-07 16:00:17.000000000 -0400
-@@ -0,0 +1,15 @@
+--- /dev/null
++++ linux-2.6.5-7.311/fs/ext3/iopen.h
+@@ -0,0 +1,24 @@
+/*
+ * iopen.h
+ *
+extern int ext3_iopen_get_inode(struct inode *inode);
+extern struct dentry *iopen_connect_dentry(struct dentry *dentry,
+ struct inode *inode, int rehash);
-Index: linux-stage/fs/ext3/namei.c
++extern void iopen_d_instantiate(struct dentry *dentry, struct inode * inode);
++
++#if !defined(HAVE_D_REHASH_COND) && defined(HAVE___D_REHASH)
++#define d_rehash_cond(dentry, lock) __d_rehash(dentry, lock)
++#endif
++
++#if !defined(HAVE_D_MOVE_LOCKED) && defined(HAVE___D_MOVE)
++#define d_move_locked(dentry, target) __d_move(dentry, target)
++#endif
+Index: linux-2.6.5-7.311/fs/ext3/namei.c
===================================================================
---- linux-stage.orig/fs/ext3/namei.c 2004-05-07 16:00:16.000000000 -0400
-+++ linux-stage/fs/ext3/namei.c 2004-05-07 16:00:17.000000000 -0400
+--- linux-2.6.5-7.311.orig/fs/ext3/namei.c
++++ linux-2.6.5-7.311/fs/ext3/namei.c
@@ -37,6 +37,7 @@
#include <linux/buffer_head.h>
#include <linux/smp_lock.h>
#include "acl.h"
/*
-@@ -979,6 +980,9 @@
+@@ -1024,6 +1025,9 @@ static struct dentry *ext3_lookup(struct
if (dentry->d_name.len > EXT3_NAME_LEN)
return ERR_PTR(-ENAMETOOLONG);
bh = ext3_find_entry(dentry, &de);
inode = NULL;
if (bh) {
-@@ -989,10 +993,8 @@
+@@ -1034,10 +1038,8 @@ static struct dentry *ext3_lookup(struct
if (!inode)
return ERR_PTR(-EACCES);
}
}
-@@ -2019,10 +2021,6 @@
+@@ -1653,7 +1655,7 @@ static int ext3_add_nondir(handle_t *han
+ if (!err) {
+ err = ext3_mark_inode_dirty(handle, inode);
+ if (!err) {
+- d_instantiate(dentry, inode);
++ iopen_d_instantiate(dentry, inode);
+ return 0;
+ }
+ }
+@@ -1814,7 +1816,7 @@ retry:
+ dir->i_nlink++;
+ ext3_update_dx_flag(dir);
+ ext3_mark_inode_dirty(handle, dir);
+- d_instantiate(dentry, inode);
++ iopen_d_instantiate(dentry, inode);
+ out_stop:
+ ext3_journal_stop(handle);
+ if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
+@@ -2075,10 +2077,6 @@ static int ext3_rmdir (struct inode * di
inode->i_nlink);
inode->i_version++;
inode->i_nlink = 0;
ext3_orphan_add(handle, inode);
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
ext3_mark_inode_dirty(handle, inode);
-@@ -2139,6 +2137,23 @@
+@@ -2199,6 +2197,23 @@ out_stop:
return err;
}
+ if (!err) {
+ err = ext3_mark_inode_dirty(handle, inode);
+ if (err == 0) {
-+ (void)iopen_connect_dentry(dentry, inode, 0);
++ dput(iopen_connect_dentry(dentry, inode, 0));
+ return 0;
+ }
+ }
static int ext3_link (struct dentry * old_dentry,
struct inode * dir, struct dentry *dentry)
{
-@@ -2161,7 +2176,8 @@
+@@ -2222,7 +2237,8 @@ retry:
ext3_inc_count(handle, inode);
atomic_inc(&inode->i_count);
- err = ext3_add_nondir(handle, dentry, inode);
+ err = ext3_add_link(handle, dentry, inode);
-+ ext3_orphan_del(handle,inode);
++ ext3_orphan_del(handle, inode);
ext3_journal_stop(handle);
- return err;
- }
-Index: linux-stage/fs/ext3/super.c
+ if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
+ goto retry;
+Index: linux-2.6.5-7.311/fs/ext3/super.c
===================================================================
---- linux-stage.orig/fs/ext3/super.c 2004-05-07 16:00:16.000000000 -0400
-+++ linux-stage/fs/ext3/super.c 2004-05-07 17:21:59.000000000 -0400
-@@ -536,7 +536,7 @@
- Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_noload,
- Opt_commit, Opt_journal_update, Opt_journal_inum,
+--- linux-2.6.5-7.311.orig/fs/ext3/super.c
++++ linux-2.6.5-7.311/fs/ext3/super.c
+@@ -581,6 +581,7 @@ enum {
Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
-- Opt_ignore, Opt_err,
-+ Opt_ignore, Opt_err, Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
+ Opt_ignore, Opt_barrier,
+ Opt_err,
++ Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
};
static match_table_t tokens = {
-@@ -575,6 +575,9 @@
+@@ -621,6 +622,9 @@ static match_table_t tokens = {
{Opt_ignore, "noquota"},
{Opt_ignore, "quota"},
{Opt_ignore, "usrquota"},
-+ {Opt_iopen, "iopen"},
-+ {Opt_noiopen, "noiopen"},
-+ {Opt_iopen_nopriv, "iopen_nopriv"},
++ {Opt_iopen, "iopen"},
++ {Opt_noiopen, "noiopen"},
++ {Opt_iopen_nopriv, "iopen_nopriv"},
+ {Opt_barrier, "barrier=%u"},
{Opt_err, NULL}
};
-
-@@ -762,6 +765,18 @@
- case Opt_abort:
- set_opt(sbi->s_mount_opt, ABORT);
+@@ -823,6 +827,18 @@ static int parse_options (char * options
+ else
+ clear_opt(sbi->s_mount_opt, BARRIER);
break;
+ case Opt_iopen:
+ set_opt (sbi->s_mount_opt, IOPEN);
case Opt_ignore:
break;
default:
-Index: linux-stage/include/linux/ext3_fs.h
+Index: linux-2.6.5-7.311/include/linux/ext3_fs.h
===================================================================
---- linux-stage.orig/include/linux/ext3_fs.h 2004-05-07 16:00:16.000000000 -0400
-+++ linux-stage/include/linux/ext3_fs.h 2004-05-07 16:00:17.000000000 -0400
-@@ -325,6 +325,8 @@
- #define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
- #define EXT3_MOUNT_XATTR_USER 0x4000 /* Extended user attributes */
- #define EXT3_MOUNT_POSIX_ACL 0x8000 /* POSIX Access Control Lists */
-+#define EXT3_MOUNT_IOPEN 0x10000 /* Allow access via iopen */
-+#define EXT3_MOUNT_IOPEN_NOPRIV 0x20000 /* Make iopen world-readable */
+--- linux-2.6.5-7.311.orig/include/linux/ext3_fs.h
++++ linux-2.6.5-7.311/include/linux/ext3_fs.h
+@@ -329,6 +329,8 @@ struct ext3_inode {
+ #define EXT3_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
+ #define EXT3_MOUNT_RESERVATION 0x10000 /* Preallocation */
+ #define EXT3_MOUNT_BARRIER 0x20000 /* Use block barriers */
++#define EXT3_MOUNT_IOPEN 0x80000 /* Allow access via iopen */
++#define EXT3_MOUNT_IOPEN_NOPRIV 0x100000/* Make iopen world-readable */
/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
#ifndef _LINUX_EXT2_FS_H