kernel: replace mini_fo with overlayfs for 2.6.38

SVN-Revision: 26213
This commit is contained in:
Felix Fietkau 2011-03-17 20:23:14 +00:00
parent de2b5158a1
commit 4f06dc1907
15 changed files with 2917 additions and 8578 deletions

View File

@ -590,8 +590,9 @@ CONFIG_EXPERIMENTAL=y
# CONFIG_EXT3_FS_XATTR is not set
# CONFIG_EXT4_DEBUG is not set
# CONFIG_EXT4_FS is not set
# CONFIG_EXT4_FS_POSIX_ACL is not set
# CONFIG_EXT4_FS_SECURITY is not set
# CONFIG_EXT4_FS_XATTR is not set
CONFIG_EXT4_FS_XATTR=y
CONFIG_EXT4_USE_FOR_EXT23=y
CONFIG_EXTRA_FIRMWARE=""
CONFIG_EXTRA_TARGETS=""
@ -1133,9 +1134,11 @@ CONFIG_JFFS2_CMODE_PRIORITY=y
CONFIG_JFFS2_COMPRESSION_OPTIONS=y
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_FS_DEBUG=0
# CONFIG_JFFS2_FS_POSIX_ACL is not set
# CONFIG_JFFS2_FS_SECURITY is not set
# CONFIG_JFFS2_FS_WBUF_VERIFY is not set
CONFIG_JFFS2_FS_WRITEBUFFER=y
# CONFIG_JFFS2_FS_XATTR is not set
CONFIG_JFFS2_FS_XATTR=y
CONFIG_JFFS2_LZMA=y
# CONFIG_JFFS2_LZO is not set
CONFIG_JFFS2_RTIME=y
@ -1315,7 +1318,6 @@ CONFIG_MII=y
# CONFIG_MIKROTIK_RB532 is not set
# CONFIG_MINIX_FS is not set
# CONFIG_MINIX_SUBPARTITION is not set
CONFIG_MINI_FO=y
# CONFIG_MIPS_ALCHEMY is not set
# CONFIG_MIPS_COBALT is not set
# CONFIG_MIPS_FPU_EMU is not set
@ -1732,6 +1734,7 @@ CONFIG_NLS_DEFAULT="iso8859-1"
# CONFIG_OMFS_FS is not set
# CONFIG_ORION_WATCHDOG is not set
# CONFIG_OSF_PARTITION is not set
CONFIG_OVERLAYFS_FS=y
# CONFIG_P54_COMMON is not set
CONFIG_PACKET=y
# CONFIG_PAGE_POISONING is not set

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,143 +0,0 @@
--- a/fs/mini_fo/main.c
+++ b/fs/mini_fo/main.c
@@ -79,6 +79,7 @@ mini_fo_tri_interpose(dentry_t *hidden_d
* of the new inode's fields
*/
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
/*
* original: inode = iget(sb, hidden_inode->i_ino);
*/
@@ -87,6 +88,13 @@ mini_fo_tri_interpose(dentry_t *hidden_d
err = -EACCES; /* should be impossible??? */
goto out;
}
+#else
+ inode = mini_fo_iget(sb, iunique(sb, 25));
+ if (IS_ERR(inode)) {
+ err = PTR_ERR(inode);
+ goto out;
+ }
+#endif
/*
* interpose the inode if not already interposed
@@ -184,9 +192,9 @@ mini_fo_parse_options(super_block_t *sb,
hidden_root = ERR_PTR(err);
goto out;
}
- hidden_root = nd.dentry;
- stopd(sb)->base_dir_dentry = nd.dentry;
- stopd(sb)->hidden_mnt = nd.mnt;
+ hidden_root = nd_get_dentry(&nd);
+ stopd(sb)->base_dir_dentry = nd_get_dentry(&nd);
+ stopd(sb)->hidden_mnt = nd_get_mnt(&nd);
} else if(!strncmp("sto=", options, 4)) {
/* parse the storage dir */
@@ -204,9 +212,9 @@ mini_fo_parse_options(super_block_t *sb,
hidden_root2 = ERR_PTR(err);
goto out;
}
- hidden_root2 = nd2.dentry;
- stopd(sb)->storage_dir_dentry = nd2.dentry;
- stopd(sb)->hidden_mnt2 = nd2.mnt;
+ hidden_root2 = nd_get_dentry(&nd2);
+ stopd(sb)->storage_dir_dentry = nd_get_dentry(&nd2);
+ stopd(sb)->hidden_mnt2 = nd_get_mnt(&nd2);
stohs2(sb) = hidden_root2->d_sb;
/* validate storage dir, this is done in
--- a/fs/mini_fo/mini_fo.h
+++ b/fs/mini_fo/mini_fo.h
@@ -302,6 +302,10 @@ extern int mini_fo_tri_interpose(dentry_
extern int mini_fo_cp_cont(dentry_t *tgt_dentry, struct vfsmount *tgt_mnt,
dentry_t *src_dentry, struct vfsmount *src_mnt);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+extern struct inode *mini_fo_iget(struct super_block *sb, unsigned long ino);
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
extern int mini_fo_create(inode_t *dir, dentry_t *dentry, int mode, struct nameidata *nd);
@@ -501,6 +505,29 @@ static inline void double_unlock(struct
#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) */
#endif /* __KERNEL__ */
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+static inline dentry_t *nd_get_dentry(struct nameidata *nd)
+{
+ return (nd->path.dentry);
+}
+
+static inline struct vfsmount *nd_get_mnt(struct nameidata *nd)
+{
+ return (nd->path.mnt);
+}
+#else
+static inline dentry_t *nd_get_dentry(struct nameidata *nd)
+{
+ return (nd->dentry);
+}
+
+static inline struct vfsmount *nd_get_mnt(struct nameidata *nd)
+{
+ return (nd->mnt);
+}
+#endif
+
/*
* Definitions for user and kernel code
*/
--- a/fs/mini_fo/super.c
+++ b/fs/mini_fo/super.c
@@ -266,10 +266,31 @@ mini_fo_umount_begin(super_block_t *sb)
}
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)
+struct inode *
+mini_fo_iget(struct super_block *sb, unsigned long ino)
+{
+ struct inode *inode;
+
+ inode = iget_locked(sb, ino);
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+
+ if (!(inode->i_state & I_NEW))
+ return inode;
+
+ mini_fo_read_inode(inode);
+
+ unlock_new_inode(inode);
+ return inode;
+}
+#endif /* if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25) */
struct super_operations mini_fo_sops =
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
read_inode: mini_fo_read_inode,
+#endif
#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
write_inode: mini_fo_write_inode,
#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */
--- a/fs/mini_fo/aux.c
+++ b/fs/mini_fo/aux.c
@@ -164,11 +164,11 @@ dentry_t *bpath_walk(super_block_t *sb,
err = vfs_path_lookup(mnt->mnt_root, mnt, bpath+1, 0, &nd);
/* validate */
- if (err || !nd.dentry || !nd.dentry->d_inode) {
+ if (err || !nd_get_dentry(&nd) || !nd_get_dentry(&nd)->d_inode) {
printk(KERN_CRIT "mini_fo: bpath_walk: path_walk failed.\n");
return NULL;
}
- return nd.dentry;
+ return nd_get_dentry(&nd);
}

View File

@ -0,0 +1,124 @@
--- a/fs/overlayfs/overlayfs.c
+++ b/fs/overlayfs/overlayfs.c
@@ -253,8 +253,7 @@ static struct ovl_cache_entry *ovl_cache
}
static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
- u64 ino, unsigned int d_type,
- bool is_whiteout)
+ u64 ino, unsigned int d_type)
{
struct ovl_cache_entry *p;
@@ -267,7 +266,7 @@ static struct ovl_cache_entry *ovl_cache
p->len = len;
p->type = d_type;
p->ino = ino;
- p->is_whiteout = is_whiteout;
+ p->is_whiteout = false;
}
return p;
@@ -275,7 +274,7 @@ static struct ovl_cache_entry *ovl_cache
static int ovl_cache_entry_add_rb(struct ovl_readdir_data *rdd,
const char *name, int len, u64 ino,
- unsigned int d_type, bool is_whiteout)
+ unsigned int d_type)
{
struct rb_node **newp = &rdd->root->rb_node;
struct rb_node *parent = NULL;
@@ -296,11 +295,18 @@ static int ovl_cache_entry_add_rb(struct
return 0;
}
- p = ovl_cache_entry_new(name, len, ino, d_type, is_whiteout);
+ p = ovl_cache_entry_new(name, len, ino, d_type);
if (p == NULL)
return -ENOMEM;
- list_add_tail(&p->l_node, rdd->list);
+ /*
+ * Add links before other types to be able to quicky mark
+ * any whiteout entries
+ */
+ if (d_type == DT_LNK)
+ list_add(&p->l_node, rdd->list);
+ else
+ list_add_tail(&p->l_node, rdd->list);
rb_link_node(&p->node, parent, newp);
rb_insert_color(&p->node, rdd->root);
@@ -318,7 +324,7 @@ static int ovl_fill_lower(void *buf, con
if (p) {
list_move_tail(&p->l_node, rdd->middle);
} else {
- p = ovl_cache_entry_new(name, namelen, ino, d_type, false);
+ p = ovl_cache_entry_new(name, namelen, ino, d_type);
if (p == NULL)
rdd->err = -ENOMEM;
else
@@ -343,26 +349,9 @@ static int ovl_fill_upper(void *buf, con
loff_t offset, u64 ino, unsigned int d_type)
{
struct ovl_readdir_data *rdd = buf;
- bool is_whiteout = false;
rdd->count++;
- if (d_type == DT_LNK) {
- struct dentry *dentry;
-
- dentry = lookup_one_len(name, rdd->dir, namelen);
- if (IS_ERR(dentry)) {
- rdd->err = PTR_ERR(dentry);
- goto out;
- }
- is_whiteout = ovl_is_whiteout(dentry);
- dput(dentry);
- }
-
- rdd->err = ovl_cache_entry_add_rb(rdd, name, namelen, ino, d_type,
- is_whiteout);
-
-out:
- return rdd->err;
+ return ovl_cache_entry_add_rb(rdd, name, namelen, ino, d_type);
}
static int ovl_dir_read(struct path *realpath, struct ovl_readdir_data *rdd,
@@ -428,6 +417,26 @@ static void ovl_dir_reset(struct file *f
}
}
+static void ovl_dir_mark_whiteouts(struct ovl_readdir_data *rdd)
+{
+ struct ovl_cache_entry *p;
+ struct dentry *dentry;
+
+ mutex_lock(&rdd->dir->d_inode->i_mutex);
+ list_for_each_entry(p, rdd->list, l_node) {
+ if (p->type != DT_LNK)
+ break;
+
+ dentry = lookup_one_len(p->name, rdd->dir, p->len);
+ if (IS_ERR(dentry))
+ continue;
+
+ p->is_whiteout = ovl_is_whiteout(dentry);
+ dput(dentry);
+ }
+ mutex_unlock(&rdd->dir->d_inode->i_mutex);
+}
+
static int ovl_dir_read_merged(struct path *upperpath, struct path *lowerpath,
struct ovl_readdir_data *rdd)
{
@@ -441,6 +450,8 @@ static int ovl_dir_read_merged(struct pa
err = ovl_dir_read(upperpath, rdd, ovl_fill_upper);
if (err)
goto out;
+
+ ovl_dir_mark_whiteouts(rdd);
}
/*
* Insert lowerpath entries before upperpath ones, this allows

View File

@ -1,66 +0,0 @@
--- a/fs/mini_fo/meta.c
+++ b/fs/mini_fo/meta.c
@@ -442,6 +442,11 @@ int meta_write_d_entry(dentry_t *dentry,
S_IRUSR | S_IWUSR);
#endif
}
+
+ /* $%& err, is this correct? */
+ meta_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt2;
+ mntget(meta_mnt);
+
/* open META-file for writing */
meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
if(!meta_file || IS_ERR(meta_file)) {
@@ -535,6 +540,11 @@ int meta_write_r_entry(dentry_t *dentry,
meta_dentry, S_IRUSR | S_IWUSR);
#endif
}
+
+ /* $%& err, is this correct? */
+ meta_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt2;
+ mntget(meta_mnt);
+
/* open META-file for writing */
meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
if(!meta_file || IS_ERR(meta_file)) {
@@ -671,14 +681,16 @@ int meta_sync_d_list(dentry_t *dentry, i
}
}
+ /* $%& err, is this correct? */
+ meta_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt2;
+ mntget(meta_mnt);
+
/* open META-file for writing */
meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_sync_d_list: \
ERROR opening meta file.\n");
- /* we don't mntget so we dont't mntput (for now)
- * mntput(meta_mnt);
- */
+ mntput(meta_mnt);
dput(meta_dentry);
err = -1;
goto out;
@@ -811,14 +823,16 @@ int meta_sync_r_list(dentry_t *dentry, i
}
}
+ /* $%& err, is this correct? */
+ meta_mnt = stopd(dentry->d_inode->i_sb)->hidden_mnt2;
+ mntget(meta_mnt);
+
/* open META-file for writing */
meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_sync_r_list: \
ERROR opening meta file.\n");
- /* we don't mntget so we dont't mntput (for now)
- * mntput(meta_mnt);
- */
+ mntput(meta_mnt);
dput(meta_dentry);
err = -1;
goto out;

View File

@ -1,37 +0,0 @@
--- a/fs/mini_fo/super.c
+++ b/fs/mini_fo/super.c
@@ -84,6 +84,7 @@ mini_fo_write_inode(inode_t *inode, int
#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
STATIC void
mini_fo_put_inode(inode_t *inode)
{
@@ -99,6 +100,7 @@ mini_fo_put_inode(inode_t *inode)
if (atomic_read(&inode->i_count) == 1)
inode->i_nlink = 0;
}
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
@@ -242,7 +244,7 @@ mini_fo_clear_inode(inode_t *inode)
* dies.
*/
STATIC void
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
mini_fo_umount_begin(struct vfsmount *mnt, int flags)
{
struct vfsmount *hidden_mnt;
@@ -294,7 +296,9 @@ struct super_operations mini_fo_sops =
#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
write_inode: mini_fo_write_inode,
#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
put_inode: mini_fo_put_inode,
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
delete_inode: mini_fo_delete_inode,
#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */

View File

@ -1,41 +0,0 @@
--- a/fs/mini_fo/inode.c
+++ b/fs/mini_fo/inode.c
@@ -439,7 +439,7 @@ mini_fo_symlink(inode_t *dir, dentry_t *
int err=0;
dentry_t *hidden_sto_dentry;
dentry_t *hidden_sto_dir_dentry;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
umode_t mode;
#endif
@@ -466,7 +466,7 @@ mini_fo_symlink(inode_t *dir, dentry_t *
down(&hidden_sto_dir_dentry->d_inode->i_sem);
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
mode = S_IALLUGO;
err = vfs_symlink(hidden_sto_dir_dentry->d_inode,
hidden_sto_dentry, symname, mode);
@@ -1128,7 +1128,7 @@ void mini_fo_put_link(struct dentry *den
#endif
STATIC int
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27))
mini_fo_permission(inode_t *inode, int mask, struct nameidata *nd)
#else
mini_fo_permission(inode_t *inode, int mask)
@@ -1150,8 +1150,9 @@ mini_fo_permission(inode_t *inode, int m
* if (err)
* goto out;
*/
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
+ err = inode_permission(hidden_inode, mask);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
err = permission(hidden_inode, mask, nd);
#else
err = permission(hidden_inode, mask);

View File

@ -1,96 +0,0 @@
--- a/fs/mini_fo/aux.c
+++ b/fs/mini_fo/aux.c
@@ -236,7 +236,7 @@ int mini_fo_cp_cont(dentry_t *tgt_dentry
mntget(src_mnt);
/* open file write only */
- tgt_file = dentry_open(tgt_dentry, tgt_mnt, 0x1);
+ tgt_file = dentry_open(tgt_dentry, tgt_mnt, 0x1, current_cred());
if(!tgt_file || IS_ERR(tgt_file)) {
printk(KERN_CRIT "mini_fo_cp_cont: ERROR opening target file.\n");
err = PTR_ERR(tgt_file);
@@ -244,7 +244,7 @@ int mini_fo_cp_cont(dentry_t *tgt_dentry
}
/* open file read only */
- src_file = dentry_open(src_dentry, src_mnt, 0x0);
+ src_file = dentry_open(src_dentry, src_mnt, 0x0, current_cred());
if(!src_file || IS_ERR(src_file)) {
printk(KERN_CRIT "mini_fo_cp_cont: ERROR opening source file.\n");
err = PTR_ERR(src_file);
--- a/fs/mini_fo/file.c
+++ b/fs/mini_fo/file.c
@@ -437,7 +437,7 @@ mini_fo_open(inode_t *inode, file_t *fil
mntget(stopd(inode->i_sb)->hidden_mnt);
hidden_file = dentry_open(hidden_dentry,
stopd(inode->i_sb)->hidden_mnt,
- hidden_flags);
+ hidden_flags, file->f_cred);
if (IS_ERR(hidden_file)) {
err = PTR_ERR(hidden_file);
dput(hidden_dentry);
@@ -479,7 +479,7 @@ mini_fo_open(inode_t *inode, file_t *fil
mntget(stopd(inode->i_sb)->hidden_mnt);
hidden_file = dentry_open(hidden_dentry,
stopd(inode->i_sb)->hidden_mnt,
- hidden_flags);
+ hidden_flags, file->f_cred);
if (IS_ERR(hidden_file)) {
err = PTR_ERR(hidden_file);
dput(hidden_dentry);
@@ -512,7 +512,7 @@ mini_fo_open(inode_t *inode, file_t *fil
mntget(stopd(inode->i_sb)->hidden_mnt2);
hidden_sto_file = dentry_open(hidden_sto_dentry,
stopd(inode->i_sb)->hidden_mnt2,
- hidden_flags);
+ hidden_flags, file->f_cred);
/* dentry_open dputs the dentry if it fails */
if (IS_ERR(hidden_sto_file)) {
--- a/fs/mini_fo/meta.c
+++ b/fs/mini_fo/meta.c
@@ -56,7 +56,7 @@ int meta_build_lists(dentry_t *dentry)
/* open META-file for reading */
- meta_file = dentry_open(meta_dentry, meta_mnt, 0x0);
+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x0, current_cred());
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_build_lists: \
ERROR opening META file.\n");
@@ -448,7 +448,7 @@ int meta_write_d_entry(dentry_t *dentry,
mntget(meta_mnt);
/* open META-file for writing */
- meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1, current_cred());
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_write_d_entry: \
ERROR opening meta file.\n");
@@ -546,7 +546,7 @@ int meta_write_r_entry(dentry_t *dentry,
mntget(meta_mnt);
/* open META-file for writing */
- meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1, current_cred());
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_write_r_entry: \
ERROR opening meta file.\n");
@@ -686,7 +686,7 @@ int meta_sync_d_list(dentry_t *dentry, i
mntget(meta_mnt);
/* open META-file for writing */
- meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1, current_cred());
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_sync_d_list: \
ERROR opening meta file.\n");
@@ -828,7 +828,7 @@ int meta_sync_r_list(dentry_t *dentry, i
mntget(meta_mnt);
/* open META-file for writing */
- meta_file = dentry_open(meta_dentry, meta_mnt, 0x1);
+ meta_file = dentry_open(meta_dentry, meta_mnt, 0x1, current_cred());
if(!meta_file || IS_ERR(meta_file)) {
printk(KERN_CRIT "mini_fo: meta_sync_r_list: \
ERROR opening meta file.\n");

View File

@ -1,157 +0,0 @@
--- a/fs/mini_fo/aux.c
+++ b/fs/mini_fo/aux.c
@@ -86,8 +86,10 @@ int get_neg_sto_dentry(dentry_t *dentry)
len = dentry->d_name.len;
name = dentry->d_name.name;
+ mutex_lock(&dtohd2(dentry->d_parent)->d_inode->i_mutex);
dtohd2(dentry) =
lookup_one_len(name, dtohd2(dentry->d_parent), len);
+ mutex_unlock(&dtohd2(dentry->d_parent)->d_inode->i_mutex);
out:
return err;
@@ -426,7 +428,9 @@ int build_sto_structure(dentry_t *dir, d
const unsigned char *name;
len = dtohd(dentry)->d_name.len;
name = dtohd(dentry)->d_name.name;
+ mutex_lock(&dtohd2(dir)->d_inode->i_mutex);
hidden_sto_dentry = lookup_one_len(name, dtohd2(dir), len);
+ mutex_unlock(&dtohd2(dir)->d_inode->i_mutex);
dtohd2(dentry) = hidden_sto_dentry;
}
--- a/fs/mini_fo/inode.c
+++ b/fs/mini_fo/inode.c
@@ -113,17 +113,23 @@ mini_fo_lookup(inode_t *dir, dentry_t *d
hidden_dir_dentry = hidden_dentry->d_parent;
kfree(bpath);
}
- else if(hidden_dir_dentry && hidden_dir_dentry->d_inode)
+ else if(hidden_dir_dentry && hidden_dir_dentry->d_inode) {
+ mutex_lock(&hidden_dir_dentry->d_inode->i_mutex);
hidden_dentry =
lookup_one_len(name, hidden_dir_dentry, namelen);
- else
+ mutex_unlock(&hidden_dir_dentry->d_inode->i_mutex);
+ } else {
hidden_dentry = NULL;
+ }
- if(hidden_sto_dir_dentry && hidden_sto_dir_dentry->d_inode)
+ if(hidden_sto_dir_dentry && hidden_sto_dir_dentry->d_inode) {
+ mutex_lock(&hidden_sto_dir_dentry->d_inode->i_mutex);
hidden_sto_dentry =
lookup_one_len(name, hidden_sto_dir_dentry, namelen);
- else
+ mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
+ } else {
hidden_sto_dentry = NULL;
+ }
/* catch error in lookup */
if (IS_ERR(hidden_dentry) || IS_ERR(hidden_sto_dentry)) {
@@ -553,9 +559,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
#endif
/* Delete an old WOL file contained in the storage dir */
+ mutex_lock(&hidden_sto_dentry->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
hidden_sto_dentry,
strlen(META_FILENAME));
+ mutex_unlock(&hidden_sto_dentry->d_inode->i_mutex);
if(meta_dentry->d_inode) {
err = vfs_unlink(hidden_sto_dentry->d_inode, meta_dentry);
dput(meta_dentry);
@@ -643,9 +651,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
#endif
/* Delete an old WOL file contained in the storage dir */
+ mutex_lock(&hidden_sto_dentry->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
hidden_sto_dentry,
strlen(META_FILENAME));
+ mutex_unlock(&hidden_sto_dentry->d_inode->i_mutex);
if(meta_dentry->d_inode) {
/* is this necessary? dget(meta_dentry); */
err = vfs_unlink(hidden_sto_dentry->d_inode,
@@ -688,9 +698,11 @@ mini_fo_rmdir(inode_t *dir, dentry_t *de
#endif
/* Delete an old WOL file contained in the storage dir */
+ mutex_lock(&hidden_sto_dentry->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
hidden_sto_dentry,
strlen(META_FILENAME));
+ mutex_unlock(&hidden_sto_dentry->d_inode->i_mutex);
if(meta_dentry->d_inode) {
/* is this necessary? dget(meta_dentry); */
err = vfs_unlink(hidden_sto_dentry->d_inode,
--- a/fs/mini_fo/meta.c
+++ b/fs/mini_fo/meta.c
@@ -43,9 +43,11 @@ int meta_build_lists(dentry_t *dentry)
/* might there be a META-file? */
if(dtohd2(dentry) && dtohd2(dentry)->d_inode) {
+ mutex_lock(&dtohd2(dentry)->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
dtohd2(dentry),
strlen(META_FILENAME));
+ mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
if(!meta_dentry->d_inode) {
dput(meta_dentry);
goto out_ok;
@@ -426,8 +428,11 @@ int meta_write_d_entry(dentry_t *dentry,
goto out;
}
}
+
+ mutex_lock(&dtohd2(dentry)->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
dtohd2(dentry), strlen (META_FILENAME));
+ mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
/* We need to create a META-file */
if(!meta_dentry->d_inode) {
@@ -527,9 +532,13 @@ int meta_write_r_entry(dentry_t *dentry,
goto out;
}
}
+
+ mutex_lock(&dtohd2(dentry)->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
dtohd2(dentry),
strlen (META_FILENAME));
+ mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+
if(!meta_dentry->d_inode) {
/* We need to create a META-file */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -641,9 +650,13 @@ int meta_sync_d_list(dentry_t *dentry, i
goto out;
}
}
+
+ mutex_lock(&dtohd2(dentry)->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
dtohd2(dentry),
strlen(META_FILENAME));
+ mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+
if(!meta_dentry->d_inode) {
/* We need to create a META-file */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -784,9 +797,13 @@ int meta_sync_r_list(dentry_t *dentry, i
goto out;
}
}
+
+ mutex_lock(&dtohd2(dentry)->d_inode->i_mutex);
meta_dentry = lookup_one_len(META_FILENAME,
dtohd2(dentry),
strlen(META_FILENAME));
+ mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+
if(!meta_dentry->d_inode) {
/* We need to create a META-file */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)

View File

@ -1,25 +0,0 @@
--- a/fs/mini_fo/state.c
+++ b/fs/mini_fo/state.c
@@ -537,17 +537,17 @@ int nondir_mod_to_del(dentry_t *dentry)
dtohd(dentry) = NULL;
dtost(dentry) = DELETED;
- /* add deleted file to META-file */
- meta_add_d_entry(dentry->d_parent,
- dentry->d_name.name,
- dentry->d_name.len);
-
/* was: unlock_dir(hidden_sto_dir_dentry); */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
mutex_unlock(&hidden_sto_dir_dentry->d_inode->i_mutex);
#else
up(&hidden_sto_dir_dentry->d_inode->i_sem);
#endif
+ /* add deleted file to META-file */
+ meta_add_d_entry(dentry->d_parent,
+ dentry->d_name.name,
+ dentry->d_name.len);
+
dput(hidden_sto_dir_dentry);
out:

View File

@ -1,45 +0,0 @@
--- a/fs/mini_fo/file.c
+++ b/fs/mini_fo/file.c
@@ -599,7 +599,7 @@ mini_fo_release(inode_t *inode, file_t *
}
STATIC int
-mini_fo_fsync(file_t *file, dentry_t *dentry, int datasync)
+mini_fo_fsync(file_t *file, int datasync)
{
int err1 = 0;
int err2 = 0;
@@ -609,14 +609,14 @@ mini_fo_fsync(file_t *file, dentry_t *de
check_mini_fo_file(file);
if ((hidden_file = ftohf(file)) != NULL) {
- hidden_dentry = dtohd(dentry);
+ hidden_dentry = dtohd(file->f_path.dentry);
if (hidden_file->f_op && hidden_file->f_op->fsync) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
mutex_lock(&hidden_dentry->d_inode->i_mutex);
#else
down(&hidden_dentry->d_inode->i_sem);
#endif
- err1 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync);
+ err1 = hidden_file->f_op->fsync(hidden_file, datasync);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
mutex_unlock(&hidden_dentry->d_inode->i_mutex);
#else
@@ -626,14 +626,14 @@ mini_fo_fsync(file_t *file, dentry_t *de
}
if ((hidden_file = ftohf2(file)) != NULL) {
- hidden_dentry = dtohd2(dentry);
+ hidden_dentry = dtohd2(file->f_path.dentry);
if (hidden_file->f_op && hidden_file->f_op->fsync) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
mutex_lock(&hidden_dentry->d_inode->i_mutex);
#else
down(&hidden_dentry->d_inode->i_sem);
#endif
- err2 = hidden_file->f_op->fsync(hidden_file, hidden_dentry, datasync);
+ err2 = hidden_file->f_op->fsync(hidden_file, datasync);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
mutex_unlock(&hidden_dentry->d_inode->i_mutex);
#else

View File

@ -1,43 +0,0 @@
--- a/fs/mini_fo/super.c
+++ b/fs/mini_fo/super.c
@@ -76,7 +76,7 @@ mini_fo_read_inode(inode_t *inode)
* to write some of our own stuff to disk.
*/
STATIC void
-mini_fo_write_inode(inode_t *inode, int sync)
+mini_fo_write_inode(inode_t *inode, struct writeback_control *wbc)
{
print_entry_location();
print_exit_location();
@@ -112,13 +112,14 @@ mini_fo_put_inode(inode_t *inode)
* on our and the lower inode.
*/
STATIC void
-mini_fo_delete_inode(inode_t *inode)
+mini_fo_evict_inode(inode_t *inode)
{
print_entry_location();
- fist_checkinode(inode, "mini_fo_delete_inode IN");
- inode->i_size = 0; /* every f/s seems to do that */
- clear_inode(inode);
+ fist_checkinode(inode, "mini_fo_evict_inode IN");
+ truncate_inode_pages(&inode->i_data, 0); /* FIXME: do we need this? */
+ invalidate_inode_buffers(inode);
+ end_writeback(inode);
print_exit_location();
}
@@ -300,11 +301,10 @@ struct super_operations mini_fo_sops =
put_inode: mini_fo_put_inode,
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
#if defined(FIST_DEBUG) || defined(FIST_FILTER_SCA)
- delete_inode: mini_fo_delete_inode,
+ evict_inode: mini_fo_evict_inode,
#endif /* defined(FIST_DEBUG) || defined(FIST_FILTER_SCA) */
put_super: mini_fo_put_super,
statfs: mini_fo_statfs,
remount_fs: mini_fo_remount_fs,
- clear_inode: mini_fo_clear_inode,
umount_begin: mini_fo_umount_begin,
};

View File

@ -1,48 +0,0 @@
--- a/fs/mini_fo/meta.c
+++ b/fs/mini_fo/meta.c
@@ -48,6 +48,9 @@ int meta_build_lists(dentry_t *dentry)
dtohd2(dentry),
strlen(META_FILENAME));
mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+ if (IS_ERR(meta_dentry))
+ goto out_ok;
+
if(!meta_dentry->d_inode) {
dput(meta_dentry);
goto out_ok;
@@ -433,6 +436,8 @@ int meta_write_d_entry(dentry_t *dentry,
meta_dentry = lookup_one_len(META_FILENAME,
dtohd2(dentry), strlen (META_FILENAME));
mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+ if (IS_ERR(meta_dentry))
+ return PTR_ERR(meta_dentry);
/* We need to create a META-file */
if(!meta_dentry->d_inode) {
@@ -538,6 +543,8 @@ int meta_write_r_entry(dentry_t *dentry,
dtohd2(dentry),
strlen (META_FILENAME));
mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+ if (IS_ERR(meta_dentry))
+ return PTR_ERR(meta_dentry);
if(!meta_dentry->d_inode) {
/* We need to create a META-file */
@@ -656,6 +663,8 @@ int meta_sync_d_list(dentry_t *dentry, i
dtohd2(dentry),
strlen(META_FILENAME));
mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+ if (IS_ERR(meta_dentry))
+ return PTR_ERR(meta_dentry);
if(!meta_dentry->d_inode) {
/* We need to create a META-file */
@@ -803,6 +812,8 @@ int meta_sync_r_list(dentry_t *dentry, i
dtohd2(dentry),
strlen(META_FILENAME));
mutex_unlock(&dtohd2(dentry)->d_inode->i_mutex);
+ if (IS_ERR(meta_dentry))
+ return PTR_ERR(meta_dentry);
if(!meta_dentry->d_inode) {
/* We need to create a META-file */

View File

@ -1,88 +0,0 @@
--- a/fs/mini_fo/dentry.c
+++ b/fs/mini_fo/dentry.c
@@ -78,7 +78,7 @@ mini_fo_d_revalidate(dentry_t *dentry, i
STATIC int
-mini_fo_d_hash(dentry_t *dentry, qstr_t *name)
+mini_fo_d_hash(const struct dentry *dentry, const struct inode *inode, qstr_t *name)
{
int err = 0;
dentry_t *hidden_dentry;
@@ -96,7 +96,7 @@ mini_fo_d_hash(dentry_t *dentry, qstr_t
if(hidden_sto_dentry &&
hidden_sto_dentry->d_op &&
hidden_sto_dentry->d_op->d_hash) {
- err = hidden_sto_dentry->d_op->d_hash(hidden_sto_dentry, name);
+ err = hidden_sto_dentry->d_op->d_hash(hidden_sto_dentry, hidden_sto_dentry->d_inode, name);
}
goto out;
}
@@ -106,7 +106,7 @@ mini_fo_d_hash(dentry_t *dentry, qstr_t
if(hidden_dentry &&
hidden_dentry->d_op &&
hidden_dentry->d_op->d_hash) {
- err = hidden_dentry->d_op->d_hash(hidden_dentry, name);
+ err = hidden_dentry->d_op->d_hash(hidden_dentry, hidden_dentry->d_inode, name);
}
goto out;
}
@@ -116,14 +116,14 @@ mini_fo_d_hash(dentry_t *dentry, qstr_t
if(hidden_sto_dentry &&
hidden_sto_dentry->d_op &&
hidden_sto_dentry->d_op->d_hash) {
- err = hidden_sto_dentry->d_op->d_hash(hidden_sto_dentry, name);
+ err = hidden_sto_dentry->d_op->d_hash(hidden_sto_dentry, hidden_sto_dentry->d_inode, name);
goto out;
}
hidden_dentry = dtohd(dentry);
if(hidden_dentry &&
hidden_dentry->d_op &&
hidden_dentry->d_op->d_hash) {
- err = hidden_dentry->d_op->d_hash(hidden_dentry, name);
+ err = hidden_dentry->d_op->d_hash(hidden_dentry, hidden_dentry->d_inode, name);
goto out;
}
}
@@ -136,21 +136,25 @@ mini_fo_d_hash(dentry_t *dentry, qstr_t
STATIC int
-mini_fo_d_compare(dentry_t *dentry, qstr_t *a, qstr_t *b)
+mini_fo_d_compare(const struct dentry *dentry_a, const struct inode *inode_a,
+ const struct dentry *dentry_b, const struct inode *inode_b,
+ unsigned int alen, const char *a, const struct qstr *b)
{
int err;
dentry_t *hidden_dentry=NULL;
/* hidden_dentry = mini_fo_hidden_dentry(dentry); */
- if(dtohd2(dentry))
- hidden_dentry = dtohd2(dentry);
- else if(dtohd(dentry))
- hidden_dentry = dtohd(dentry);
+ if(dtohd2(dentry_a))
+ hidden_dentry = dtohd2(dentry_a);
+ else if(dtohd(dentry_a))
+ hidden_dentry = dtohd(dentry_a);
if (hidden_dentry && hidden_dentry->d_op && hidden_dentry->d_op->d_compare) {
- err = hidden_dentry->d_op->d_compare(hidden_dentry, a, b);
+ err = hidden_dentry->d_op->d_compare(hidden_dentry, hidden_dentry->d_inode,
+ dentry_b, inode_b,
+ alen, a, b);
} else {
- err = ((a->len != b->len) || memcmp(a->name, b->name, b->len));
+ err = ((alen != b->len) || memcmp(a, b->name, b->len));
}
return err;
@@ -158,7 +162,7 @@ mini_fo_d_compare(dentry_t *dentry, qstr
int
-mini_fo_d_delete(dentry_t *dentry)
+mini_fo_d_delete(const struct dentry *dentry)
{
dentry_t *hidden_dentry;
dentry_t *hidden_sto_dentry;