Unionfs cleanups and fixes
Subsystems (2)
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]>
PATCH 1/21 Unionfs: Tiny documentation fixups
From: Erez Zadok <[email protected]>
--- Documentation/filesystems/unionfs/usage.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
Documentation/filesystems/unionfs/usage.txt +2 -2
@@ -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/>.
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 2/21 Unionfs: Coding style fixes
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
Includes:
- indentation fixes
- 80 column wrapping
- removing unnecessary braces
- removing trailing whitespace
--- 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(-)
fs/stack.c +1 -1
@@ -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;
fs/unionfs/branchman.c +1 -2
@@ -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; } -
fs/unionfs/commonfops.c +44 -31
195 lines not on this page · raw message
fs/unionfs/copyup.c +46 -36
202 lines not on this page · raw message
fs/unionfs/dentry.c +24 -21
124 lines not on this page · raw message
fs/unionfs/dirfops.c +10 -5
@@ -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, }; -
fs/unionfs/dirhelper.c +16 -10
@@ -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; } -
fs/unionfs/fanout.h +27 -15
113 lines not on this page · raw message
fs/unionfs/file.c +3 -3
@@ -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, }; -
fs/unionfs/inode.c +100 -62
402 lines not on this page · raw message
fs/unionfs/lookup.c +29 -21
134 lines not on this page · raw message
fs/unionfs/main.c +22 -19
138 lines not on this page · raw message
fs/unionfs/rdstate.c +15 -13
@@ -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; } -
fs/unionfs/rename.c +36 -29
185 lines not on this page · raw message
fs/unionfs/sioq.c +2 -3
@@ -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); } -
fs/unionfs/sioq.h +0 -1
@@ -75,4 +75,3 @@ extern void __delete_whiteouts(struct work_struct *work);extern void __is_opaque_dir (struct work_struct *work);#endif /* _SIOQ_H */ -
fs/unionfs/subr.c +11 -12
@@ -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; } -
fs/unionfs/super.c +16 -15
@@ -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, }; -
fs/unionfs/union.h +26 -19
133 lines not on this page · raw message
fs/unionfs/unlink.c +1 -2
@@ -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; } -
fs/unionfs/xattr.c +6 -6
@@ -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; } -
include/linux/fs_stack.h +3 -2
@@ -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,
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 3/21 Unionfs: Every printk should prefix with "unionfs: " consistently
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[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(-)
fs/unionfs/commonfops.c +4 -3
@@ -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);
fs/unionfs/copyup.c +1 -1
@@ -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 (); }
fs/unionfs/dentry.c +5 -3
@@ -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; }
fs/unionfs/inode.c +8 -7
@@ -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 ; }
fs/unionfs/lookup.c +3 -2
@@ -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);
fs/unionfs/main.c +4 -4
@@ -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 ;
fs/unionfs/rdstate.c +2 -2
@@ -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); }
fs/unionfs/rename.c +15 -15
@@ -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 ; }
fs/unionfs/sioq.c +1 -1
@@ -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; }
fs/unionfs/subr.c +2 -2
@@ -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 ; } }
fs/unionfs/super.c +4 -4
@@ -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 (); }
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 4/21 Unionfs: Add missing copyright notices
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[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(-)
fs/stack.c +11 -0
@@ -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>
fs/unionfs/sioq.c +0 -5
@@ -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 *
fs/unionfs/sioq.h +13 -0
@@ -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
include/linux/fs_stack.h +11 -0
@@ -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
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 5/21 Unionfs: Cleanup of strings and comments
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
Includes:
- consistent style for multi-line comments
- spell-check of all strings and comments
--- 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(-)
fs/stack.c +4 -2
@@ -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,
fs/unionfs/branchman.c +2 -1
@@ -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
fs/unionfs/commonfops.c +17 -9
@@ -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))
fs/unionfs/copyup.c +29 -17
142 lines not on this page · raw message
fs/unionfs/dentry.c +4 -2
@@ -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);
fs/unionfs/dirfops.c +4 -2
@@ -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 = {
fs/unionfs/dirhelper.c +2 -1
@@ -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 */
fs/unionfs/file.c +1 -1
@@ -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; }
fs/unionfs/inode.c +29 -16
121 lines not on this page · raw message
fs/unionfs/lookup.c +25 -14
@@ -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)
fs/unionfs/main.c +16 -8
@@ -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
fs/unionfs/rdstate.c +10 -5
@@ -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) {
fs/unionfs/rename.c +17 -10
@@ -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);
fs/unionfs/sioq.c +2 -1
@@ -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).
fs/unionfs/sioq.h +1 -1
@@ -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);
fs/unionfs/subr.c +10 -5
@@ -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)
fs/unionfs/super.c +13 -8
@@ -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 ;
fs/unionfs/union.h +11 -6
@@ -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)
fs/unionfs/xattr.c +8 -4
@@ -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)
include/linux/fs_stack.h +2 -1
@@ -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. */
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 6/21 Unionfs: Added numerous comments
In reply to Josef 'Jeff' SipekFrom: 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.
--- 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(-)
fs/unionfs/commonfops.c +4 -3
@@ -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))) {
fs/unionfs/copyup.c +12 -10
@@ -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) {
fs/unionfs/dentry.c +2 -3
@@ -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;
fs/unionfs/file.c +1 -0
@@ -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) {
fs/unionfs/lookup.c +2 -1
@@ -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;
fs/unionfs/main.c +7 -1
@@ -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;
fs/unionfs/rename.c +9 -4
@@ -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) {
fs/unionfs/subr.c +10 -9
@@ -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) {
fs/unionfs/super.c +9 -6
@@ -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)
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 7/21 Unionfs: Consistent pointer declaration spacing
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
Change instances of "foo * var" to "foo *var" for consistency.
--- 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(-)
fs/unionfs/copyup.c +3 -3
@@ -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);
fs/unionfs/file.c +7 -7
@@ -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 ;
fs/unionfs/inode.c +1 -1
@@ -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;
fs/unionfs/super.c +1 -1
@@ -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;
fs/unionfs/xattr.c +2 -2
@@ -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 ;
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 8/21 Unionfs: Rename Unionfs's double_lock_dentry to avoid confusion
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
To avoid potential confusion with a VFS function, rename our version of double_lock_dentry to unionfs_double_lock_dentry.
--- fs/unionfs/inode.c | 2 +- fs/unionfs/rename.c | 2 +- fs/unionfs/union.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-)
fs/unionfs/inode.c +1 -1
@@ -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);
fs/unionfs/rename.c +1 -1
@@ -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);
fs/unionfs/union.h +2 -1
@@ -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;
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 9/21 Unionfs: Rename our "do_rename" to __unionfs_rename
In reply to Josef 'Jeff' SipekFrom: 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.
--- fs/unionfs/rename.c | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)
fs/unionfs/rename.c +11 -10
@@ -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) {
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 10/21 Unionfs: Move unionfs_query_file to commonfops.c
In reply to Josef 'Jeff' SipekMoved 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.
--- 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
fs/unionfs/Makefile +2 -2
@@ -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
fs/unionfs/branchman.c deleted +0 -60
60 lines not on this page · raw message
fs/unionfs/commonfops.c +41 -0
47 lines not on this page · raw message
fs/unionfs/union.h +0 -6
@@ -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);
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 11/21 Unionfs: Combine unionfs_write with __unionfs_write.
In reply to Josef 'Jeff' SipekThe __unionfs_write helper function was used only by unionfs_write, and there is really no reason why they should not be combined.
--- fs/unionfs/file.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-)
fs/unionfs/file.c +10 -20
@@ -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; }
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 12/21 Unionfs: Prefix external functions with 'extern' properly
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
--- fs/unionfs/sioq.h | 1 + fs/unionfs/union.h | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-)
fs/unionfs/sioq.h +1 -0
@@ -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);
fs/unionfs/union.h +25 -25
83 lines not on this page · raw message
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 13/21 Unionfs: Don't leak resources when copyup fails partially
In reply to Josef 'Jeff' Sipek--- fs/unionfs/copyup.c | 24 ++++++++++++++++++++++-- 1 files changed, 22 insertions(+), 2 deletions(-)
fs/unionfs/copyup.c +22 -2
@@ -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; }
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 14/21 Unionfs: Call realloc unconditionally
In reply to Josef 'Jeff' Sipekkrealloc already checks if the new size is greater than the old size. Therefore, we can call realloc unconditionally - making the code simpler and cleaner.
--- fs/unionfs/lookup.c | 26 ++++++++------------------ 1 files changed, 8 insertions(+), 18 deletions(-)
fs/unionfs/lookup.c +8 -18
@@ -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);
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 15/21 Unionfs: Use krealloc instead of open-coding the functionality
In reply to Josef 'Jeff' SipekChange the branch management code to use krealloc instead of playing tricks with kmalloc/memcpy/kfree.
--- fs/unionfs/super.c | 56 +++++++++++++--------------------------------------- 1 files changed, 14 insertions(+), 42 deletions(-)
fs/unionfs/super.c +14 -42
@@ -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; }/*
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 16/21 Unionfs: Disallow setting leftmost branch to readonly
In reply to Josef 'Jeff' SipekFrom: 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).
--- fs/unionfs/super.c | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-)
fs/unionfs/super.c +12 -4
@@ -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 );
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 17/21 Unionfs: Documentation update regarding overlapping branches and new lookup code
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
Added detailed comment and updated documentation to explain why overlapping branches are disallowed, and better explain the cache coherency issues.
--- Documentation/filesystems/unionfs/issues.txt | 16 ++++++++-------- fs/unionfs/main.c | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 9 deletions(-)
Documentation/filesystems/unionfs/issues.txt +8 -8
@@ -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
fs/unionfs/main.c +15 -1
@@ -351,7 +351,21 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_infoBUG_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;
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 18/21 Unionfs: Remove defunct unionfs_put_inode super op
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
Removed old workaround code that was needed to get mmap working, is no longer needed with recent kernels.
--- fs/unionfs/super.c | 20 -------------------- 1 files changed, 0 insertions(+), 20 deletions(-)
fs/unionfs/super.c +0 -20
@@ -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,
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 19/21 Unionfs: Actually catch bad use of unionfs_mnt{get,put}
In reply to Josef 'Jeff' Sipek--- fs/unionfs/union.h | 34 +++++++--------------------------- 1 files changed, 7 insertions(+), 27 deletions(-)
fs/unionfs/union.h +7 -27
@@ -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_ */
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 20/21 Unionfs: Removed a trailing whitespace
In reply to Josef 'Jeff' SipekFrom: Yiannis Pericleous <[email protected]>
--- fs/unionfs/super.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
fs/unionfs/super.c +4 -2
@@ -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
Signature · 1 line
1.5.2.rc1.165.gaf9b
PATCH 21/21 Unionfs: Correctly decrement refcounts of mnt's upon branch management
In reply to Josef 'Jeff' SipekFrom: 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.
--- fs/unionfs/commonfops.c | 17 ++++++++++++----- fs/unionfs/dentry.c | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-)
fs/unionfs/commonfops.c +12 -5
@@ -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 )); } }
fs/unionfs/dentry.c +13 -5
@@ -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 */
Signature · 1 line
1.5.2.rc1.165.gaf9b