Unionfs cleanups and fixes
The following patches consist of mostly cleanups and bug fixes of the Unionfs code.
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 5 new commits:
Erez Zadok (4):
Unionfs: Convert all instances of "hidden" to "lower"
Unionfs: Use file->f_path instead of file->f_dentry
Unionfs: Clarification comment for unionfs_lookup
Unionfs: Remove unnecessary BUG_ON in unionfs_follow_link
Josef 'Jeff' Sipek (1):
Unionfs: Add missing unlock call in unionfs_file_release
Thanks,
Josef 'Jeff' Sipek <[email protected]>
PATCH 1/5 Unionfs: Convert all instances of "hidden" to "lower"
From: Erez Zadok <[email protected]>
The Unionfs code contained many references to symbols whose name had the string "hidden" in it, referring to, for example, a "hidden inode" below the Unionfs inode. The term "hidden" was there for historical reasons and was a misnomer, implying that the objects at Unionfs's lower branches were somehow hidden or unavailable. This was not just incorrect, but confusing. The lower objects are just that: lower. They are not hidden from users. In fact, users can 'cd' to lower branches and manipulate files directly there. This long patch renames all such mis-named symbols, and re-indents the code as needed to comply with coding standards.
--- fs/unionfs/commonfops.c | 174 +++++++++++++------------- fs/unionfs/copyup.c | 210 ++++++++++++++++---------------- fs/unionfs/dentry.c | 26 ++-- fs/unionfs/dirfops.c | 14 +- fs/unionfs/dirhelper.c | 84 +++++++------- fs/unionfs/inode.c | 312 +++++++++++++++++++++++----------------------- fs/unionfs/lookup.c | 140 +++++++++++----------- fs/unionfs/main.c | 170 +++++++++++++------------- fs/unionfs/rdstate.c | 8 +- fs/unionfs/rename.c | 100 ++++++++-------- fs/unionfs/subr.c | 98 ++++++++-------- fs/unionfs/super.c | 38 +++--- fs/unionfs/union.h | 8 +- fs/unionfs/unlink.c | 46 ++++---- fs/unionfs/xattr.c | 24 ++-- 15 files changed, 726 insertions(+), 726 deletions(-)
fs/unionfs/commonfops.c +87 -87
@@ -34,13 +34,13 @@ static int copyup_deleted_file(struct file *file, struct dentry *dentry,int err;struct dentry *tmp_dentry =NULL ; -struct dentry *hidden_dentry; -struct dentry *hidden_dir_dentry =NULL ; +struct dentry *lower_dentry; +struct dentry *lower_dir_dentry =NULL ; - hidden_dentry =unionfs_lower_dentry_idx (dentry, bstart); + lower_dentry =unionfs_lower_dentry_idx (dentry, bstart);sprintf (name,".unionfs%*.*lx" , - i_inosize, i_inosize, hidden_dentry->d_inode->i_ino); + i_inosize, i_inosize, lower_dentry->d_inode->i_ino); retry:/*
@@ -63,7 +63,7 @@ retry:printk (KERN_DEBUG "unionfs: trying to rename %s to %s\n" , dentry->d_name.name, name); - tmp_dentry =lookup_one_len (name, hidden_dentry->d_parent, + tmp_dentry =lookup_one_len (name, lower_dentry->d_parent, nlen);if (IS_ERR (tmp_dentry)) { err =PTR_ERR (tmp_dentry);
@@ -80,10 +80,10 @@ retry: goto out;/* bring it to the same state as an unlinked file */ - hidden_dentry =unionfs_lower_dentry_idx (dentry,dbstart (dentry)); - hidden_dir_dentry =lock_parent (hidden_dentry); - err =vfs_unlink (hidden_dir_dentry->d_inode, hidden_dentry); -unlock_dir (hidden_dir_dentry); + lower_dentry =unionfs_lower_dentry_idx (dentry,dbstart (dentry)); + lower_dir_dentry =lock_parent (lower_dentry); + err =vfs_unlink (lower_dir_dentry->d_inode, lower_dentry); +unlock_dir (lower_dir_dentry); out:return err;
@@ -147,8 +147,8 @@ static void cleanup_file(struct file *file)static int open_all_files (struct file *file) {int bindex, bstart, bend, err =0 ; -struct file *hidden_file; -struct dentry *hidden_dentry; +struct file *lower_file; +struct dentry *lower_dentry;struct dentry *dentry = file->f_dentry;struct super_block *sb = dentry->d_sb;
@@ -156,23 +156,23 @@ static int open_all_files(struct file *file) bend =dbend (dentry);for (bindex = bstart; bindex <= bend; bindex++) { - hidden_dentry =unionfs_lower_dentry_idx (dentry, bindex); -if (!hidden_dentry) + lower_dentry =unionfs_lower_dentry_idx (dentry, bindex); +if (!lower_dentry)continue ; -dget (hidden_dentry); +dget (lower_dentry);unionfs_mntget (dentry, bindex);branchget (sb, bindex); - hidden_file = -dentry_open (hidden_dentry, + lower_file = +dentry_open (lower_dentry,unionfs_lower_mnt_idx (dentry, bindex), file->f_flags); -if (IS_ERR (hidden_file)) { - err =PTR_ERR (hidden_file); +if (IS_ERR (lower_file)) { + err =PTR_ERR (lower_file); goto out; }else -unionfs_set_lower_file_idx (file, bindex, hidden_file); +unionfs_set_lower_file_idx (file, bindex, lower_file); } out:return err;
@@ -182,8 +182,8 @@ out:static int open_highest_file (struct file *file,int willwrite) {int bindex, bstart, bend, err =0 ; -struct file *hidden_file; -struct dentry *hidden_dentry; +struct file *lower_file; +struct dentry *lower_dentry;struct dentry *dentry = file->f_dentry;struct inode *parent_inode = dentry->d_parent->d_inode;
@@ -193,7 +193,7 @@ static int open_highest_file(struct file *file, int willwrite) bstart =dbstart (dentry); bend =dbend (dentry); - hidden_dentry =unionfs_lower_dentry (dentry); + lower_dentry =unionfs_lower_dentry (dentry);if (willwrite &&IS_WRITE_FLAG (file->f_flags) &&is_robranch (dentry)) {for (bindex = bstart -1 ; bindex >=0 ; bindex--) { err = copyup_file(parent_inode, file, bstart, bindex,
@@ -207,21 +207,21 @@ static int open_highest_file(struct file *file, int willwrite) goto out; } -dget (hidden_dentry); +dget (lower_dentry);unionfs_mntget (dentry, bstart);branchget (sb, bstart); - hidden_file =dentry_open (hidden_dentry, -unionfs_lower_mnt_idx (dentry, bstart), - file->f_flags); -if (IS_ERR (hidden_file)) { - err =PTR_ERR (hidden_file); + lower_file =dentry_open (lower_dentry, +unionfs_lower_mnt_idx (dentry, bstart), + file->f_flags); +if (IS_ERR (lower_file)) { + err =PTR_ERR (lower_file); goto out; } -unionfs_set_lower_file (file, hidden_file); +unionfs_set_lower_file (file, lower_file);/* Fix up the position. */ - hidden_file->f_pos = file->f_pos; + lower_file->f_pos = file->f_pos; -memcpy (&hidden_file->f_ra, &file->f_ra,sizeof (struct file_ra_state )); +memcpy (&lower_file->f_ra, &file->f_ra,sizeof (struct file_ra_state )); out:return err; }
@@ -364,29 +364,29 @@ out_nofree:/* unionfs_open helper function: open a directory */ static int __open_dir (struct inode *inode,struct file *file) { -struct dentry *hidden_dentry; -struct file *hidden_file; +struct dentry *lower_dentry; +struct file *lower_file;int bindex, bstart, bend; bstart =fbstart (file) =dbstart (file->f_dentry); bend =fbend (file) =dbend (file->f_dentry);for (bindex = bstart; bindex <= bend; bindex++) { - hidden_dentry = + lower_dentry =unionfs_lower_dentry_idx (file->f_dentry, bindex); -if (!hidden_dentry) +if (!lower_dentry)continue ; -dget (hidden_dentry); +dget (lower_dentry);unionfs_mntget (file->f_dentry, bindex); - hidden_file =dentry_open (hidden_dentry, -unionfs_lower_mnt_idx (file->f_dentry, + lower_file =dentry_open (lower_dentry, +unionfs_lower_mnt_idx (file->f_dentry, bindex), - file->f_flags); -if (IS_ERR (hidden_file)) -return PTR_ERR (hidden_file); + file->f_flags); +if (IS_ERR (lower_file)) +return PTR_ERR (lower_file); -unionfs_set_lower_file_idx (file, bindex, hidden_file); +unionfs_set_lower_file_idx (file, bindex, lower_file);/* * The branchget goes after the open, because otherwise
@@ -401,27 +401,27 @@ static int __open_dir(struct inode *inode, struct file *file)/* unionfs_open helper function: open a file */ static int __open_file (struct inode *inode,struct file *file) { -struct dentry *hidden_dentry; -struct file *hidden_file; -int hidden_flags; +struct dentry *lower_dentry; +struct file *lower_file; +int lower_flags;int bindex, bstart, bend; - hidden_dentry =unionfs_lower_dentry (file->f_dentry); - hidden_flags = file->f_flags; + lower_dentry =unionfs_lower_dentry (file->f_dentry); + lower_flags = file->f_flags; 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 lower file. If the error is * COPYUP_ERR, copyup the file. */ -if (hidden_dentry->d_inode &&is_robranch (file->f_dentry)) { +if (lower_dentry->d_inode &&is_robranch (file->f_dentry)) {/* * if the open will change the file, copy it up otherwise * defer it. */ -if (hidden_flags &O_TRUNC ) { +if (lower_flags &O_TRUNC ) {int size =0 ;int err = -EROFS ;
@@ -435,24 +435,24 @@ static int __open_file(struct inode *inode, struct file *file) }return err; }else - hidden_flags &= ~(OPEN_WRITE_FLAGS ); + lower_flags &= ~(OPEN_WRITE_FLAGS ); } -dget (hidden_dentry); +dget (lower_dentry);/* * 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); - hidden_file = -dentry_open (hidden_dentry, + lower_file = +dentry_open (lower_dentry,unionfs_lower_mnt_idx (file->f_dentry, bstart), - hidden_flags); -if (IS_ERR (hidden_file)) -return PTR_ERR (hidden_file); + lower_flags); +if (IS_ERR (lower_file)) +return PTR_ERR (lower_file); -unionfs_set_lower_file (file, hidden_file); +unionfs_set_lower_file (file, lower_file);branchget (inode->i_sb, bstart);return 0 ;
@@ -461,7 +461,7 @@ static int __open_file(struct inode *inode, struct file *file)int unionfs_open (struct inode *inode,struct file *file) {int err =0 ; -struct file *hidden_file =NULL ; +struct file *lower_file =NULL ;struct dentry *dentry =NULL ;int bindex =0 , bstart =0 , bend =0 ;int size;
@@ -503,7 +503,7 @@ int unionfs_open(struct inode *inode, struct file *file)/* * open all directories and make the unionfs file struct point to -* these hidden file structs +* these lower file structs */ if (S_ISDIR (inode->i_mode)) err =__open_dir (inode, file);/* open a dir */
@@ -514,13 +514,13 @@ int unionfs_open(struct inode *inode, struct file *file)if (err) {atomic_dec (&UNIONFS_I (dentry->d_inode)->totalopens);for (bindex = bstart; bindex <= bend; bindex++) { - hidden_file =unionfs_lower_file_idx (file, bindex); -if (!hidden_file) + lower_file =unionfs_lower_file_idx (file, bindex); +if (!lower_file)continue ;branchput (file->f_dentry->d_sb, bindex); -/* fput calls dput for hidden_dentry */ -fput (hidden_file); +/* fput calls dput for lower_dentry */ +fput (lower_file); } }
@@ -544,7 +544,7 @@ out_nofree:*/ int unionfs_file_release (struct inode *inode,struct file *file) { -struct file *hidden_file =NULL ; +struct file *lower_file =NULL ;struct unionfs_file_info *fileinfo;struct unionfs_inode_info *inodeinfo;struct super_block *sb = inode->i_sb;
@@ -564,16 +564,16 @@ int unionfs_file_release(struct inode *inode, struct file *file)BUG_ON (file->f_dentry->d_inode != inode); inodeinfo =UNIONFS_I (inode); -/* fput all the hidden files */ +/* fput all the lower files */ fgen =atomic_read (&fileinfo->generation); bstart =fbstart (file); bend =fbend (file);for (bindex = bstart; bindex <= bend; bindex++) { - hidden_file =unionfs_lower_file_idx (file, bindex); + lower_file =unionfs_lower_file_idx (file, bindex); -if (hidden_file) { -fput (hidden_file); +if (lower_file) { +fput (lower_file);branchput (inode->i_sb, bindex); } }
@@ -602,24 +602,24 @@ int unionfs_file_release(struct inode *inode, struct file *file)/* pass the ioctl to the lower fs */ static long do_ioctl (struct file *file,unsigned int cmd,unsigned long arg) { -struct file *hidden_file; +struct file *lower_file;int err; - hidden_file =unionfs_lower_file (file); + lower_file =unionfs_lower_file (file); - err =security_file_ioctl (hidden_file, cmd, arg); + err =security_file_ioctl (lower_file, cmd, arg);if (err) goto out; err = -ENOTTY ; -if (!hidden_file || !hidden_file->f_op) +if (!lower_file || !lower_file->f_op) goto out; -if (hidden_file->f_op->unlocked_ioctl) { - err = hidden_file->f_op->unlocked_ioctl (hidden_file, cmd, arg); - }else if (hidden_file->f_op->ioctl) { +if (lower_file->f_op->unlocked_ioctl) { + err = lower_file->f_op->unlocked_ioctl (lower_file, cmd, arg); + }else if (lower_file->f_op->ioctl) {lock_kernel (); - err = hidden_file->f_op->ioctl (hidden_file->f_dentry->d_inode, - hidden_file, cmd, arg); + err = lower_file->f_op->ioctl (lower_file->f_dentry->d_inode, + lower_file, cmd, arg);unlock_kernel (); }
@@ -640,7 +640,7 @@ static int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,fd_set branchlist;int bstart =0 , bend =0 , bindex =0 ; -struct dentry *dentry, *hidden_dentry; +struct dentry *dentry, *lower_dentry; dentry = file->f_dentry;unionfs_lock_dentry (dentry);
@@ -652,10 +652,10 @@ static int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,FD_ZERO (&branchlist);for (bindex = bstart; bindex <= bend; bindex++) { - hidden_dentry =unionfs_lower_dentry_idx (dentry, bindex); -if (!hidden_dentry) + lower_dentry =unionfs_lower_dentry_idx (dentry, bindex); +if (!lower_dentry)continue ; -if (hidden_dentry->d_inode) +if (lower_dentry->d_inode)FD_SET (bindex, &branchlist); }
@@ -705,7 +705,7 @@ out:int unionfs_flush (struct file *file,fl_owner_t id) {int err =0 ; -struct file *hidden_file =NULL ; +struct file *lower_file =NULL ;struct dentry *dentry = file->f_dentry;int bindex, bstart, bend;
@@ -722,11 +722,11 @@ int unionfs_flush(struct file *file, fl_owner_t id) bstart =fbstart (file); bend =fbend (file);for (bindex = bstart; bindex <= bend; bindex++) { - hidden_file =unionfs_lower_file_idx (file, bindex); + lower_file =unionfs_lower_file_idx (file, bindex); -if (hidden_file && hidden_file->f_op && - hidden_file->f_op->flush) { - err = hidden_file->f_op->flush (hidden_file, id); +if (lower_file && lower_file->f_op && + lower_file->f_op->flush) { + err = lower_file->f_op->flush (lower_file, id);if (err) goto out_lock;
fs/unionfs/copyup.c +105 -105
507 lines not on this page · raw message
fs/unionfs/dentry.c +13 -13
@@ -29,7 +29,7 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, struct nameidata *nd) {int valid =1 ;/* default is valid (1); invalid is 0. */ -struct dentry *hidden_dentry; +struct dentry *lower_dentry;int bindex, bstart, bend;int sbgen, dgen;int positive =0 ;
@@ -78,12 +78,12 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, bstart =dbstart (dentry); bend =dbend (dentry);if (bstart >=0 ) { -struct dentry *hidden_dentry; +struct dentry *lower_dentry;for (bindex = bstart; bindex <= bend; bindex++) { - hidden_dentry = + lower_dentry =unionfs_lower_dentry_idx (dentry, bindex); -dput (hidden_dentry); +dput (lower_dentry); } }set_dbstart (dentry,-1 );
@@ -106,14 +106,14 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, bstart =ibstart (dentry->d_inode); bend =ibend (dentry->d_inode);if (bstart >=0 ) { -struct inode *hidden_inode; +struct inode *lower_inode;for (bindex = bstart; bindex <= bend; bindex++) { - hidden_inode = + lower_inode =unionfs_lower_inode_idx ( dentry->d_inode, bindex); -iput (hidden_inode); +iput (lower_inode); } }kfree (UNIONFS_I (dentry->d_inode)->lower_inodes);
@@ -153,11 +153,11 @@ static int __unionfs_d_revalidate_one(struct dentry *dentry, bend =dbend (dentry);BUG_ON (bstart ==-1 );for (bindex = bstart; bindex <= bend; bindex++) { - hidden_dentry =unionfs_lower_dentry_idx (dentry, bindex); -if (!hidden_dentry || !hidden_dentry->d_op - || !hidden_dentry->d_op->d_revalidate) + lower_dentry =unionfs_lower_dentry_idx (dentry, bindex); +if (!lower_dentry || !lower_dentry->d_op + || !lower_dentry->d_op->d_revalidate)continue ; -if (!hidden_dentry->d_op->d_revalidate (hidden_dentry, +if (!lower_dentry->d_op->d_revalidate (lower_dentry, &lowernd)) valid =0 ; }
@@ -318,13 +318,13 @@ static void unionfs_d_release(struct dentry *dentry) goto out; }else if (dbstart (dentry) <0 ) {/* this is due to a failed lookup */ -printk (KERN_DEBUG "unionfs: dentry without hidden " +printk (KERN_DEBUG "unionfs: dentry without lower " "dentries: %.*s" , dentry->d_name.len, dentry->d_name.name); goto out_free; } -/* Release all the hidden dentries */ +/* Release all the lower dentries */ bstart =dbstart (dentry); bend =dbend (dentry);for (bindex = bstart; bindex <= bend; bindex++) {
fs/unionfs/dirfops.c +7 -7
@@ -90,7 +90,7 @@ out:static int unionfs_readdir (struct file *file,void *dirent,filldir_t filldir) {int err =0 ; -struct file *hidden_file =NULL ; +struct file *lower_file =NULL ;struct inode *inode =NULL ;struct unionfs_getdents_callback buf;struct unionfs_dir_state *uds;
@@ -123,8 +123,8 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir) bend =fbend (file);while (uds->bindex <= bend) { - hidden_file =unionfs_lower_file_idx (file, uds->bindex); -if (!hidden_file) { + lower_file =unionfs_lower_file_idx (file, uds->bindex); +if (!lower_file) { uds->bindex++; uds->dirpos =0 ;continue ;
@@ -140,15 +140,15 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir) buf.sb = inode->i_sb;/* Read starting from where we last left off. */ - offset =vfs_llseek (hidden_file, uds->dirpos,SEEK_SET ); + offset =vfs_llseek (lower_file, uds->dirpos,SEEK_SET );if (offset <0 ) { err = offset; goto out; } - err =vfs_readdir (hidden_file, unionfs_filldir, &buf); + err =vfs_readdir (lower_file, unionfs_filldir, &buf);/* Save the position for when we continue. */ - offset =vfs_llseek (hidden_file,0 ,SEEK_CUR ); + offset =vfs_llseek (lower_file,0 ,SEEK_CUR );if (offset <0 ) { err = offset; goto out;
@@ -156,7 +156,7 @@ static int unionfs_readdir(struct file *file, void *dirent, filldir_t filldir) uds->dirpos = offset;/* Copy the atime. */ -fsstack_copy_attr_atime (inode, hidden_file->f_dentry->d_inode); +fsstack_copy_attr_atime (inode, lower_file->f_dentry->d_inode);if (err <0 ) goto out;
fs/unionfs/dirhelper.c +42 -42
169 lines not on this page · raw message
fs/unionfs/inode.c +156 -156
719 lines not on this page · raw message
fs/unionfs/lookup.c +70 -70
283 lines not on this page · raw message
fs/unionfs/main.c +85 -85
395 lines not on this page · raw message
fs/unionfs/rdstate.c +4 -4
@@ -64,7 +64,7 @@ void unionfs_destroy_filldir_cache(void)#define MINHASHSIZE 1static int guesstimate_hash_size (struct inode *inode) { -struct inode *hidden_inode; +struct inode *lower_inode;int bindex;int hashsize =MINHASHSIZE ;
@@ -72,13 +72,13 @@ static int guesstimate_hash_size(struct inode *inode)return UNIONFS_I (inode)->hashsize;for (bindex =ibstart (inode); bindex <=ibend (inode); bindex++) { -if (!(hidden_inode =unionfs_lower_inode_idx (inode, bindex))) +if (!(lower_inode =unionfs_lower_inode_idx (inode, bindex)))continue ; -if (hidden_inode->i_size ==DENTPAGE ) +if (lower_inode->i_size ==DENTPAGE ) hashsize +=DENTPERONEPAGE ;else - hashsize += (hidden_inode->i_size /DENTPAGE ) * + hashsize += (lower_inode->i_size /DENTPAGE ) *DENTPERPAGE ; }
fs/unionfs/rename.c +50 -50
207 lines not on this page · raw message
fs/unionfs/subr.c +49 -49
207 lines not on this page · raw message
fs/unionfs/super.c +19 -19
@@ -188,7 +188,7 @@ static noinline int do_remount_mode_option(char *optarg, int cur_branches, err =path_lookup (optarg,LOOKUP_FOLLOW , &nd);if (err) {
Lines of this file are not shown. View the raw message.
fs/unionfs/unlink.c +23 -23
46 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.5.2.2.238.g7cbf2f2
Part of the diff is not shown here. View the raw message.
PATCH 2/5 Unionfs: Add missing unlock call in unionfs_file_release
In reply to Josef 'Jeff' Sipek--- fs/unionfs/commonfops.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
fs/unionfs/commonfops.c +4 -2
@@ -559,7 +559,7 @@ int unionfs_file_release(struct inode *inode, struct file *file)* support. */ if ((err =unionfs_file_revalidate (file,1 ))) -return err; + goto out; fileinfo =UNIONFS_F (file);BUG_ON (file->f_dentry->d_inode != inode); inodeinfo =UNIONFS_I (inode);
@@ -596,7 +596,9 @@ int unionfs_file_release(struct inode *inode, struct file *file) fileinfo->rdstate =NULL ; }kfree (fileinfo); -return 0 ; +out: +unionfs_read_unlock (sb); +return err; }/* pass the ioctl to the lower fs */
Signature · 1 line
1.5.2.2.238.g7cbf2f2
PATCH 3/5 Unionfs: Use file->f_path instead of file->f_dentry
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
--- fs/unionfs/commonfops.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
fs/unionfs/commonfops.c +3 -3
@@ -708,10 +708,10 @@ int unionfs_flush(struct file *file, fl_owner_t id) {int err =0 ;struct file *lower_file =NULL ; -struct dentry *dentry = file->f_dentry; +struct dentry *dentry = file->f_path.dentry;int bindex, bstart, bend; -unionfs_read_lock (file->f_path.dentry->d_sb); +unionfs_read_lock (dentry->d_sb);if ((err =unionfs_file_revalidate (file,1 ))) goto out;
@@ -745,6 +745,6 @@ int unionfs_flush(struct file *file, fl_owner_t id) out_lock:unionfs_unlock_dentry (dentry); out: -unionfs_read_unlock (file->f_path.dentry->d_sb); +unionfs_read_unlock (dentry->d_sb);return err; }
Signature · 1 line
1.5.2.2.238.g7cbf2f2
PATCH 4/5 Unionfs: Clarification comment for unionfs_lookup
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
--- fs/unionfs/inode.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
fs/unionfs/inode.c +5 -0
@@ -217,6 +217,11 @@ out:return err; } +/* +* unionfs_lookup is the only special function which takes a dentry, yet we +* do NOT want to call __unionfs_d_revalidate_chain because by definition, +* we don't have a valid dentry here yet. +*/ static struct dentry *unionfs_lookup (struct inode *parent,struct dentry *dentry,struct nameidata *nd)
Signature · 1 line
1.5.2.2.238.g7cbf2f2
PATCH 5/5 Unionfs: Remove unnecessary BUG_ON in unionfs_follow_link
In reply to Josef 'Jeff' SipekFrom: Erez Zadok <[email protected]>
--- fs/unionfs/inode.c | 30 ++++++++---------------------- 1 files changed, 8 insertions(+), 22 deletions(-)
fs/unionfs/inode.c +8 -22
@@ -832,35 +832,21 @@ out: }/* -* Check if dentry is valid or not, as per our generation numbers. -* @dentry: dentry to check. -* Returns 1 (valid) or 0 (invalid/stale). +* unionfs_follow_link takes a dentry, but it is simple. It only needs to +* allocate some memory and then call our ->readlink method. Our +* unionfs_readlink *does* lock our dentry and revalidate the dentry. +* Therefore, we do not have to lock our dentry here, to prevent a deadlock; +* nor do we need to revalidate it either. It is safe to not lock our +* dentry here, nor revalidate it, because unionfs_follow_link does not do +* anything (prior to calling ->readlink) which could become inconsistent +* due to branch management. */ -static inline int is_valid_dentry (struct dentry *dentry) -{ -BUG_ON (!UNIONFS_D (dentry)); -BUG_ON (!UNIONFS_SB (dentry->d_sb)); -return (atomic_read (&UNIONFS_D (dentry)->generation) == -atomic_read (&UNIONFS_SB (dentry->d_sb)->generation)); -} - -/* We don't lock the dentry here, because readlink does the heavy lifting. */ static void *unionfs_follow_link (struct dentry *dentry,struct nameidata *nd) {char *buf;int len =PAGE_SIZE , err;mm_segment_t old_fs; -/* -* FIXME: Really nasty...we can get called from two distinct places: -* 1) read_link - locks the dentry -* 2) VFS lookup code - does NOT lock the dentry -* -* The proper thing would be to call dentry revalidate. It however -* expects a locked dentry, and we can't cleanly guarantee that. -*/ -BUG_ON (!is_valid_dentry (dentry)); -unionfs_read_lock (dentry->d_sb);/* This is freed by the put_link method assuming a successful call. */
Signature · 1 line
1.5.2.2.238.g7cbf2f2