hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/include/linux/buffer_head.h
....@@ -22,9 +22,6 @@
2222 BH_Dirty, /* Is dirty */
2323 BH_Lock, /* Is locked */
2424 BH_Req, /* Has been submitted for I/O */
25
- BH_Uptodate_Lock,/* Used by the first bh in a page, to serialise
26
- * IO completion of other buffers in the page
27
- */
2825
2926 BH_Mapped, /* Has a disk mapping */
3027 BH_New, /* Disk mapping was newly created by get_block */
....@@ -76,6 +73,9 @@
7673 struct address_space *b_assoc_map; /* mapping this buffer is
7774 associated with */
7875 atomic_t b_count; /* users using this buffer_head */
76
+ spinlock_t b_uptodate_lock; /* Used by the first bh in a page, to
77
+ * serialise IO completion of other
78
+ * buffers in the page */
7979 };
8080
8181 /*
....@@ -117,7 +117,6 @@
117117 * of the form "mark_buffer_foo()". These are higher-level functions which
118118 * do something in addition to setting a b_state bit.
119119 */
120
-BUFFER_FNS(Uptodate, uptodate)
121120 BUFFER_FNS(Dirty, dirty)
122121 TAS_BUFFER_FNS(Dirty, dirty)
123122 BUFFER_FNS(Lock, locked)
....@@ -134,6 +133,41 @@
134133 BUFFER_FNS(Meta, meta)
135134 BUFFER_FNS(Prio, prio)
136135 BUFFER_FNS(Defer_Completion, defer_completion)
136
+
137
+static __always_inline void set_buffer_uptodate(struct buffer_head *bh)
138
+{
139
+ /*
140
+ * If somebody else already set this uptodate, they will
141
+ * have done the memory barrier, and a reader will thus
142
+ * see *some* valid buffer state.
143
+ *
144
+ * Any other serialization (with IO errors or whatever that
145
+ * might clear the bit) has to come from other state (eg BH_Lock).
146
+ */
147
+ if (test_bit(BH_Uptodate, &bh->b_state))
148
+ return;
149
+
150
+ /*
151
+ * make it consistent with folio_mark_uptodate
152
+ * pairs with smp_load_acquire in buffer_uptodate
153
+ */
154
+ smp_mb__before_atomic();
155
+ set_bit(BH_Uptodate, &bh->b_state);
156
+}
157
+
158
+static __always_inline void clear_buffer_uptodate(struct buffer_head *bh)
159
+{
160
+ clear_bit(BH_Uptodate, &bh->b_state);
161
+}
162
+
163
+static __always_inline int buffer_uptodate(const struct buffer_head *bh)
164
+{
165
+ /*
166
+ * make it consistent with folio_test_uptodate
167
+ * pairs with smp_mb__before_atomic in set_buffer_uptodate
168
+ */
169
+ return (smp_load_acquire(&bh->b_state) & (1UL << BH_Uptodate)) != 0;
170
+}
137171
138172 #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
139173
....@@ -194,6 +228,8 @@
194228 struct buffer_head *__bread_gfp(struct block_device *,
195229 sector_t block, unsigned size, gfp_t gfp);
196230 void invalidate_bh_lrus(void);
231
+void invalidate_bh_lrus_cpu(void);
232
+bool has_bh_in_lru(int cpu, void *dummy);
197233 struct buffer_head *alloc_buffer_head(gfp_t gfp_flags);
198234 void free_buffer_head(struct buffer_head * bh);
199235 void unlock_buffer(struct buffer_head *bh);
....@@ -244,7 +280,7 @@
244280 int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf,
245281 get_block_t get_block);
246282 /* Convert errno to return value from ->page_mkwrite() call */
247
-static inline int block_page_mkwrite_return(int err)
283
+static inline vm_fault_t block_page_mkwrite_return(int err)
248284 {
249285 if (err == 0)
250286 return VM_FAULT_LOCKED;
....@@ -271,14 +307,6 @@
271307 /*
272308 * inline definitions
273309 */
274
-
275
-static inline void attach_page_buffers(struct page *page,
276
- struct buffer_head *head)
277
-{
278
- get_page(page);
279
- SetPagePrivate(page);
280
- set_page_private(page, (unsigned long)head);
281
-}
282310
283311 static inline void get_bh(struct buffer_head *bh)
284312 {
....@@ -414,6 +442,9 @@
414442 static inline void invalidate_inode_buffers(struct inode *inode) {}
415443 static inline int remove_inode_buffers(struct inode *inode) { return 1; }
416444 static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; }
445
+static inline void invalidate_bh_lrus_cpu(void) {}
446
+static inline bool has_bh_in_lru(int cpu, void *dummy) { return 0; }
447
+#define buffer_heads_over_limit 0
417448
418449 #endif /* CONFIG_BLOCK */
419450 #endif /* _LINUX_BUFFER_HEAD_H */