removed odf locks, added LOCK comments where we might still want to
authorYiannis Pericleous <yiannos@agora2.fsl.cs.sunysb.edu>
Fri, 25 May 2007 16:41:48 +0000 (12:41 -0400)
committerRachita Kothiyal <rachita@dewey.fsl.cs.sunysb.edu>
Thu, 1 May 2008 23:02:34 +0000 (19:02 -0400)
lock something, ie when operating in odf/ic /sr and /reclaim

fs/unionfs/dirhelper.c
fs/unionfs/odf.c
fs/unionfs/odf.h
fs/unionfs/union.h

index b8cf4bf782eaa3f5ab1fe8303952a6973e8cccb8..040e4e422a58a4f3a69e5b0c638dc5623a59372b 100644 (file)
@@ -308,7 +308,6 @@ int odf_cache_dir(struct dentry *d_upper, struct dentry *d_odf, struct timespec
                goto out_sb;
 
 retry:
-       odf_lock(UNIONFS_SB(sb)->odf->odi_ic);
        BUG_ON(!S_ISDIR(d_upper->d_inode->i_mode));
 
        i_odf = d_odf->d_inode;
@@ -360,7 +359,7 @@ retry:
        }
 
        /* lock to prevent concurrent writes */
-       odf_lock(UNIONFS_D(d_upper)->odf_info);
+       /* LOCK: need to lock ic? */
        /* Process the hidden directories with rdutil_callback as a filldir. */
        for (bindex = bstart; bindex <= bend; bindex++) {
                hidden_dentry = unionfs_lower_dentry_idx(d_upper, bindex);
@@ -380,7 +379,7 @@ retry:
                        err = PTR_ERR(hidden_file);
                        dput(hidden_dentry);
                        branchput(sb, bindex);
-                       goto out_unlock;
+                       goto out;
                }
 
                do {
@@ -399,9 +398,8 @@ retry:
                branchput(sb, bindex);
 
                if (err < 0)
-                       goto out_unlock;
+                       goto out;
        }
-       odf_unlock(UNIONFS_D(d_upper)->odf_info);
 
        /* set mtime of odf file to that of higher file */
        attr.ia_mtime = *mtime;
@@ -409,9 +407,6 @@ retry:
        err = notify_change(d_odf, &attr);
        goto out;
 
-out_unlock:
-       odf_unlock(UNIONFS_D(d_upper)->odf_info);
-
 out:
        if (buf && buf->rdstate)
                free_rdstate(buf->rdstate);
@@ -422,8 +417,6 @@ out:
                filp_close(odf_file, NULL);
        odf_file = NULL;
 
-       odf_unlock(UNIONFS_SB(sb)->odf->odi_ic);
-
        if (err == -ENOSPC && !cleaned) {
                cleaned = 1;
                wake_up_and_wait_sioa(UNIONFS_SB(sb)->odf->cleanup);
index 7a45279dc18f31d5e3e7e19477d9ffb5d54f2847..617e3ddf8ccdfb114d1d239ef398f863cf0a4221 100644 (file)
@@ -333,8 +333,6 @@ int odf_reclaim(struct dentry *dentry, int sr)
                goto out;
        }
        sprintf(new_name, "%lu", odf_dentry->d_inode->i_ino);
-       /* lock new dir, the old dir should already be locked */
-       odf_lock(odi);
 
        old_dentry = odf_dentry;
        old_dir = odf_dentry->d_parent->d_inode;
@@ -342,7 +340,7 @@ int odf_reclaim(struct dentry *dentry, int sr)
        new_dentry = lookup_one_len(new_name, odi->dentry, strlen(new_name));
        if (IS_ERR(new_dentry)) {
                err = PTR_ERR(new_dentry);
-               goto out_unlock;
+               goto out;
        }
 
        lock_rename(old_dentry->d_parent, new_dentry->d_parent);
@@ -350,9 +348,6 @@ int odf_reclaim(struct dentry *dentry, int sr)
        unlock_rename(old_dentry->d_parent, new_dentry->d_parent);
        dput(new_dentry);
 
-out_unlock:
-       odf_unlock(odi); /* unlock new dir */
-
 out:
        kfree(new_name);
        return err;
@@ -379,8 +374,7 @@ int odf_release_sr(struct inode *inode)
        }
        sprintf(name, "%lu", inode->i_ino);
 
-       odf_lock(odi_sr);
-       odf_lock(odi_rc);
+       /* LOCK: need to lock sr? */
 
        /* check for an entry in /odf/sr */
        old_dentry = lookup_one_len(name, odi_sr->dentry, strlen(name));
@@ -410,8 +404,6 @@ int odf_release_sr(struct inode *inode)
        unlock_rename(old_dentry->d_parent, new_dentry->d_parent);
 
 out_unlock:
-       odf_unlock(odi_rc);
-       odf_unlock(odi_sr);
        dput(old_dentry);
        dput(new_dentry);
 out:
@@ -449,9 +441,6 @@ int odf_rename(struct dentry *old_dentry, struct dentry *new_dentry)
        if (UNIONFS_D(new_dentry)->odf_info)
                err = odf_remove(new_dentry, ODF_RMV_ANY);
 
-       odf_lock(UNIONFS_D(old_dentry)->odf_info);
-       odf_lock(UNIONFS_D(new_dentry->d_parent)->odf_info);
-
        old_odfdentry = UNIONFS_D(old_dentry)->odf_info->dentry;
        old_dir = old_odfdentry->d_parent;
        new_dir = (UNIONFS_D(new_dentry->d_parent))->odf_info->dentry;
@@ -479,8 +468,6 @@ int odf_rename(struct dentry *old_dentry, struct dentry *new_dentry)
        dput(new_odfdentry);
 
 out_unlock:
-       odf_unlock(UNIONFS_D(old_dentry)->odf_info);
-       odf_unlock(UNIONFS_D(new_dentry->d_parent)->odf_info);
        err = odf_lookup(old_dentry->d_parent, old_dentry, 0);
 out:
        return err;
@@ -507,8 +494,6 @@ int odf_link(struct dentry *old_dentry, struct dentry *new_dentry)
        if (UNIONFS_D(new_dentry)->odf_info)
                err = odf_remove(new_dentry, ODF_RMV_ANY);
 
-       odf_lock(UNIONFS_D(old_dentry)->odf_info);
-       odf_lock(UNIONFS_D(new_dentry->d_parent)->odf_info);
        old_odfdentry = UNIONFS_D(old_dentry)->odf_info->dentry;
        old_dir = old_odfdentry->d_parent;
        new_dir = (UNIONFS_D(new_dentry->d_parent))->odf_info->dentry;
@@ -518,7 +503,7 @@ int odf_link(struct dentry *old_dentry, struct dentry *new_dentry)
                                new_dentry->d_name.len);
        if (IS_ERR(new_odfdentry)) {
                err = PTR_ERR(new_odfdentry);
-               goto out_unlock;
+               goto out;
        }
 
        /* this should never happen */
@@ -531,9 +516,6 @@ int odf_link(struct dentry *old_dentry, struct dentry *new_dentry)
        current->fsgid = oldgid;
 
        dput(new_odfdentry);
-out_unlock:
-       odf_unlock(UNIONFS_D(old_dentry)->odf_info);
-       odf_unlock(UNIONFS_D(new_dentry->d_parent)->odf_info);
 out:
        return err;
 }
@@ -808,8 +790,6 @@ skip:
        if (branch_dst >= 0)
                dst_ro = is_robranch_super(dentry->d_sb, branch_dst);
 
-       odf_lock(UNIONFS_D(dentry->d_parent)->odf_info);
-
        /* case 0:
         * - dest branch id has changed because of remounts
         * - do not copyup, remove copyup info from link info file
@@ -825,7 +805,7 @@ skip:
                if (err != sizeof(__le32)){
                        set_fs(oldfs);
                        err = -EIO;
-                       goto out_unlock;
+                       goto out;
                }
 
                le64 = 0;
@@ -834,7 +814,7 @@ skip:
                if (err != sizeof(__le64)){
                        set_fs(oldfs);
                        err = -EIO;
-                       goto out_unlock;
+                       goto out;
                }
 
                set_fs(oldfs);
@@ -860,7 +840,7 @@ skip:
                if (!lower_dentry || IS_ERR(lower_dentry)) {
                        if (IS_ERR(lower_dentry))
                                err = PTR_ERR(lower_dentry);
-                       goto out_unlock;
+                       goto out;
                }
                /* now link */
        }
@@ -891,10 +871,6 @@ skip:
                ;
        }
 
-
-out_unlock:
-       odf_unlock(UNIONFS_D(dentry->d_parent)->odf_info);
-       goto out;
 out_fs:
        set_fs(oldfs);
 out:
@@ -1050,14 +1026,6 @@ struct odf_dentry_info *__odf_lookup(struct odf_sb_info *osi,
                        BUG_ON(len==1 || (name[1]=='.'&&len==2));
 retry:
                /* FIXME need to check hardlinks before create */
-               if (!(flags & ODF_LOOKUP_LOCKED)){
-                       if (osi->odi_ic != parent)
-                               odf_lock(osi->odi_ic);
-                       odf_lock(parent); /* lock parent */
-               }
-               else if (cleaned)
-                       odf_lock(osi->odi_ic);
-
                if (link && (flags & (ODF_LOOKUP_FILE | ODF_LOOKUP_LINK))) {
                        /* link to the given dentry */
                        vfs_link(link, odf_dentry->d_parent->d_inode, odf_dentry);
@@ -1079,22 +1047,10 @@ retry:
                }
                else {
                        dput(odf_dentry);
-                       if (!(flags & ODF_LOOKUP_LOCKED)){
-                               odf_unlock(parent);
-                               if (osi->odi_ic != parent)
-                                       odf_unlock(osi->odi_ic);
-                       }
                        odf_put_info(old_odi);
                        odi = NULL;
                        goto out;
                }
-               if (!(flags & ODF_LOOKUP_LOCKED)){
-                       odf_unlock(parent);
-                       if (osi->odi_ic != parent)
-                               odf_unlock(osi->odi_ic);
-               }
-               else if (cleaned)
-                       odf_unlock(osi->odi_ic);
 
                current->fsuid = olduid;
                current->fsgid = oldgid;
@@ -1102,8 +1058,6 @@ retry:
                if (err) {
                        if (err == -ENOSPC && !cleaned) {
                                /* let the cleanup thread do its work and retry once */
-                               if (flags & ODF_LOOKUP_LOCKED)
-                                       odf_unlock(osi->odi_ic);
                                cleaned = 1;
                                wake_up_and_wait_sioa(osi->cleanup);
                                goto retry;
@@ -1439,7 +1393,6 @@ int odf_remove(struct dentry *dentry, int flags)
                goto out;
 
        odf_dir = UNIONFS_D(dentry->d_parent)->odf_info;
-       odf_lock(odf_dir);
 
        /* remove */
        current->fsuid = 0;
@@ -1458,13 +1411,11 @@ int odf_remove(struct dentry *dentry, int flags)
        current->fsuid = olduid;
        current->fsgid = oldgid;
        if (err)
-               goto out_unlock;
+               goto out;
 
        /* clean up */
        odf_put_info(odi);
        UNIONFS_D(dentry)->odf_info = NULL;
-out_unlock:
-       odf_unlock(odf_dir);
 out:
        return err;
 }
@@ -1902,7 +1853,6 @@ struct odf_dentry_info *odf_alloc_info(struct odf_sb_info *osi, struct dentry *o
        odi->inum = odf_dentry->d_inode->i_ino;
        odi->osi = osi;
        dget(odf_dentry);
-       mutex_init(&odi->lock);
        return odi;
 }
 struct odf_dentry_info *odf_fill_info(struct odf_dentry_info *odi, struct odf_sb_info *osi, struct dentry *odf_dentry)
@@ -1946,8 +1896,7 @@ void __odf_cleanup(void *args)
        /* update timeout */
        sioa_args->timeout = msecs_to_jiffies(cl->attr->timeout->val * 1000);
 
-       odf_lock(cl->odf->odi_ic);
-       odf_lock(cl->odf->odi_rc);
+       /* LOCK: need to lock ic/reclaim/sr? */
 
        vfs_statfs(cl->odf->sb, &stat);
        if (cl->force) {
@@ -1977,6 +1926,4 @@ void __odf_cleanup(void *args)
                }
                cl->success = err;
        }
-       odf_unlock(cl->odf->odi_ic);
-       odf_unlock(cl->odf->odi_rc);
 }
index 0301ba4700b6f68beb52e07449b31a75b6ba474e..ece557e5f969ee65c67179799558dbb97414c6ac 100644 (file)
@@ -108,17 +108,6 @@ int __odf_set_opaque(struct dentry *d, int branch);
 extern void __odf_cleanup(void *args);
 int odf_cleanup(struct odf_sb_info *odf, int mode, u64 size);
 
-/* Macros for locking an odf dentry info. */
-static inline void odf_lock(struct odf_dentry_info *odi)
-{
-       mutex_lock(&odi->lock);
-}
-
-static inline void odf_unlock(struct odf_dentry_info *odi)
-{
-       mutex_unlock(&odi->lock);
-}
-
 extern void generate_random_uuid(unsigned char uuid_out[16]);
 
 #endif /* _ODF_H_ */
index 0c7ebc7bb2909ca699bdcacb25bd4ba6c313bc77..47b90a88c840ce3c5f844eea4ef39cc06f7c9342 100644 (file)
@@ -95,7 +95,6 @@ struct odf_dentry_info {
         * the data in the odf file. Right now i keep a dentry for easy
         * lookup in the underlying ext2
         */
-       struct mutex lock;
        u64 inum;
        int whiteout;
        int opaque;