ANDROID: sdcardfs: Use d_invalidate instead of drop_recurisve
authorDaniel Rosenberg <drosen@google.com>
Thu, 9 Mar 2017 01:45:46 +0000 (17:45 -0800)
committerStricted <info@stricted.net>
Thu, 11 Oct 2018 16:03:28 +0000 (18:03 +0200)
drop_recursive did not properly remove stale dentries.
Instead, we use the vfs's d_invalidate, which does the proper cleanup.

Additionally, remove the no longer used drop_recursive, and
fixup_top_recursive that that are no longer used.

Signed-off-by: Daniel Rosenberg <drosen@google.com>
Change-Id: Ibff61b0c34b725b024a050169047a415bc90f0d8

fs/sdcardfs/derived_perm.c
fs/sdcardfs/inode.c
fs/sdcardfs/sdcardfs.h

index f9232b1d97c61d7b8c3b9baf10ef2fec9792fb48..4a3e9348bac7d78a226b683174d50314177eafdb 100644 (file)
@@ -296,44 +296,6 @@ void fixup_perms_recursive(struct dentry *dentry, struct limit_search *limit) {
        __fixup_perms_recursive(dentry, limit, 0);
 }
 
-void drop_recursive(struct dentry *parent) {
-       struct dentry *dentry;
-       struct sdcardfs_inode_info *info;
-       if (!parent->d_inode)
-               return;
-       info = SDCARDFS_I(parent->d_inode);
-       spin_lock(&parent->d_lock);
-       list_for_each_entry(dentry, &parent->d_subdirs, d_u.d_child) {
-               if (dentry->d_inode) {
-                       if (SDCARDFS_I(parent->d_inode)->top != SDCARDFS_I(dentry->d_inode)->top) {
-                               drop_recursive(dentry);
-                               d_drop(dentry);
-                       }
-               }
-       }
-       spin_unlock(&parent->d_lock);
-}
-
-void fixup_top_recursive(struct dentry *parent) {
-       struct dentry *dentry;
-       struct sdcardfs_inode_info *info;
-
-       if (!parent->d_inode)
-               return;
-       info = SDCARDFS_I(parent->d_inode);
-       spin_lock(&parent->d_lock);
-       list_for_each_entry(dentry, &parent->d_subdirs, d_u.d_child) {
-               if (dentry->d_inode) {
-                       if (SDCARDFS_I(parent->d_inode)->top != SDCARDFS_I(dentry->d_inode)->top) {
-                               get_derived_permission(parent, dentry);
-                               fixup_tmp_permissions(dentry->d_inode);
-                               fixup_top_recursive(dentry);
-                       }
-               }
-       }
-       spin_unlock(&parent->d_lock);
-}
-
 /* main function for updating derived permission */
 inline void update_derived_permission_lock(struct dentry *dentry)
 {
index 4382917942da453d96a2a9584b4ef9aa66a44dca..d7967cc6d383c2a4fffc763bf6c35bdcd123276a 100644 (file)
@@ -528,7 +528,7 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        get_derived_permission_new(new_dentry->d_parent, old_dentry, &new_dentry->d_name);
        fixup_tmp_permissions(old_dentry->d_inode);
        fixup_lower_ownership(old_dentry, new_dentry->d_name.name);
-       drop_recursive(old_dentry); /* Can't fixup ownership recursively :( */
+       d_invalidate(old_dentry); /* Can't fixup ownership recursively :( */
 out:
        unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
        dput(lower_old_dir_dentry);
index 00bbfd6f8ddcdb867f117162b0913c8468de2c97..2caee49aa8ec9f66c42f7ac6bf1352f05f2a80e2 100644 (file)
@@ -478,8 +478,6 @@ extern void setup_derived_state(struct inode *inode, perm_t perm, userid_t useri
                        uid_t uid, bool under_android, struct inode *top);
 extern void get_derived_permission(struct dentry *parent, struct dentry *dentry);
 extern void get_derived_permission_new(struct dentry *parent, struct dentry *dentry, const struct qstr *name);
-extern void drop_recursive(struct dentry *parent);
-extern void fixup_top_recursive(struct dentry *parent);
 extern void fixup_perms_recursive(struct dentry *dentry, struct limit_search *limit);
 
 extern void update_derived_permission_lock(struct dentry *dentry);