aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-02-27 00:51:39 -0500
committerDave Chinner <david@fromorbit.com>2014-02-27 00:51:39 -0500
commit93a8614e3a4dccd526aca34e892ac0b27f64b506 (patch)
tree494837b23f0f9c4a867537e684903b7f135d9ee4 /fs
parenta1358aa3d39251c16c6d8b20945e40bdfc2aad68 (diff)
xfs: fix directory inode iolock lockdep false positive
The change to add the IO lock to protect the directory extent map during readdir operations has cause lockdep to have a heart attack as it now sees a different locking order on inodes w.r.t. the mmap_sem because readdir has a different ordering to write(). Add a new lockdep class for directory inodes to avoid this false positive. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_iops.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index f35d5c953ff9..234e84387ec5 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -48,6 +48,18 @@
48#include <linux/fiemap.h> 48#include <linux/fiemap.h>
49#include <linux/slab.h> 49#include <linux/slab.h>
50 50
51/*
52 * Directories have different lock order w.r.t. mmap_sem compared to regular
53 * files. This is due to readdir potentially triggering page faults on a user
54 * buffer inside filldir(), and this happens with the ilock on the directory
55 * held. For regular files, the lock order is the other way around - the
56 * mmap_sem is taken during the page fault, and then we lock the ilock to do
57 * block mapping. Hence we need a different class for the directory ilock so
58 * that lockdep can tell them apart.
59 */
60static struct lock_class_key xfs_nondir_ilock_class;
61static struct lock_class_key xfs_dir_ilock_class;
62
51static int 63static int
52xfs_initxattrs( 64xfs_initxattrs(
53 struct inode *inode, 65 struct inode *inode,
@@ -1191,6 +1203,7 @@ xfs_setup_inode(
1191 xfs_diflags_to_iflags(inode, ip); 1203 xfs_diflags_to_iflags(inode, ip);
1192 1204
1193 ip->d_ops = ip->i_mount->m_nondir_inode_ops; 1205 ip->d_ops = ip->i_mount->m_nondir_inode_ops;
1206 lockdep_set_class(&ip->i_lock.mr_lock, &xfs_nondir_ilock_class);
1194 switch (inode->i_mode & S_IFMT) { 1207 switch (inode->i_mode & S_IFMT) {
1195 case S_IFREG: 1208 case S_IFREG:
1196 inode->i_op = &xfs_inode_operations; 1209 inode->i_op = &xfs_inode_operations;
@@ -1198,6 +1211,7 @@ xfs_setup_inode(
1198 inode->i_mapping->a_ops = &xfs_address_space_operations; 1211 inode->i_mapping->a_ops = &xfs_address_space_operations;
1199 break; 1212 break;
1200 case S_IFDIR: 1213 case S_IFDIR:
1214 lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class);
1201 if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb)) 1215 if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
1202 inode->i_op = &xfs_dir_ci_inode_operations; 1216 inode->i_op = &xfs_dir_ci_inode_operations;
1203 else 1217 else