Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e5ef445 authored by Amit Pundir's avatar Amit Pundir
Browse files

ANDROID: sdcardfs: use wrappers to access i_mutex



Use inode_{lock,unlock,lock_nested} wrappers as suggested by upstream
commit 5955102c (wrappers for ->i_mutex access) for access to ->i_mutex.

Signed-off-by: default avatarAmit Pundir <amit.pundir@linaro.org>
parent 09172081
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -113,11 +113,11 @@ void get_derive_permissions_recursive(struct dentry *parent) {
	struct dentry *dentry;
	list_for_each_entry(dentry, &parent->d_subdirs, d_child) {
		if (dentry->d_inode) {
			mutex_lock(&dentry->d_inode->i_mutex);
			inode_lock(dentry->d_inode);
			get_derived_permission(parent, dentry);
			fix_derived_permission(dentry->d_inode);
			get_derive_permissions_recursive(dentry);
			mutex_unlock(&dentry->d_inode->i_mutex);
			inode_unlock(dentry->d_inode);
		}
	}
}
@@ -135,7 +135,7 @@ inline void update_derived_permission_lock(struct dentry *dentry)
	 * 1. need to check whether the dentry is updated or not
	 * 2. remove the root dentry update
	 */
	mutex_lock(&dentry->d_inode->i_mutex);
	inode_lock(dentry->d_inode);
	if(IS_ROOT(dentry)) {
		//setup_default_pre_root_state(dentry->d_inode);
	} else {
@@ -146,7 +146,7 @@ inline void update_derived_permission_lock(struct dentry *dentry)
		}
	}
	fix_derived_permission(dentry->d_inode);
	mutex_unlock(&dentry->d_inode->i_mutex);
	inode_unlock(dentry->d_inode);
}

int need_graft_path(struct dentry *dentry)
+4 −4
Original line number Diff line number Diff line
@@ -513,11 +513,11 @@ static int sdcardfs_rename(struct inode *old_dir, struct dentry *old_dentry,
	}
	/* At this point, not all dentry information has been moved, so
	 * we pass along new_dentry for the name.*/
	mutex_lock(&d_inode(old_dentry)->i_mutex);
	inode_lock(d_inode(old_dentry));
	get_derived_permission_new(new_dentry->d_parent, old_dentry, new_dentry);
	fix_derived_permission(d_inode(old_dentry));
	get_derive_permissions_recursive(old_dentry);
	mutex_unlock(&d_inode(old_dentry)->i_mutex);
	inode_unlock(d_inode(old_dentry));
out:
	unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
	dput(lower_old_dir_dentry);
@@ -703,10 +703,10 @@ static int sdcardfs_setattr(struct dentry *dentry, struct iattr *ia)
	 * unlinked (no inode->i_sb and i_ino==0.  This happens if someone
	 * tries to open(), unlink(), then ftruncate() a file.
	 */
	mutex_lock(&d_inode(lower_dentry)->i_mutex);
	inode_lock(d_inode(lower_dentry));
	err = notify_change(lower_dentry, &lower_ia, /* note: lower_ia */
			NULL);
	mutex_unlock(&d_inode(lower_dentry)->i_mutex);
	inode_unlock(d_inode(lower_dentry));
	if (current->mm)
		up_write(&current->mm->mmap_sem);
	if (err)
+3 −3
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
 * On fail (== error)
 * 	returns error ptr
 *
 * @dir : Parent inode. It is locked (dir->i_mutex)
 * @dir : Parent inode.
 * @dentry : Target dentry to lookup. we should set each of fields.
 *	     (dentry->d_name is initialized already)
 * @nd : nameidata of parent inode
@@ -366,10 +366,10 @@ struct dentry *sdcardfs_lookup(struct inode *dir, struct dentry *dentry,
		fsstack_copy_attr_times(dentry->d_inode,
					sdcardfs_lower_inode(dentry->d_inode));
		/* get drived permission */
		mutex_lock(&dentry->d_inode->i_mutex);
		inode_lock(dentry->d_inode);
		get_derived_permission(parent, dentry);
		fix_derived_permission(dentry->d_inode);
		mutex_unlock(&dentry->d_inode->i_mutex);
		inode_unlock(dentry->d_inode);
	}
	/* update parent directory's atime */
	fsstack_copy_attr_atime(parent->d_inode,
+2 −2
Original line number Diff line number Diff line
@@ -144,9 +144,9 @@ static int insert_str_to_int_lock(struct packagelist_data *pkgl_dat, char *key,

static void fixup_perms(struct super_block *sb) {
	if (sb && sb->s_magic == SDCARDFS_SUPER_MAGIC) {
		mutex_lock(&sb->s_root->d_inode->i_mutex);
		inode_lock(sb->s_root->d_inode);
		get_derive_permissions_recursive(sb->s_root);
		mutex_unlock(&sb->s_root->d_inode->i_mutex);
		inode_unlock(sb->s_root->d_inode);
	}
}

+5 −5
Original line number Diff line number Diff line
@@ -419,13 +419,13 @@ extern int setup_obb_dentry(struct dentry *dentry, struct path *lower_path);
static inline struct dentry *lock_parent(struct dentry *dentry)
{
	struct dentry *dir = dget_parent(dentry);
	mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
	inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
	return dir;
}

static inline void unlock_dir(struct dentry *dir)
{
	mutex_unlock(&d_inode(dir)->i_mutex);
	inode_unlock(d_inode(dir));
	dput(dir);
}

@@ -454,16 +454,16 @@ static inline int prepare_dir(const char *path_s, uid_t uid, gid_t gid, mode_t m
	attrs.ia_uid = make_kuid(&init_user_ns, uid);
	attrs.ia_gid = make_kgid(&init_user_ns, gid);
	attrs.ia_valid = ATTR_UID | ATTR_GID;
	mutex_lock(&d_inode(dent)->i_mutex);
	inode_lock(d_inode(dent));
	notify_change(dent, &attrs, NULL);
	mutex_unlock(&d_inode(dent)->i_mutex);
	inode_unlock(d_inode(dent));

out_dput:
	dput(dent);

out_unlock:
	/* parent dentry locked by lookup_create */
	mutex_unlock(&d_inode(parent.dentry)->i_mutex);
	inode_unlock(d_inode(parent.dentry));
	path_put(&parent);
	return err;
}