Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6
[sfrench/cifs-2.6.git] / fs / ext4 / ext4_jbd2.h
index 05eca817d7046258f54d3a8715dafb946ff5e155..b79ad5126468867efb31cab9835517e38e3bce04 100644 (file)
@@ -304,4 +304,28 @@ static inline int ext4_should_writeback_data(struct inode *inode)
        return 0;
 }
 
+/*
+ * This function controls whether or not we should try to go down the
+ * dioread_nolock code paths, which makes it safe to avoid taking
+ * i_mutex for direct I/O reads.  This only works for extent-based
+ * files, and it doesn't work for nobh or if data journaling is
+ * enabled, since the dioread_nolock code uses b_private to pass
+ * information back to the I/O completion handler, and this conflicts
+ * with the jbd's use of b_private.
+ */
+static inline int ext4_should_dioread_nolock(struct inode *inode)
+{
+       if (!test_opt(inode->i_sb, DIOREAD_NOLOCK))
+               return 0;
+       if (test_opt(inode->i_sb, NOBH))
+               return 0;
+       if (!S_ISREG(inode->i_mode))
+               return 0;
+       if (!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL))
+               return 0;
+       if (ext4_should_journal_data(inode))
+               return 0;
+       return 1;
+}
+
 #endif /* _EXT4_JBD2_H */