ANDROID: sdcardfs: use wrappers to access i_mutex

Use inode_{lock,unlock,lock_nested} wrappers as suggested by upstream
commit 5955102c99 (wrappers for ->i_mutex access) for access to
->i_mutex, otherwise we run into following build error:

  CC [M]  fs/sdcardfs/dentry.o
In file included from fs/sdcardfs/dentry.c:21:0:
fs/sdcardfs/sdcardfs.h: In function ‘lock_parent’:
fs/sdcardfs/sdcardfs.h:422:33: error: ‘struct inode’ has no member named ‘i_mutex’
  mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
                                 ^
fs/sdcardfs/sdcardfs.h: In function ‘unlock_dir’:
fs/sdcardfs/sdcardfs.h:428:28: error: ‘struct inode’ has no member named ‘i_mutex’
  mutex_unlock(&d_inode(dir)->i_mutex);
                            ^
In file included from ./include/linux/fs.h:19:0,
                 from fs/sdcardfs/sdcardfs.h:31,
                 from fs/sdcardfs/dentry.c:21:
fs/sdcardfs/sdcardfs.h: In function ‘prepare_dir’:
fs/sdcardfs/sdcardfs.h:457:27: error: ‘struct inode’ has no member named ‘i_mutex’
  mutex_lock(&d_inode(dent)->i_mutex);
                           ^
./include/linux/mutex.h:146:44: note: in definition of macro ‘mutex_lock’
 #define mutex_lock(lock) mutex_lock_nested(lock, 0)
                                            ^
In file included from fs/sdcardfs/dentry.c:21:0:
fs/sdcardfs/sdcardfs.h:459:29: error: ‘struct inode’ has no member named‘i_mutex’
  mutex_unlock(&d_inode(dent)->i_mutex);
                             ^
fs/sdcardfs/sdcardfs.h:466:38: error: ‘struct inode’ has no member named ‘i_mutex’
  mutex_unlock(&d_inode(parent.dentry)->i_mutex);
                                      ^

Change-Id: I4c8298045ac511aba5542d9ca967331f550376a5
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
This commit is contained in:
Amit Pundir 2016-06-01 21:53:20 +05:30
parent 99a236713f
commit 911cd16e2f
3 changed files with 10 additions and 10 deletions

View file

@ -807,10 +807,10 @@ static int sdcardfs_setattr(struct vfsmount *mnt, struct dentry *dentry, struct
* 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_change2(lower_mnt, 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)

View file

@ -244,7 +244,7 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
if (err == -ENOENT) {
struct dentry *child;
struct dentry *match = NULL;
mutex_lock(&d_inode(lower_dir_dentry)->i_mutex);
inode_lock(d_inode(lower_dir_dentry));
spin_lock(&lower_dir_dentry->d_lock);
list_for_each_entry(child, &lower_dir_dentry->d_subdirs, d_child) {
if (child && d_inode(child)) {
@ -255,7 +255,7 @@ static struct dentry *__sdcardfs_lookup(struct dentry *dentry,
}
}
spin_unlock(&lower_dir_dentry->d_lock);
mutex_unlock(&d_inode(lower_dir_dentry)->i_mutex);
inode_unlock(d_inode(lower_dir_dentry));
if (match) {
err = vfs_path_lookup(lower_dir_dentry,
lower_dir_mnt,
@ -344,7 +344,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

View file

@ -465,13 +465,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);
}
@ -500,16 +500,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_change2(parent.mnt, 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;
}