mm/readahead: add DEFINE_READAHEAD
[linux-2.6-microblaze.git] / include / linux / pagemap.h
index c3afd32..63c81b5 100644 (file)
@@ -29,6 +29,7 @@ enum mapping_flags {
        AS_EXITING      = 4,    /* final truncate in progress */
        /* writeback related tags are not used */
        AS_NO_WRITEBACK_TAGS = 5,
+       AS_THP_SUPPORT = 6,     /* THPs supported */
 };
 
 /**
@@ -120,6 +121,40 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
        m->gfp_mask = mask;
 }
 
+static inline bool mapping_thp_support(struct address_space *mapping)
+{
+       return test_bit(AS_THP_SUPPORT, &mapping->flags);
+}
+
+static inline int filemap_nr_thps(struct address_space *mapping)
+{
+#ifdef CONFIG_READ_ONLY_THP_FOR_FS
+       return atomic_read(&mapping->nr_thps);
+#else
+       return 0;
+#endif
+}
+
+static inline void filemap_nr_thps_inc(struct address_space *mapping)
+{
+#ifdef CONFIG_READ_ONLY_THP_FOR_FS
+       if (!mapping_thp_support(mapping))
+               atomic_inc(&mapping->nr_thps);
+#else
+       WARN_ON_ONCE(1);
+#endif
+}
+
+static inline void filemap_nr_thps_dec(struct address_space *mapping)
+{
+#ifdef CONFIG_READ_ONLY_THP_FOR_FS
+       if (!mapping_thp_support(mapping))
+               atomic_dec(&mapping->nr_thps);
+#else
+       WARN_ON_ONCE(1);
+#endif
+}
+
 void release_pages(struct page **pages, int nr);
 
 /*
@@ -777,6 +812,13 @@ struct readahead_control {
        unsigned int _batch_count;
 };
 
+#define DEFINE_READAHEAD(rac, f, m, i)                                 \
+       struct readahead_control rac = {                                \
+               .file = f,                                              \
+               .mapping = m,                                           \
+               ._index = i,                                            \
+       }
+
 /**
  * readahead_page - Get the next page to read.
  * @rac: The current readahead request.