1 From af20f2ae6b96fe1d1981fdad37d5c0a7b80ef8f2 Mon Sep 17 00:00:00 2001
2 From: Thomas Gleixner <tglx@linutronix.de>
3 Date: Fri, 18 Mar 2011 09:18:52 +0100
4 Subject: [PATCH 051/366] buffer_head: Replace bh_uptodate_lock for -rt
6 Wrap the bit_spin_lock calls into a separate inline and add the RT
7 replacements with a real spinlock.
9 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
11 fs/buffer.c | 21 +++++++--------------
12 fs/ntfs/aops.c | 10 +++-------
13 include/linux/buffer_head.h | 34 ++++++++++++++++++++++++++++++++++
14 3 files changed, 44 insertions(+), 21 deletions(-)
16 diff --git a/fs/buffer.c b/fs/buffer.c
17 index 4f4cd95..72b27e1 100644
20 @@ -305,8 +305,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
21 * decide that the page is now completely done.
23 first = page_buffers(page);
24 - local_irq_save(flags);
25 - bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
26 + flags = bh_uptodate_lock_irqsave(first);
27 clear_buffer_async_read(bh);
30 @@ -319,8 +318,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
32 tmp = tmp->b_this_page;
34 - bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
35 - local_irq_restore(flags);
36 + bh_uptodate_unlock_irqrestore(first, flags);
39 * If none of the buffers had errors and they are all
40 @@ -332,9 +330,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
44 - bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
45 - local_irq_restore(flags);
47 + bh_uptodate_unlock_irqrestore(first, flags);
51 @@ -362,8 +358,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
54 first = page_buffers(page);
55 - local_irq_save(flags);
56 - bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
57 + flags = bh_uptodate_lock_irqsave(first);
59 clear_buffer_async_write(bh);
61 @@ -375,15 +370,12 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
63 tmp = tmp->b_this_page;
65 - bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
66 - local_irq_restore(flags);
67 + bh_uptodate_unlock_irqrestore(first, flags);
68 end_page_writeback(page);
72 - bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
73 - local_irq_restore(flags);
75 + bh_uptodate_unlock_irqrestore(first, flags);
77 EXPORT_SYMBOL(end_buffer_async_write);
79 @@ -3325,6 +3317,7 @@ struct buffer_head *alloc_buffer_head(gfp_t gfp_flags)
80 struct buffer_head *ret = kmem_cache_zalloc(bh_cachep, gfp_flags);
82 INIT_LIST_HEAD(&ret->b_assoc_buffers);
83 + buffer_head_init_locks(ret);
85 __this_cpu_inc(bh_accounting.nr);
87 diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
88 index 7521e11..39b08f5 100644
91 @@ -107,8 +107,7 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
92 "0x%llx.", (unsigned long long)bh->b_blocknr);
94 first = page_buffers(page);
95 - local_irq_save(flags);
96 - bit_spin_lock(BH_Uptodate_Lock, &first->b_state);
97 + flags = bh_uptodate_lock_irqsave(first);
98 clear_buffer_async_read(bh);
101 @@ -123,8 +122,7 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
103 tmp = tmp->b_this_page;
105 - bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
106 - local_irq_restore(flags);
107 + bh_uptodate_unlock_irqrestore(first, flags);
109 * If none of the buffers had errors then we can set the page uptodate,
110 * but we first have to perform the post read mst fixups, if the
111 @@ -159,9 +157,7 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
115 - bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
116 - local_irq_restore(flags);
118 + bh_uptodate_unlock_irqrestore(first, flags);
122 diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
123 index 89d9aa9e..ab04527 100644
124 --- a/include/linux/buffer_head.h
125 +++ b/include/linux/buffer_head.h
126 @@ -75,8 +75,42 @@ struct buffer_head {
127 struct address_space *b_assoc_map; /* mapping this buffer is
129 atomic_t b_count; /* users using this buffer_head */
130 +#ifdef CONFIG_PREEMPT_RT_BASE
131 + spinlock_t b_uptodate_lock;
135 +static inline unsigned long bh_uptodate_lock_irqsave(struct buffer_head *bh)
137 + unsigned long flags;
139 +#ifndef CONFIG_PREEMPT_RT_BASE
140 + local_irq_save(flags);
141 + bit_spin_lock(BH_Uptodate_Lock, &bh->b_state);
143 + spin_lock_irqsave(&bh->b_uptodate_lock, flags);
149 +bh_uptodate_unlock_irqrestore(struct buffer_head *bh, unsigned long flags)
151 +#ifndef CONFIG_PREEMPT_RT_BASE
152 + bit_spin_unlock(BH_Uptodate_Lock, &bh->b_state);
153 + local_irq_restore(flags);
155 + spin_unlock_irqrestore(&bh->b_uptodate_lock, flags);
159 +static inline void buffer_head_init_locks(struct buffer_head *bh)
161 +#ifdef CONFIG_PREEMPT_RT_BASE
162 + spin_lock_init(&bh->b_uptodate_lock);
167 * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
168 * and buffer_foo() functions.