[PATCH 1/1] Updated locking documentation for struct inode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We used LockDoc to derive locking rules for each member
of struct inode.
Based on those results, we extended the existing documentation
by more members of struct inode, and updated the existing
documentation.

Signed-off-by: Alexander Lochmann <alexander.lochmann@xxxxxxxxxxxxxx>
Signed-off-by: Horst Schirmeier <horst.schirmeier@xxxxxxxxxxxxxx>
---
 fs/inode.c         | 49 ++++++++++++++++++++++++++++++++++++----------
 include/linux/fs.h |  2 +-
 2 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/fs/inode.c b/fs/inode.c
index 0cd47fe0dbe5..ade9d3aa1ada 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -24,17 +24,46 @@
 
 /*
  * Inode locking rules:
+ * (Documentation improved by LockDoc)
  *
- * inode->i_lock protects:
- *   inode->i_state, inode->i_hash, __iget()
- * Inode LRU list locks protect:
- *   inode->i_sb->s_inode_lru, inode->i_lru
- * inode->i_sb->s_inode_list_lock protects:
- *   inode->i_sb->s_inodes, inode->i_sb_list
- * bdi->wb.list_lock protects:
- *   bdi->wb.b_{dirty,io,more_io,dirty_time}, inode->i_io_list
- * inode_hash_lock protects:
- *   inode_hashtable, inode->i_hash
+ * No locks needed for:
+ *   i_data.a_ops, i_data.nrexceptional, i_rdev, i_data.gfp_mask,
+ *   i_generation, i_security, i_nlink, __i_nlink, i_flctx,
+ *   i_size, i_atime, i_mtime, i_data.host, i_sb
+ *
+ * backing_dev_info.wb.list_lock protects:
+ *   dirtied_when, i_io_list
+ *
+ * inode.i_rwsem protects:
+ *   i_flags, i_uid, i_gid, i_version, i_ctime, i_size_seqcount
+ *
+ * inode.i_rwsem -> rcu protects:
+ *   i_default_acl
+ *
+ * block_device.bd_mutex protects:
+ *   i_blkbits
+ *
+ * cdev_lock protects:
+ *   i_cdev, i_devices
+ *
+ * inode.i_data.i_mmap_rwsem protects:
+ *   i_data.i_mmap, i_data.i_mmap
+ *
+ * hardirq -> inode.i_data.tree_lock protects:
+ *   i_data.page_tree, i_wb_list, i_data.nrpages
+ *
+ * hardirq -> super_block.s_inode_wblist_lock protects:
+ *   i_wb_list
+ *
+ * inode.i_lock protects:
+ *   i_pipe, i_fsnotify_mask, i_fsnotify_marks, i_blocks, i_opflags,
+ *   i_state, i_bytes
+ *
+ * super_block.s_inode_list_lock protects:
+ *   i_sb_list
+ *
+ * inode_hash_lock -> inode.i_lock protects:
+ *   i_hash
  *
  * Lock ordering:
  *
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 92966678539d..744e2a817ad3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -639,7 +639,7 @@ struct inode {
 	struct timespec64	i_atime;
 	struct timespec64	i_mtime;
 	struct timespec64	i_ctime;
-	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
+	spinlock_t		i_lock;
 	unsigned short          i_bytes;
 	u8			i_blkbits;
 	u8			i_write_hint;
-- 
2.20.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux