From: Erez Zadok <[email protected]>
Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/super.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index fe02941..b3a5e64 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -335,7 +335,13 @@ found_insertion_point:
new_branch, err);
goto out;
}
- /* it's probably safe to check_mode the new branch to insert */
+ /*
+ * It's probably safe to check_mode the new branch to insert. Note:
+ * we don't allow inserting branches which are unionfs's by
+ * themselves (check_branch returns EINVAL in that case). This is
+ * because this code base doesn't support stacking unionfs: the ODF
+ * code base supports that correctly.
+ */
if ((err = check_branch(&nd))) {
printk(KERN_WARNING "unionfs: hidden directory "
"\"%s\" is not a valid branch\n", optarg);
@@ -400,15 +406,17 @@ static int unionfs_remount_fs(struct super_block *sb, int *flags,
int i;
char *optionstmp, *tmp_to_free; /* kstrdup'ed of "options" */
char *optname;
- int cur_branches; /* no. of current branches */
- int new_branches; /* no. of branches actually left in the end */
+ int cur_branches = 0; /* no. of current branches */
+ int new_branches = 0; /* no. of branches actually left in the end */
int add_branches; /* est. no. of branches to add */
int del_branches; /* est. no. of branches to del */
int max_branches; /* max possible no. of branches */
struct unionfs_data *new_data = NULL, *tmp_data = NULL;
struct path *new_lower_paths = NULL, *tmp_lower_paths = NULL;
+ struct inode **new_lower_inodes = NULL;
int new_high_branch_id; /* new high branch ID */
int size; /* memory allocation size, temp var */
+ int old_ibstart, old_ibend;
unionfs_write_lock(sb);
@@ -640,6 +648,14 @@ out_no_change:
goto out_release;
}
+ /* allocate space for new pointers to lower inodes */
+ new_lower_inodes = kcalloc(new_branches,
+ sizeof(struct inode *), GFP_KERNEL);
+ if (!new_lower_inodes) {
+ err = -ENOMEM;
+ goto out_release;
+ }
+
/*
* OK, just before we actually put the new set of branches in place,
* we need to ensure that our own f/s has no dirty objects left.
@@ -660,7 +676,7 @@ out_no_change:
* fsync_super() which would not have returned until all dirty pages
* were flushed.
*
- * But do w have to worry about locked pages? Is there any chance
+ * But do we have to worry about locked pages? Is there any chance
* that in here we'll get locked pages?
*
* XXX: what about pages mapped into pagetables? Are these pages
@@ -687,8 +703,31 @@ out_no_change:
i = sbmax(sb); /* save no. of branches to release at end */
sbend(sb) = new_branches - 1;
set_dbend(sb->s_root, new_branches - 1);
+ old_ibstart = ibstart(sb->s_root->d_inode);
+ old_ibend = ibend(sb->s_root->d_inode);
+ ibend(sb->s_root->d_inode) = new_branches - 1;
UNIONFS_D(sb->s_root)->bcount = new_branches;
- new_branches = i; /* no. of branches to release below */
+ new_branches = i; /* no. of branches to release below */
+
+ /*
+ * Update lower inodes: 3 steps
+ * 1. grab ref on all new lower inodes
+ */
+ for (i=dbstart(sb->s_root); i<=dbend(sb->s_root); i++) {
+ struct dentry *lower_dentry =
+ unionfs_lower_dentry_idx(sb->s_root, i);
+ atomic_inc(&lower_dentry->d_inode->i_count);
+ new_lower_inodes[i] = lower_dentry->d_inode;
+ }
+ /* 2. release reference on all older lower inodes */
+ for (i=old_ibstart; i<=old_ibend; i++) {
+ iput(unionfs_lower_inode_idx(sb->s_root->d_inode, i));
+ unionfs_set_lower_inode_idx(sb->s_root->d_inode, i, NULL);
+ }
+ kfree(UNIONFS_I(sb->s_root->d_inode)->lower_inodes);
+ /* 3. update root dentry's inode to new lower_inodes array */
+ UNIONFS_I(sb->s_root->d_inode)->lower_inodes = new_lower_inodes;
+ new_lower_inodes = NULL;
/* maxbytes may have changed */
sb->s_maxbytes = unionfs_lower_super_idx(sb, 0)->s_maxbytes;
@@ -723,6 +762,7 @@ out_free:
kfree(tmp_data);
kfree(new_lower_paths);
kfree(new_data);
+ kfree(new_lower_inodes);
out_error:
unionfs_write_unlock(sb);
return err;
--
1.5.2.rc1.165.gaf9b
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]