2007-05-24 00:36:31

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [GIT PULL -mm] Unionfs cleanups and fixes

The following patches consist of mostly cleanups of the Unionfs code, as
well as fixes for several harder to hit bugs (resource/memory leaks).

As before, there is a git repo at:

git://git.kernel.org/pub/scm/linux/kernel/git/jsipek/unionfs.git

(master.kernel.org:/pub/scm/linux/kernel/git/jsipek/unionfs.git)

There are 21 new commits:

Unionfs: Correctly decrement refcounts of mnt's upon branch management
Unionfs: Removed a trailing whitespace
Unionfs: Actually catch bad use of unionfs_mnt{get,put}
Unionfs: Remove defunct unionfs_put_inode super op
Unionfs: Documentation update regarding overlapping branches and new lookup code
Unionfs: Disallow setting leftmost branch to readonly
Unionfs: Use krealloc instead of open-coding the functionality
Unionfs: Call realloc unconditionally
Unionfs: Don't leak resources when copyup fails partially
Unionfs: Prefix external functions with 'extern' properly
Unionfs: Combine unionfs_write with __unionfs_write.
Unionfs: Move unionfs_query_file to commonfops.c
Unionfs: Rename our "do_rename" to __unionfs_rename
Unionfs: Rename Unionfs's double_lock_dentry to avoid confusion
Unionfs: Consistent pointer declaration spacing
Unionfs: Added numerous comments
Unionfs: Cleanup of strings and comments
Unionfs: Add missing copyright notices
Unionfs: Every printk should prefix with "unionfs: " consistently
Unionfs: Coding style fixes
Unionfs: Tiny documentation fixups

Thanks,

Josef 'Jeff' Sipek <[email protected]>


2007-05-24 00:36:53

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 01/21] Unionfs: Tiny documentation fixups

From: Erez Zadok <[email protected]>

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
Documentation/filesystems/unionfs/usage.txt | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/filesystems/unionfs/usage.txt b/Documentation/filesystems/unionfs/usage.txt
index 13fbcea..1c7554b 100644
--- a/Documentation/filesystems/unionfs/usage.txt
+++ b/Documentation/filesystems/unionfs/usage.txt
@@ -81,10 +81,10 @@ CACHE CONSISTENCY
If you modify any file on any of the lower branches directly, while there is
a Unionfs 2.0 mounted above any of those branches, you should tell Unionfs
to purge its caches and re-get the objects. To do that, you have to
-incremenet the generation number of the superblock using the following
+increment the generation number of the superblock using the following
command:

-# mount -t unionfs -o remount,remount,incgen none MOUNTPOINT
+# mount -t unionfs -o remount,incgen none MOUNTPOINT


For more information, see <http://unionfs.filesystems.org/>.
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:37:22

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 04/21] Unionfs: Add missing copyright notices

From: Erez Zadok <[email protected]>

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/stack.c | 11 +++++++++++
fs/unionfs/sioq.c | 5 -----
fs/unionfs/sioq.h | 13 +++++++++++++
include/linux/fs_stack.h | 11 +++++++++++
4 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/fs/stack.c b/fs/stack.c
index 9aee8fc..1f5b161 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2006-2007 Erez Zadok
+ * Copyright (c) 2006-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2006-2007 Stony Brook University
+ * Copyright (c) 2006-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/fs_stack.h>
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index a1e8ffa..34e25b0 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -1,13 +1,8 @@
/*
* Copyright (c) 2003-2007 Erez Zadok
- * Copyright (c) 2003-2006 Charles P. Wright
* Copyright (c) 2005-2007 Josef 'Jeff' Sipek
* Copyright (c) 2005-2006 Junjiro Okajima
- * Copyright (c) 2005 Arun M. Krishnakumar
* Copyright (c) 2004-2006 David P. Quigley
- * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
- * Copyright (c) 2003 Puja Gupta
- * Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
* Copyright (c) 2003-2007 The Research Foundation of SUNY
*
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 4827514..dd6c44b 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -1,3 +1,16 @@
+/*
+ * Copyright (c) 2003-2007 Erez Zadok
+ * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2005-2006 Junjiro Okajima
+ * Copyright (c) 2004-2006 David P. Quigley
+ * Copyright (c) 2003-2007 Stony Brook University
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
#ifndef _SIOQ_H
#define _SIOQ_H

diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index 2fe2387..9a896d6 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -1,3 +1,14 @@
+/*
+ * Copyright (c) 2006-2007 Erez Zadok
+ * Copyright (c) 2006-2007 Josef 'Jeff' Sipek
+ * Copyright (c) 2006-2007 Stony Brook University
+ * Copyright (c) 2006-2007 The Research Foundation of SUNY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
#ifndef _LINUX_FS_STACK_H
#define _LINUX_FS_STACK_H

--
1.5.2.rc1.165.gaf9b

2007-05-24 00:37:58

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 21/21] Unionfs: Correctly decrement refcounts of mnt's upon branch management

From: Erez Zadok <[email protected]>

The old logic was broken in one place, which another place tried to "fix"
incorrectly. Also added detailed comments to explain the new/correct logic.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/commonfops.c | 17 ++++++++++++-----
fs/unionfs/dentry.c | 18 +++++++++++++-----
2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 69d9c87..83001aa 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -135,14 +135,21 @@ static void cleanup_file(struct file *file)
"file %p\n", file);
else {
unionfs_read_lock(sb);
+ /* decrement count of open files */
branchput(sb, i);
unionfs_read_unlock(sb);
- /* XXX: is it OK to use sb->s_root here? */
- unionfs_mntput(sb->s_root, i);
- /* mntget b/c fput below will call mntput */
- unionfs_mntget(sb->s_root, bindex);
+ /*
+ * fput will perform an mntput for us on the
+ * correct branch. Although we're using the
+ * file's old branch configuration, bindex,
+ * which is the old index, correctly points
+ * to the right branch in the file's branch
+ * list. In other words, we're going to
+ * mntput the correct branch even if
+ * branches have been added/removed.
+ */
+ fput(unionfs_lower_file_idx(file, bindex));
}
- fput(unionfs_lower_file_idx(file, bindex));
}
}

diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 95cea3b..db0ef43 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -258,14 +258,22 @@ out_this:
/* finally, lock this dentry and revalidate it */
verify_locked(dentry);
dgen = atomic_read(&UNIONFS_D(dentry)->generation);
- saved_bstart = dbstart(dentry);
- saved_bend = dbend(dentry);
valid = __unionfs_d_revalidate_one(dentry, nd);

- if (valid && chain_len > 0 && sbgen != dgen) {
- for (bindex = saved_bstart; bindex <= saved_bend; bindex++)
+ /*
+ * If __unionfs_d_revalidate_one() succeeded above, then it will
+ * have incremented the refcnt of the mnt's, but also the branch
+ * indices of the dentry will have been updated (to take into
+ * account any branch insertions/deletion. So the current
+ * dbstart/dbend match the current, and new, indices of the mnts
+ * which __unionfs_d_revalidate_one has incremented. Note: the "if"
+ * test below does not depend on whether chain_len was 0 or greater.
+ */
+ if (valid && sbgen != dgen)
+ for (bindex = dbstart(dentry);
+ bindex <= dbend(dentry);
+ bindex++)
unionfs_mntput(dentry, bindex);
- }

out_free:
/* unlock/dput all dentries in chain and return status */
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:38:25

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 15/21] Unionfs: Use krealloc instead of open-coding the functionality

Change the branch management code to use krealloc instead of playing tricks
with kmalloc/memcpy/kfree.

Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/super.c | 56 +++++++++++++---------------------------------------
1 files changed, 14 insertions(+), 42 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index b7f0b45..3dee863 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -427,6 +427,7 @@ static int unionfs_remount_fs(struct super_block *sb, int *flags,
struct unionfs_data *new_data = NULL, *tmp_data = NULL;
struct path *new_lower_paths = NULL, *tmp_lower_paths = NULL;
int new_high_branch_id; /* new high branch ID */
+ int size; /* memory allocation size, temp var */

unionfs_write_lock(sb);

@@ -634,49 +635,20 @@ out_no_change:
* Also handle invalidating any pages that will have to be re-read.
*******************************************************************/

- /*
- * Allocate space for actual pointers, if needed. By the time we
- * finish this block of code, new_branches and new_lower_paths will
- * have the correct size. None of this code below would be needed
- * if the kernel had a realloc() function, at least one capable of
- * shrinking/truncating an allocation's size (hint, hint).
- */
- if (new_branches < max_branches) {
+ /* (re)allocate space for new pointers to hidden dentry */
+ size = new_branches * sizeof(struct unionfs_data);
+ new_data = krealloc(tmp_data, size, GFP_KERNEL);
+ if (!new_data) {
+ err = -ENOMEM;
+ goto out_release;
+ }

- /* allocate space for new pointers to hidden dentry */
- new_data = kcalloc(new_branches,
- sizeof(struct unionfs_data), GFP_KERNEL);
- if (!new_data) {
- err = -ENOMEM;
- goto out_release;
- }
- /* allocate space for new pointers to lower paths */
- new_lower_paths = kcalloc(new_branches,
- sizeof(struct path), GFP_KERNEL);
- if (!new_lower_paths) {
- err = -ENOMEM;
- goto out_release;
- }
- /*
- * copy current info into new placeholders, incrementing
- * refcounts.
- */
- memcpy(new_data, tmp_data,
- new_branches * sizeof(struct unionfs_data));
- memcpy(new_lower_paths, tmp_lower_paths,
- new_branches * sizeof(struct path));
- /*
- * Since we already hold various refcnts on the objects, we
- * don't need to redo it here. Just free the older memory
- * and re-point the pointers.
- */
- kfree(tmp_data);
- kfree(tmp_lower_paths);
- /* no need to nullify pointers here */
- } else {
- /* number of branches didn't change, no need to re-alloc */
- new_data = tmp_data;
- new_lower_paths = tmp_lower_paths;
+ /* allocate space for new pointers to lower paths */
+ size = new_branches * sizeof(struct path);
+ new_lower_paths = krealloc(tmp_lower_paths, size, GFP_KERNEL);
+ if (!new_lower_paths) {
+ err = -ENOMEM;
+ goto out_release;
}

/*
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:38:43

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 20/21] Unionfs: Removed a trailing whitespace

From: Yiannis Pericleous <[email protected]>

Signed-off-by: Yiannis Pericleous <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/super.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index bfd6c24..fe02941 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -699,10 +699,12 @@ out_no_change:
i = atomic_inc_return(&UNIONFS_SB(sb)->generation);
atomic_set(&UNIONFS_D(sb->s_root)->generation, i);
atomic_set(&UNIONFS_I(sb->s_root->d_inode)->generation, i);
- if (!(*flags & MS_SILENT))
- printk("unionfs: new generation number %d\n", i);
+
err = 0; /* reset to success */

+ if (!(*flags & MS_SILENT))
+ printk("unionfs: new generation number %d\n", i);
+
/*
* The code above falls through to the next label, and releases the
* refcnts of the older ones (stored in tmp_*): if we fell through
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:39:04

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 14/21] Unionfs: Call realloc unconditionally

krealloc already checks if the new size is greater than the old size.
Therefore, we can call realloc unconditionally - making the code simpler and
cleaner.

Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/lookup.c | 26 ++++++++------------------
1 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index cf78c46..758c813 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -451,17 +451,17 @@ void free_dentry_private_data(struct unionfs_dentry_info *udi)
/* allocate new dentry private data, free old one if necessary */
int new_dentry_private_data(struct dentry *dentry)
{
- int new_size;
int size;
struct unionfs_dentry_info *info = UNIONFS_D(dentry);
+ void *p;
int unlock_on_err = 0;

spin_lock(&dentry->d_lock);
if (!info) {
dentry->d_fsdata = kmem_cache_alloc(unionfs_dentry_cachep,
GFP_ATOMIC);
+
info = UNIONFS_D(dentry);
-
if (!info)
goto out;

@@ -470,9 +470,7 @@ int new_dentry_private_data(struct dentry *dentry)
unlock_on_err = 1;

info->lower_paths = NULL;
- size = 0;
- } else
- size = sizeof(struct path) * info->bcount;
+ }

info->bstart = -1;
info->bend = -1;
@@ -481,21 +479,13 @@ int new_dentry_private_data(struct dentry *dentry)
atomic_set(&info->generation,
atomic_read(&UNIONFS_SB(dentry->d_sb)->generation));

- new_size = sizeof(struct path) * sbmax(dentry->d_sb);
-
- /*
- * Don't reallocate when we already have enough space.
- */
- if (new_size > size) {
- void *p;
+ size = sizeof(struct path) * sbmax(dentry->d_sb);

- p = krealloc(info->lower_paths, new_size, GFP_ATOMIC);
- if (!p)
- goto out_free;
+ p = krealloc(info->lower_paths, size, GFP_ATOMIC);
+ if (!p)
+ goto out_free;

- info->lower_paths = p;
- size = new_size;
- }
+ info->lower_paths = p;
memset(info->lower_paths, 0, size);

spin_unlock(&dentry->d_lock);
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:39:30

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 19/21] Unionfs: Actually catch bad use of unionfs_mnt{get,put}

Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/union.h | 34 +++++++---------------------------
1 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 5376b76..335d579 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -459,38 +459,18 @@ static inline void unlock_dir(struct dentry *dir)
static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
int bindex)
{
- struct vfsmount *mnt;
+ BUG_ON(!dentry || bindex < 0);

- if (!dentry) {
- if (bindex < 0)
- return NULL;
- BUG_ON(bindex < 0);
- }
- mnt = unionfs_lower_mnt_idx(dentry, bindex);
- if (!mnt) {
- if (bindex < 0)
- return NULL;
- BUG_ON(mnt && bindex < 0);
- }
- mnt = mntget(mnt);
- return mnt;
+ return mntget(unionfs_lower_mnt_idx(dentry, bindex));
}

static inline void unionfs_mntput(struct dentry *dentry, int bindex)
{
- struct vfsmount *mnt;
+ if (!dentry)
+ return;

- if (!dentry) {
- if (bindex < 0)
- return;
- BUG_ON(dentry && bindex < 0);
- }
- mnt = unionfs_lower_mnt_idx(dentry, bindex);
- if (!mnt) {
- if (bindex < 0)
- return;
- BUG_ON(mnt && bindex < 0);
- }
- mntput(mnt);
+ BUG_ON(bindex < 0);
+
+ mntput(unionfs_lower_mnt_idx(dentry, bindex));
}
#endif /* not _UNION_H_ */
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:39:47

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 17/21] Unionfs: Documentation update regarding overlapping branches and new lookup code

From: Erez Zadok <[email protected]>

Added detailed comment and updated documentation to explain why overlapping
branches are disallowed, and better explain the cache coherency issues.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
Documentation/filesystems/unionfs/issues.txt | 16 ++++++++--------
fs/unionfs/main.c | 16 +++++++++++++++-
2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/Documentation/filesystems/unionfs/issues.txt b/Documentation/filesystems/unionfs/issues.txt
index a434fee..c634604 100644
--- a/Documentation/filesystems/unionfs/issues.txt
+++ b/Documentation/filesystems/unionfs/issues.txt
@@ -5,14 +5,14 @@ KNOWN Unionfs 2.0 ISSUES:
This means we can't reliably detect a read-only NFS export.

2. Modifying a Unionfs branch directly, while the union is mounted, is
- currently unsupported. We have tested Unionfs under such conditions, and
- fixed any bugs we found (Unionfs comes with an extensive regression test
- suite). However, it may still be possible that changes made to lower
- branches directly could cause cache incoherency which, in the worst case,
- may case an oops. We are currently addressing this problem for Unionfs
- and also generically for all stackable file systems, by handing mmap and
- introducing small VFS/MM changes that would allow a file system to handle
- cache coherency correctly.
+ currently unsupported, because it could cause a cache incoherency between
+ the union layer and the lower file systems (for that reason, Unionfs
+ currently prohibits using branches which overlap with each other, even
+ partially). We have tested Unionfs under such conditions, and fixed any
+ bugs we found (Unionfs comes with an extensive regression test suite).
+ However, it may still be possible that changes made to lower branches
+ directly could cause cache incoherency which, in the worst case, may case
+ an oops.

Unionfs 2.0 has a temporary workaround for this. You can force Unionfs
to increase the superblock generation number, and hence purge all cached
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 84d3bf5..a9ad445 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -351,7 +351,21 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info

BUG_ON(branches != (hidden_root_info->bend + 1));

- /* ensure that no overlaps exist in the branches */
+ /*
+ * Ensure that no overlaps exist in the branches.
+ *
+ * This test is required because the Linux kernel has no support
+ * currently for ensuring coherency between stackable layers and
+ * branches. If we were to allow overlapping branches, it would be
+ * possible, for example, to delete a file via one branch, which
+ * would not be reflected in another branch. Such incoherency could
+ * lead to inconsistencies and even kernel oopses. Rather than
+ * implement hacks to work around some of these cache-coherency
+ * problems, we prevent branch overlapping, for now. A complete
+ * solution will involve proper kernel/VFS support for cache
+ * coherency, at which time we could safely remove this
+ * branch-overlapping test.
+ */
for (i = 0; i < branches; i++) {
for (j = i + 1; j < branches; j++) {
dent1 = hidden_root_info->lower_paths[i].dentry;
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:40:13

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 09/21] Unionfs: Rename our "do_rename" to __unionfs_rename

From: Erez Zadok <[email protected]>

To avoid confusion with the VFS function do_rename, and to help ctags,
rename our utility (static) function do_rename to __unionfs_rename.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/rename.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 0e1e71a..edc5a5c 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -18,9 +18,9 @@

#include "union.h"

-static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
- struct inode *new_dir, struct dentry *new_dentry,
- int bindex, struct dentry **wh_old)
+static int __unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
+ struct inode *new_dir, struct dentry *new_dentry,
+ int bindex, struct dentry **wh_old)
{
int err = 0;
struct dentry *hidden_old_dentry;
@@ -144,7 +144,7 @@ out:
/*
* Main rename code. This is sufficienly complex, that it's documented in
* Docmentation/filesystems/unionfs/rename.txt. This routine calls
- * do_rename() above to perform some of the work.
+ * __unionfs_rename() above to perform some of the work.
*/
static int do_unionfs_rename(struct inode *old_dir,
struct dentry *old_dentry,
@@ -171,8 +171,8 @@ static int do_unionfs_rename(struct inode *old_dir,
new_bend = dbend(new_dentry);

/* Rename source to destination. */
- err = do_rename(old_dir, old_dentry, new_dir, new_dentry, old_bstart,
- &wh_old);
+ err = __unionfs_rename(old_dir, old_dentry, new_dir, new_dentry,
+ old_bstart, &wh_old);
if (err) {
if (!IS_COPYUP_ERR(err))
goto out;
@@ -230,8 +230,9 @@ static int do_unionfs_rename(struct inode *old_dir,
if (!err) {
dput(wh_old);
bwh_old = bindex;
- err = do_rename(old_dir, old_dentry, new_dir,
- new_dentry, bindex, &wh_old);
+ err = __unionfs_rename(old_dir, old_dentry,
+ new_dir, new_dentry,
+ bindex, &wh_old);
break;
}
}
@@ -306,8 +307,8 @@ revert:
goto revert_out;
}

- local_err = do_rename(new_dir, new_dentry,
- old_dir, old_dentry, old_bstart, NULL);
+ local_err = __unionfs_rename(new_dir, new_dentry,
+ old_dir, old_dentry, old_bstart, NULL);

/* If we can't fix it, then we cop-out with -EIO. */
if (local_err) {
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:40:40

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 16/21] Unionfs: Disallow setting leftmost branch to readonly

From: Erez Zadok <[email protected]>

Unionfs requires the leftmost branch to be writeable for copyup to work
properly and simply. If, through branch-management commands (add, delete,
or mode change), the leftmost branch will becomes readonly, then return an
error (and tell the user to use "remount,ro" if they want a readonly union).

[jsipek: fixed up to apply cleanly]
Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/super.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 3dee863..446faf8 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -629,12 +629,20 @@ static int unionfs_remount_fs(struct super_block *sb, int *flags,
out_no_change:

/******************************************************************
- * WE'RE ALMOST DONE: see if we need to allocate a small-sized new
- * vector, copy the vectors to their correct place, release the
- * refcnt of the older ones, and return.
- * Also handle invalidating any pages that will have to be re-read.
+ * WE'RE ALMOST DONE: check if leftmost branch might be read-only,
+ * see if we need to allocate a small-sized new vector, copy the
+ * vectors to their correct place, release the refcnt of the older
+ * ones, and return. Also handle invalidating any pages that will
+ * have to be re-read.
*******************************************************************/

+ if (!(tmp_data[0].branchperms & MAY_WRITE)) {
+ printk("unionfs: leftmost branch cannot be read-only "
+ "(use \"remount,ro\" to create a read-only union)\n");
+ err = -EINVAL;
+ goto out_release;
+ }
+
/* (re)allocate space for new pointers to hidden dentry */
size = new_branches * sizeof(struct unionfs_data);
new_data = krealloc(tmp_data, size, GFP_KERNEL);
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:40:56

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 07/21] Unionfs: Consistent pointer declaration spacing

From: Erez Zadok <[email protected]>

Change instances of "foo * var" to "foo *var" for consistency.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/copyup.c | 6 +++---
fs/unionfs/file.c | 14 +++++++-------
fs/unionfs/inode.c | 2 +-
fs/unionfs/super.c | 2 +-
fs/unionfs/xattr.c | 4 ++--
5 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 4924685..0975b6e 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -541,7 +541,7 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
}

/* purge a dentry's lower-branch states (dput/mntput, etc.) */
-static void __cleanup_dentry(struct dentry * dentry, int bindex,
+static void __cleanup_dentry(struct dentry *dentry, int bindex,
int old_bstart, int old_bend)
{
int loop_start;
@@ -592,7 +592,7 @@ static void __cleanup_dentry(struct dentry * dentry, int bindex,
}

/* set lower inode ptr and update bstart & bend if necessary */
-static void __set_inode(struct dentry * upper, struct dentry * lower,
+static void __set_inode(struct dentry *upper, struct dentry *lower,
int bindex)
{
unionfs_set_lower_inode_idx(upper->d_inode, bindex,
@@ -605,7 +605,7 @@ static void __set_inode(struct dentry * upper, struct dentry * lower,
}

/* set lower dentry ptr and update bstart & bend if necessary */
-static void __set_dentry(struct dentry * upper, struct dentry * lower,
+static void __set_dentry(struct dentry *upper, struct dentry *lower,
int bindex)
{
unionfs_set_lower_dentry_idx(upper, bindex, lower);
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 57f2bdd..1dfcfcb 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -53,8 +53,8 @@ out:
return err;
}

-static ssize_t unionfs_read(struct file * file, char __user * buf,
- size_t count, loff_t * ppos)
+static ssize_t unionfs_read(struct file *file, char __user *buf,
+ size_t count, loff_t *ppos)
{
struct file *hidden_file;
loff_t pos = *ppos;
@@ -78,8 +78,8 @@ out:
}

/* helper function to unionfs_write */
-static ssize_t __unionfs_write(struct file * file, const char __user * buf,
- size_t count, loff_t * ppos)
+static ssize_t __unionfs_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
{
int err = -EINVAL;
struct file *hidden_file = NULL;
@@ -123,8 +123,8 @@ out:
return err;
}

-static ssize_t unionfs_write(struct file * file, const char __user * buf,
- size_t count, loff_t * ppos)
+static ssize_t unionfs_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
{
int err = 0;

@@ -145,7 +145,7 @@ static int unionfs_file_readdir(struct file *file, void *dirent,
return -ENOTDIR;
}

-static unsigned int unionfs_poll(struct file *file, poll_table * wait)
+static unsigned int unionfs_poll(struct file *file, poll_table *wait)
{
unsigned int mask = DEFAULT_POLLMASK;
struct file *hidden_file = NULL;
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 2d0822a..c54b290 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -768,7 +768,7 @@ out:
return err;
}

-static int unionfs_readlink(struct dentry *dentry, char __user * buf,
+static int unionfs_readlink(struct dentry *dentry, char __user *buf,
int bufsiz)
{
int err;
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 39939ba..b7f0b45 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -824,7 +824,7 @@ static void unionfs_destroy_inode(struct inode *inode)
}

/* unionfs inode cache constructor */
-static void init_once(void *v, struct kmem_cache * cachep, unsigned long flags)
+static void init_once(void *v, struct kmem_cache *cachep, unsigned long flags)
{
struct unionfs_inode_info *i = v;

diff --git a/fs/unionfs/xattr.c b/fs/unionfs/xattr.c
index 4dc8ada..12d618b 100644
--- a/fs/unionfs/xattr.c
+++ b/fs/unionfs/xattr.c
@@ -51,7 +51,7 @@ void unionfs_xattr_free(void *ptr, size_t size)
* BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
-ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
+ssize_t unionfs_getxattr(struct dentry *dentry, const char *name, void *value,
size_t size)
{
struct dentry *hidden_dentry = NULL;
@@ -115,7 +115,7 @@ int unionfs_removexattr(struct dentry *dentry, const char *name)
* BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
-ssize_t unionfs_listxattr(struct dentry * dentry, char *list, size_t size)
+ssize_t unionfs_listxattr(struct dentry *dentry, char *list, size_t size)
{
struct dentry *hidden_dentry = NULL;
int err = -EOPNOTSUPP;
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:41:38

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 11/21] Unionfs: Combine unionfs_write with __unionfs_write.

The __unionfs_write helper function was used only by unionfs_write, and
there is really no reason why they should not be combined.

Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/file.c | 30 ++++++++++--------------------
1 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 1dfcfcb..2e5ec42 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -77,17 +77,20 @@ out:
return err;
}

-/* helper function to unionfs_write */
-static ssize_t __unionfs_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t unionfs_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
{
- int err = -EINVAL;
+ int err;
struct file *hidden_file = NULL;
struct inode *inode;
struct inode *hidden_inode;
loff_t pos = *ppos;
int bstart, bend;

+ unionfs_read_lock(file->f_dentry->d_sb);
+ if ((err = unionfs_file_revalidate(file, 1)))
+ goto out;
+
inode = file->f_dentry->d_inode;

bstart = fbstart(file);
@@ -98,8 +101,10 @@ static ssize_t __unionfs_write(struct file *file, const char __user *buf,
hidden_file = unionfs_lower_file(file);
hidden_inode = hidden_file->f_dentry->d_inode;

- if (!hidden_file->f_op || !hidden_file->f_op->write)
+ if (!hidden_file->f_op || !hidden_file->f_op->write) {
+ err = -EINVAL;
goto out;
+ }

/* adjust for append -- seek to the end of the file */
if (file->f_flags & O_APPEND)
@@ -120,21 +125,6 @@ static ssize_t __unionfs_write(struct file *file, const char __user *buf,
if (pos > inode->i_size)
inode->i_size = pos;
out:
- return err;
-}
-
-static ssize_t unionfs_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- int err = 0;
-
- unionfs_read_lock(file->f_dentry->d_sb);
- if ((err = unionfs_file_revalidate(file, 1)))
- goto out;
-
- err = __unionfs_write(file, buf, count, ppos);
-
-out:
unionfs_read_unlock(file->f_dentry->d_sb);
return err;
}
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:41:58

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 12/21] Unionfs: Prefix external functions with 'extern' properly

From: Erez Zadok <[email protected]>

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/sioq.h | 1 +
fs/unionfs/union.h | 50 +++++++++++++++++++++++++-------------------------
2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 5a96f66..55b781e 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -74,6 +74,7 @@ struct sioq_args {
};
};

+/* Extern definitions for SIOQ functions */
extern int __init init_sioq(void);
extern __exit void stop_sioq(void);
extern void run_sioq(work_func_t func, struct sioq_args *args);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index dab408f..5376b76 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -183,26 +183,26 @@ struct unionfs_dir_state {
#include "fanout.h"
#include "sioq.h"

-/* Cache creation/deletion routines. */
-void unionfs_destroy_filldir_cache(void);
-int unionfs_init_filldir_cache(void);
-int unionfs_init_inode_cache(void);
-void unionfs_destroy_inode_cache(void);
-int unionfs_init_dentry_cache(void);
-void unionfs_destroy_dentry_cache(void);
+/* externs for cache creation/deletion routines */
+extern void unionfs_destroy_filldir_cache(void);
+extern int unionfs_init_filldir_cache(void);
+extern int unionfs_init_inode_cache(void);
+extern void unionfs_destroy_inode_cache(void);
+extern int unionfs_init_dentry_cache(void);
+extern void unionfs_destroy_dentry_cache(void);

/* Initialize and free readdir-specific state. */
-int init_rdstate(struct file *file);
-struct unionfs_dir_state *alloc_rdstate(struct inode *inode, int bindex);
-struct unionfs_dir_state *find_rdstate(struct inode *inode, loff_t fpos);
-void free_rdstate(struct unionfs_dir_state *state);
-int add_filldir_node(struct unionfs_dir_state *rdstate, const char *name,
- int namelen, int bindex, int whiteout);
-struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
- const char *name, int namelen);
-
-struct dentry **alloc_new_dentries(int objs);
-struct unionfs_data *alloc_new_data(int objs);
+extern int init_rdstate(struct file *file);
+extern struct unionfs_dir_state *alloc_rdstate(struct inode *inode, int bindex);
+extern struct unionfs_dir_state *find_rdstate(struct inode *inode, loff_t fpos);
+extern void free_rdstate(struct unionfs_dir_state *state);
+extern int add_filldir_node(struct unionfs_dir_state *rdstate, const char *name,
+ int namelen, int bindex, int whiteout);
+extern struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
+ const char *name, int namelen);
+
+extern struct dentry **alloc_new_dentries(int objs);
+extern struct unionfs_data *alloc_new_data(int objs);

/* We can only use 32-bits of offset for rdstate --- blech! */
#define DIREOF (0xfffff)
@@ -236,8 +236,8 @@ static inline void unionfs_double_lock_dentry(struct dentry *d1,
}

extern int new_dentry_private_data(struct dentry *dentry);
-void free_dentry_private_data(struct unionfs_dentry_info *udi);
-void update_bstart(struct dentry *dentry);
+extern void free_dentry_private_data(struct unionfs_dentry_info *udi);
+extern void update_bstart(struct dentry *dentry);

/*
* EXTERNALS:
@@ -246,6 +246,7 @@ void update_bstart(struct dentry *dentry);
/* replicates the directory structure up to given dentry in given branch */
extern struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
int bindex);
+extern int make_dir_opaque(struct dentry *dir, int bindex);

/* partial lookup */
extern int unionfs_partial_lookup(struct dentry *dentry);
@@ -304,10 +305,11 @@ extern long unionfs_ioctl(struct file *file, unsigned int cmd,
/* Inode operations */
extern int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry);
-int unionfs_unlink(struct inode *dir, struct dentry *dentry);
-int unionfs_rmdir(struct inode *dir, struct dentry *dentry);
+extern int unionfs_unlink(struct inode *dir, struct dentry *dentry);
+extern int unionfs_rmdir(struct inode *dir, struct dentry *dentry);

-int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd);
+extern int __unionfs_d_revalidate_chain(struct dentry *dentry,
+ struct nameidata *nd);

/* The values for unionfs_interpose's flag. */
#define INTERPOSE_DEFAULT 0
@@ -454,8 +456,6 @@ static inline void unlock_dir(struct dentry *dir)
dput(dir);
}

-extern int make_dir_opaque(struct dentry *dir, int bindex);
-
static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
int bindex)
{
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:42:27

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 10/21] Unionfs: Move unionfs_query_file to commonfops.c

Moved unionfs_query_file closer to its one user in commonfops.c.
Additionally, it can now become static, and branchman.c can be removed as it
is empty.

Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/Makefile | 4 +-
fs/unionfs/branchman.c | 60 -----------------------------------------------
fs/unionfs/commonfops.c | 41 ++++++++++++++++++++++++++++++++
fs/unionfs/union.h | 6 ----
4 files changed, 43 insertions(+), 68 deletions(-)
delete mode 100644 fs/unionfs/branchman.c

diff --git a/fs/unionfs/Makefile b/fs/unionfs/Makefile
index e6b2e0c..6986d79 100644
--- a/fs/unionfs/Makefile
+++ b/fs/unionfs/Makefile
@@ -1,7 +1,7 @@
obj-$(CONFIG_UNION_FS) += unionfs.o

unionfs-y := subr.o dentry.o file.o inode.o main.o super.o \
- branchman.o rdstate.o copyup.o dirhelper.o rename.o \
- unlink.o lookup.o commonfops.o dirfops.o sioq.o
+ rdstate.o copyup.o dirhelper.o rename.o unlink.o \
+ lookup.o commonfops.o dirfops.o sioq.o

unionfs-$(CONFIG_UNION_FS_XATTR) += xattr.o
diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
deleted file mode 100644
index 4545e18..0000000
--- a/fs/unionfs/branchman.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2003-2007 Erez Zadok
- * Copyright (c) 2003-2006 Charles P. Wright
- * Copyright (c) 2005-2007 Josef 'Jeff' Sipek
- * Copyright (c) 2005-2006 Junjiro Okajima
- * Copyright (c) 2005 Arun M. Krishnakumar
- * Copyright (c) 2004-2006 David P. Quigley
- * Copyright (c) 2003-2004 Mohammad Nayyer Zubair
- * Copyright (c) 2003 Puja Gupta
- * Copyright (c) 2003 Harikesavan Krishnan
- * Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of SUNY
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include "union.h"
-
-/*
- * return to user-space the branch indices containing the file in question
- *
- * We use fd_set and therefore we are limited to the number of the branches
- * to FD_SETSIZE, which is currently 1024 - plenty for most people
- */
-int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- int err = 0;
- fd_set branchlist;
-
- int bstart = 0, bend = 0, bindex = 0;
- struct dentry *dentry, *hidden_dentry;
-
- dentry = file->f_dentry;
- unionfs_lock_dentry(dentry);
- if ((err = unionfs_partial_lookup(dentry)))
- goto out;
- bstart = dbstart(dentry);
- bend = dbend(dentry);
-
- FD_ZERO(&branchlist);
-
- for (bindex = bstart; bindex <= bend; bindex++) {
- hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
- if (!hidden_dentry)
- continue;
- if (hidden_dentry->d_inode)
- FD_SET(bindex, &branchlist);
- }
-
- err = copy_to_user((void __user *)arg, &branchlist, sizeof(fd_set));
- if (err)
- err = -EFAULT;
-
-out:
- unionfs_unlock_dentry(dentry);
- return err < 0 ? err : bend;
-}
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index a57471e..69d9c87 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -632,6 +632,47 @@ out:
return err;
}

+/*
+ * return to user-space the branch indices containing the file in question
+ *
+ * We use fd_set and therefore we are limited to the number of the branches
+ * to FD_SETSIZE, which is currently 1024 - plenty for most people
+ */
+static int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int err = 0;
+ fd_set branchlist;
+
+ int bstart = 0, bend = 0, bindex = 0;
+ struct dentry *dentry, *hidden_dentry;
+
+ dentry = file->f_dentry;
+ unionfs_lock_dentry(dentry);
+ if ((err = unionfs_partial_lookup(dentry)))
+ goto out;
+ bstart = dbstart(dentry);
+ bend = dbend(dentry);
+
+ FD_ZERO(&branchlist);
+
+ for (bindex = bstart; bindex <= bend; bindex++) {
+ hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
+ if (!hidden_dentry)
+ continue;
+ if (hidden_dentry->d_inode)
+ FD_SET(bindex, &branchlist);
+ }
+
+ err = copy_to_user((void __user *)arg, &branchlist, sizeof(fd_set));
+ if (err)
+ err = -EFAULT;
+
+out:
+ unionfs_unlock_dentry(dentry);
+ return err < 0 ? err : bend;
+}
+
long unionfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
long err;
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index fee4f88..dab408f 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -319,12 +319,6 @@ int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd);
extern int unionfs_interpose(struct dentry *this_dentry,
struct super_block *sb, int flag);

-/* Branch management ioctls. */
-int unionfs_ioctl_incgen(struct file *file, unsigned int cmd,
- unsigned long arg);
-int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
- unsigned long arg);
-
#ifdef CONFIG_UNION_FS_XATTR
/* Extended attribute functions. */
extern void *unionfs_xattr_alloc(size_t size, size_t limit);
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:42:47

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 08/21] Unionfs: Rename Unionfs's double_lock_dentry to avoid confusion

From: Erez Zadok <[email protected]>

To avoid potential confusion with a VFS function, rename our version of
double_lock_dentry to unionfs_double_lock_dentry.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/inode.c | 2 +-
fs/unionfs/rename.c | 2 +-
fs/unionfs/union.h | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index c54b290..627c2a7 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -265,7 +265,7 @@ static int unionfs_link(struct dentry *old_dentry, struct inode *dir,
BUG_ON(!is_valid_dentry(new_dentry));
BUG_ON(!is_valid_dentry(old_dentry));

- double_lock_dentry(new_dentry, old_dentry);
+ unionfs_double_lock_dentry(new_dentry, old_dentry);

hidden_new_dentry = unionfs_lower_dentry(new_dentry);

diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 231866e..0e1e71a 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -400,7 +400,7 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
BUG_ON(!is_valid_dentry(old_dentry));
BUG_ON(!is_valid_dentry(new_dentry));

- double_lock_dentry(old_dentry, new_dentry);
+ unionfs_double_lock_dentry(old_dentry, new_dentry);

if (!S_ISDIR(old_dentry->d_inode->i_mode))
err = unionfs_partial_lookup(old_dentry);
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 0ce3a27..fee4f88 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -223,7 +223,8 @@ static inline off_t rdstate2offset(struct unionfs_dir_state *buf)
#define unionfs_write_lock(sb) down_write(&UNIONFS_SB(sb)->rwsem)
#define unionfs_write_unlock(sb) up_write(&UNIONFS_SB(sb)->rwsem)

-static inline void double_lock_dentry(struct dentry *d1, struct dentry *d2)
+static inline void unionfs_double_lock_dentry(struct dentry *d1,
+ struct dentry *d2)
{
if (d2 < d1) {
struct dentry *tmp = d1;
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:43:17

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 05/21] Unionfs: Cleanup of strings and comments

From: Erez Zadok <[email protected]>

Includes:
- consistent style for multi-line comments
- spell-check of all strings and comments

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/stack.c | 6 ++++--
fs/unionfs/branchman.c | 3 ++-
fs/unionfs/commonfops.c | 26 +++++++++++++++++---------
fs/unionfs/copyup.c | 46 +++++++++++++++++++++++++++++-----------------
fs/unionfs/dentry.c | 6 ++++--
fs/unionfs/dirfops.c | 6 ++++--
fs/unionfs/dirhelper.c | 3 ++-
fs/unionfs/file.c | 2 +-
fs/unionfs/inode.c | 45 +++++++++++++++++++++++++++++----------------
fs/unionfs/lookup.c | 39 +++++++++++++++++++++++++--------------
fs/unionfs/main.c | 24 ++++++++++++++++--------
fs/unionfs/rdstate.c | 15 ++++++++++-----
fs/unionfs/rename.c | 27 +++++++++++++++++----------
fs/unionfs/sioq.c | 3 ++-
fs/unionfs/sioq.h | 2 +-
fs/unionfs/subr.c | 15 ++++++++++-----
fs/unionfs/super.c | 21 +++++++++++++--------
fs/unionfs/union.h | 17 +++++++++++------
fs/unionfs/xattr.c | 12 ++++++++----
include/linux/fs_stack.h | 3 ++-
20 files changed, 207 insertions(+), 114 deletions(-)

diff --git a/fs/stack.c b/fs/stack.c
index 1f5b161..4368d4b 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -13,7 +13,8 @@
#include <linux/fs.h>
#include <linux/fs_stack.h>

-/* does _NOT_ require i_mutex to be held.
+/*
+ * does _NOT_ require i_mutex to be held.
*
* This function cannot be inlined since i_size_{read,write} is rather
* heavy-weight on 32-bit systems
@@ -25,7 +26,8 @@ void fsstack_copy_inode_size(struct inode *dst, const struct inode *src)
}
EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);

-/* copy all attributes; get_nlinks is optional way to override the i_nlink
+/*
+ * copy all attributes; get_nlinks is optional way to override the i_nlink
* copying
*/
void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
index eba2221..4545e18 100644
--- a/fs/unionfs/branchman.c
+++ b/fs/unionfs/branchman.c
@@ -18,7 +18,8 @@

#include "union.h"

-/* return to userspace the branch indices containing the file in question
+/*
+ * return to user-space the branch indices containing the file in question
*
* We use fd_set and therefore we are limited to the number of the branches
* to FD_SETSIZE, which is currently 1024 - plenty for most people
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 778901f..666b3c7 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -18,7 +18,8 @@

#include "union.h"

-/* 1) Copyup the file
+/*
+ * 1) Copyup the file
* 2) Rename the file to '.unionfs<original inode#><counter>' - obviously
* stolen from NFS's silly rename
*/
@@ -111,7 +112,8 @@ static int find_new_branch_index(struct file *file, int bindex,
return -1;
}

-/* put all references held by upper struct file and free lower file pointer
+/*
+ * put all references held by upper struct file and free lower file pointer
* array
*/
static void cleanup_file(struct file *file)
@@ -129,7 +131,7 @@ static void cleanup_file(struct file *file)
int i; /* holds (possibly) updated branch index */
i = find_new_branch_index(file, bindex, sb);
if (i < 0)
- printk(KERN_ERR "unionfs: no supberlock for "
+ printk(KERN_ERR "unionfs: no superblock for "
"file %p\n", file);
else {
unionfs_read_lock(sb);
@@ -308,7 +310,8 @@ int unionfs_file_revalidate(struct file *file, int willwrite)

BUG_ON(sbgen > dgen);

- /* There are two cases we are interested in. The first is if the
+ /*
+ * There are two cases we are interested in. The first is if the
* generation is lower than the super-block. The second is if someone
* has copied up this file from underneath us, we also need to refresh
* things.
@@ -397,7 +400,8 @@ static int __open_dir(struct inode *inode, struct file *file)

unionfs_set_lower_file_idx(file, bindex, hidden_file);

- /* The branchget goes after the open, because otherwise
+ /*
+ * The branchget goes after the open, because otherwise
* we would miss the reference on release.
*/
unionfs_read_lock(inode->i_sb);
@@ -422,11 +426,13 @@ static int __open_file(struct inode *inode, struct file *file)
bstart = fbstart(file) = dbstart(file->f_dentry);
bend = fbend(file) = dbend(file->f_dentry);

- /* check for the permission for hidden file. If the error is
+ /*
+ * check for the permission for hidden file. If the error is
* COPYUP_ERR, copyup the file.
*/
if (hidden_dentry->d_inode && is_robranch(file->f_dentry)) {
- /* if the open will change the file, copy it up otherwise
+ /*
+ * if the open will change the file, copy it up otherwise
* defer it.
*/
if (hidden_flags & O_TRUNC) {
@@ -448,7 +454,8 @@ static int __open_file(struct inode *inode, struct file *file)

dget(hidden_dentry);

- /* dentry_open will decrement mnt refcnt if err.
+ /*
+ * dentry_open will decrement mnt refcnt if err.
* otherwise fput() will do an mntput() for us upon file close.
*/
unionfs_mntget(file->f_dentry, bstart);
@@ -509,7 +516,8 @@ int unionfs_open(struct inode *inode, struct file *file)
/* increment, so that we can flush appropriately */
atomic_inc(&UNIONFS_I(dentry->d_inode)->totalopens);

- /* open all directories and make the unionfs file struct point to
+ /*
+ * open all directories and make the unionfs file struct point to
* these hidden file structs
*/
if (S_ISDIR(inode->i_mode))
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 8fae308..1495778 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -26,7 +26,8 @@ static struct dentry *create_parents_named(struct inode *dir,
struct dentry *dentry,
const char *name, int bindex);

-/* For detailed explanation of copyup see:
+/*
+ * For detailed explanation of copyup see:
* Documentation/filesystems/unionfs/concepts.txt
*/

@@ -135,7 +136,8 @@ int copyup_dentry(struct inode *dir, struct dentry *dentry,
dentry->d_name.len, copyup_file, len);
}

-/* create the new device/file/directory - use copyup_permission to copyup
+/*
+ * create the new device/file/directory - use copyup_permission to copyup
* times, and mode
*
* if the object being copied up is a regular file, the file is only created,
@@ -314,7 +316,8 @@ out:
return err;
}

-/* dput the lower references for old and new dentry & clear a lower dentry
+/*
+ * dput the lower references for old and new dentry & clear a lower dentry
* pointer
*/
static void __clear(struct dentry *dentry, struct dentry *old_hidden_dentry,
@@ -434,15 +437,15 @@ static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
goto out_unlink;
#endif

- /* do not allow files getting deleted to be reinterposed */
+ /* do not allow files getting deleted to be re-interposed */
if (!d_deleted(dentry))
unionfs_reinterpose(dentry);

goto out_unlock;
- /****/

out_unlink:
- /* copyup failed, because we possibly ran out of space or
+ /*
+ * copyup failed, because we possibly ran out of space or
* quota, or something else happened so let's unlink; we don't
* really care about the return value of vfs_unlink
*/
@@ -460,7 +463,7 @@ out_unlink:
/*
* TODO: should we reset the error to something like -EIO?
*
- * If we don't reset, the user may get some non-sensical errors, but
+ * If we don't reset, the user may get some nonsensical errors, but
* on the other hand, if we reset to EIO, we guarantee that the user
* will get a "confusing" error message.
*/
@@ -472,7 +475,7 @@ out_free:
/*
* If old_hidden_dentry was a directory, we need to dput it. If it
* was a file, then it was already dput indirectly by other
- * functions we call ablve which operate on regular files.
+ * functions we call above which operate on regular files.
*/
if (old_hidden_dentry && old_hidden_dentry->d_inode &&
S_ISDIR(old_hidden_dentry->d_inode->i_mode))
@@ -483,7 +486,8 @@ out:
return err;
}

-/* This function creates a copy of a file represented by 'file' which currently
+/*
+ * This function creates a copy of a file represented by 'file' which currently
* resides in branch 'bstart' to branch 'new_bindex.' The copy will be named
* "name".
*/
@@ -504,7 +508,8 @@ int copyup_named_file(struct inode *dir, struct file *file, char *name,
return err;
}

-/* This function creates a copy of a file represented by 'file' which currently
+/*
+ * This function creates a copy of a file represented by 'file' which currently
* resides in branch 'bstart' to branch 'new_bindex'.
*/
int copyup_file(struct inode *dir, struct file *file, int bstart,
@@ -523,7 +528,8 @@ int copyup_file(struct inode *dir, struct file *file, int bstart,
return err;
}

-/* This function replicates the directory structure upto given dentry in the
+/*
+ * This function replicates the directory structure up-to given dentry in the
* bindex branch. Can create directory structure recursively to the right
* also.
*/
@@ -545,7 +551,8 @@ static void __cleanup_dentry(struct dentry * dentry, int bindex,
loop_start = min(old_bstart, bindex);
loop_end = max(old_bend, bindex);

- /* This loop sets the bstart and bend for the new dentry by
+ /*
+ * This loop sets the bstart and bend for the new dentry by
* traversing from left to right. It also dputs all negative
* dentries except bindex
*/
@@ -606,7 +613,8 @@ static void __set_dentry(struct dentry * upper, struct dentry * lower,
set_dbend(upper, bindex);
}

-/* This function replicates the directory structure upto given dentry
+/*
+ * This function replicates the directory structure up-to given dentry
* in the bindex branch.
*/
static struct dentry *create_parents_named(struct inode *dir,
@@ -651,7 +659,8 @@ static struct dentry *create_parents_named(struct inode *dir,
parent_dentry = dentry;

count = 0;
- /* This loop finds the first parent that exists in the given branch.
+ /*
+ * This loop finds the first parent that exists in the given branch.
* We start building the directory structure from there. At the end
* of the loop, the following should hold:
* - child_dentry is the first nonexistent child
@@ -690,7 +699,8 @@ static struct dentry *create_parents_named(struct inode *dir,

sb = dentry->d_sb;

- /* This is basically while(child_dentry != dentry). This loop is
+ /*
+ * This is basically while(child_dentry != dentry). This loop is
* horrible to follow and should be replaced with cleaner code.
*/
while (1) {
@@ -712,7 +722,8 @@ static struct dentry *create_parents_named(struct inode *dir,
goto out;
} else {

- /* is the name a whiteout of the childname ?
+ /*
+ * is the name a whiteout of the child name ?
* lookup the whiteout child in the underlying file
* system
*/
@@ -735,7 +746,8 @@ static struct dentry *create_parents_named(struct inode *dir,
}

if (hidden_dentry->d_inode) {
- /* since this already exists we dput to avoid
+ /*
+ * since this already exists we dput to avoid
* multiple references on the same dentry
*/
dput(hidden_dentry);
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 463cf4c..46a52f7 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -59,7 +59,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
positive = 1;
dgen = atomic_read(&UNIONFS_D(dentry)->generation);
sbgen = atomic_read(&UNIONFS_SB(dentry->d_sb)->generation);
- /* If we are working on an unconnected dentry, then there is no
+ /*
+ * If we are working on an unconnected dentry, then there is no
* revalidation to be done, because this file does not exist within the
* namespace, and Unionfs operates on the namespace, not data.
*/
@@ -131,7 +132,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
valid = 0;
goto out;
}
- /* current unionfs_lookup_backend() doesn't return
+ /*
+ * current unionfs_lookup_backend() doesn't return
* a valid dentry
*/
dput(dentry);
diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index cab7b6d..7306b3f 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -183,7 +183,8 @@ out:
return err;
}

-/* This is not meant to be a generic repositioning function. If you do
+/*
+ * This is not meant to be a generic repositioning function. If you do
* things that aren't supported, then we return EINVAL.
*
* What is allowed:
@@ -258,7 +259,8 @@ out:
return err;
}

-/* Trimmed directory options, we shouldn't pass everything down since
+/*
+ * Trimmed directory options, we shouldn't pass everything down since
* we don't want to operate on partial directories.
*/
struct file_operations unionfs_dir_fops = {
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index cbea6c1..975d6fe 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -18,7 +18,8 @@

#include "union.h"

-/* Delete all of the whiteouts in a given directory for rmdir.
+/*
+ * Delete all of the whiteouts in a given directory for rmdir.
*
* hidden directory inode should be locked
*/
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 430cb43..47ce5ce 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -151,7 +151,7 @@ static unsigned int unionfs_poll(struct file *file, poll_table * wait)

unionfs_read_lock(file->f_dentry->d_sb);
if (unionfs_file_revalidate(file, 0)) {
- /* We should pretend an error happend. */
+ /* We should pretend an error happened. */
mask = POLLERR | POLLIN | POLLOUT;
goto out;
}
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index f0616ed..2d0822a 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -80,8 +80,9 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
}

if (wh_dentry->d_inode) {
- /* .wh.foo has been found. */
- /* First truncate it and then rename it to foo (hence having
+ /*
+ * .wh.foo has been found.
+ * First truncate it and then rename it to foo (hence having
* the same overall effect as a normal create.
*/
struct dentry *hidden_dir_dentry;
@@ -141,13 +142,15 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
/* exit if the error returned was NOT -EROFS */
if (!IS_COPYUP_ERR(err))
goto out;
- /* We were not able to create the file in this
+ /*
+ * We were not able to create the file in this
* branch, so, we try to create it in one branch to
* left
*/
bstart--;
} else {
- /* reset the unionfs dentry to point to the .wh.foo
+ /*
+ * reset the unionfs dentry to point to the .wh.foo
* entry.
*/

@@ -167,11 +170,13 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
for (bindex = bstart; bindex >= 0; bindex--) {
hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!hidden_dentry) {
- /* if hidden_dentry is NULL, create the entire
+ /*
+ * if hidden_dentry is NULL, create the entire
* dentry directory structure in branch 'bindex'.
* hidden_dentry will NOT be null when bindex == bstart
* because lookup passed as a negative unionfs dentry
- * pointing to a lone negative underlying dentry */
+ * pointing to a lone negative underlying dentry.
+ */
hidden_dentry = create_parents(parent, dentry, bindex);
if (!hidden_dentry || IS_ERR(hidden_dentry)) {
if (IS_ERR(hidden_dentry))
@@ -264,7 +269,8 @@ static int unionfs_link(struct dentry *old_dentry, struct inode *dir,

hidden_new_dentry = unionfs_lower_dentry(new_dentry);

- /* check if whiteout exists in the branch of new dentry, i.e. lookup
+ /*
+ * check if whiteout exists in the branch of new dentry, i.e. lookup
* .wh.foo first. If present, delete it
*/
name = alloc_whname(new_dentry->d_name.name, new_dentry->d_name.len);
@@ -395,7 +401,8 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,

hidden_dentry = unionfs_lower_dentry(dentry);

- /* check if whiteout exists in this branch, i.e. lookup .wh.foo
+ /*
+ * check if whiteout exists in this branch, i.e. lookup .wh.foo
* first. If present, delete it
*/
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
@@ -445,13 +452,15 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
}
}

- /* deleted whiteout if it was present, now do a normal vfs_symlink()
+ /*
+ * deleted whiteout if it was present, now do a normal vfs_symlink()
* with possible recursive directory creation
*/
for (bindex = bstart; bindex >= 0; bindex--) {
hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!hidden_dentry) {
- /* if hidden_dentry is NULL, create the entire
+ /*
+ * if hidden_dentry is NULL, create the entire
* dentry directory structure in branch 'bindex'.
* hidden_dentry will NOT be null when bindex ==
* bstart because lookup passed as a negative
@@ -604,7 +613,7 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)

unlock_dir(hidden_parent_dentry);

- /* did the mkdir suceed? */
+ /* did the mkdir succeed? */
if (err)
break;

@@ -827,7 +836,8 @@ static void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,
kfree(nd_get_link(nd));
}

-/* Basically copied from the kernel vfs permission(), but we've changed
+/*
+ * Basically copied from the kernel vfs permission(), but we've changed
* the following:
* (1) the IS_RDONLY check is skipped, and
* (2) if you set the mount option `mode=nfsro', we assume that -EACCES
@@ -912,19 +922,22 @@ static int unionfs_permission(struct inode *inode, int mask,
if (!hidden_inode)
continue;

- /* check the condition for D-F-D underlying files/directories,
- * we dont have to check for files, if we are checking for
+ /*
+ * check the condition for D-F-D underlying files/directories,
+ * we don't have to check for files, if we are checking for
* directories.
*/
if (!is_file && !S_ISDIR(hidden_inode->i_mode))
continue;

- /* We use our own special version of permission, such that
+ /*
+ * We use our own special version of permission, such that
* only the first branch returns -EROFS.
*/
err = inode_permission(hidden_inode, mask, nd, bindex);

- /* The permissions are an intersection of the overall directory
+ /*
+ * The permissions are an intersection of the overall directory
* permissions, so we fail if one fails.
*/
if (err)
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 8e5f419..6ea5aea 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -93,7 +93,8 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
const char *name;
int namelen;

- /* We should already have a lock on this dentry in the case of a
+ /*
+ * We should already have a lock on this dentry in the case of a
* partial lookup, or a revalidation. Otherwise it is returned from
* new_dentry_private_data already locked.
*/
@@ -138,7 +139,8 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
bopaque = dbopaque(parent_dentry);
BUG_ON(bstart < 0);

- /* It would be ideal if we could convert partial lookups to only have
+ /*
+ * It would be ideal if we could convert partial lookups to only have
* to do this work when they really need to. It could probably improve
* performance quite a bit, and maybe simplify the rest of the code.
*/
@@ -219,14 +221,16 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
goto out_free;
}

- /* Store the first negative dentry specially, because if they
+ /*
+ * Store the first negative dentry specially, because if they
* are all negative we need this for future creates.
*/
if (!hidden_dentry->d_inode) {
if (!first_hidden_dentry && (dbstart(dentry) == -1)) {
first_hidden_dentry = hidden_dentry;
- /* FIXME: following line needs to be changed
- * to allow mountpoint crossing
+ /*
+ * FIXME: following line needs to be changed
+ * to allow mount-point crossing
*/
first_dentry = parent_dentry;
first_hidden_mnt =
@@ -245,8 +249,9 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
if (dbstart(dentry) == -1)
set_dbstart(dentry, bindex);
unionfs_set_lower_dentry_idx(dentry, bindex, hidden_dentry);
- /* FIXME: the following line needs to get fixed to allow
- * mountpoint crossing
+ /*
+ * FIXME: the following line needs to get fixed to allow
+ * mount-point crossing
*/
unionfs_set_lower_mnt_idx(dentry, bindex,
unionfs_mntget(parent_dentry,
@@ -313,8 +318,9 @@ out_negative:
goto out;
}

- /* FIXME: the following line needs to be changed to allow
- * mountpoint crossing
+ /*
+ * FIXME: the following line needs to be changed to allow
+ * mount-point crossing
*/
first_dentry = dentry;
first_hidden_mnt = unionfs_mntget(dentry, bindex);
@@ -336,20 +342,22 @@ out_negative:
out_positive:
BUG_ON(dentry_count <= 0);

- /* If we're holding onto the first negative dentry & corresponding
+ /*
+ * If we're holding onto the first negative dentry & corresponding
* vfsmount - throw it out.
*/
dput(first_hidden_dentry);
unionfs_mntput(first_dentry, first_dentry_offset);

- /* Partial lookups need to reinterpose, or throw away older negs. */
+ /* Partial lookups need to re-interpose, or throw away older negs. */
if (lookupmode == INTERPOSE_PARTIAL) {
if (dentry->d_inode) {
unionfs_reinterpose(dentry);
goto out;
}

- /* This somehow turned positive, so it is as if we had a
+ /*
+ * This somehow turned positive, so it is as if we had a
* negative revalidation.
*/
lookupmode = INTERPOSE_REVAL_NEG;
@@ -474,7 +482,9 @@ int new_dentry_private_data(struct dentry *dentry)

new_size = sizeof(struct path) * sbmax(dentry->d_sb);

- /* Don't reallocate when we already have enough space. */
+ /*
+ * Don't reallocate when we already have enough space.
+ */
if (new_size > size) {
void *p;

@@ -502,7 +512,8 @@ out:
return -ENOMEM;
}

-/* scan through the lower dentry objects, and set bstart to reflect the
+/*
+ * scan through the lower dentry objects, and set bstart to reflect the
* starting branch
*/
void update_bstart(struct dentry *dentry)
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index cdfe96a..a72e844 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -45,12 +45,14 @@ int unionfs_interpose(struct dentry *dentry, struct super_block *sb, int flag)
}
BUG_ON(is_negative_dentry);

- /* We allocate our new inode below, by calling iget.
+ /*
+ * We allocate our new inode below, by calling iget.
* iget will call our read_inode which will initialize some
* of the new inode's fields
*/

- /* On revalidate we've already got our own inode and just need
+ /*
+ * On revalidate we've already got our own inode and just need
* to fix it up.
*/
if (flag == INTERPOSE_REVAL) {
@@ -114,7 +116,8 @@ int unionfs_interpose(struct dentry *dentry, struct super_block *sb, int flag)
S_ISFIFO(hidden_inode->i_mode) || S_ISSOCK(hidden_inode->i_mode))
init_special_inode(inode, hidden_inode->i_mode,
hidden_inode->i_rdev);
- /* Fix our inode's address operations to that of the lower inode
+ /*
+ * Fix our inode's address operations to that of the lower inode
* (Unionfs is FiST-Lite)
*/
if (inode->i_mapping->a_ops != hidden_inode->i_mapping->a_ops)
@@ -175,7 +178,8 @@ void unionfs_reinterpose(struct dentry *dentry)
ibend(inode) = dbend(dentry);
}

-/* make sure the branch we just looked up (nd) makes sense:
+/*
+ * make sure the branch we just looked up (nd) makes sense:
*
* 1) we're not trying to stack unionfs on top of unionfs
* 2) it exists
@@ -259,7 +263,8 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
goto out;
}

- /* Each colon means we have a separator, this is really just a rough
+ /*
+ * Each colon means we have a separator, this is really just a rough
* guess, since strsep will handle empty fields for us.
*/
for (i = 0; options[i]; i++)
@@ -367,7 +372,8 @@ out:
kfree(hidden_root_info->lower_paths);
kfree(UNIONFS_SB(sb)->data);

- /* MUST clear the pointers to prevent potential double free if
+ /*
+ * MUST clear the pointers to prevent potential double free if
* the caller dies later on
*/
hidden_root_info->lower_paths = NULL;
@@ -414,7 +420,8 @@ static struct unionfs_dentry_info *unionfs_parse_options(
if (optarg)
*optarg++ = '\0';

- /* All of our options take an argument now. Insert ones that
+ /*
+ * All of our options take an argument now. Insert ones that
* don't, above this check.
*/
if (!optarg) {
@@ -486,7 +493,8 @@ out:
return hidden_root_info;
}

-/* our custom d_alloc_root workalike
+/*
+ * our custom d_alloc_root work-alike
*
* we can't use d_alloc_root if we want to use our own interpose function
* unchanged, so we simply call our own "fake" d_alloc_root
diff --git a/fs/unionfs/rdstate.c b/fs/unionfs/rdstate.c
index e84161d..f0525ff 100644
--- a/fs/unionfs/rdstate.c
+++ b/fs/unionfs/rdstate.c
@@ -20,11 +20,13 @@

/* This file contains the routines for maintaining readdir state. */

-/* There are two structures here, rdstate which is a hash table
+/*
+ * There are two structures here, rdstate which is a hash table
* of the second structure which is a filldir_node.
*/

-/* This is a struct kmem_cache for filldir nodes, because we allocate a lot
+/*
+ * This is a struct kmem_cache for filldir nodes, because we allocate a lot
* of them and they shouldn't waste memory. If the node has a small name
* (as defined by the dentry structure), then we use an inline name to
* preserve kmalloc space.
@@ -47,7 +49,8 @@ void unionfs_destroy_filldir_cache(void)
kmem_cache_destroy(unionfs_filldir_cachep);
}

-/* This is a tuning parameter that tells us roughly how big to make the
+/*
+ * This is a tuning parameter that tells us roughly how big to make the
* hash table in directory entries per page. This isn't perfect, but
* at least we get a hash table size that shouldn't be too overloaded.
* The following averages are based on my home directory.
@@ -204,12 +207,14 @@ struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,

if (cursor->namelen == namelen && cursor->hash == hash &&
!strncmp(cursor->name, name, namelen)) {
- /* a duplicate exists, and hence no need to create
+ /*
+ * a duplicate exists, and hence no need to create
* entry to the list
*/
found = 1;

- /* if the duplicate is in this branch, then the file
+ /*
+ * if the duplicate is in this branch, then the file
* system is corrupted.
*/
if (cursor->bindex == rdstate->bindex) {
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 224ce5c..f71bba6 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -95,7 +95,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
if (err)
goto out_unlock;

- /* ready to whiteout for old_dentry. caller will create the actual
+ /*
+ * ready to whiteout for old_dentry. caller will create the actual
* whiteout, and must dput(*wh_old)
*/
if (wh_old) {
@@ -128,7 +129,7 @@ out_unlock:

out:
if (!err) {
- /* Fixup the newdentry. */
+ /* Fixup the new_dentry. */
if (bindex < dbstart(new_dentry))
set_dbstart(new_dentry, bindex);
else if (bindex > dbend(new_dentry))
@@ -174,7 +175,8 @@ static int do_unionfs_rename(struct inode *old_dir,
} else
revert = 1;

- /* Unlink all instances of destination that exist to the left of
+ /*
+ * Unlink all instances of destination that exist to the left of
* bstart of source. On error, revert back, goto out.
*/
for (bindex = old_bstart - 1; bindex >= new_bstart; bindex--) {
@@ -213,7 +215,8 @@ static int do_unionfs_rename(struct inode *old_dir,

if (do_copyup != -1) {
for (bindex = do_copyup; bindex >= 0; bindex--) {
- /* copyup the file into some left directory, so that
+ /*
+ * copyup the file into some left directory, so that
* you can rename it
*/
err = copyup_dentry(old_dentry->d_parent->d_inode,
@@ -236,7 +239,8 @@ static int do_unionfs_rename(struct inode *old_dir,
goto revert;
}

- /* Create whiteout for source, only if:
+ /*
+ * Create whiteout for source, only if:
* (1) There is more than one underlying instance of source.
* (2) We did a copy_up
*/
@@ -353,9 +357,10 @@ static struct dentry *lookup_whiteout(struct dentry *dentry)
return wh_dentry;
}

-/* We can't copyup a directory, because it may involve huge
+/*
+ * We can't copyup a directory, because it may involve huge
* numbers of children, etc. Doing that in the kernel would
- * be bad, so instead we let the userspace recurse and ask us
+ * be bad, so instead we let the user-space recurse and ask us
* to copy up each file separately
*/
static int may_rename_dir(struct dentry *dentry)
@@ -406,7 +411,7 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,

/*
* if new_dentry is already hidden because of whiteout,
- * simply override it even if the whiteouted dir is not empty.
+ * simply override it even if the whited-out dir is not empty.
*/
wh_dentry = lookup_whiteout(new_dentry);
if (!IS_ERR(wh_dentry))
@@ -444,8 +449,10 @@ out:
/* clear the new_dentry stuff created */
d_drop(new_dentry);
else
- /* force re-lookup since the dir on ro branch is not renamed,
- and hidden dentries still indicate the un-renamed ones. */
+ /*
+ * force re-lookup since the dir on ro branch is not renamed,
+ * and hidden dentries still indicate the un-renamed ones.
+ */
if (S_ISDIR(old_dentry->d_inode->i_mode))
atomic_dec(&UNIONFS_D(old_dentry)->generation);

diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index 34e25b0..575f08d 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -13,7 +13,8 @@

#include "union.h"

-/* Super-user IO work Queue - sometimes we need to perform actions which
+/*
+ * Super-user IO work Queue - sometimes we need to perform actions which
* would fail due to the unix permissions on the parent directory (e.g.,
* rmdir a directory which appears empty, but in reality contains
* whiteouts).
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index dd6c44b..5a96f66 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -78,7 +78,7 @@ extern int __init init_sioq(void);
extern __exit void stop_sioq(void);
extern void run_sioq(work_func_t func, struct sioq_args *args);

-/* Extern definitions for our privlege escalation helpers */
+/* Extern definitions for our privilege escalation helpers */
extern void __unionfs_create(struct work_struct *work);
extern void __unionfs_mkdir(struct work_struct *work);
extern void __unionfs_mknod(struct work_struct *work);
diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c
index f77101b..fb769ba 100644
--- a/fs/unionfs/subr.c
+++ b/fs/unionfs/subr.c
@@ -18,7 +18,8 @@

#include "union.h"

-/* Pass an unionfs dentry and an index. It will try to create a whiteout
+/*
+ * Pass an unionfs dentry and an index. It will try to create a whiteout
* for the filename in dentry, and will try in branch 'index'. On error,
* it will proceed to a branch to the left.
*/
@@ -47,7 +48,8 @@ int create_whiteout(struct dentry *dentry, int start)
hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);

if (!hidden_dentry) {
- /* if hidden dentry is not present, create the entire
+ /*
+ * if hidden dentry is not present, create the entire
* hidden dentry directory structure and go ahead.
* Since we want to just create whiteout, we only want
* the parent dentry, and hence get rid of this dentry.
@@ -67,7 +69,8 @@ int create_whiteout(struct dentry *dentry, int start)
if (IS_ERR(hidden_wh_dentry))
continue;

- /* The whiteout already exists. This used to be impossible, but
+ /*
+ * The whiteout already exists. This used to be impossible, but
* now is possible because of opaqueness.
*/
if (hidden_wh_dentry->d_inode) {
@@ -98,7 +101,8 @@ out:
return err;
}

-/* This is a helper function for rename, which ends up with hosed over dentries
+/*
+ * This is a helper function for rename, which ends up with hosed over dentries
* when it needs to revert.
*/
int unionfs_refresh_hidden_dentry(struct dentry *dentry, int bindex)
@@ -170,7 +174,8 @@ out:
return err;
}

-/* returns the sum of the n_link values of all the underlying inodes of the
+/*
+ * returns the sum of the n_link values of all the underlying inodes of the
* passed inode
*/
int unionfs_get_nlinks(struct inode *inode)
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index eab844e..7813ea8 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -18,7 +18,8 @@

#include "union.h"

-/* The inode cache is used with alloc_inode for both our inode info and the
+/*
+ * The inode cache is used with alloc_inode for both our inode info and the
* vfs inode.
*/
static struct kmem_cache *unionfs_inode_cachep;
@@ -120,7 +121,8 @@ static void unionfs_put_super(struct super_block *sb)
sb->s_fs_info = NULL;
}

-/* Since people use this to answer the "How big of a file can I write?"
+/*
+ * Since people use this to answer the "How big of a file can I write?"
* question, we report the size of the highest priority branch as the size of
* the union.
*/
@@ -627,7 +629,7 @@ out_no_change:
* WE'RE ALMOST DONE: see if we need to allocate a small-sized new
* vector, copy the vectors to their correct place, release the
* refcnt of the older ones, and return.
- * Also handle invalidating any pgaes that will have to be re-read.
+ * Also handle invalidating any pages that will have to be re-read.
*******************************************************************/

/*
@@ -690,7 +692,7 @@ out_no_change:
* super. This function calls invalidate_inode_pages(mapping),
* which calls invalidate_mapping_pages(): the latter, however, will
* not invalidate pages which are dirty, locked, under writeback, or
- * mapped into pagetables. We shouldn't have to worry about dirty
+ * mapped into page tables. We shouldn't have to worry about dirty
* or under-writeback pages, because do_remount_sb() called
* fsync_super() which would not have returned until all dirty pages
* were flushed.
@@ -780,7 +782,8 @@ static void unionfs_clear_inode(struct inode *inode)
free_rdstate(rdstate);
}

- /* Decrement a reference to a hidden_inode, which was incremented
+ /*
+ * Decrement a reference to a hidden_inode, which was incremented
* by our read_inode when it was created initially.
*/
bstart = ibstart(inode);
@@ -845,7 +848,8 @@ void unionfs_destroy_inode_cache(void)
kmem_cache_destroy(unionfs_inode_cachep);
}

-/* Called when we have a dirty inode, right here we only throw out
+/*
+ * Called when we have a dirty inode, right here we only throw out
* parts of our readdir list that are too old.
*/
static int unionfs_write_inode(struct inode *inode, int sync)
@@ -879,8 +883,9 @@ static void unionfs_umount_begin(struct vfsmount *mnt, int flags)
int bindex, bstart, bend;

if (!(flags & MNT_FORCE))
- /* we are not being MNT_FORCEd, therefore we should emulate
- * old behaviour
+ /*
+ * we are not being MNT_FORCE'd, therefore we should emulate
+ * old behavior
*/
return;

diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index 034b1b2..0ce3a27 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -109,7 +109,8 @@ struct unionfs_inode_info {

/* unionfs dentry data in memory */
struct unionfs_dentry_info {
- /* The semaphore is used to lock the dentry as soon as we get into a
+ /*
+ * The semaphore is used to lock the dentry as soon as we get into a
* unionfs function from the VFS. Our lock ordering is that children
* go before their parents.
*/
@@ -150,7 +151,8 @@ struct filldir_node {
int hash; /* name hash */
int namelen; /* name len since name is not 0 terminated */

- /* we can check for duplicate whiteouts and files in the same branch
+ /*
+ * we can check for duplicate whiteouts and files in the same branch
* in order to return -EIO.
*/
int bindex;
@@ -240,14 +242,15 @@ void update_bstart(struct dentry *dentry);
* EXTERNALS:
*/

-/* replicates the directory structure upto given dentry in given branch */
+/* replicates the directory structure up to given dentry in given branch */
extern struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
int bindex);

/* partial lookup */
extern int unionfs_partial_lookup(struct dentry *dentry);

-/* Pass an unionfs dentry and an index and it will try to create a whiteout
+/*
+ * Pass an unionfs dentry and an index and it will try to create a whiteout
* in branch 'index'.
*
* On error, it will proceed to a branch to the left
@@ -419,7 +422,8 @@ static inline int is_valid_dentry(struct dentry *dentry)
/* What do we use for whiteouts. */
#define UNIONFS_WHPFX ".wh."
#define UNIONFS_WHLEN 4
-/* If a directory contains this file, then it is opaque. We start with the
+/*
+ * If a directory contains this file, then it is opaque. We start with the
* .wh. flag so that it is blocked by lookup.
*/
#define UNIONFS_DIR_OPAQUE_NAME "__dir_opaque"
@@ -437,7 +441,8 @@ extern int check_branch(struct nameidata *nd);
extern int __parse_branch_mode(const char *name);
extern int parse_branch_mode(const char *name);

-/* These two functions are here because it is kind of daft to copy and paste
+/*
+ * These two functions are here because it is kind of daft to copy and paste
* the contents of the two functions to 32+ places in unionfs
*/
static inline struct dentry *lock_parent(struct dentry *dentry)
diff --git a/fs/unionfs/xattr.c b/fs/unionfs/xattr.c
index 9d3073b..4dc8ada 100644
--- a/fs/unionfs/xattr.c
+++ b/fs/unionfs/xattr.c
@@ -47,7 +47,8 @@ void unionfs_xattr_free(void *ptr, size_t size)
vfree(ptr);
}

-/* BKL held by caller.
+/*
+ * BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
@@ -68,7 +69,8 @@ ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
return err;
}

-/* BKL held by caller.
+/*
+ * BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
int unionfs_setxattr(struct dentry *dentry, const char *name,
@@ -89,7 +91,8 @@ int unionfs_setxattr(struct dentry *dentry, const char *name,
return err;
}

-/* BKL held by caller.
+/*
+ * BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
int unionfs_removexattr(struct dentry *dentry, const char *name)
@@ -108,7 +111,8 @@ int unionfs_removexattr(struct dentry *dentry, const char *name)
return err;
}

-/* BKL held by caller.
+/*
+ * BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
ssize_t unionfs_listxattr(struct dentry * dentry, char *list, size_t size)
diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index 9a896d6..f3cd7f4 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -12,7 +12,8 @@
#ifndef _LINUX_FS_STACK_H
#define _LINUX_FS_STACK_H

-/* This file defines generic functions used primarily by stackable
+/*
+ * This file defines generic functions used primarily by stackable
* filesystems; none of these functions require i_mutex to be held.
*/

--
1.5.2.rc1.165.gaf9b

2007-05-24 00:43:46

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 06/21] Unionfs: Added numerous comments

From: Erez Zadok <[email protected]>

Audited entire code for documentation. Added comments at top of functions
where it felt necessary (i.e., function's name and size don't make it clear
what it may be doing precisely). Reformatted some long comments. Fixed a
few comment typos and spelling errors.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/commonfops.c | 7 ++++---
fs/unionfs/copyup.c | 22 ++++++++++++----------
fs/unionfs/dentry.c | 5 ++---
fs/unionfs/file.c | 1 +
fs/unionfs/lookup.c | 3 ++-
fs/unionfs/main.c | 8 +++++++-
fs/unionfs/rename.c | 13 +++++++++----
fs/unionfs/subr.c | 19 ++++++++++---------
fs/unionfs/super.c | 15 +++++++++------
9 files changed, 56 insertions(+), 37 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 666b3c7..a57471e 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -240,6 +240,7 @@ out:
return err;
}

+/* perform a delayed copyup of a read-write file on a read-only branch */
static int do_delayed_copyup(struct file *file, struct dentry *dentry)
{
int bindex, bstart, bend, err = 0;
@@ -312,9 +313,9 @@ int unionfs_file_revalidate(struct file *file, int willwrite)

/*
* There are two cases we are interested in. The first is if the
- * generation is lower than the super-block. The second is if someone
- * has copied up this file from underneath us, we also need to refresh
- * things.
+ * generation is lower than the super-block. The second is if
+ * someone has copied up this file from underneath us, we also need
+ * to refresh things.
*/
if (!d_deleted(dentry) &&
(sbgen > fgen || dbstart(dentry) != fbstart(file))) {
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 1495778..4924685 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -18,6 +18,12 @@

#include "union.h"

+/*
+ * For detailed explanation of copyup see:
+ * Documentation/filesystems/unionfs/concepts.txt
+ */
+
+/* forward definitions */
static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
int bstart, int new_bindex, const char *name,
int namelen, struct file **copyup_file,
@@ -26,11 +32,6 @@ static struct dentry *create_parents_named(struct inode *dir,
struct dentry *dentry,
const char *name, int bindex);

-/*
- * For detailed explanation of copyup see:
- * Documentation/filesystems/unionfs/concepts.txt
- */
-
#ifdef CONFIG_UNION_FS_XATTR
/* copyup all extended attrs for a given dentry */
static int copyup_xattrs(struct dentry *old_hidden_dentry,
@@ -487,9 +488,9 @@ out:
}

/*
- * This function creates a copy of a file represented by 'file' which currently
- * resides in branch 'bstart' to branch 'new_bindex.' The copy will be named
- * "name".
+ * This function creates a copy of a file represented by 'file' which
+ * currently resides in branch 'bstart' to branch 'new_bindex.' The copy
+ * will be named "name".
*/
int copyup_named_file(struct inode *dir, struct file *file, char *name,
int bstart, int new_bindex, loff_t len)
@@ -509,8 +510,8 @@ int copyup_named_file(struct inode *dir, struct file *file, char *name,
}

/*
- * This function creates a copy of a file represented by 'file' which currently
- * resides in branch 'bstart' to branch 'new_bindex'.
+ * This function creates a copy of a file represented by 'file' which
+ * currently resides in branch 'bstart' to branch 'new_bindex'.
*/
int copyup_file(struct inode *dir, struct file *file, int bstart,
int new_bindex, loff_t len)
@@ -539,6 +540,7 @@ struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
return create_parents_named(dir, dentry, dentry->d_name.name, bindex);
}

+/* purge a dentry's lower-branch states (dput/mntput, etc.) */
static void __cleanup_dentry(struct dentry * dentry, int bindex,
int old_bstart, int old_bend)
{
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 46a52f7..95cea3b 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -18,7 +18,6 @@

#include "union.h"

-
/*
* Revalidate a single dentry.
* Assume that dentry's info node is locked.
@@ -61,8 +60,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,
sbgen = atomic_read(&UNIONFS_SB(dentry->d_sb)->generation);
/*
* If we are working on an unconnected dentry, then there is no
- * revalidation to be done, because this file does not exist within the
- * namespace, and Unionfs operates on the namespace, not data.
+ * revalidation to be done, because this file does not exist within
+ * the namespace, and Unionfs operates on the namespace, not data.
*/
if (sbgen != dgen) {
struct dentry *result;
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 47ce5ce..57f2bdd 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -77,6 +77,7 @@ out:
return err;
}

+/* helper function to unionfs_write */
static ssize_t __unionfs_write(struct file * file, const char __user * buf,
size_t count, loff_t * ppos)
{
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 6ea5aea..cf78c46 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -70,6 +70,7 @@ out:
return err;
}

+/* main (and complex) driver function for Unionfs's lookup */
struct dentry *unionfs_lookup_backend(struct dentry *dentry,
struct nameidata *nd, int lookupmode)
{
@@ -406,7 +407,7 @@ out:
return ERR_PTR(err);
}

-/* This is a utility function that fills in a unionfs dentry.*/
+/* This is a utility function that fills in a unionfs dentry */
int unionfs_partial_lookup(struct dentry *dentry)
{
struct dentry *tmp;
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index a72e844..84d3bf5 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -20,7 +20,12 @@
#include <linux/module.h>
#include <linux/moduleparam.h>

-/* sb we pass is unionfs's super_block */
+/*
+ * Connect a unionfs inode dentry/inode with several lower ones. This is
+ * the classic stackable file system "vnode interposition" action.
+ *
+ * @sb: unionfs's super_block
+ */
int unionfs_interpose(struct dentry *dentry, struct super_block *sb, int flag)
{
struct inode *hidden_inode;
@@ -149,6 +154,7 @@ out:
return err;
}

+/* like interpose above, but for an already existing dentry */
void unionfs_reinterpose(struct dentry *dentry)
{
struct dentry *hidden_dentry;
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index f71bba6..231866e 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -141,6 +141,11 @@ out:
return err;
}

+/*
+ * Main rename code. This is sufficienly complex, that it's documented in
+ * Docmentation/filesystems/unionfs/rename.txt. This routine calls
+ * do_rename() above to perform some of the work.
+ */
static int do_unionfs_rename(struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,
@@ -358,10 +363,10 @@ static struct dentry *lookup_whiteout(struct dentry *dentry)
}

/*
- * We can't copyup a directory, because it may involve huge
- * numbers of children, etc. Doing that in the kernel would
- * be bad, so instead we let the user-space recurse and ask us
- * to copy up each file separately
+ * We can't copyup a directory, because it may involve huge numbers of
+ * children, etc. Doing that in the kernel would be bad, so instead we
+ * return EXDEV to the user-space utility that caused this, and let the
+ * user-space recurse and ask us to copy up each file separately.
*/
static int may_rename_dir(struct dentry *dentry)
{
diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c
index fb769ba..d5689f5 100644
--- a/fs/unionfs/subr.c
+++ b/fs/unionfs/subr.c
@@ -49,10 +49,11 @@ int create_whiteout(struct dentry *dentry, int start)

if (!hidden_dentry) {
/*
- * if hidden dentry is not present, create the entire
- * hidden dentry directory structure and go ahead.
- * Since we want to just create whiteout, we only want
- * the parent dentry, and hence get rid of this dentry.
+ * if hidden dentry is not present, create the
+ * entire hidden dentry directory structure and go
+ * ahead. Since we want to just create whiteout, we
+ * only want the parent dentry, and hence get rid of
+ * this dentry.
*/
hidden_dentry = create_parents(dentry->d_inode,
dentry, bindex);
@@ -70,8 +71,8 @@ int create_whiteout(struct dentry *dentry, int start)
continue;

/*
- * The whiteout already exists. This used to be impossible, but
- * now is possible because of opaqueness.
+ * The whiteout already exists. This used to be impossible,
+ * but now is possible because of opaqueness.
*/
if (hidden_wh_dentry->d_inode) {
dput(hidden_wh_dentry);
@@ -92,7 +93,7 @@ int create_whiteout(struct dentry *dentry, int start)
break;
}

- /* set dbopaque so that lookup will not proceed after this branch */
+ /* set dbopaque so that lookup will not proceed after this branch */
if (!err)
set_dbopaque(dentry, bindex);

@@ -102,8 +103,8 @@ out:
}

/*
- * This is a helper function for rename, which ends up with hosed over dentries
- * when it needs to revert.
+ * This is a helper function for rename, which ends up with hosed over
+ * dentries when it needs to revert.
*/
int unionfs_refresh_hidden_dentry(struct dentry *dentry, int bindex)
{
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 7813ea8..39939ba 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -66,13 +66,15 @@ static void unionfs_put_inode(struct inode *inode)
{
/*
* This is really funky stuff:
+ *
* Basically, if i_count == 1, iput will then decrement it and this
- * inode will be destroyed. It is currently holding a reference to the
- * hidden inode. Therefore, it needs to release that reference by
- * calling iput on the hidden inode. iput() _will_ do it for us (by
- * calling our clear_inode), but _only_ if i_nlink == 0. The problem
- * is, NFS keeps i_nlink == 1 for silly_rename'd files. So we must for
- * our i_nlink to 0 here to trick iput() into calling our clear_inode.
+ * inode will be destroyed. It is currently holding a reference to
+ * the hidden inode. Therefore, it needs to release that reference
+ * by calling iput on the hidden inode. iput() _will_ do it for us
+ * (by calling our clear_inode), but _only_ if i_nlink == 0. The
+ * problem is, NFS keeps i_nlink == 1 for silly_rename'd files. So
+ * we must force our i_nlink to 0 here to trick iput() into calling
+ * our clear_inode.
*/

if (atomic_read(&inode->i_count) == 1)
@@ -842,6 +844,7 @@ int unionfs_init_inode_cache(void)
return err;
}

+/* unionfs inode cache destructor */
void unionfs_destroy_inode_cache(void)
{
if (unionfs_inode_cachep)
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:44:44

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 03/21] Unionfs: Every printk should prefix with "unionfs: " consistently

From: Erez Zadok <[email protected]>

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/commonfops.c | 7 ++++---
fs/unionfs/copyup.c | 2 +-
fs/unionfs/dentry.c | 8 +++++---
fs/unionfs/inode.c | 15 ++++++++-------
fs/unionfs/lookup.c | 5 +++--
fs/unionfs/main.c | 8 ++++----
fs/unionfs/rdstate.c | 4 ++--
fs/unionfs/rename.c | 30 +++++++++++++++---------------
fs/unionfs/sioq.c | 2 +-
fs/unionfs/subr.c | 4 ++--
fs/unionfs/super.c | 8 ++++----
11 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index 9cf6b81..778901f 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -355,8 +355,8 @@ int unionfs_file_revalidate(struct file *file, int willwrite)
if (willwrite && IS_WRITE_FLAG(file->f_flags) &&
!IS_WRITE_FLAG(unionfs_lower_file(file)->f_flags) &&
is_robranch(dentry)) {
- printk(KERN_DEBUG "Doing delayed copyup of a read-write "
- "file on a read-only branch.\n");
+ printk(KERN_DEBUG "unionfs: Doing delayed copyup of a "
+ "read-write file on a read-only branch.\n");
err = do_delayed_copyup(file, dentry);
}

@@ -576,7 +576,8 @@ int unionfs_file_release(struct inode *inode, struct file *file)

if (fileinfo->rdstate) {
fileinfo->rdstate->access = jiffies;
- printk(KERN_DEBUG "Saving rdstate with cookie %u [%d.%lld]\n",
+ printk(KERN_DEBUG "unionfs: saving rdstate with cookie "
+ "%u [%d.%lld]\n",
fileinfo->rdstate->cookie,
fileinfo->rdstate->bindex,
(long long)fileinfo->rdstate->dirpos);
diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 502a40f..8fae308 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -183,7 +183,7 @@ static int __copyup_ndentry(struct dentry *old_hidden_dentry,
run_sioq(__unionfs_create, &args);
err = args.err;
} else {
- printk(KERN_ERR "Unknown inode type %d\n",
+ printk(KERN_ERR "unionfs: unknown inode type %d\n",
old_mode);
BUG();
}
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 067732c..463cf4c 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -48,7 +48,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry,

/* if the dentry is unhashed, do NOT revalidate */
if (d_deleted(dentry)) {
- printk(KERN_DEBUG "unhashed dentry being revalidated: %*s\n",
+ printk(KERN_DEBUG "unionfs: unhashed dentry being "
+ "revalidated: %*s\n",
dentry->d_name.len, dentry->d_name.name);
goto out;
}
@@ -297,12 +298,13 @@ static void unionfs_d_release(struct dentry *dentry)

/* this could be a negative dentry, so check first */
if (!UNIONFS_D(dentry)) {
- printk(KERN_DEBUG "dentry without private data: %.*s",
+ printk(KERN_DEBUG "unionfs: dentry without private data: %.*s",
dentry->d_name.len, dentry->d_name.name);
goto out;
} else if (dbstart(dentry) < 0) {
/* this is due to a failed lookup */
- printk(KERN_DEBUG "dentry without hidden dentries : %.*s",
+ printk(KERN_DEBUG "unionfs: dentry without hidden "
+ "dentries: %.*s",
dentry->d_name.len, dentry->d_name.name);
goto out_free;
}
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 0b9cb29..f0616ed 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -463,8 +463,9 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
if (IS_ERR(hidden_dentry))
err = PTR_ERR(hidden_dentry);

- printk(KERN_DEBUG "hidden dentry NULL (or error)"
- "for bindex = %d\n", bindex);
+ printk(KERN_DEBUG "unionfs: hidden dentry "
+ "NULL (or error) for bindex = %d\n",
+ bindex);
continue;
}
}
@@ -585,8 +586,8 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
if (!hidden_dentry) {
hidden_dentry = create_parents(parent, dentry, bindex);
if (!hidden_dentry || IS_ERR(hidden_dentry)) {
- printk(KERN_DEBUG "hidden dentry NULL for "
- "bindex = %d\n", bindex);
+ printk(KERN_DEBUG "unionfs: hidden dentry "
+ " NULL for bindex = %d\n", bindex);
continue;
}
}
@@ -628,7 +629,7 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)

err = make_dir_opaque(dentry, dbstart(dentry));
if (err) {
- printk(KERN_ERR "mkdir: error creating "
+ printk(KERN_ERR "unionfs: mkdir: error creating "
".wh.__dir_opaque: %d\n", err);
goto out;
}
@@ -713,8 +714,8 @@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
if (!hidden_dentry) {
hidden_dentry = create_parents(dir, dentry, bindex);
if (IS_ERR(hidden_dentry)) {
- printk(KERN_DEBUG
- "failed to create parents on %d, err = %ld\n",
+ printk(KERN_DEBUG "unionfs: failed to create "
+ "parents on %d, err = %ld\n",
bindex, PTR_ERR(hidden_dentry));
continue;
}
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 4be590f..8e5f419 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -193,8 +193,9 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry,
break;
}
err = -EIO;
- printk(KERN_NOTICE "EIO: Invalid whiteout entry type"
- " %d.\n", wh_hidden_dentry->d_inode->i_mode);
+ printk(KERN_NOTICE "unionfs: EIO: invalid whiteout "
+ "entry type %d.\n",
+ wh_hidden_dentry->d_inode->i_mode);
dput(wh_hidden_dentry);
dput(first_hidden_dentry);
unionfs_mntput(first_dentry, first_dentry_offset);
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index ffedbcd..cdfe96a 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -138,7 +138,7 @@ skip:
/* Do nothing. */
break;
default:
- printk(KERN_ERR "Invalid interpose flag passed!");
+ printk(KERN_ERR "unionfs: invalid interpose flag passed!");
BUG();
}

@@ -518,7 +518,7 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data,

if (!raw_data) {
printk(KERN_WARNING
- "unionfs_read_super: missing data argument\n");
+ "unionfs: read_super: missing data argument\n");
err = -EINVAL;
goto out;
}
@@ -526,7 +526,7 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data,
/* Allocate superblock private data */
sb->s_fs_info = kzalloc(sizeof(struct unionfs_sb_info), GFP_KERNEL);
if (!UNIONFS_SB(sb)) {
- printk(KERN_WARNING "%s: out of memory\n", __FUNCTION__);
+ printk(KERN_WARNING "unionfs: read_super: out of memory\n");
err = -ENOMEM;
goto out;
}
@@ -539,7 +539,7 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data,
hidden_root_info = unionfs_parse_options(sb, raw_data);
if (IS_ERR(hidden_root_info)) {
printk(KERN_WARNING
- "unionfs_read_super: error while parsing options "
+ "unionfs: read_super: error while parsing options "
"(err = %ld)\n", PTR_ERR(hidden_root_info));
err = PTR_ERR(hidden_root_info);
hidden_root_info = NULL;
diff --git a/fs/unionfs/rdstate.c b/fs/unionfs/rdstate.c
index 4e875b1..e84161d 100644
--- a/fs/unionfs/rdstate.c
+++ b/fs/unionfs/rdstate.c
@@ -213,8 +213,8 @@ struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
* system is corrupted.
*/
if (cursor->bindex == rdstate->bindex) {
- printk(KERN_DEBUG "Possible I/O error "
- "unionfs_filldir: a file is duplicated "
+ printk(KERN_DEBUG "unionfs: filldir: possible "
+ "I/O error: a file is duplicated "
"in the same branch %d: %s\n",
rdstate->bindex, cursor->name);
}
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 5c6a33f..224ce5c 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -39,8 +39,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
create_parents(new_dentry->d_parent->d_inode,
new_dentry, bindex);
if (IS_ERR(hidden_new_dentry)) {
- printk(KERN_DEBUG "error creating directory tree for"
- " rename, bindex = %d, err = %ld\n",
+ printk(KERN_DEBUG "unionfs: error creating directory "
+ "tree for rename, bindex = %d, err = %ld\n",
bindex, PTR_ERR(hidden_new_dentry));
err = PTR_ERR(hidden_new_dentry);
goto out;
@@ -65,8 +65,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
if (hidden_wh_dentry->d_inode) {
/* get rid of the whiteout that is existing */
if (hidden_new_dentry->d_inode) {
- printk(KERN_WARNING "Both a whiteout and a dentry"
- " exist when doing a rename!\n");
+ printk(KERN_WARNING "unionfs: both a whiteout and a "
+ "dentry exist when doing a rename!\n");
err = -EIO;

dput(hidden_wh_dentry);
@@ -254,8 +254,8 @@ static int do_unionfs_rename(struct inode *old_dir,
* we can't fix anything now, so we cop-out and use
* -EIO.
*/
- printk(KERN_ERR "We can't create a whiteout for the "
- "source in rename!\n");
+ printk(KERN_ERR "unionfs: can't create a whiteout for "
+ "the source in rename!\n");
err = -EIO;
}
}
@@ -268,31 +268,31 @@ revert:
/* Do revert here. */
local_err = unionfs_refresh_hidden_dentry(new_dentry, old_bstart);
if (local_err) {
- printk(KERN_WARNING "Revert failed in rename: the new refresh "
- "failed.\n");
+ printk(KERN_WARNING "unionfs: revert failed in rename: "
+ "the new refresh failed.\n");
eio = -EIO;
}

local_err = unionfs_refresh_hidden_dentry(old_dentry, old_bstart);
if (local_err) {
- printk(KERN_WARNING "Revert failed in rename: the old refresh "
- "failed.\n");
+ printk(KERN_WARNING "unionfs: revert failed in rename: "
+ "the old refresh failed.\n");
eio = -EIO;
goto revert_out;
}

if (!unionfs_lower_dentry_idx(new_dentry, bindex) ||
!unionfs_lower_dentry_idx(new_dentry, bindex)->d_inode) {
- printk(KERN_WARNING "Revert failed in rename: the object "
- "disappeared from under us!\n");
+ printk(KERN_WARNING "unionfs: revert failed in rename: "
+ "the object disappeared from under us!\n");
eio = -EIO;
goto revert_out;
}

if (unionfs_lower_dentry_idx(old_dentry, bindex) &&
unionfs_lower_dentry_idx(old_dentry, bindex)->d_inode) {
- printk(KERN_WARNING "Revert failed in rename: the object was "
- "created underneath us!\n");
+ printk(KERN_WARNING "unionfs: revert failed in rename: "
+ "the object was created underneath us!\n");
eio = -EIO;
goto revert_out;
}
@@ -302,7 +302,7 @@ revert:

/* If we can't fix it, then we cop-out with -EIO. */
if (local_err) {
- printk(KERN_WARNING "Revert failed in rename!\n");
+ printk(KERN_WARNING "unionfs: revert failed in rename!\n");
eio = -EIO;
}

diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index bef970b..a1e8ffa 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -35,7 +35,7 @@ int __init init_sioq(void)
return 0;

err = PTR_ERR(superio_workqueue);
- printk(KERN_ERR "create_workqueue failed %d\n", err);
+ printk(KERN_ERR "unionfs: create_workqueue failed %d\n", err);
superio_workqueue = NULL;
return err;
}
diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c
index 0257cca..f77101b 100644
--- a/fs/unionfs/subr.c
+++ b/fs/unionfs/subr.c
@@ -55,8 +55,8 @@ int create_whiteout(struct dentry *dentry, int start)
hidden_dentry = create_parents(dentry->d_inode,
dentry, bindex);
if (!hidden_dentry || IS_ERR(hidden_dentry)) {
- printk(KERN_DEBUG "create_parents failed for "
- "bindex = %d\n", bindex);
+ printk(KERN_DEBUG "unionfs: create_parents "
+ "failed for bindex = %d\n", bindex);
continue;
}
}
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index f8116a5..eab844e 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -30,8 +30,8 @@ static void unionfs_read_inode(struct inode *inode)
struct unionfs_inode_info *info = UNIONFS_I(inode);

if (!info) {
- printk(KERN_ERR "No kernel memory when allocating inode "
- "private data!\n");
+ printk(KERN_ERR "unionfs: no kernel memory when allocating "
+ "inode private data!\n");
BUG();
}

@@ -48,8 +48,8 @@ static void unionfs_read_inode(struct inode *inode)
size = sbmax(inode->i_sb) * sizeof(struct inode *);
info->lower_inodes = kzalloc(size, GFP_KERNEL);
if (!info->lower_inodes) {
- printk(KERN_ERR "No kernel memory when allocating lower-"
- "pointer array!\n");
+ printk(KERN_ERR "unionfs: no kernel memory when allocating "
+ "lower-pointer array!\n");
BUG();
}

--
1.5.2.rc1.165.gaf9b

2007-05-24 00:45:23

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 02/21] Unionfs: Coding style fixes

From: Erez Zadok <[email protected]>

Includes:
- indentation fixes
- 80 column wrapping
- removing unnecessary braces
- removing trailing whitespace

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/stack.c | 2 +-
fs/unionfs/branchman.c | 3 +-
fs/unionfs/commonfops.c | 75 +++++++++++++---------
fs/unionfs/copyup.c | 82 +++++++++++++----------
fs/unionfs/dentry.c | 45 +++++++------
fs/unionfs/dirfops.c | 15 +++--
fs/unionfs/dirhelper.c | 26 +++++---
fs/unionfs/fanout.h | 42 ++++++++----
fs/unionfs/file.c | 6 +-
fs/unionfs/inode.c | 162 ++++++++++++++++++++++++++++------------------
fs/unionfs/lookup.c | 50 ++++++++------
fs/unionfs/main.c | 41 ++++++------
fs/unionfs/rdstate.c | 28 ++++----
fs/unionfs/rename.c | 65 ++++++++++--------
fs/unionfs/sioq.c | 5 +-
fs/unionfs/sioq.h | 1 -
fs/unionfs/subr.c | 23 +++----
fs/unionfs/super.c | 31 +++++----
fs/unionfs/union.h | 45 +++++++------
fs/unionfs/unlink.c | 3 +-
fs/unionfs/xattr.c | 12 ++--
include/linux/fs_stack.h | 5 +-
22 files changed, 439 insertions(+), 328 deletions(-)

diff --git a/fs/stack.c b/fs/stack.c
index 67716f6..9aee8fc 100644
--- a/fs/stack.c
+++ b/fs/stack.c
@@ -18,7 +18,7 @@ EXPORT_SYMBOL_GPL(fsstack_copy_inode_size);
* copying
*/
void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
- int (*get_nlinks)(struct inode *))
+ int (*get_nlinks)(struct inode *))
{
dest->i_mode = src->i_mode;
dest->i_uid = src->i_uid;
diff --git a/fs/unionfs/branchman.c b/fs/unionfs/branchman.c
index 6912be9..eba2221 100644
--- a/fs/unionfs/branchman.c
+++ b/fs/unionfs/branchman.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -57,4 +57,3 @@ out:
unionfs_unlock_dentry(dentry);
return err < 0 ? err : bend;
}
-
diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c
index c9df99d..9cf6b81 100644
--- a/fs/unionfs/commonfops.c
+++ b/fs/unionfs/commonfops.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -39,7 +39,7 @@ static int copyup_deleted_file(struct file *file, struct dentry *dentry,
hidden_dentry = unionfs_lower_dentry_idx(dentry, bstart);

sprintf(name, ".unionfs%*.*lx",
- i_inosize, i_inosize, hidden_dentry->d_inode->i_ino);
+ i_inosize, i_inosize, hidden_dentry->d_inode->i_ino);

/*
* Loop, looking for an unused temp name to copyup to.
@@ -59,7 +59,7 @@ static int copyup_deleted_file(struct file *file, struct dentry *dentry,
sprintf(suffix, "%*.*x", countersize, countersize, counter);

printk(KERN_DEBUG "unionfs: trying to rename %s to %s\n",
- dentry->d_name.name, name);
+ dentry->d_name.name, name);

tmp_dentry = lookup_one_len(name, hidden_dentry->d_parent,
UNIONFS_TMPNAM_LEN);
@@ -129,15 +129,15 @@ static void cleanup_file(struct file *file)
int i; /* holds (possibly) updated branch index */
i = find_new_branch_index(file, bindex, sb);
if (i < 0)
- printk(KERN_ERR "unionfs: no supberlock for file %p\n",
- file);
+ printk(KERN_ERR "unionfs: no supberlock for "
+ "file %p\n", file);
else {
unionfs_read_lock(sb);
branchput(sb, i);
unionfs_read_unlock(sb);
- /* XXX: is it correct to use sb->s_root here? */
+ /* XXX: is it OK to use sb->s_root here? */
unionfs_mntput(sb->s_root, i);
- /* XXX: mntget b/c fput below will call mntput */
+ /* mntget b/c fput below will call mntput */
unionfs_mntget(sb->s_root, bindex);
}
fput(unionfs_lower_file_idx(file, bindex));
@@ -174,9 +174,10 @@ static int open_all_files(struct file *file)
branchget(sb, bindex);
unionfs_read_unlock(sb);

- hidden_file = dentry_open(hidden_dentry,
- unionfs_lower_mnt_idx(dentry, bindex),
- file->f_flags);
+ hidden_file =
+ dentry_open(hidden_dentry,
+ unionfs_lower_mnt_idx(dentry, bindex),
+ file->f_flags);
if (IS_ERR(hidden_file)) {
err = PTR_ERR(hidden_file);
goto out;
@@ -211,7 +212,8 @@ static int open_highest_file(struct file *file, int willwrite)
break;
}
atomic_set(&UNIONFS_F(file)->generation,
- atomic_read(&UNIONFS_I(dentry->d_inode)->generation));
+ atomic_read(&UNIONFS_I(dentry->d_inode)->
+ generation));
goto out;
}

@@ -221,7 +223,8 @@ static int open_highest_file(struct file *file, int willwrite)
branchget(sb, bstart);
unionfs_read_unlock(sb);
hidden_file = dentry_open(hidden_dentry,
- unionfs_lower_mnt_idx(dentry, bstart), file->f_flags);
+ unionfs_lower_mnt_idx(dentry, bstart),
+ file->f_flags);
if (IS_ERR(hidden_file)) {
err = PTR_ERR(hidden_file);
goto out;
@@ -249,9 +252,10 @@ static int do_delayed_copyup(struct file *file, struct dentry *dentry)
for (bindex = bstart - 1; bindex >= 0; bindex--) {
if (!d_deleted(file->f_dentry))
err = copyup_file(parent_inode, file, bstart,
- bindex, inode_size);
+ bindex, inode_size);
else
- err = copyup_deleted_file(file, dentry, bstart, bindex);
+ err = copyup_deleted_file(file, dentry, bstart,
+ bindex);

if (!err)
break;
@@ -292,7 +296,8 @@ int unionfs_file_revalidate(struct file *file, int willwrite)
sb = dentry->d_sb;

/* first revalidate the dentry inside struct file */
- if (!__unionfs_d_revalidate_chain(dentry, NULL) && !d_deleted(dentry)) {
+ if (!__unionfs_d_revalidate_chain(dentry, NULL) &&
+ !d_deleted(dentry)) {
err = -ESTALE;
goto out_nofree;
}
@@ -351,7 +356,7 @@ int unionfs_file_revalidate(struct file *file, int willwrite)
!IS_WRITE_FLAG(unionfs_lower_file(file)->f_flags) &&
is_robranch(dentry)) {
printk(KERN_DEBUG "Doing delayed copyup of a read-write "
- "file on a read-only branch.\n");
+ "file on a read-only branch.\n");
err = do_delayed_copyup(file, dentry);
}

@@ -376,15 +381,17 @@ static int __open_dir(struct inode *inode, struct file *file)
bend = fbend(file) = dbend(file->f_dentry);

for (bindex = bstart; bindex <= bend; bindex++) {
- hidden_dentry = unionfs_lower_dentry_idx(file->f_dentry, bindex);
+ hidden_dentry =
+ unionfs_lower_dentry_idx(file->f_dentry, bindex);
if (!hidden_dentry)
continue;

dget(hidden_dentry);
unionfs_mntget(file->f_dentry, bindex);
hidden_file = dentry_open(hidden_dentry,
- unionfs_lower_mnt_idx(file->f_dentry, bindex),
- file->f_flags);
+ unionfs_lower_mnt_idx(file->f_dentry,
+ bindex),
+ file->f_flags);
if (IS_ERR(hidden_file))
return PTR_ERR(hidden_file);

@@ -415,8 +422,8 @@ static int __open_file(struct inode *inode, struct file *file)
bstart = fbstart(file) = dbstart(file->f_dentry);
bend = fbend(file) = dbend(file->f_dentry);

- /* check for the permission for hidden file. If the error is COPYUP_ERR,
- * copyup the file.
+ /* check for the permission for hidden file. If the error is
+ * COPYUP_ERR, copyup the file.
*/
if (hidden_dentry->d_inode && is_robranch(file->f_dentry)) {
/* if the open will change the file, copy it up otherwise
@@ -428,8 +435,9 @@ static int __open_file(struct inode *inode, struct file *file)

/* copyup the file */
for (bindex = bstart - 1; bindex >= 0; bindex--) {
- err = copyup_file(file->f_dentry->d_parent->d_inode,
- file, bstart, bindex, size);
+ err = copyup_file(
+ file->f_dentry->d_parent->d_inode,
+ file, bstart, bindex, size);
if (!err)
break;
}
@@ -444,9 +452,10 @@ static int __open_file(struct inode *inode, struct file *file)
* otherwise fput() will do an mntput() for us upon file close.
*/
unionfs_mntget(file->f_dentry, bstart);
- hidden_file = dentry_open(hidden_dentry,
- unionfs_lower_mnt_idx(file->f_dentry, bstart),
- hidden_flags);
+ hidden_file =
+ dentry_open(hidden_dentry,
+ unionfs_lower_mnt_idx(file->f_dentry, bstart),
+ hidden_flags);
if (IS_ERR(hidden_file))
return PTR_ERR(hidden_file);

@@ -467,7 +476,8 @@ int unionfs_open(struct inode *inode, struct file *file)
int size;

unionfs_read_lock(inode->i_sb);
- file->private_data = kzalloc(sizeof(struct unionfs_file_info), GFP_KERNEL);
+ file->private_data =
+ kzalloc(sizeof(struct unionfs_file_info), GFP_KERNEL);
if (!UNIONFS_F(file)) {
err = -ENOMEM;
goto out_nofree;
@@ -624,7 +634,8 @@ long unionfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
switch (cmd) {
case UNIONFS_IOCTL_INCGEN:
/* Increment the superblock generation count */
- printk("unionfs: incgen ioctl deprecated; use \"-o remount,incgen\"\n");
+ printk("unionfs: incgen ioctl deprecated; "
+ "use \"-o remount,incgen\"\n");
err = -ENOSYS;
break;

@@ -665,15 +676,17 @@ int unionfs_flush(struct file *file, fl_owner_t id)
for (bindex = bstart; bindex <= bend; bindex++) {
hidden_file = unionfs_lower_file_idx(file, bindex);

- if (hidden_file && hidden_file->f_op && hidden_file->f_op->flush) {
+ if (hidden_file && hidden_file->f_op &&
+ hidden_file->f_op->flush) {
err = hidden_file->f_op->flush(hidden_file, id);
if (err)
goto out_lock;

- /* if there are no more references to the dentry, dput it */
+ /* if there are no more refs to the dentry, dput it */
if (d_deleted(dentry)) {
dput(unionfs_lower_dentry_idx(dentry, bindex));
- unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
+ unionfs_set_lower_dentry_idx(dentry, bindex,
+ NULL);
}
}

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 331c6ee..502a40f 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York*
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -85,7 +85,7 @@ static int copyup_xattrs(struct dentry *old_hidden_dentry,
goto out;
name_list += strlen(name_list) + 1;
}
- out:
+out:
name_list = name_list_orig;

if (name_list)
@@ -118,8 +118,8 @@ static int copyup_permissions(struct super_block *sb,
newattrs.ia_mode = i->i_mode;

newattrs.ia_valid = ATTR_CTIME | ATTR_ATIME | ATTR_MTIME |
- ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_FORCE |
- ATTR_GID | ATTR_UID | ATTR_MODE;
+ ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_FORCE |
+ ATTR_GID | ATTR_UID | ATTR_MODE;

err = notify_change(new_hidden_dentry, &newattrs);

@@ -184,7 +184,7 @@ static int __copyup_ndentry(struct dentry *old_hidden_dentry,
err = args.err;
} else {
printk(KERN_ERR "Unknown inode type %d\n",
- old_mode);
+ old_mode);
BUG();
}

@@ -211,8 +211,8 @@ static int __copyup_reg_data(struct dentry *dentry,
branchget(sb, old_bindex);
unionfs_read_unlock(sb);
input_file = dentry_open(old_hidden_dentry,
- unionfs_lower_mnt_idx(dentry, old_bindex),
- O_RDONLY | O_LARGEFILE);
+ unionfs_lower_mnt_idx(dentry, old_bindex),
+ O_RDONLY | O_LARGEFILE);
if (IS_ERR(input_file)) {
dput(old_hidden_dentry);
err = PTR_ERR(input_file);
@@ -230,8 +230,8 @@ static int __copyup_reg_data(struct dentry *dentry,
branchget(sb, new_bindex);
unionfs_read_unlock(sb);
output_file = dentry_open(new_hidden_dentry,
- unionfs_lower_mnt_idx(dentry, new_bindex),
- O_WRONLY | O_LARGEFILE);
+ unionfs_lower_mnt_idx(dentry, new_bindex),
+ O_WRONLY | O_LARGEFILE);
if (IS_ERR(output_file)) {
err = PTR_ERR(output_file);
goto out_close_in2;
@@ -265,19 +265,19 @@ static int __copyup_reg_data(struct dentry *dentry,
len -= PAGE_SIZE;

read_bytes =
- input_file->f_op->read(input_file,
- (char __user *)buf, size,
- &input_file->f_pos);
+ input_file->f_op->read(input_file,
+ (char __user *)buf, size,
+ &input_file->f_pos);
if (read_bytes <= 0) {
err = read_bytes;
break;
}

write_bytes =
- output_file->f_op->write(output_file,
- (char __user *)buf,
- read_bytes,
- &output_file->f_pos);
+ output_file->f_op->write(output_file,
+ (char __user *)buf,
+ read_bytes,
+ &output_file->f_pos);
if ((write_bytes < 0) || (write_bytes < read_bytes)) {
err = write_bytes;
break;
@@ -362,7 +362,8 @@ static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
goto out;

/* Create the directory structure above this dentry. */
- new_hidden_dentry = create_parents_named(dir, dentry, name, new_bindex);
+ new_hidden_dentry =
+ create_parents_named(dir, dentry, name, new_bindex);
if (IS_ERR(new_hidden_dentry)) {
err = PTR_ERR(new_hidden_dentry);
goto out;
@@ -387,9 +388,9 @@ static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
oldfs = get_fs();
set_fs(KERNEL_DS);
err = old_hidden_dentry->d_inode->i_op->readlink(
- old_hidden_dentry,
- (char __user *)symbuf,
- PATH_MAX);
+ old_hidden_dentry,
+ (char __user *)symbuf,
+ PATH_MAX);
set_fs(oldfs);
if (err) {
__clear(dentry, old_hidden_dentry,
@@ -417,12 +418,14 @@ static int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
/* We actually copyup the file here. */
if (S_ISREG(old_hidden_dentry->d_inode->i_mode))
err = __copyup_reg_data(dentry, new_hidden_dentry, new_bindex,
- old_hidden_dentry, old_bindex, copyup_file, len);
+ old_hidden_dentry, old_bindex,
+ copyup_file, len);
if (err)
goto out_unlink;

/* Set permissions. */
- if ((err = copyup_permissions(sb, old_hidden_dentry, new_hidden_dentry)))
+ if ((err = copyup_permissions(sb, old_hidden_dentry,
+ new_hidden_dentry)))
goto out_unlink;

#ifdef CONFIG_UNION_FS_XATTR
@@ -520,8 +523,8 @@ int copyup_file(struct inode *dir, struct file *file, int bstart,
return err;
}

-/* This function replicates the directory structure upto given dentry
- * in the bindex branch. Can create directory structure recursively to the right
+/* This function replicates the directory structure upto given dentry in the
+ * bindex branch. Can create directory structure recursively to the right
* also.
*/
struct dentry *create_parents(struct inode *dir, struct dentry *dentry,
@@ -584,7 +587,7 @@ static void __set_inode(struct dentry * upper, struct dentry * lower,
int bindex)
{
unionfs_set_lower_inode_idx(upper->d_inode, bindex,
- igrab(lower->d_inode));
+ igrab(lower->d_inode));
if (likely(ibstart(upper->d_inode) > bindex))
ibstart(upper->d_inode) = bindex;
if (likely(ibend(upper->d_inode) < bindex))
@@ -664,7 +667,8 @@ static struct dentry *create_parents_named(struct inode *dir,
unionfs_lock_dentry(parent_dentry);

/* find out the hidden_parent_dentry in the given branch */
- hidden_parent_dentry = unionfs_lower_dentry_idx(parent_dentry, bindex);
+ hidden_parent_dentry =
+ unionfs_lower_dentry_idx(parent_dentry, bindex);

/* grow path table */
if (count == nr_dentry) {
@@ -691,7 +695,8 @@ static struct dentry *create_parents_named(struct inode *dir,
*/
while (1) {
/* get hidden parent dir in the current branch */
- hidden_parent_dentry = unionfs_lower_dentry_idx(parent_dentry, bindex);
+ hidden_parent_dentry =
+ unionfs_lower_dentry_idx(parent_dentry, bindex);
unionfs_unlock_dentry(parent_dentry);

/* init the values to lookup */
@@ -701,24 +706,29 @@ static struct dentry *create_parents_named(struct inode *dir,
if (child_dentry != dentry) {
/* lookup child in the underlying file system */
hidden_dentry =
- lookup_one_len(childname, hidden_parent_dentry,
- childnamelen);
+ lookup_one_len(childname, hidden_parent_dentry,
+ childnamelen);
if (IS_ERR(hidden_dentry))
goto out;
} else {

/* is the name a whiteout of the childname ?
- * lookup the whiteout child in the underlying file system
+ * lookup the whiteout child in the underlying file
+ * system
*/
hidden_dentry =
- lookup_one_len(name, hidden_parent_dentry,
- strlen(name));
+ lookup_one_len(name, hidden_parent_dentry,
+ strlen(name));
if (IS_ERR(hidden_dentry))
goto out;

- /* Replace the current dentry (if any) with the new one. */
+ /*
+ * Replace the current dentry (if any) with the new
+ * one.
+ */
dput(unionfs_lower_dentry_idx(dentry, bindex));
- unionfs_set_lower_dentry_idx(dentry, bindex, hidden_dentry);
+ unionfs_set_lower_dentry_idx(dentry, bindex,
+ hidden_dentry);

__cleanup_dentry(dentry, bindex, old_bstart, old_bend);
break;
@@ -744,7 +754,8 @@ static struct dentry *create_parents_named(struct inode *dir,

if (!err)
err = copyup_permissions(dir->i_sb,
- child_dentry, hidden_dentry);
+ child_dentry,
+ hidden_dentry);
unlock_dir(hidden_parent_dentry);
if (err) {
dput(hidden_dentry);
@@ -764,4 +775,3 @@ out:
kfree(path);
return hidden_dentry;
}
-
diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c
index 9eb143d..067732c 100644
--- a/fs/unionfs/dentry.c
+++ b/fs/unionfs/dentry.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -26,7 +26,8 @@
* the child may not yet be valid.
* Returns 1 if valid, 0 otherwise.
*/
-static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *nd)
+static int __unionfs_d_revalidate_one(struct dentry *dentry,
+ struct nameidata *nd)
{
int valid = 1; /* default is valid (1); invalid is 0. */
struct dentry *hidden_dentry;
@@ -79,7 +80,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *n
struct dentry *hidden_dentry;
for (bindex = bstart; bindex <= bend; bindex++) {
hidden_dentry =
- unionfs_lower_dentry_idx(dentry, bindex);
+ unionfs_lower_dentry_idx(dentry,
+ bindex);
dput(hidden_dentry);
}
}
@@ -104,9 +106,11 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *n
bend = ibend(dentry->d_inode);
if (bstart >= 0) {
struct inode *hidden_inode;
- for (bindex = bstart; bindex <= bend; bindex++) {
+ for (bindex = bstart; bindex <= bend;
+ bindex++) {
hidden_inode =
- unionfs_lower_inode_idx(dentry->d_inode,
+ unionfs_lower_inode_idx(
+ dentry->d_inode,
bindex);
iput(hidden_inode);
}
@@ -119,7 +123,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *n
mutex_unlock(&dentry->d_inode->i_mutex);
}

- result = unionfs_lookup_backend(dentry, &lowernd, interpose_flag);
+ result = unionfs_lookup_backend(dentry, &lowernd,
+ interpose_flag);
if (result) {
if (IS_ERR(result)) {
valid = 0;
@@ -150,7 +155,8 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *n
if (!hidden_dentry || !hidden_dentry->d_op
|| !hidden_dentry->d_op->d_revalidate)
continue;
- if (!hidden_dentry->d_op->d_revalidate(hidden_dentry, &lowernd))
+ if (!hidden_dentry->d_op->d_revalidate(hidden_dentry,
+ &lowernd))
valid = 0;
}

@@ -159,10 +165,10 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *n

if (valid) {
fsstack_copy_attr_all(dentry->d_inode,
- unionfs_lower_inode(dentry->d_inode),
- unionfs_get_nlinks);
+ unionfs_lower_inode(dentry->d_inode),
+ unionfs_get_nlinks);
fsstack_copy_inode_size(dentry->d_inode,
- unionfs_lower_inode(dentry->d_inode));
+ unionfs_lower_inode(dentry->d_inode));
}

out:
@@ -195,9 +201,8 @@ int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd)
dtmp = dtmp->d_parent;
dgen = atomic_read(&UNIONFS_D(dtmp)->generation);
}
- if (chain_len == 0) {
+ if (chain_len == 0)
goto out_this; /* shortcut if parents are OK */
- }

/*
* Allocate array of dentries to reval. We could use linked lists,
@@ -236,18 +241,18 @@ int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd)
if (valid && chain_len > 0 &&
sbgen != dgen && chain[i]->d_inode &&
S_ISDIR(chain[i]->d_inode->i_mode)) {
- for (bindex = saved_bstart; bindex <= saved_bend; bindex++)
+ for (bindex = saved_bstart; bindex <= saved_bend;
+ bindex++)
unionfs_mntput(chain[i], bindex);
}
unionfs_unlock_dentry(chain[i]);

- if (!valid) {
+ if (!valid)
goto out_free;
- }
}


- out_this:
+out_this:
/* finally, lock this dentry and revalidate it */
verify_locked(dentry);
dgen = atomic_read(&UNIONFS_D(dentry)->generation);
@@ -260,15 +265,14 @@ int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd)
unionfs_mntput(dentry, bindex);
}

- out_free:
+out_free:
/* unlock/dput all dentries in chain and return status */
if (chain_len > 0) {
- for (i=0; i<chain_len; i++) {
+ for (i=0; i<chain_len; i++)
dput(chain[i]);
- }
kfree(chain);
}
- out:
+out:
return valid;
}

@@ -330,4 +334,3 @@ struct dentry_operations unionfs_dops = {
.d_revalidate = unionfs_d_revalidate,
.d_release = unionfs_d_release,
};
-
diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c
index 6ff32a0..cab7b6d 100644
--- a/fs/unionfs/dirfops.c
+++ b/fs/unionfs/dirfops.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -70,7 +70,10 @@ static int unionfs_filldir(void *dirent, const char *name, int namelen,
verify_rdstate_offset(buf->rdstate);
}
}
- /* If we did fill it, stuff it in our hash, otherwise return an error */
+ /*
+ * If we did fill it, stuff it in our hash, otherwise return an
+ * error.
+ */
if (err) {
buf->filldir_error = err;
goto out;
@@ -200,7 +203,10 @@ static loff_t unionfs_dir_llseek(struct file *file, loff_t offset, int origin)

rdstate = UNIONFS_F(file)->rdstate;

- /* We let users seek to their current position, but not anywhere else. */
+ /*
+ * we let users seek to their current position, but not anywhere
+ * else.
+ */
if (!offset) {
switch (origin) {
case SEEK_SET:
@@ -231,7 +237,7 @@ static loff_t unionfs_dir_llseek(struct file *file, loff_t offset, int origin)
err = -EINVAL;
} else {
rdstate = find_rdstate(file->f_dentry->d_inode,
- offset);
+ offset);
if (rdstate) {
UNIONFS_F(file)->rdstate = rdstate;
err = rdstate->offset;
@@ -264,4 +270,3 @@ struct file_operations unionfs_dir_fops = {
.release = unionfs_file_release,
.flush = unionfs_flush,
};
-
diff --git a/fs/unionfs/dirhelper.c b/fs/unionfs/dirhelper.c
index bd15eb4..cbea6c1 100644
--- a/fs/unionfs/dirhelper.c
+++ b/fs/unionfs/dirhelper.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -23,7 +23,7 @@
* hidden directory inode should be locked
*/
int do_delete_whiteouts(struct dentry *dentry, int bindex,
- struct unionfs_dir_state *namelist)
+ struct unionfs_dir_state *namelist)
{
int err = 0;
struct dentry *hidden_dir_dentry = NULL;
@@ -52,7 +52,8 @@ int do_delete_whiteouts(struct dentry *dentry, int bindex,
for (i = 0; !err && i < namelist->size; i++) {
list_for_each(pos, &namelist->list[i]) {
cursor =
- list_entry(pos, struct filldir_node, file_list);
+ list_entry(pos, struct filldir_node,
+ file_list);
/* Only operate on whiteouts in this branch. */
if (cursor->bindex != bindex)
continue;
@@ -61,8 +62,9 @@ int do_delete_whiteouts(struct dentry *dentry, int bindex,

strcpy(p, cursor->name);
hidden_dentry =
- lookup_one_len(name, hidden_dir_dentry,
- cursor->namelen + UNIONFS_WHLEN);
+ lookup_one_len(name, hidden_dir_dentry,
+ cursor->namelen +
+ UNIONFS_WHLEN);
if (IS_ERR(hidden_dentry)) {
err = PTR_ERR(hidden_dentry);
break;
@@ -148,7 +150,8 @@ static int readdir_util_callback(void *dirent, const char *name, int namelen,

buf->filldir_called = 1;

- if (name[0] == '.' && (namelen == 1 || (name[1] == '.' && namelen == 2)))
+ if (name[0] == '.' && (namelen == 1 ||
+ (name[1] == '.' && namelen == 2)))
goto out;

if (namelen > UNIONFS_WHLEN &&
@@ -163,7 +166,10 @@ static int readdir_util_callback(void *dirent, const char *name, int namelen,
if (found)
goto out;

- /* If it wasn't found and isn't a whiteout, the directory isn't empty. */
+ /*
+ * if it wasn't found and isn't a whiteout, the directory isn't
+ * empty.
+ */
err = -ENOTEMPTY;
if ((buf->mode == RD_CHECK_EMPTY) && !whiteout)
goto out;
@@ -230,8 +236,9 @@ int check_empty(struct dentry *dentry, struct unionfs_dir_state **namelist)
branchget(sb, bindex);
unionfs_read_unlock(sb);
hidden_file =
- dentry_open(hidden_dentry, unionfs_lower_mnt_idx(dentry, bindex),
- O_RDONLY);
+ dentry_open(hidden_dentry,
+ unionfs_lower_mnt_idx(dentry, bindex),
+ O_RDONLY);
if (IS_ERR(hidden_file)) {
err = PTR_ERR(hidden_file);
dput(hidden_dentry);
@@ -273,4 +280,3 @@ out:

return err;
}
-
diff --git a/fs/unionfs/fanout.h b/fs/unionfs/fanout.h
index 9e4a35f..71052a3 100644
--- a/fs/unionfs/fanout.h
+++ b/fs/unionfs/fanout.h
@@ -8,7 +8,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -61,12 +61,14 @@ static inline struct file *unionfs_lower_file(const struct file *f)
return UNIONFS_F(f)->lower_files[fbstart(f)];
}

-static inline struct file *unionfs_lower_file_idx(const struct file *f, int index)
+static inline struct file *unionfs_lower_file_idx(const struct file *f,
+ int index)
{
return UNIONFS_F(f)->lower_files[index];
}

-static inline void unionfs_set_lower_file_idx(struct file *f, int index, struct file *val)
+static inline void unionfs_set_lower_file_idx(struct file *f, int index,
+ struct file *val)
{
UNIONFS_F(f)->lower_files[index] = val;
/* save branch ID (may be redundant?) */
@@ -85,13 +87,14 @@ static inline struct inode *unionfs_lower_inode(const struct inode *i)
return UNIONFS_I(i)->lower_inodes[ibstart(i)];
}

-static inline struct inode *unionfs_lower_inode_idx(const struct inode *i, int index)
+static inline struct inode *unionfs_lower_inode_idx(const struct inode *i,
+ int index)
{
return UNIONFS_I(i)->lower_inodes[index];
}

static inline void unionfs_set_lower_inode_idx(struct inode *i, int index,
- struct inode *val)
+ struct inode *val)
{
UNIONFS_I(i)->lower_inodes[index] = val;
}
@@ -102,23 +105,28 @@ static inline void unionfs_set_lower_inode(struct inode *i, struct inode *val)
}

/* Superblock to lower superblock. */
-static inline struct super_block *unionfs_lower_super(const struct super_block *sb)
+static inline struct super_block *unionfs_lower_super(
+ const struct super_block *sb)
{
return UNIONFS_SB(sb)->data[sbstart(sb)].sb;
}

-static inline struct super_block *unionfs_lower_super_idx(const struct super_block *sb, int index)
+static inline struct super_block *unionfs_lower_super_idx(
+ const struct super_block *sb,
+ int index)
{
return UNIONFS_SB(sb)->data[index].sb;
}

-static inline void unionfs_set_lower_super_idx(struct super_block *sb, int index,
- struct super_block *val)
+static inline void unionfs_set_lower_super_idx(struct super_block *sb,
+ int index,
+ struct super_block *val)
{
UNIONFS_SB(sb)->data[index].sb = val;
}

-static inline void unionfs_set_lower_super(struct super_block *sb, struct super_block *val)
+static inline void unionfs_set_lower_super(struct super_block *sb,
+ struct super_block *val)
{
UNIONFS_SB(sb)->data[sbstart(sb)].sb = val;
}
@@ -181,12 +189,14 @@ static inline void set_dbopaque(struct dentry *dent, int val)
}

static inline void unionfs_set_lower_dentry_idx(struct dentry *dent, int index,
- struct dentry *val)
+ struct dentry *val)
{
UNIONFS_D(dent)->lower_paths[index].dentry = val;
}

-static inline struct dentry *unionfs_lower_dentry_idx(const struct dentry *dent, int index)
+static inline struct dentry *unionfs_lower_dentry_idx(
+ const struct dentry *dent,
+ int index)
{
return UNIONFS_D(dent)->lower_paths[index].dentry;
}
@@ -197,19 +207,21 @@ static inline struct dentry *unionfs_lower_dentry(const struct dentry *dent)
}

static inline void unionfs_set_lower_mnt_idx(struct dentry *dent, int index,
- struct vfsmount *mnt)
+ struct vfsmount *mnt)
{
UNIONFS_D(dent)->lower_paths[index].mnt = mnt;
}

-static inline struct vfsmount *unionfs_lower_mnt_idx(const struct dentry *dent, int index)
+static inline struct vfsmount *unionfs_lower_mnt_idx(
+ const struct dentry *dent,
+ int index)
{
return UNIONFS_D(dent)->lower_paths[index].mnt;
}

static inline struct vfsmount *unionfs_lower_mnt(const struct dentry *dent)
{
- return unionfs_lower_mnt_idx(dent,dbstart(dent));
+ return unionfs_lower_mnt_idx(dent, dbstart(dent));
}

/* Macros for locking a dentry. */
diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index 84d6bab..430cb43 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -205,7 +205,8 @@ out:
return err;
}

-static int unionfs_fsync(struct file *file, struct dentry *dentry, int datasync)
+static int unionfs_fsync(struct file *file, struct dentry *dentry,
+ int datasync)
{
int err;
struct file *hidden_file = NULL;
@@ -263,4 +264,3 @@ struct file_operations unionfs_main_fops = {
.fsync = unionfs_fsync,
.fasync = unionfs_fasync,
};
-
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 97dad8c..0b9cb29 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -61,7 +61,10 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
bstart = dbstart(dentry);
hidden_dentry = unionfs_lower_dentry(dentry);

- /* check if whiteout exists in this branch, i.e. lookup .wh.foo first */
+ /*
+ * check if whiteout exists in this branch, i.e. lookup .wh.foo
+ * first.
+ */
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
if (IS_ERR(name)) {
err = PTR_ERR(name);
@@ -69,7 +72,7 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
}

wh_dentry = lookup_one_len(name, hidden_dentry->d_parent,
- dentry->d_name.len + UNIONFS_WHLEN);
+ dentry->d_name.len + UNIONFS_WHLEN);
if (IS_ERR(wh_dentry)) {
err = PTR_ERR(wh_dentry);
wh_dentry = NULL;
@@ -86,8 +89,8 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,

mutex_lock(&wh_dentry->d_inode->i_mutex);
newattrs.ia_valid = ATTR_CTIME | ATTR_MODE | ATTR_ATIME
- | ATTR_MTIME | ATTR_UID | ATTR_GID | ATTR_FORCE
- | ATTR_KILL_SUID | ATTR_KILL_SGID;
+ | ATTR_MTIME | ATTR_UID | ATTR_GID | ATTR_FORCE
+ | ATTR_KILL_SUID | ATTR_KILL_SGID;

newattrs.ia_mode = mode & ~current->fs->umask;
newattrs.ia_uid = current->fsuid;
@@ -104,8 +107,8 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,

if (err)
printk(KERN_WARNING "unionfs: %s:%d: notify_change "
- "failed: %d, ignoring..\n",
- __FILE__, __LINE__, err);
+ "failed: %d, ignoring..\n",
+ __FILE__, __LINE__, err);

new_hidden_dentry = unionfs_lower_dentry(dentry);
dget(new_hidden_dentry);
@@ -121,9 +124,11 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
}
if (!err) {
fsstack_copy_attr_times(parent,
- new_hidden_dentry->d_parent->d_inode);
+ new_hidden_dentry->d_parent->
+ d_inode);
fsstack_copy_inode_size(parent,
- new_hidden_dentry->d_parent->d_inode);
+ new_hidden_dentry->d_parent->
+ d_inode);
parent->i_nlink = unionfs_get_nlinks(parent);
}

@@ -150,7 +155,8 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
dput(unionfs_lower_dentry(dentry));

/* Trade one reference to another. */
- unionfs_set_lower_dentry_idx(dentry, bstart, wh_dentry);
+ unionfs_set_lower_dentry_idx(dentry, bstart,
+ wh_dentry);
wh_dentry = NULL;

err = unionfs_interpose(dentry, parent->i_sb, 0);
@@ -194,10 +200,12 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry,
err = unionfs_interpose(dentry, parent->i_sb, 0);
if (!err) {
fsstack_copy_attr_times(parent,
- hidden_parent_dentry->d_inode);
+ hidden_parent_dentry->
+ d_inode);
fsstack_copy_inode_size(parent,
- hidden_parent_dentry->d_inode);
- /* update number of links on parent directory */
+ hidden_parent_dentry->
+ d_inode);
+ /* update no. of links on parent directory */
parent->i_nlink = unionfs_get_nlinks(parent);
}
unlock_dir(hidden_parent_dentry);
@@ -266,7 +274,8 @@ static int unionfs_link(struct dentry *old_dentry, struct inode *dir,
}

whiteout_dentry = lookup_one_len(name, hidden_new_dentry->d_parent,
- new_dentry->d_name.len + UNIONFS_WHLEN);
+ new_dentry->d_name.len +
+ UNIONFS_WHLEN);
if (IS_ERR(whiteout_dentry)) {
err = PTR_ERR(whiteout_dentry);
goto out;
@@ -281,7 +290,7 @@ static int unionfs_link(struct dentry *old_dentry, struct inode *dir,
err = is_robranch_super(new_dentry->d_sb, dbstart(new_dentry));
if (!err)
err = vfs_unlink(hidden_dir_dentry->d_inode,
- whiteout_dentry);
+ whiteout_dentry);

fsstack_copy_attr_times(dir, hidden_dir_dentry->d_inode);
dir->i_nlink = unionfs_get_nlinks(dir);
@@ -294,7 +303,7 @@ static int unionfs_link(struct dentry *old_dentry, struct inode *dir,

if (dbstart(old_dentry) != dbstart(new_dentry)) {
hidden_new_dentry =
- create_parents(dir, new_dentry, dbstart(old_dentry));
+ create_parents(dir, new_dentry, dbstart(old_dentry));
err = PTR_ERR(hidden_new_dentry);
if (IS_COPYUP_ERR(err))
goto docopyup;
@@ -308,7 +317,7 @@ static int unionfs_link(struct dentry *old_dentry, struct inode *dir,
hidden_dir_dentry = lock_parent(hidden_new_dentry);
if (!(err = is_robranch(old_dentry)))
err = vfs_link(hidden_old_dentry, hidden_dir_dentry->d_inode,
- hidden_new_dentry);
+ hidden_new_dentry);
unlock_dir(hidden_dir_dentry);

docopyup:
@@ -317,21 +326,22 @@ docopyup:
int bindex;

for (bindex = old_bstart - 1; bindex >= 0; bindex--) {
- err =
- copyup_dentry(old_dentry->d_parent->
- d_inode, old_dentry,
- old_bstart, bindex, NULL,
- old_dentry->d_inode->i_size);
+ err = copyup_dentry(old_dentry->d_parent->d_inode,
+ old_dentry, old_bstart,
+ bindex, NULL,
+ old_dentry->d_inode->i_size);
if (!err) {
hidden_new_dentry =
- create_parents(dir, new_dentry, bindex);
- hidden_old_dentry = unionfs_lower_dentry(old_dentry);
+ create_parents(dir, new_dentry,
+ bindex);
+ hidden_old_dentry =
+ unionfs_lower_dentry(old_dentry);
hidden_dir_dentry =
- lock_parent(hidden_new_dentry);
+ lock_parent(hidden_new_dentry);
/* do vfs_link */
err = vfs_link(hidden_old_dentry,
- hidden_dir_dentry->d_inode,
- hidden_new_dentry);
+ hidden_dir_dentry->d_inode,
+ hidden_new_dentry);
unlock_dir(hidden_dir_dentry);
goto check_link;
}
@@ -347,7 +357,7 @@ check_link:
new_dentry->d_inode = igrab(old_dentry->d_inode);
d_instantiate(new_dentry, new_dentry->d_inode);
fsstack_copy_attr_all(dir, hidden_new_dentry->d_parent->d_inode,
- unionfs_get_nlinks);
+ unionfs_get_nlinks);
fsstack_copy_inode_size(dir, hidden_new_dentry->d_parent->d_inode);

/* propagate number of hard-links */
@@ -395,8 +405,8 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
}

whiteout_dentry =
- lookup_one_len(name, hidden_dentry->d_parent,
- dentry->d_name.len + UNIONFS_WHLEN);
+ lookup_one_len(name, hidden_dentry->d_parent,
+ dentry->d_name.len + UNIONFS_WHLEN);
if (IS_ERR(whiteout_dentry)) {
err = PTR_ERR(whiteout_dentry);
goto out;
@@ -406,12 +416,15 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
dput(whiteout_dentry);
whiteout_dentry = NULL;
} else {
- /* found a .wh.foo entry, unlink it and then call vfs_symlink() */
+ /*
+ * found a .wh.foo entry, unlink it and then call
+ * vfs_symlink().
+ */
hidden_dir_dentry = lock_parent(whiteout_dentry);

if (!(err = is_robranch_super(dentry->d_sb, bstart)))
err = vfs_unlink(hidden_dir_dentry->d_inode,
- whiteout_dentry);
+ whiteout_dentry);
dput(whiteout_dentry);

fsstack_copy_attr_times(dir, hidden_dir_dentry->d_inode);
@@ -424,7 +437,10 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
/* exit if the error returned was NOT -EROFS */
if (!IS_COPYUP_ERR(err))
goto out;
- /* should now try to create symlink in the another branch */
+ /*
+ * should now try to create symlink in the another
+ * branch.
+ */
bstart--;
}
}
@@ -448,7 +464,7 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
err = PTR_ERR(hidden_dentry);

printk(KERN_DEBUG "hidden dentry NULL (or error)"
- "for bindex = %d\n", bindex);
+ "for bindex = %d\n", bindex);
continue;
}
}
@@ -458,23 +474,31 @@ static int unionfs_symlink(struct inode *dir, struct dentry *dentry,
if (!(err = is_robranch_super(dentry->d_sb, bindex))) {
mode = S_IALLUGO;
err =
- vfs_symlink(hidden_dir_dentry->d_inode,
- hidden_dentry, symname, mode);
+ vfs_symlink(hidden_dir_dentry->d_inode,
+ hidden_dentry, symname, mode);
}
unlock_dir(hidden_dir_dentry);

if (err || !hidden_dentry->d_inode) {
- /* break out of for loop if error returned was NOT -EROFS */
+ /*
+ * break out of for loop if error returned was NOT
+ * -EROFS.
+ */
if (!IS_COPYUP_ERR(err))
break;
} else {
err = unionfs_interpose(dentry, dir->i_sb, 0);
if (!err) {
fsstack_copy_attr_times(dir,
- hidden_dir_dentry->d_inode);
+ hidden_dir_dentry->
+ d_inode);
fsstack_copy_inode_size(dir,
- hidden_dir_dentry->d_inode);
- /* update number of links on parent directory */
+ hidden_dir_dentry->
+ d_inode);
+ /*
+ * update number of links on parent
+ * directory.
+ */
dir->i_nlink = unionfs_get_nlinks(dir);
}
break;
@@ -507,7 +531,10 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)

hidden_dentry = unionfs_lower_dentry(dentry);

- /* check if whiteout exists in this branch, i.e. lookup .wh.foo first */
+ /*
+ * check if whiteout exists in this branch, i.e. lookup .wh.foo
+ * first.
+ */
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
if (IS_ERR(name)) {
err = PTR_ERR(name);
@@ -515,7 +542,7 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
}

whiteout_dentry = lookup_one_len(name, hidden_dentry->d_parent,
- dentry->d_name.len + UNIONFS_WHLEN);
+ dentry->d_name.len + UNIONFS_WHLEN);
if (IS_ERR(whiteout_dentry)) {
err = PTR_ERR(whiteout_dentry);
goto out;
@@ -559,7 +586,7 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
hidden_dentry = create_parents(parent, dentry, bindex);
if (!hidden_dentry || IS_ERR(hidden_dentry)) {
printk(KERN_DEBUG "hidden dentry NULL for "
- "bindex = %d\n", bindex);
+ "bindex = %d\n", bindex);
continue;
}
}
@@ -571,7 +598,8 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
goto out;
}

- err = vfs_mkdir(hidden_parent_dentry->d_inode, hidden_dentry, mode);
+ err = vfs_mkdir(hidden_parent_dentry->d_inode, hidden_dentry,
+ mode);

unlock_dir(hidden_parent_dentry);

@@ -590,9 +618,9 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
err = unionfs_interpose(dentry, parent->i_sb, 0);
if (!err) {
fsstack_copy_attr_times(parent,
- hidden_parent_dentry->d_inode);
+ hidden_parent_dentry->d_inode);
fsstack_copy_inode_size(parent,
- hidden_parent_dentry->d_inode);
+ hidden_parent_dentry->d_inode);

/* update number of links on parent directory */
parent->i_nlink = unionfs_get_nlinks(parent);
@@ -601,7 +629,7 @@ static int unionfs_mkdir(struct inode *parent, struct dentry *dentry, int mode)
err = make_dir_opaque(dentry, dbstart(dentry));
if (err) {
printk(KERN_ERR "mkdir: error creating "
- ".wh.__dir_opaque: %d\n", err);
+ ".wh.__dir_opaque: %d\n", err);
goto out;
}

@@ -636,7 +664,10 @@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,

hidden_dentry = unionfs_lower_dentry(dentry);

- /* check if whiteout exists in this branch, i.e. lookup .wh.foo first */
+ /*
+ * check if whiteout exists in this branch, i.e. lookup .wh.foo
+ * first.
+ */
name = alloc_whname(dentry->d_name.name, dentry->d_name.len);
if (IS_ERR(name)) {
err = PTR_ERR(name);
@@ -644,7 +675,7 @@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
}

whiteout_dentry = lookup_one_len(name, hidden_dentry->d_parent,
- dentry->d_name.len + UNIONFS_WHLEN);
+ dentry->d_name.len + UNIONFS_WHLEN);
if (IS_ERR(whiteout_dentry)) {
err = PTR_ERR(whiteout_dentry);
goto out;
@@ -706,9 +737,9 @@ static int unionfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
err = unionfs_interpose(dentry, dir->i_sb, 0);
if (!err) {
fsstack_copy_attr_times(dir,
- hidden_parent_dentry->d_inode);
+ hidden_parent_dentry->d_inode);
fsstack_copy_inode_size(dir,
- hidden_parent_dentry->d_inode);
+ hidden_parent_dentry->d_inode);
/* update number of links on parent directory */
dir->i_nlink = unionfs_get_nlinks(dir);
}
@@ -744,9 +775,11 @@ static int unionfs_readlink(struct dentry *dentry, char __user * buf,
goto out;
}

- err = hidden_dentry->d_inode->i_op->readlink(hidden_dentry, buf, bufsiz);
+ err = hidden_dentry->d_inode->i_op->readlink(hidden_dentry,
+ buf, bufsiz);
if (err > 0)
- fsstack_copy_attr_atime(dentry->d_inode, hidden_dentry->d_inode);
+ fsstack_copy_attr_atime(dentry->d_inode,
+ hidden_dentry->d_inode);

out:
unionfs_unlock_dentry(dentry);
@@ -795,7 +828,7 @@ static void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,

/* Basically copied from the kernel vfs permission(), but we've changed
* the following:
- * (1) the IS_RDONLY check is skipped, and
+ * (1) the IS_RDONLY check is skipped, and
* (2) if you set the mount option `mode=nfsro', we assume that -EACCES
* means that the export is read-only and we should check standard Unix
* permissions. This means that NFS ACL checks (or other advanced
@@ -803,8 +836,8 @@ static void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,
* security_inode_permission, and therefore security inside SELinux, etc.
* are performed.
*/
-static int inode_permission(struct inode *inode, int mask, struct nameidata *nd,
- int bindex)
+static int inode_permission(struct inode *inode, int mask,
+ struct nameidata *nd, int bindex)
{
int retval, submask;

@@ -813,7 +846,7 @@ static int inode_permission(struct inode *inode, int mask, struct nameidata *nd,
if (bindex == 0) {
umode_t mode = inode->i_mode;
if (IS_RDONLY(inode) &&
- (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
+ (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
return -EROFS;
}
/*
@@ -835,7 +868,8 @@ static int inode_permission(struct inode *inode, int mask, struct nameidata *nd,
perms = branchperms(nd->mnt->mnt_sb, bindex);
unionfs_read_unlock(nd->mnt->mnt_sb);
if (perms & MAY_NFSRO)
- retval = generic_permission(inode, submask, NULL);
+ retval = generic_permission(inode, submask,
+ NULL);
}
} else
retval = generic_permission(inode, submask, NULL);
@@ -928,7 +962,8 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
bend = dbend(dentry);
inode = dentry->d_inode;

- for (bindex = bstart; (bindex <= bend) || (bindex == bstart); bindex++) {
+ for (bindex = bstart; (bindex <= bend) || (bindex == bstart);
+ bindex++) {
hidden_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!hidden_dentry)
continue;
@@ -950,10 +985,14 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)

if (!err) {
copyup = 1;
- hidden_dentry = unionfs_lower_dentry(dentry);
+ hidden_dentry =
+ unionfs_lower_dentry(dentry);
break;
}
- /* if error is in the leftmost branch, pass it up */
+ /*
+ * if error is in the leftmost branch, pass
+ * it up.
+ */
if (i == 0)
goto out;
}
@@ -1013,4 +1052,3 @@ struct inode_operations unionfs_main_iops = {
.listxattr = unionfs_listxattr,
#endif
};
-
diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index 5157f36..4be590f 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -46,8 +46,9 @@ static noinline int is_opaque_dir(struct dentry *dentry, int bindex)
mutex_lock(&hidden_inode->i_mutex);

if (!permission(hidden_inode, MAY_EXEC, NULL))
- wh_hidden_dentry = lookup_one_len(UNIONFS_DIR_OPAQUE, hidden_dentry,
- sizeof(UNIONFS_DIR_OPAQUE) - 1);
+ wh_hidden_dentry =
+ lookup_one_len(UNIONFS_DIR_OPAQUE, hidden_dentry,
+ sizeof(UNIONFS_DIR_OPAQUE) - 1);
else {
args.is_opaque.dentry = hidden_dentry;
run_sioq(__is_opaque_dir, &args);
@@ -69,8 +70,8 @@ out:
return err;
}

-struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd,
- int lookupmode)
+struct dentry *unionfs_lookup_backend(struct dentry *dentry,
+ struct nameidata *nd, int lookupmode)
{
int err = 0;
struct dentry *hidden_dentry = NULL;
@@ -153,7 +154,8 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
continue;
BUG_ON(hidden_dentry != NULL);

- hidden_dir_dentry = unionfs_lower_dentry_idx(parent_dentry, bindex);
+ hidden_dir_dentry =
+ unionfs_lower_dentry_idx(parent_dentry, bindex);

/* if the parent hidden dentry does not exist skip this */
if (!(hidden_dir_dentry && hidden_dir_dentry->d_inode))
@@ -208,7 +210,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
nd->mnt = unionfs_lower_mnt_idx(parent_dentry, bindex);

hidden_dentry = lookup_one_len_nd(name, hidden_dir_dentry,
- namelen, nd);
+ namelen, nd);
if (IS_ERR(hidden_dentry)) {
dput(first_hidden_dentry);
unionfs_mntput(first_dentry, first_dentry_offset);
@@ -226,7 +228,8 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
* to allow mountpoint crossing
*/
first_dentry = parent_dentry;
- first_hidden_mnt = unionfs_mntget(parent_dentry, bindex);
+ first_hidden_mnt =
+ unionfs_mntget(parent_dentry, bindex);
first_dentry_offset = bindex;
} else
dput(hidden_dentry);
@@ -245,12 +248,13 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
* mountpoint crossing
*/
unionfs_set_lower_mnt_idx(dentry, bindex,
- unionfs_mntget(parent_dentry, bindex));
+ unionfs_mntget(parent_dentry,
+ bindex));
set_dbend(dentry, bindex);

/* update parent directory's atime with the bindex */
fsstack_copy_attr_atime(parent_dentry->d_inode,
- hidden_dir_dentry->d_inode);
+ hidden_dir_dentry->d_inode);

/* We terminate file lookups here. */
if (!S_ISDIR(hidden_dentry->d_inode->i_mode)) {
@@ -259,7 +263,8 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
if (dentry_count == 1)
goto out_positive;
/* This can only happen with mixed D-*-F-* */
- BUG_ON(!S_ISDIR(unionfs_lower_dentry(dentry)->d_inode->i_mode));
+ BUG_ON(!S_ISDIR(unionfs_lower_dentry(dentry)->
+ d_inode->i_mode));
continue;
}

@@ -298,22 +303,25 @@ out_negative:
/* FIXME: fix following line for mount point crossing */
nd->mnt = unionfs_lower_mnt_idx(parent_dentry, bindex);

- first_hidden_dentry = lookup_one_len_nd(name, hidden_dir_dentry,
- namelen, nd);
+ first_hidden_dentry =
+ lookup_one_len_nd(name, hidden_dir_dentry,
+ namelen, nd);
first_dentry_offset = bindex;
if (IS_ERR(first_hidden_dentry)) {
err = PTR_ERR(first_hidden_dentry);
goto out;
}
-
+
/* FIXME: the following line needs to be changed to allow
* mountpoint crossing
*/
first_dentry = dentry;
first_hidden_mnt = unionfs_mntget(dentry, bindex);
}
- unionfs_set_lower_dentry_idx(dentry, first_dentry_offset, first_hidden_dentry);
- unionfs_set_lower_mnt_idx(dentry, first_dentry_offset, first_hidden_mnt);
+ unionfs_set_lower_dentry_idx(dentry, first_dentry_offset,
+ first_hidden_dentry);
+ unionfs_set_lower_mnt_idx(dentry, first_dentry_offset,
+ first_hidden_mnt);
set_dbstart(dentry, first_dentry_offset);
set_dbend(dentry, first_dentry_offset);

@@ -409,9 +417,10 @@ int unionfs_partial_lookup(struct dentry *dentry)
static struct kmem_cache *unionfs_dentry_cachep;
int unionfs_init_dentry_cache(void)
{
- unionfs_dentry_cachep = kmem_cache_create("unionfs_dentry",
- sizeof(struct unionfs_dentry_info), 0,
- SLAB_RECLAIM_ACCOUNT, NULL, NULL);
+ unionfs_dentry_cachep =
+ kmem_cache_create("unionfs_dentry",
+ sizeof(struct unionfs_dentry_info),
+ 0, SLAB_RECLAIM_ACCOUNT, NULL, NULL);

return (unionfs_dentry_cachep ? 0 : -ENOMEM);
}
@@ -440,7 +449,7 @@ int new_dentry_private_data(struct dentry *dentry)
spin_lock(&dentry->d_lock);
if (!info) {
dentry->d_fsdata = kmem_cache_alloc(unionfs_dentry_cachep,
- GFP_ATOMIC);
+ GFP_ATOMIC);
info = UNIONFS_D(dentry);

if (!info)
@@ -514,4 +523,3 @@ void update_bstart(struct dentry *dentry)
unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
}
}
-
diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c
index 4fffafa..ffedbcd 100644
--- a/fs/unionfs/main.c
+++ b/fs/unionfs/main.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -61,7 +61,7 @@ int unionfs_interpose(struct dentry *dentry, struct super_block *sb, int flag)
atomic_read(&UNIONFS_SB(sb)->generation));

UNIONFS_I(inode)->lower_inodes =
- kcalloc(sbmax(sb), sizeof(struct inode *), GFP_KERNEL);
+ kcalloc(sbmax(sb), sizeof(struct inode *), GFP_KERNEL);
if (!UNIONFS_I(inode)->lower_inodes) {
err = -ENOMEM;
goto out;
@@ -90,7 +90,7 @@ int unionfs_interpose(struct dentry *dentry, struct super_block *sb, int flag)
continue;

unionfs_set_lower_inode_idx(inode, bindex,
- igrab(hidden_dentry->d_inode));
+ igrab(hidden_dentry->d_inode));
}

ibstart(inode) = dbstart(dentry);
@@ -169,7 +169,7 @@ void unionfs_reinterpose(struct dentry *dentry)
if (unionfs_lower_inode_idx(inode, bindex))
continue;
unionfs_set_lower_inode_idx(inode, bindex,
- igrab(hidden_dentry->d_inode));
+ igrab(hidden_dentry->d_inode));
}
ibstart(inode) = dbstart(dentry);
ibend(inode) = dbend(dentry);
@@ -232,6 +232,7 @@ int __parse_branch_mode(const char *name)
int parse_branch_mode(const char *name)
{
int perms = __parse_branch_mode(name);
+
if (perms == 0)
perms = MAY_READ | MAY_WRITE;
return perms;
@@ -266,15 +267,15 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
branches++;

/* allocate space for underlying pointers to hidden dentry */
- UNIONFS_SB(sb)->data = kcalloc(branches,
- sizeof(struct unionfs_data), GFP_KERNEL);
+ UNIONFS_SB(sb)->data =
+ kcalloc(branches, sizeof(struct unionfs_data), GFP_KERNEL);
if (!UNIONFS_SB(sb)->data) {
err = -ENOMEM;
goto out;
}

- hidden_root_info->lower_paths = kcalloc(branches,
- sizeof(struct path), GFP_KERNEL);
+ hidden_root_info->lower_paths =
+ kcalloc(branches, sizeof(struct path), GFP_KERNEL);
if (!hidden_root_info->lower_paths) {
err = -ENOMEM;
goto out;
@@ -304,7 +305,8 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
err = path_lookup(name, LOOKUP_FOLLOW, &nd);
if (err) {
printk(KERN_WARNING "unionfs: error accessing "
- "hidden directory '%s' (error %d)\n", name, err);
+ "hidden directory '%s' (error %d)\n",
+ name, err);
goto out;
}

@@ -346,7 +348,7 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info

if (is_branch_overlap(dent1, dent2)) {
printk(KERN_WARNING "unionfs: branches %d and "
- "%d overlap\n", i, j);
+ "%d overlap\n", i, j);
err = -EINVAL;
goto out;
}
@@ -358,7 +360,7 @@ out:
for (i = 0; i < branches; i++)
if (hidden_root_info->lower_paths[i].dentry) {
dput(hidden_root_info->lower_paths[i].dentry);
- /* initializing: can't use unionfs_mntput here */
+ /* initialize: can't use unionfs_mntput here */
mntput(hidden_root_info->lower_paths[i].mnt);
}

@@ -380,8 +382,9 @@ out:
* Returns the dentry object of the lower-level (hidden) directory;
* We want to mount our stackable file system on top of that hidden directory.
*/
-static struct unionfs_dentry_info *unionfs_parse_options(struct super_block *sb,
- char *options)
+static struct unionfs_dentry_info *unionfs_parse_options(
+ struct super_block *sb,
+ char *options)
{
struct unionfs_dentry_info *hidden_root_info;
char *optname;
@@ -392,7 +395,7 @@ static struct unionfs_dentry_info *unionfs_parse_options(struct super_block *sb,
/* allocate private data area */
err = -ENOMEM;
hidden_root_info =
- kzalloc(sizeof(struct unionfs_dentry_info), GFP_KERNEL);
+ kzalloc(sizeof(struct unionfs_dentry_info), GFP_KERNEL);
if (!hidden_root_info)
goto out_error;
hidden_root_info->bstart = -1;
@@ -483,7 +486,7 @@ out:
return hidden_root_info;
}

-/* our custom d_alloc_root workalike
+/* our custom d_alloc_root workalike
*
* we can't use d_alloc_root if we want to use our own interpose function
* unchanged, so we simply call our own "fake" d_alloc_root
@@ -561,7 +564,7 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data,
unionfs_write_unlock(sb);
}

- /* Unionfs: Max Bytes is the maximum bytes from highest priority branch */
+ /* max Bytes is the maximum bytes from highest priority branch */
unionfs_read_lock(sb);
sb->s_maxbytes = unionfs_lower_super_idx(sb, 0)->s_maxbytes;
unionfs_read_unlock(sb);
@@ -661,6 +664,7 @@ static struct file_system_type unionfs_fs_type = {
static int __init init_unionfs_fs(void)
{
int err;
+
printk("Registering unionfs " UNIONFS_VERSION "\n");

if ((err = unionfs_init_filldir_cache()))
@@ -693,11 +697,10 @@ static void __exit exit_unionfs_fs(void)
}

MODULE_AUTHOR("Erez Zadok, Filesystems and Storage Lab, Stony Brook University"
- " (http://www.fsl.cs.sunysb.edu)");
+ " (http://www.fsl.cs.sunysb.edu)");
MODULE_DESCRIPTION("Unionfs " UNIONFS_VERSION
- " (http://unionfs.filesystems.org)");
+ " (http://unionfs.filesystems.org)");
MODULE_LICENSE("GPL");

module_init(init_unionfs_fs);
module_exit(exit_unionfs_fs);
-
diff --git a/fs/unionfs/rdstate.c b/fs/unionfs/rdstate.c
index b67a86a..4e875b1 100644
--- a/fs/unionfs/rdstate.c
+++ b/fs/unionfs/rdstate.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -34,8 +34,9 @@ static struct kmem_cache *unionfs_filldir_cachep;
int unionfs_init_filldir_cache(void)
{
unionfs_filldir_cachep =
- kmem_cache_create("unionfs_filldir", sizeof(struct filldir_node), 0,
- SLAB_RECLAIM_ACCOUNT, NULL, NULL);
+ kmem_cache_create("unionfs_filldir",
+ sizeof(struct filldir_node), 0,
+ SLAB_RECLAIM_ACCOUNT, NULL, NULL);

return (unionfs_filldir_cachep ? 0 : -ENOMEM);
}
@@ -74,7 +75,8 @@ static int guesstimate_hash_size(struct inode *inode)
if (hidden_inode->i_size == DENTPAGE)
hashsize += DENTPERONEPAGE;
else
- hashsize += (hidden_inode->i_size / DENTPAGE) * DENTPERPAGE;
+ hashsize += (hidden_inode->i_size / DENTPAGE) *
+ DENTPERPAGE;
}

return hashsize;
@@ -82,12 +84,13 @@ static int guesstimate_hash_size(struct inode *inode)

int init_rdstate(struct file *file)
{
- BUG_ON(sizeof(loff_t) != (sizeof(unsigned int) + sizeof(unsigned int)));
+ BUG_ON(sizeof(loff_t) !=
+ (sizeof(unsigned int) + sizeof(unsigned int)));
BUG_ON(UNIONFS_F(file)->rdstate != NULL);

UNIONFS_F(file)->rdstate = alloc_rdstate(file->f_dentry->d_inode,
fbstart(file));
-
+
return (UNIONFS_F(file)->rdstate ? 0 : -ENOMEM);
}

@@ -99,7 +102,7 @@ struct unionfs_dir_state *find_rdstate(struct inode *inode, loff_t fpos)
spin_lock(&UNIONFS_I(inode)->rdlock);
list_for_each(pos, &UNIONFS_I(inode)->readdircache) {
struct unionfs_dir_state *r =
- list_entry(pos, struct unionfs_dir_state, cache);
+ list_entry(pos, struct unionfs_dir_state, cache);
if (fpos == rdstate2offset(r)) {
UNIONFS_I(inode)->rdcount--;
list_del(&r->cache);
@@ -126,8 +129,8 @@ struct unionfs_dir_state *alloc_rdstate(struct inode *inode, int bindex)
if (mallocsize > PAGE_SIZE)
mallocsize = PAGE_SIZE;

- hashsize = (mallocsize -
- sizeof(struct unionfs_dir_state)) / sizeof(struct list_head);
+ hashsize = (mallocsize - sizeof(struct unionfs_dir_state)) /
+ sizeof(struct list_head);

rdstate = kmalloc(mallocsize, GFP_KERNEL);
if (!rdstate)
@@ -211,9 +214,9 @@ struct filldir_node *find_filldir_node(struct unionfs_dir_state *rdstate,
*/
if (cursor->bindex == rdstate->bindex) {
printk(KERN_DEBUG "Possible I/O error "
- "unionfs_filldir: a file is duplicated "
- "in the same branch %d: %s\n",
- rdstate->bindex, cursor->name);
+ "unionfs_filldir: a file is duplicated "
+ "in the same branch %d: %s\n",
+ rdstate->bindex, cursor->name);
}
break;
}
@@ -272,4 +275,3 @@ int add_filldir_node(struct unionfs_dir_state *rdstate, const char *name,
out:
return err;
}
-
diff --git a/fs/unionfs/rename.c b/fs/unionfs/rename.c
index 0044492..5c6a33f 100644
--- a/fs/unionfs/rename.c
+++ b/fs/unionfs/rename.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -36,24 +36,27 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,

if (!hidden_new_dentry) {
hidden_new_dentry =
- create_parents(new_dentry->d_parent->d_inode, new_dentry, bindex);
+ create_parents(new_dentry->d_parent->d_inode,
+ new_dentry, bindex);
if (IS_ERR(hidden_new_dentry)) {
printk(KERN_DEBUG "error creating directory tree for"
- " rename, bindex = %d, err = %ld\n",
- bindex, PTR_ERR(hidden_new_dentry));
+ " rename, bindex = %d, err = %ld\n",
+ bindex, PTR_ERR(hidden_new_dentry));
err = PTR_ERR(hidden_new_dentry);
goto out;
}
}

- wh_name = alloc_whname(new_dentry->d_name.name, new_dentry->d_name.len);
+ wh_name = alloc_whname(new_dentry->d_name.name,
+ new_dentry->d_name.len);
if (IS_ERR(wh_name)) {
err = PTR_ERR(wh_name);
goto out;
}

hidden_wh_dentry = lookup_one_len(wh_name, hidden_new_dentry->d_parent,
- new_dentry->d_name.len + UNIONFS_WHLEN);
+ new_dentry->d_name.len +
+ UNIONFS_WHLEN);
if (IS_ERR(hidden_wh_dentry)) {
err = PTR_ERR(hidden_wh_dentry);
goto out;
@@ -63,7 +66,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
/* get rid of the whiteout that is existing */
if (hidden_new_dentry->d_inode) {
printk(KERN_WARNING "Both a whiteout and a dentry"
- " exist when doing a rename!\n");
+ " exist when doing a rename!\n");
err = -EIO;

dput(hidden_wh_dentry);
@@ -73,7 +76,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
hidden_wh_dir_dentry = lock_parent(hidden_wh_dentry);
if (!(err = is_robranch_super(old_dentry->d_sb, bindex)))
err = vfs_unlink(hidden_wh_dir_dentry->d_inode,
- hidden_wh_dentry);
+ hidden_wh_dentry);

dput(hidden_wh_dentry);
unlock_dir(hidden_wh_dir_dentry);
@@ -103,7 +106,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
if (IS_ERR(whname))
goto out_unlock;
*wh_old = lookup_one_len(whname, hidden_old_dir_dentry,
- old_dentry->d_name.len + UNIONFS_WHLEN);
+ old_dentry->d_name.len +
+ UNIONFS_WHLEN);
kfree(whname);
err = PTR_ERR(*wh_old);
if (IS_ERR(*wh_old)) {
@@ -137,9 +141,9 @@ out:
}

static int do_unionfs_rename(struct inode *old_dir,
- struct dentry *old_dentry,
- struct inode *new_dir,
- struct dentry *new_dentry)
+ struct dentry *old_dentry,
+ struct inode *new_dir,
+ struct dentry *new_dentry)
{
int err = 0;
int bindex, bwh_old;
@@ -184,19 +188,20 @@ static int do_unionfs_rename(struct inode *old_dir,
unlink_dir_dentry = lock_parent(unlink_dentry);
if (!(err = is_robranch_super(old_dir->i_sb, bindex)))
err = vfs_unlink(unlink_dir_dentry->d_inode,
- unlink_dentry);
+ unlink_dentry);

fsstack_copy_attr_times(new_dentry->d_parent->d_inode,
- unlink_dir_dentry->d_inode);
+ unlink_dir_dentry->d_inode);
/* propagate number of hard-links */
new_dentry->d_parent->d_inode->i_nlink =
- unionfs_get_nlinks(new_dentry->d_parent->d_inode);
+ unionfs_get_nlinks(new_dentry->d_parent->d_inode);

unlock_dir(unlink_dir_dentry);
if (!err) {
if (bindex != new_bstart) {
dput(unlink_dentry);
- unionfs_set_lower_dentry_idx(new_dentry, bindex, NULL);
+ unionfs_set_lower_dentry_idx(new_dentry,
+ bindex, NULL);
}
} else if (IS_COPYUP_ERR(err)) {
do_copyup = bindex - 1;
@@ -212,8 +217,8 @@ static int do_unionfs_rename(struct inode *old_dir,
* you can rename it
*/
err = copyup_dentry(old_dentry->d_parent->d_inode,
- old_dentry, old_bstart, bindex, NULL,
- old_dentry->d_inode->i_size);
+ old_dentry, old_bstart, bindex,
+ NULL, old_dentry->d_inode->i_size);
if (!err) {
dput(wh_old);
bwh_old = bindex;
@@ -245,9 +250,12 @@ static int do_unionfs_rename(struct inode *old_dir,
if (!local_err)
set_dbopaque(old_dentry, bwh_old);
else {
- /* We can't fix anything now, so we cop-out and use -EIO. */
+ /*
+ * we can't fix anything now, so we cop-out and use
+ * -EIO.
+ */
printk(KERN_ERR "We can't create a whiteout for the "
- "source in rename!\n");
+ "source in rename!\n");
err = -EIO;
}
}
@@ -261,14 +269,14 @@ revert:
local_err = unionfs_refresh_hidden_dentry(new_dentry, old_bstart);
if (local_err) {
printk(KERN_WARNING "Revert failed in rename: the new refresh "
- "failed.\n");
+ "failed.\n");
eio = -EIO;
}

local_err = unionfs_refresh_hidden_dentry(old_dentry, old_bstart);
if (local_err) {
printk(KERN_WARNING "Revert failed in rename: the old refresh "
- "failed.\n");
+ "failed.\n");
eio = -EIO;
goto revert_out;
}
@@ -276,7 +284,7 @@ revert:
if (!unionfs_lower_dentry_idx(new_dentry, bindex) ||
!unionfs_lower_dentry_idx(new_dentry, bindex)->d_inode) {
printk(KERN_WARNING "Revert failed in rename: the object "
- "disappeared from under us!\n");
+ "disappeared from under us!\n");
eio = -EIO;
goto revert_out;
}
@@ -284,13 +292,13 @@ revert:
if (unionfs_lower_dentry_idx(old_dentry, bindex) &&
unionfs_lower_dentry_idx(old_dentry, bindex)->d_inode) {
printk(KERN_WARNING "Revert failed in rename: the object was "
- "created underneath us!\n");
+ "created underneath us!\n");
eio = -EIO;
goto revert_out;
}

- local_err = do_rename(new_dir, new_dentry, old_dir, old_dentry, old_bstart,
- NULL);
+ local_err = do_rename(new_dir, new_dentry,
+ old_dir, old_dentry, old_bstart, NULL);

/* If we can't fix it, then we cop-out with -EIO. */
if (local_err) {
@@ -331,7 +339,7 @@ static struct dentry *lookup_whiteout(struct dentry *dentry)
if (!hidden_parent)
continue;
wh_dentry = lookup_one_len(whname, hidden_parent,
- dentry->d_name.len + UNIONFS_WHLEN);
+ dentry->d_name.len + UNIONFS_WHLEN);
if (IS_ERR(wh_dentry))
continue;
if (wh_dentry->d_inode)
@@ -407,7 +415,7 @@ int unionfs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (S_ISDIR(old_dentry->d_inode->i_mode) !=
S_ISDIR(new_dentry->d_inode->i_mode)) {
err = S_ISDIR(old_dentry->d_inode->i_mode) ?
- -ENOTDIR : -EISDIR;
+ -ENOTDIR : -EISDIR;
goto out;
}

@@ -445,4 +453,3 @@ out:
unionfs_unlock_dentry(old_dentry);
return err;
}
-
diff --git a/fs/unionfs/sioq.c b/fs/unionfs/sioq.c
index c0d89a3..bef970b 100644
--- a/fs/unionfs/sioq.c
+++ b/fs/unionfs/sioq.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -117,7 +117,6 @@ void __is_opaque_dir(struct work_struct *work)
struct sioq_args *args = container_of(work, struct sioq_args, work);

args->ret = lookup_one_len(UNIONFS_DIR_OPAQUE, args->is_opaque.dentry,
- sizeof(UNIONFS_DIR_OPAQUE) - 1);
+ sizeof(UNIONFS_DIR_OPAQUE) - 1);
complete(&args->comp);
}
-
diff --git a/fs/unionfs/sioq.h b/fs/unionfs/sioq.h
index 20e3b0c..4827514 100644
--- a/fs/unionfs/sioq.h
+++ b/fs/unionfs/sioq.h
@@ -75,4 +75,3 @@ extern void __delete_whiteouts(struct work_struct *work);
extern void __is_opaque_dir(struct work_struct *work);

#endif /* _SIOQ_H */
-
diff --git a/fs/unionfs/subr.c b/fs/unionfs/subr.c
index d274752..0257cca 100644
--- a/fs/unionfs/subr.c
+++ b/fs/unionfs/subr.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -56,13 +56,14 @@ int create_whiteout(struct dentry *dentry, int start)
dentry, bindex);
if (!hidden_dentry || IS_ERR(hidden_dentry)) {
printk(KERN_DEBUG "create_parents failed for "
- "bindex = %d\n", bindex);
+ "bindex = %d\n", bindex);
continue;
}
}

- hidden_wh_dentry = lookup_one_len(name, hidden_dentry->d_parent,
- dentry->d_name.len + UNIONFS_WHLEN);
+ hidden_wh_dentry =
+ lookup_one_len(name, hidden_dentry->d_parent,
+ dentry->d_name.len + UNIONFS_WHLEN);
if (IS_ERR(hidden_wh_dentry))
continue;

@@ -76,12 +77,11 @@ int create_whiteout(struct dentry *dentry, int start)
}

hidden_dir_dentry = lock_parent(hidden_wh_dentry);
- if (!(err = is_robranch_super(dentry->d_sb, bindex))) {
+ if (!(err = is_robranch_super(dentry->d_sb, bindex)))
err = vfs_create(hidden_dir_dentry->d_inode,
- hidden_wh_dentry,
- ~current->fs->umask & S_IRWXUGO, NULL);
-
- }
+ hidden_wh_dentry,
+ ~current->fs->umask & S_IRWXUGO,
+ NULL);
unlock_dir(hidden_dir_dentry);
dput(hidden_wh_dentry);

@@ -116,7 +116,7 @@ int unionfs_refresh_hidden_dentry(struct dentry *dentry, int bindex)
BUG_ON(!S_ISDIR(hidden_parent->d_inode->i_mode));

hidden_dentry = lookup_one_len(dentry->d_name.name, hidden_parent,
- dentry->d_name.len);
+ dentry->d_name.len);
if (IS_ERR(hidden_dentry)) {
err = PTR_ERR(hidden_dentry);
goto out;
@@ -132,7 +132,7 @@ int unionfs_refresh_hidden_dentry(struct dentry *dentry, int bindex)
} else {
unionfs_set_lower_dentry_idx(dentry, bindex, hidden_dentry);
unionfs_set_lower_inode_idx(dentry->d_inode, bindex,
- igrab(hidden_dentry->d_inode));
+ igrab(hidden_dentry->d_inode));
}

out:
@@ -230,4 +230,3 @@ char *alloc_whname(const char *name, int len)

return buf;
}
-
diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index c1048e9..f8116a5 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -31,7 +31,7 @@ static void unionfs_read_inode(struct inode *inode)

if (!info) {
printk(KERN_ERR "No kernel memory when allocating inode "
- "private data!\n");
+ "private data!\n");
BUG();
}

@@ -49,7 +49,7 @@ static void unionfs_read_inode(struct inode *inode)
info->lower_inodes = kzalloc(size, GFP_KERNEL);
if (!info->lower_inodes) {
printk(KERN_ERR "No kernel memory when allocating lower-"
- "pointer array!\n");
+ "pointer array!\n");
BUG();
}

@@ -102,7 +102,7 @@ static void unionfs_put_super(struct super_block *sb)
spd = UNIONFS_SB(sb);
if (!spd)
return;
-
+
bstart = sbstart(sb);
bend = sbend(sb);

@@ -110,7 +110,7 @@ static void unionfs_put_super(struct super_block *sb)
for (bindex = bstart; bindex <= bend; bindex++)
if (branch_count(sb, bindex) != 0) {
printk("unionfs: branch %d has %d references left!\n",
- bindex, branch_count(sb,bindex));
+ bindex, branch_count(sb, bindex));
leaks = 1;
}
BUG_ON(leaks != 0);
@@ -214,6 +214,7 @@ static noinline int do_remount_del_option(char *optarg, int cur_branches,
int err = -EINVAL;
int idx;
struct nameidata nd;
+
/* optarg contains the branch name to delete */

/*
@@ -257,7 +258,8 @@ static noinline int do_remount_del_option(char *optarg, int cur_branches,
if (idx < cur_branches - 1) {
/* if idx==cur_branches-1, we delete last branch: easy */
memmove(&new_data[idx], &new_data[idx+1],
- (cur_branches - 1 - idx) * sizeof(struct unionfs_data));
+ (cur_branches - 1 - idx) *
+ sizeof(struct unionfs_data));
memmove(&new_lower_paths[idx], &new_lower_paths[idx+1],
(cur_branches - 1 - idx) * sizeof(struct path));
}
@@ -504,7 +506,7 @@ static int unionfs_remount_fs(struct super_block *sb, int *flags,
}
/* allocate space for new pointers to lower paths */
tmp_lower_paths = kcalloc(max_branches,
- sizeof(struct path), GFP_KERNEL);
+ sizeof(struct path), GFP_KERNEL);
if (!tmp_lower_paths) {
err = -ENOMEM;
goto out_free;
@@ -572,8 +574,8 @@ static int unionfs_remount_fs(struct super_block *sb, int *flags,
goto out_release;
new_branches++;
if (new_branches > UNIONFS_MAX_BRANCHES) {
- printk("unionfs: command exceeds %d branches\n",
- UNIONFS_MAX_BRANCHES);
+ printk("unionfs: command exceeds "
+ "%d branches\n", UNIONFS_MAX_BRANCHES);
err = -E2BIG;
goto out_release;
}
@@ -829,9 +831,9 @@ int unionfs_init_inode_cache(void)
int err = 0;

unionfs_inode_cachep =
- kmem_cache_create("unionfs_inode_cache",
- sizeof(struct unionfs_inode_info), 0,
- SLAB_RECLAIM_ACCOUNT, init_once, NULL);
+ kmem_cache_create("unionfs_inode_cache",
+ sizeof(struct unionfs_inode_info), 0,
+ SLAB_RECLAIM_ACCOUNT, init_once, NULL);
if (!unionfs_inode_cachep)
err = -ENOMEM;
return err;
@@ -921,8 +923,8 @@ static int unionfs_show_options(struct seq_file *m, struct vfsmount *mnt)
seq_printf(m, ",dirs=");
for (bindex = bstart; bindex <= bend; bindex++) {
path = d_path(unionfs_lower_dentry_idx(sb->s_root, bindex),
- unionfs_lower_mnt_idx(sb->s_root, bindex), tmp_page,
- PAGE_SIZE);
+ unionfs_lower_mnt_idx(sb->s_root, bindex),
+ tmp_page, PAGE_SIZE);
if (IS_ERR(path)) {
ret = PTR_ERR(path);
goto out;
@@ -960,4 +962,3 @@ struct super_operations unionfs_sops = {
.alloc_inode = unionfs_alloc_inode,
.destroy_inode = unionfs_destroy_inode,
};
-
diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h
index b6fa0a2..034b1b2 100644
--- a/fs/unionfs/union.h
+++ b/fs/unionfs/union.h
@@ -8,7 +8,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -98,7 +98,7 @@ struct unionfs_inode_info {
int rdcount;
int hashsize;
int cookie;
-
+
/* The hidden inodes */
struct inode **lower_inodes;
/* to keep track of reads/writes for unlinks before closes */
@@ -152,8 +152,8 @@ struct filldir_node {

/* we can check for duplicate whiteouts and files in the same branch
* in order to return -EIO.
- */
- int bindex;
+ */
+ int bindex;

/* is this a whiteout entry? */
int whiteout;
@@ -164,10 +164,10 @@ struct filldir_node {

/* Directory hash table. */
struct unionfs_dir_state {
- unsigned int cookie; /* The cookie, which is based off of rdversion */
+ unsigned int cookie; /* the cookie, based off of rdversion */
unsigned int offset; /* The entry we have returned. */
int bindex;
- loff_t dirpos; /* The offset within the lower level directory. */
+ loff_t dirpos; /* offset within the lower level directory */
int size; /* How big is the hash table? */
int hashentries; /* How many entries have been inserted? */
unsigned long access;
@@ -210,6 +210,7 @@ struct unionfs_data *alloc_new_data(int objs);
static inline off_t rdstate2offset(struct unionfs_dir_state *buf)
{
off_t tmp;
+
tmp = ((buf->cookie & MAXRDCOOKIE) << RDOFFBITS)
| (buf->offset & DIREOF);
return tmp;
@@ -260,13 +261,14 @@ extern int copyup_named_file(struct inode *dir, struct file *file,
loff_t len);
/* copies a dentry from dbstart to newbindex branch */
extern int copyup_dentry(struct inode *dir, struct dentry *dentry, int bstart,
- int new_bindex, struct file **copyup_file, loff_t len);
+ int new_bindex, struct file **copyup_file,
+ loff_t len);

-extern int remove_whiteouts(struct dentry *dentry, struct dentry *hidden_dentry,
- int bindex);
+extern int remove_whiteouts(struct dentry *dentry,
+ struct dentry *hidden_dentry, int bindex);

extern int do_delete_whiteouts(struct dentry *dentry, int bindex,
- struct unionfs_dir_state *namelist);
+ struct unionfs_dir_state *namelist);

extern int unionfs_get_nlinks(struct inode *inode);

@@ -310,8 +312,8 @@ int __unionfs_d_revalidate_chain(struct dentry *dentry, struct nameidata *nd);
#define INTERPOSE_REVAL_NEG 3
#define INTERPOSE_PARTIAL 4

-extern int unionfs_interpose(struct dentry *this_dentry, struct super_block *sb,
- int flag);
+extern int unionfs_interpose(struct dentry *this_dentry,
+ struct super_block *sb, int flag);

/* Branch management ioctls. */
int unionfs_ioctl_incgen(struct file *file, unsigned int cmd,
@@ -325,12 +327,12 @@ extern void *unionfs_xattr_alloc(size_t size, size_t limit);
extern void unionfs_xattr_free(void *ptr, size_t size);

extern ssize_t unionfs_getxattr(struct dentry *dentry, const char *name,
- void *value, size_t size);
+ void *value, size_t size);
extern int unionfs_removexattr(struct dentry *dentry, const char *name);
extern ssize_t unionfs_listxattr(struct dentry *dentry, char *list,
- size_t size);
+ size_t size);
extern int unionfs_setxattr(struct dentry *dentry, const char *name,
- const void *value, size_t size, int flags);
+ const void *value, size_t size, int flags);
#endif /* CONFIG_UNION_FS_XATTR */

/* The root directory is unhashed, but isn't deleted. */
@@ -339,7 +341,8 @@ static inline int d_deleted(struct dentry *d)
return d_unhashed(d) && (d != d->d_sb->s_root);
}

-struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *nd, int lookupmode);
+struct dentry *unionfs_lookup_backend(struct dentry *dentry,
+ struct nameidata *nd, int lookupmode);

/* unionfs_permission, check if we should bypass error to facilitate copyup */
#define IS_COPYUP_ERR(err) ((err) == -EROFS)
@@ -368,6 +371,7 @@ static inline int set_branchperms(struct super_block *sb, int index, int perms)
static inline int is_robranch_super(const struct super_block *sb, int index)
{
int ret;
+
unionfs_read_lock(sb);
ret = (!(branchperms(sb, index) & MAY_WRITE)) ? -EROFS : 0;
unionfs_read_unlock(sb);
@@ -433,8 +437,8 @@ extern int check_branch(struct nameidata *nd);
extern int __parse_branch_mode(const char *name);
extern int parse_branch_mode(const char *name);

-/* These two functions are here because it is kind of daft to copy and paste the
- * contents of the two functions to 32+ places in unionfs
+/* These two functions are here because it is kind of daft to copy and paste
+ * the contents of the two functions to 32+ places in unionfs
*/
static inline struct dentry *lock_parent(struct dentry *dentry)
{
@@ -452,9 +456,11 @@ static inline void unlock_dir(struct dentry *dir)

extern int make_dir_opaque(struct dentry *dir, int bindex);

-static inline struct vfsmount *unionfs_mntget(struct dentry *dentry, int bindex)
+static inline struct vfsmount *unionfs_mntget(struct dentry *dentry,
+ int bindex)
{
struct vfsmount *mnt;
+
if (!dentry) {
if (bindex < 0)
return NULL;
@@ -473,6 +479,7 @@ static inline struct vfsmount *unionfs_mntget(struct dentry *dentry, int bindex)
static inline void unionfs_mntput(struct dentry *dentry, int bindex)
{
struct vfsmount *mnt;
+
if (!dentry) {
if (bindex < 0)
return;
diff --git a/fs/unionfs/unlink.c b/fs/unionfs/unlink.c
index dd1dd9c..27b4542 100644
--- a/fs/unionfs/unlink.c
+++ b/fs/unionfs/unlink.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -163,4 +163,3 @@ out:
unionfs_unlock_dentry(dentry);
return err;
}
-
diff --git a/fs/unionfs/xattr.c b/fs/unionfs/xattr.c
index 6e1f4bd..9d3073b 100644
--- a/fs/unionfs/xattr.c
+++ b/fs/unionfs/xattr.c
@@ -9,7 +9,7 @@
* Copyright (c) 2003 Puja Gupta
* Copyright (c) 2003 Harikesavan Krishnan
* Copyright (c) 2003-2007 Stony Brook University
- * Copyright (c) 2003-2007 The Research Foundation of State University of New York*
+ * Copyright (c) 2003-2007 The Research Foundation of SUNY
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -51,7 +51,7 @@ void unionfs_xattr_free(void *ptr, size_t size)
* dentry->d_inode->i_mutex locked
*/
ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
- size_t size)
+ size_t size)
{
struct dentry *hidden_dentry = NULL;
int err = -EOPNOTSUPP;
@@ -71,8 +71,8 @@ ssize_t unionfs_getxattr(struct dentry * dentry, const char *name, void *value,
/* BKL held by caller.
* dentry->d_inode->i_mutex locked
*/
-int unionfs_setxattr(struct dentry *dentry, const char *name, const void *value,
- size_t size, int flags)
+int unionfs_setxattr(struct dentry *dentry, const char *name,
+ const void *value, size_t size, int flags)
{
struct dentry *hidden_dentry = NULL;
int err = -EOPNOTSUPP;
@@ -82,7 +82,8 @@ int unionfs_setxattr(struct dentry *dentry, const char *name, const void *value,
unionfs_lock_dentry(dentry);
hidden_dentry = unionfs_lower_dentry(dentry);

- err = vfs_setxattr(hidden_dentry, (char*) name, (void*) value, size, flags);
+ err = vfs_setxattr(hidden_dentry, (char*) name, (void*) value,
+ size, flags);

unionfs_unlock_dentry(dentry);
return err;
@@ -128,4 +129,3 @@ ssize_t unionfs_listxattr(struct dentry * dentry, char *list, size_t size)
unionfs_unlock_dentry(dentry);
return err;
}
-
diff --git a/include/linux/fs_stack.h b/include/linux/fs_stack.h
index bb516ce..2fe2387 100644
--- a/include/linux/fs_stack.h
+++ b/include/linux/fs_stack.h
@@ -9,9 +9,10 @@

/* externs for fs/stack.c */
extern void fsstack_copy_attr_all(struct inode *dest, const struct inode *src,
- int (*get_nlinks)(struct inode *));
+ int (*get_nlinks)(struct inode *));

-extern void fsstack_copy_inode_size(struct inode *dst, const struct inode *src);
+extern void fsstack_copy_inode_size(struct inode *dst,
+ const struct inode *src);

/* inlines */
static inline void fsstack_copy_attr_atime(struct inode *dest,
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:46:03

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 13/21] Unionfs: Don't leak resources when copyup fails partially

Original-patch-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/copyup.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index 0975b6e..a80ece6 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -632,7 +632,7 @@ static struct dentry *create_parents_named(struct inode *dir,
unsigned int childnamelen;

int nr_dentry;
- int count;
+ int count = 0;

int old_bstart;
int old_bend;
@@ -660,7 +660,6 @@ static struct dentry *create_parents_named(struct inode *dir,
/* assume the negative dentry of unionfs as the parent dentry */
parent_dentry = dentry;

- count = 0;
/*
* This loop finds the first parent that exists in the given branch.
* We start building the directory structure from there. At the end
@@ -772,6 +771,23 @@ static struct dentry *create_parents_named(struct inode *dir,
hidden_dentry);
unlock_dir(hidden_parent_dentry);
if (err) {
+ struct inode *inode = hidden_dentry->d_inode;
+ /*
+ * If we get here, it means that we created a new
+ * dentry+inode, but copying permissions failed.
+ * Therefore, we should delete this inode and dput
+ * the dentry so as not to leave cruft behind.
+ *
+ * XXX: call dentry_iput() instead, but then we have
+ * to export that symbol.
+ */
+ if (hidden_dentry->d_op && hidden_dentry->d_op->d_iput)
+ hidden_dentry->d_op->d_iput(hidden_dentry,
+ inode);
+ else
+ iput(inode);
+ hidden_dentry->d_inode = NULL;
+
dput(hidden_dentry);
hidden_dentry = ERR_PTR(err);
goto out;
@@ -786,6 +802,10 @@ static struct dentry *create_parents_named(struct inode *dir,
child_dentry = path[--count];
}
out:
+ /* cleanup any leftover locks from the do/while loop above */
+ if (IS_ERR(hidden_dentry))
+ while (count)
+ unionfs_unlock_dentry(path[count--]);
kfree(path);
return hidden_dentry;
}
--
1.5.2.rc1.165.gaf9b

2007-05-24 00:46:36

by Josef 'Jeff' Sipek

[permalink] [raw]
Subject: [PATCH 18/21] Unionfs: Remove defunct unionfs_put_inode super op

From: Erez Zadok <[email protected]>

Removed old workaround code that was needed to get mmap working, is no
longer needed with recent kernels.

Signed-off-by: Erez Zadok <[email protected]>
Signed-off-by: Josef 'Jeff' Sipek <[email protected]>
---
fs/unionfs/super.c | 20 --------------------
1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/fs/unionfs/super.c b/fs/unionfs/super.c
index 446faf8..bfd6c24 100644
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -62,25 +62,6 @@ static void unionfs_read_inode(struct inode *inode)
inode->i_mapping->a_ops = &unionfs_empty_aops;
}

-static void unionfs_put_inode(struct inode *inode)
-{
- /*
- * This is really funky stuff:
- *
- * Basically, if i_count == 1, iput will then decrement it and this
- * inode will be destroyed. It is currently holding a reference to
- * the hidden inode. Therefore, it needs to release that reference
- * by calling iput on the hidden inode. iput() _will_ do it for us
- * (by calling our clear_inode), but _only_ if i_nlink == 0. The
- * problem is, NFS keeps i_nlink == 1 for silly_rename'd files. So
- * we must force our i_nlink to 0 here to trick iput() into calling
- * our clear_inode.
- */
-
- if (atomic_read(&inode->i_count) == 1)
- inode->i_nlink = 0;
-}
-
/*
* we now define delete_inode, because there are two VFS paths that may
* destroy an inode: one of them calls clear inode before doing everything
@@ -938,7 +919,6 @@ out:

struct super_operations unionfs_sops = {
.read_inode = unionfs_read_inode,
- .put_inode = unionfs_put_inode,
.delete_inode = unionfs_delete_inode,
.put_super = unionfs_put_super,
.statfs = unionfs_statfs,
--
1.5.2.rc1.165.gaf9b