ANDROID: incfs: vfs: Annotate stacked filesystem re-entry with lockdep subclasses
Lockdep reports recursive locking warnings in `incfs_setattr` and `iterate_dir`. Because IncFS is a stacked filesystem, these operations re-enter VFS on the backing (lower) directory or file, calling VFS helpers or locking the lower inode directly. Since VFS acquires the upper inode's `i_rwsem` with subclass 0, the unannotated re-entry into the lower inode (which also uses subclass 0) falsely triggers lockdep's recursive lock detection. Fix this by annotating the lower inode acquisitions with the `I_MUTEX_PARENT` subclass: 1. In `incfs_setattr`, use `inode_lock_nested(..., I_MUTEX_PARENT)` consistently with all other directory operations in this file. 2. In `iterate_incfs_dir`, temporarily set the backing inode's lock class subclass to `I_MUTEX_PARENT` around the `iterate_dir()` VFS helper call, and restore it to 0 immediately afterwards. Bug: 419203261 Bug: 419264069 Change-Id: I0447aa79f91576b67290eadf143acfb87d8cb9b4 Signed-off-by: Howard Chen <howardsoc@google.com>
This commit is contained in:
1 parent
f9a1c0bebb
commit
59b735704e
1 file changed
+3
-1
+3
-1
@@ -384,7 +384,9 @@ static int iterate_incfs_dir(struct file *file, struct dir_context *ctx)
|
||||
}
|
||||
|
||||
ctx->pos -= PSEUDO_FILE_COUNT;
|
||||
lockdep_set_subclass(&dir->backing_dir->f_inode->i_rwsem, I_MUTEX_PARENT);
|
||||
error = iterate_dir(dir->backing_dir, ctx);
|
||||
lockdep_set_subclass(&dir->backing_dir->f_inode->i_rwsem, 0);
|
||||
ctx->pos += PSEUDO_FILE_COUNT;
|
||||
file->f_pos = dir->backing_dir->f_pos;
|
||||
out:
|
||||
@@ -1621,7 +1623,7 @@ static int incfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
ia->ia_mode |= 0222;
|
||||
}
|
||||
|
||||
inode_lock(d_inode(backing_dentry));
|
||||
inode_lock_nested(d_inode(backing_dentry), I_MUTEX_PARENT);
|
||||
error = notify_change(idmap, backing_dentry, ia, NULL);
|
||||
inode_unlock(d_inode(backing_dentry));
|
||||
|
||||
|
||||
Reference in new issue
Block a user