locks: protect most of the file_lock handling with i_lock
[platform/adaptation/renesas_rcar/renesas_kernel.git] / Documentation / filesystems / Locking
index 0706d32..c2963a7 100644 (file)
@@ -11,10 +11,8 @@ be able to use diff(1).
 prototypes:
        int (*d_revalidate)(struct dentry *, unsigned int);
        int (*d_weak_revalidate)(struct dentry *, unsigned int);
-       int (*d_hash)(const struct dentry *, const struct inode *,
-                       struct qstr *);
-       int (*d_compare)(const struct dentry *, const struct inode *,
-                       const struct dentry *, const struct inode *,
+       int (*d_hash)(const struct dentry *, struct qstr *);
+       int (*d_compare)(const struct dentry *, const struct dentry *,
                        unsigned int, const char *, const struct qstr *);
        int (*d_delete)(struct dentry *);
        void (*d_release)(struct dentry *);
@@ -344,7 +342,7 @@ prototypes:
 
 
 locking rules:
-                       file_lock_lock  may block
+                       inode->i_lock   may block
 fl_copy_lock:          yes             no
 fl_release_private:    maybe           no
 
@@ -357,12 +355,19 @@ prototypes:
        int (*lm_change)(struct file_lock **, int);
 
 locking rules:
-                       file_lock_lock  may block
-lm_compare_owner:      yes             no
-lm_notify:             yes             no
-lm_grant:              no              no
-lm_break:              yes             no
-lm_change              yes             no
+
+                       inode->i_lock   file_lock_lock  may block
+lm_compare_owner:      yes[1]          maybe           no
+lm_notify:             yes             yes             no
+lm_grant:              no              no              no
+lm_break:              yes             no              no
+lm_change              yes             no              no
+
+[1]:   ->lm_compare_owner is generally called with *an* inode->i_lock held. It
+may not be the i_lock of the inode for either file_lock being compared! This is
+the case with deadlock detection, since the code has to chase down the owners
+of locks that may be entirely unrelated to the one on which the lock is being
+acquired. When doing a search for deadlocks, the file_lock_lock is also held.
 
 --------------------------- buffer_head -----------------------------------
 prototypes:
@@ -414,7 +419,7 @@ prototypes:
        ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
        ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
        ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
-       int (*readdir) (struct file *, void *, filldir_t);
+       int (*iterate) (struct file *, struct dir_context *);
        unsigned int (*poll) (struct file *, struct poll_table_struct *);
        long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);