]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0051-buffer_head-Replace-bh_uptodate_lock-for-rt.patch
rt_patches: required rebase due to printk change
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0051-buffer_head-Replace-bh_uptodate_lock-for-rt.patch
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
5
6 Wrap the bit_spin_lock calls into a separate inline and add the RT
7 replacements with a real spinlock.
8
9 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
10 ---
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(-)
15
16 diff --git a/fs/buffer.c b/fs/buffer.c
17 index 4f4cd95..72b27e1 100644
18 --- a/fs/buffer.c
19 +++ b/fs/buffer.c
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.
22          */
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);
28         unlock_buffer(bh);
29         tmp = bh;
30 @@ -319,8 +318,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
31                 }
32                 tmp = tmp->b_this_page;
33         } while (tmp != bh);
34 -       bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
35 -       local_irq_restore(flags);
36 +       bh_uptodate_unlock_irqrestore(first, flags);
37  
38         /*
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)
41         return;
42  
43  still_busy:
44 -       bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
45 -       local_irq_restore(flags);
46 -       return;
47 +       bh_uptodate_unlock_irqrestore(first, flags);
48  }
49  
50  /*
51 @@ -362,8 +358,7 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
52         }
53  
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);
58  
59         clear_buffer_async_write(bh);
60         unlock_buffer(bh);
61 @@ -375,15 +370,12 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate)
62                 }
63                 tmp = tmp->b_this_page;
64         }
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);
69         return;
70  
71  still_busy:
72 -       bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
73 -       local_irq_restore(flags);
74 -       return;
75 +       bh_uptodate_unlock_irqrestore(first, flags);
76  }
77  EXPORT_SYMBOL(end_buffer_async_write);
78  
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);
81         if (ret) {
82                 INIT_LIST_HEAD(&ret->b_assoc_buffers);
83 +               buffer_head_init_locks(ret);
84                 preempt_disable();
85                 __this_cpu_inc(bh_accounting.nr);
86                 recalc_bh_state();
87 diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
88 index 7521e11..39b08f5 100644
89 --- a/fs/ntfs/aops.c
90 +++ b/fs/ntfs/aops.c
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);
93         }
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);
99         unlock_buffer(bh);
100         tmp = bh;
101 @@ -123,8 +122,7 @@ static void ntfs_end_buffer_async_read(struct buffer_head *bh, int uptodate)
102                 }
103                 tmp = tmp->b_this_page;
104         } while (tmp != bh);
105 -       bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
106 -       local_irq_restore(flags);
107 +       bh_uptodate_unlock_irqrestore(first, flags);
108         /*
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)
112         unlock_page(page);
113         return;
114  still_busy:
115 -       bit_spin_unlock(BH_Uptodate_Lock, &first->b_state);
116 -       local_irq_restore(flags);
117 -       return;
118 +       bh_uptodate_unlock_irqrestore(first, flags);
119  }
120  
121  /**
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
128                                                    associated with */
129         atomic_t b_count;               /* users using this buffer_head */
130 +#ifdef CONFIG_PREEMPT_RT_BASE
131 +       spinlock_t b_uptodate_lock;
132 +#endif
133  };
134  
135 +static inline unsigned long bh_uptodate_lock_irqsave(struct buffer_head *bh)
136 +{
137 +       unsigned long flags;
138 +
139 +#ifndef CONFIG_PREEMPT_RT_BASE
140 +       local_irq_save(flags);
141 +       bit_spin_lock(BH_Uptodate_Lock, &bh->b_state);
142 +#else
143 +       spin_lock_irqsave(&bh->b_uptodate_lock, flags);
144 +#endif
145 +       return flags;
146 +}
147 +
148 +static inline void
149 +bh_uptodate_unlock_irqrestore(struct buffer_head *bh, unsigned long flags)
150 +{
151 +#ifndef CONFIG_PREEMPT_RT_BASE
152 +       bit_spin_unlock(BH_Uptodate_Lock, &bh->b_state);
153 +       local_irq_restore(flags);
154 +#else
155 +       spin_unlock_irqrestore(&bh->b_uptodate_lock, flags);
156 +#endif
157 +}
158 +
159 +static inline void buffer_head_init_locks(struct buffer_head *bh)
160 +{
161 +#ifdef CONFIG_PREEMPT_RT_BASE
162 +       spin_lock_init(&bh->b_uptodate_lock);
163 +#endif
164 +}
165 +
166  /*
167   * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
168   * and buffer_foo() functions.
169 -- 
170 1.9.1
171